Download Chapter 4 - Packt Publishing

Transcript
Chapter 5
Now that we found the SDK Object of the OvDC, let's get the Organization Network.
//get ONet Ref
$netRefs = $sdkOrg->getOrgNetworkRefs($OrgNetName);
//as we know what we are looking for we can search directly for it
if (0 == count($netRefs))
{
exit("Onet $OrgNetName not found\n");
}
$netRef = $netRefs[0];
$pnetwkRef = VMware_VCloud_SDK_Helper::createReferenceTypeObj(
$netRef->get_href(),
'ParentNetwork');
//to connect the Network directly we need to get the parent network
reference.
Last but not least, we need the template Ref. We use the same method we used in the OvDC.
We loop through all Orgs and all OvDCs to find the vApp template.
//get Template
$TOrgRefs=$service->getOrgRefs();
foreach ($TOrgRefs as $TOrgRef) {
$TsdkOrg = $service->createSDKObj($TOrgRef);
$TvdcRefs = $sdkOrg->getVdcRefs();
foreach ($TvdcRefs as $TvdcRef) {
$TsdkVdc = $service->createSDKObj($TvdcRef);
$vAppTemplateRefs = $TsdkVdc>getVAppTemplateRefs($vAppTempName);
if ($vAppTemplateRefs)
{
$vAppTemplateRef = $vAppTemplateRefs[0];
break 2;
}
}
}
if (!$vAppTemplateRef){
exit("No vAppTemplate with name $vAppTempName is found\n");
}
Creating a new vApp
Now it is time to create a new vApp. I would recommend having a look at the REST section and
to spot the similarities.
$info = new VMware_VCloud_API_OVF_Msg_Type();
$info->set_valueOf("Configuration parameters for logical
networks");
175
For More Information:
www.packtpub.com/vmware-vcloud-director-cookbook/book