I am managing vApps via the vCloud API(1.5) and the vCloud PHP SDK(1.5).
I can start a stopped VM using the following below, however I am not sure how you can stop a running/deployed VM while reading the documentation. I see that you can invoke an action/powerOff, however I am not sure how you would do it within the SDK. Any help is appreciated!
<?php
// This will start/turn on a vApp/VM. However, I cannot figure out how to turn it off from reading the documentation using the PHP SDK. Any help is appreciated!
// login
$service = VMware_VCloud_SDK_Service::getService();
$service->login($server, array('username'=>$user, 'password'=>$pswd), $httpConfig);
// create an SDK Org object
$orgRefs = $service->getOrgRefs($orgName);
if (0 == count($orgRefs))
{
exit("No organization with name $orgName is found
");
}
$orgRef = $orgRefs[0];
$sdkOrg = $service->createSDKObj($orgRef);
// create an SDK vDC object
$vdcRefs = $sdkOrg->getVdcRefs($vdcName);
if (0 == count($vdcRefs))
{
exit("No vDC with name $vdcName is found
");
}
$vdcRef = $vdcRefs[0];
$sdkVdc = $service->createSDKObj($vdcRef);
// get a reference to a vApp in the vDC
$vAppRefs = $sdkVdc->getVAppRefs($vAppName);
if (!$vAppRefs)
{
exit("No vApp with name $vAppName is found
");
}
$vAppRef = $vAppRefs[0];
// create an SDK vApp object
$sdkVApp = $service->createSDKObj($vAppRef);
// create a VMware_VCloud_API_DeployVAppParamsType data object
$params = new VMware_VCloud_API_DeployVAppParamsType();
$params->set_powerOn($powerOn);
$params->set_deploymentLeaseSeconds($deploymentLeaseSeconds);
// deploy the vApp
$sdkVApp->deploy($params)
<?php
References:
vCloud API Programming Guide : http://vmware.com/pdf/vcd_15_api_guide.pdf
vCloud SDK for PHP Developer's Guide : http://www.vmware.com/pdf/vcd_15_sdk_php_dg.pdf