Question

I want to recompose vApp and add new VM to it. I use a slightly modified recomposevapp.php from SDK samples.

I am using this code:

// Create Network Connection Section
$info = new VMware_VCloud_API_OVF_Msg_Type();
$info->set_valueOf("Network Paramemters for my source");
$nsection = new VMware_VCloud_API_NetworkConnectionSectionType();
$nsection->setInfo($info);
$nsection->setPrimaryNetworkConnectionIndex(0);

// Create Network Connection
$netconf = new VMware_VCloud_API_NetworkConnectionType();
$netconf->set_network($orgNetName);
$netconf->set_needsCustomization(false);
$netconf->setNetworkConnectionIndex(0);
$netconf->setIpAddress(NULL);
$netconf->setExternalIpAddress(NULL);
$netconf->setIsConnected(true);
$netconf->setMACAddress(NULL);
$netconf->setIpAddressAllocationMode("DHCP");

// Add Network Connection to Network Connection Section
$nsection->addNetworkConnection($netconf);

$iparams = new VMware_VCloud_API_InstantiationParamsType();
$iparams->setSection(array($nsection));

$params = new VMware_VCloud_API_RecomposeVAppParamsType();
...
$params->setInstantiationParams($iparams);
...

$task = $sdkVApp->recompose($params);

But I get the following error:

<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="BAD_REQUEST" message="Unsupported instantiation section: {http://www.vmware.com/vcloud/v1.5}NetworkConnectionSection" majorErrorCode="400" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://some_ip/api/v1.5/schema/master.xsd"></Error>

Bonus question: how to turn the instantiated VM on?

Was it helpful?

Solution

I have a solution! You have to get reference to the VM you just added and then configure the network. Turing it on is pretty easy after that.

$vmRefs = $sdkVApp->getContainedVmRefs($newVmName);
$sdkVm = $service->createSDKObj($vmRefs[0]);
$service->waitForTask($sdkVm->modifyNetworkConnectionSettings($nsection));
$service->waitForTask($sdkVm->powerOn());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top