Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
api/server: support deploy-as-is template as VNF template#12499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
d64089d333780874e3b55fb012c80bfc65a9889064ed56c59469df6b4d9c382976b969File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -16,6 +16,7 @@ | ||
| // under the License. | ||
| package org.apache.cloudstack.storage.template; | ||
| import com.cloud.agent.api.to.deployasis.OVFNetworkTO; | ||
| import com.cloud.exception.InvalidParameterValueException; | ||
| import com.cloud.network.VNF; | ||
| import com.cloud.storage.Storage; | ||
| @@ -124,6 +125,9 @@ public static void validateVnfNics(List<VNF.VnfNic> nicsList) { | ||
| public static void validateApiCommandParams(BaseCmd cmd, VirtualMachineTemplate template) { | ||
| if (cmd instanceof RegisterVnfTemplateCmd) { | ||
| RegisterVnfTemplateCmd registerCmd = (RegisterVnfTemplateCmd) cmd; | ||
| if (registerCmd.isDeployAsIs() && CollectionUtils.isNotEmpty(registerCmd.getVnfNics())) { | ||
| throw new InvalidParameterValueException("VNF nics cannot be specified when register a deploy-as-is Template. Please wait until Template settings are read from OVA."); | ||
| } | ||
| validateApiCommandParams(registerCmd.getVnfDetails(), registerCmd.getVnfNics(), registerCmd.getTemplateType()); | ||
| } else if (cmd instanceof UpdateVnfTemplateCmd) { | ||
| UpdateVnfTemplateCmd updateCmd = (UpdateVnfTemplateCmd) cmd; | ||
| @@ -149,4 +153,18 @@ public static void validateVnfCidrList(List<String> cidrList) { | ||
| } | ||
| } | ||
| } | ||
| public static void validateDeployAsIsTemplateVnfNics(List<OVFNetworkTO> ovfNetworks, List<VNF.VnfNic> vnfNics) { | ||
| if (CollectionUtils.isEmpty(vnfNics)) { | ||
| return; | ||
| } | ||
| if (CollectionUtils.isEmpty(ovfNetworks)) { | ||
| throw new InvalidParameterValueException("The list of networks read from OVA is empty. Please wait until the template is fully downloaded and processed."); | ||
| } | ||
| for (VNF.VnfNic vnfNic : vnfNics) { | ||
| if (vnfNic.getDeviceId() < ovfNetworks.size() && !vnfNic.isRequired()) { | ||
| throw new InvalidParameterValueException(String.format("The VNF nic [device ID: %s ] is required as it is defined in the OVA template.", vnfNic.getDeviceId())); | ||
| } | ||
Comment on lines
+165
to
+167
CopilotAI | ||
| } | ||
| } | ||
Comment on lines
+157
to
+169
CopilotAI | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -122,6 +122,7 @@ | ||
| import com.cloud.agent.api.to.DiskTO; | ||
| import com.cloud.agent.api.to.NfsTO; | ||
| import com.cloud.agent.api.to.VirtualMachineTO; | ||
| import com.cloud.agent.api.to.deployasis.OVFNetworkTO; | ||
| import com.cloud.api.ApiDBUtils; | ||
| import com.cloud.api.query.dao.UserVmJoinDao; | ||
| import com.cloud.api.query.vo.UserVmJoinVO; | ||
| @@ -131,6 +132,7 @@ | ||
| import com.cloud.dc.DataCenterVO; | ||
| import com.cloud.dc.dao.DataCenterDao; | ||
| import com.cloud.deploy.DeployDestination; | ||
| import com.cloud.deployasis.dao.TemplateDeployAsIsDetailsDao; | ||
| import com.cloud.domain.Domain; | ||
| import com.cloud.domain.dao.DomainDao; | ||
| import com.cloud.event.ActionEvent; | ||
| @@ -313,6 +315,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, | ||
| protected SnapshotHelper snapshotHelper; | ||
| @Inject | ||
| VnfTemplateManager vnfTemplateManager; | ||
| @Inject | ||
| TemplateDeployAsIsDetailsDao templateDeployAsIsDetailsDao; | ||
| @Inject | ||
| private SecondaryStorageHeuristicDao secondaryStorageHeuristicDao; | ||
| @@ -2172,6 +2176,11 @@ private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) { | ||
| templateType = validateTemplateType(cmd, isAdmin, template.isCrossZones()); | ||
| if (cmd instanceof UpdateVnfTemplateCmd) { | ||
| VnfTemplateUtils.validateApiCommandParams(cmd, template); | ||
| UpdateVnfTemplateCmd updateCmd = (UpdateVnfTemplateCmd) cmd; | ||
| if (template.isDeployAsIs() && CollectionUtils.isNotEmpty(updateCmd.getVnfNics())) { | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this parameter allowed on update but not on VM creation? (https://github.com/apache/cloudstack/pull/12499/files#diff-f5ab861d900497f6f7c83d03a840a7994f407c2dd52c237a4b560aaf9e75c202R128) MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nvazquez | ||
| List<OVFNetworkTO> ovfNetworks = templateDeployAsIsDetailsDao.listNetworkRequirementsByTemplateId(template.getId()); | ||
| VnfTemplateUtils.validateDeployAsIsTemplateVnfNics(ovfNetworks, updateCmd.getVnfNics()); | ||
| } | ||
| vnfTemplateManager.updateVnfTemplate(template.getId(), (UpdateVnfTemplateCmd) cmd); | ||
| } | ||
| templateTag = ((UpdateTemplateCmd)cmd).getTemplateTag(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -6127,7 +6127,7 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE | ||
| throw new InvalidParameterValueException("Unable to use template " + templateId); | ||
| } | ||
| if (TemplateType.VNF.equals(template.getTemplateType())) { | ||
| vnfTemplateManager.validateVnfApplianceNics(template, cmd.getNetworkIds()); | ||
| vnfTemplateManager.validateVnfApplianceNics(template, cmd.getNetworkIds(), cmd.getVmNetworkMap()); | ||
| } else if (cmd instanceof DeployVnfApplianceCmd) { | ||
| throw new InvalidParameterValueException("Can't deploy VNF appliance from a non-VNF template"); | ||
| } | ||
weizhouapache marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.