VMware Cloud Community
ctc0wley
Contributor
Contributor

Add VM to vApp with customized hardware settings

I have successfully modified the addVAppVM  action to   change the VM name, description and vApp network.  I also need to modify the CPU, RAM and add addition disks.   Currently a get the source vclVirtualHardwareSection and then planned to update the vclVirtualHardwareSection with new values CPU, RAM  and SCSI  controller.

I have included code to change the SCSI controller as a proof of concept but if I replace "VirtualSCSI"  with "LSILogic"

I get;

"(com.vmware.library.vCloud.operation/recomposeVApp) Error in (Dynamic Script Module name : recomposeVApp#1) com.vmware.vmo.plugin.vcloud.VCloudPluginException: [VcdErrorResponseException] HTTP status code = 500
Request ID: 932d9070-7e8b-407b-a7ef-1cd70d9e708b-d1dfb984-4395-4473-88fb-783dbd7cd76e
VCD Error: [ 932d9070-7e8b-407b-a7ef-1cd70d9e708b-d1dfb984-4395-4473-88fb-783dbd7cd76e ] class java.lang.NullPointerException"  

when I try to run the recompose.

 

logModule.log("Getting vCloud:VAppTemplate from href: " + sourceVmHref,"info");
var Hosts = VclHostManager.getHostList();
for each (var Host in Hosts) {
if (sourceVmHref.match(Host.url)) {
logModule.log("Found host: " + Host.url,"info");
break;
}
}
Host.login();
try {
var entityTemplate = Host.getEntityByHref('VAppTemplate', sourceVmHref);
}
catch(error) {
throw "Failed to find vApp Template with provided HREF:" + sourceVmHref ;
}

var vclVirtualHardwareSection = entityTemplate.getVirtualHardwareSection() ;
vclVirtualHardwareSection.required = true ;
var vHardwareItemList = vclVirtualHardwareSection.item.enumerate() ;

for (var index = 0; index < vHardwareItemList.length; index++) {
if (vHardwareItemList[index].resourceType.value == 6 ) {
var scsiController = new VclCimString() ;
scsiController.value = "VirtualSCSI" ;
vHardwareItemList[index].resourceSubType = scsiController ;

logModule.log("vHardwareItemList Item 0: " + vHardwareItemList[index].toXml(),"log");
}
}

logModule.log("Setting up vclVirtualHardwareSection","log") ;
vmItem.instantiationParams.section.add(vclVirtualHardwareSection) ;

Labels (4)
0 Kudos
0 Replies