0

我想重构 vApp 并向其添加新的虚拟机。recomposevapp.php我使用了从 SDK 示例中稍作修改的版本。

我正在使用这段代码:

// 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);

但我收到以下错误:

<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>

额外的问题:如何打开实例化的 VM?

4

1 回答 1

0

我有办法!您必须获取对刚刚添加的 VM 的引用,然后配置网络。之后打开它非常容易。

$vmRefs = $sdkVApp->getContainedVmRefs($newVmName);
$sdkVm = $service->createSDKObj($vmRefs[0]);
$service->waitForTask($sdkVm->modifyNetworkConnectionSettings($nsection));
$service->waitForTask($sdkVm->powerOn());
于 2014-01-30T09:23:05.707 回答