def force_customization(self, vm_name): children = self.me.get_Children() if children: vms = [vm for vm in children.get_Vm() if vm.name == vm_name] if len(vms) == 1: sections = vms[0].get_Section() links = filter(lambda link: link.rel == "deploy", vms[0].Link) if len(links) == 1: forceCustomizationValue = 'true' deployVAppParams = vcloudType.DeployVAppParamsType() deployVAppParams.set_powerOn('true') deployVAppParams.set_deploymentLeaseSeconds(0) deployVAppParams.set_forceCustomization('true') body = CommonUtils.convertPythonObjToStr( deployVAppParams, name="DeployVAppParams", namespacedef='xmlns="http://www.vmware.com/vcloud/v1.5"' ) headers = self.headers headers[ 'Content-type'] = 'application/vnd.vmware.vcloud.deployVAppParams+xml' self.response = requests.post(links[0].href, data=body, headers=headers, verify=self.verify) if self.response.status_code == requests.codes.accepted: return taskType.parseString(self.response.content, True) else: print self.response.content
def deploy(self, powerOn=True): powerOnValue = 'true' if powerOn else 'false' deployVAppParams = vcloudType.DeployVAppParamsType() deployVAppParams.set_powerOn(powerOnValue) body = CommonUtils.convertPythonObjToStr( deployVAppParams, name="DeployVAppParams", namespacedef='xmlns="http://www.vmware.com/vcloud/v1.5"') return self.execute("deploy", "post", body=body)
def deploy(self, powerOn=True): """ Deploy the vapp :param powerOn: (bool, optional): Power on the vApp and its contained VMs after deployment. :return: (bool): True if the user was vApp was successfully deployed, False otherwise. """ powerOnValue = 'true' if powerOn else 'false' deployVAppParams = vcloudType.DeployVAppParamsType() deployVAppParams.set_powerOn(powerOnValue) body = CommonUtils.convertPythonObjToStr(deployVAppParams, name = "DeployVAppParams", namespacedef = 'xmlns="http://www.vmware.com/vcloud/v1.5"') return self.execute("deploy", "post", body=body)
def force_customization(self, vm_name, power_on=True): """ Force the guest OS customization script to be run for a specific vm in the vApp. A customization script must have been previously associated with the VM using the pyvcloud customize_guest_os method or using the vCD console The VMware tools must be installed in the Guest OS. :param vm_name: (str): The name of the vm to be customized. :param power_on (bool): Wether to power the vm on after customization or not :return: (TaskType) a :class:`pyvcloud.schema.vcd.v1_5.schemas.admin.vCloudEntities.TaskType` object that can be used to monitor the request.b\n if the task cannot be created a debug level log message is generated detailing the reason. """ children = self.me.get_Children() if children: vms = [vm for vm in children.get_Vm() if vm.name == vm_name] if len(vms) == 1: sections = vms[0].get_Section() links = filter(lambda link: link.rel == "deploy", vms[0].Link) if len(links) == 1: forceCustomizationValue = 'true' deployVAppParams = vcloudType.DeployVAppParamsType() if power_on: deployVAppParams.set_powerOn('true') else: deployVAppParams.set_powerOn('false') deployVAppParams.set_deploymentLeaseSeconds(0) deployVAppParams.set_forceCustomization('true') body = CommonUtils.convertPythonObjToStr( deployVAppParams, name="DeployVAppParams", namespacedef='xmlns="http://www.vmware.com/vcloud/v1.5"' ) headers = self.headers headers[ 'Content-type'] = 'application/vnd.vmware.vcloud.deployVAppParams+xml' self.response = Http.post(links[0].href, data=body, headers=headers, verify=self.verify, logger=self.logger) if self.response.status_code == requests.codes.accepted: return taskType.parseString(self.response.content, True) else: Log.debug( self.logger, "response status=%d, content=%s" % (self.response.status_code, self.response.text))