当前位置: 首页>>代码示例>>Python>>正文


Python Log.debug方法代码示例

本文整理汇总了Python中pyvcloud.Log.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Log.debug方法的具体用法?Python Log.debug怎么用?Python Log.debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyvcloud.Log的用法示例。


在下文中一共展示了Log.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: blueprint

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
def blueprint(cmd_proc, operation, blueprint, blueprint_file, include_plan):
    """Operations with Blueprints"""
    scoreclient = None
    if 'validate' != operation:
        scoreclient = _authorize(cmd_proc)
    else:
        scoreclient = Score(cmd_proc.host_score)
        Log.debug(cmd_proc.logger, 'using host score: %s' %
                  cmd_proc.host_score)
    if 'validate' == operation:
        _validate(cmd_proc, blueprint_file, scoreclient)
    elif 'list' == operation:
        _list_blueprints(cmd_proc, scoreclient)
    elif 'upload' == operation:
        _upload(cmd_proc, blueprint, blueprint_file, scoreclient)
    elif 'delete' == operation:
        _delete_blueprint(cmd_proc, blueprint, scoreclient)
    elif 'info' == operation:
        _info_blueprint(cmd_proc, scoreclient,
                        include_plan=include_plan)
    elif 'status' == operation:
        try:
            scoreclient = _authorize(cmd_proc)
            status = scoreclient.get_status()
            print_utils.print_dict(json.loads(status))
        except exceptions.ClientException as e:
            utils.print_error("Unable to get blueprinting service status. "
                              "Reason: {0}"
                              .format(str(e)), cmd_proc)
开发者ID:amwelch,项目名称:vca-cli,代码行数:31,代码来源:vca_cli_blueprint.py

示例2: get_status

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
 def get_status(self):
     self.response = Http.get(self.url + '/status',
                              headers=self.get_headers(),
                              verify=self.verify, logger=self.logger)
     Log.debug(self.logger, self.response.status_code)
     Log.debug(self.logger, self.response.content)
     return self.response.content
开发者ID:digideskio,项目名称:pyvcloud,代码行数:9,代码来源:score.py

示例3: blueprint

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
def blueprint(cmd_proc, operation, blueprint_id, blueprint_file, include_plan):
    """Operations with Blueprints"""

    if "validate" != operation:
        scoreclient = _authorize(cmd_proc)
    else:
        scoreclient = Score(cmd_proc.host_score)
        Log.debug(cmd_proc.logger, "using host score: %s" % cmd_proc.host_score)

    _run_operation(cmd_proc, operation, blueprint_id, blueprint_file, include_plan, scoreclient)
开发者ID:tsugliani,项目名称:vca-cli,代码行数:12,代码来源:vca_cli_blueprint.py

示例4: customize_guest_os

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
    def customize_guest_os(self, vm_name, customization_script=None,
                           computer_name=None, admin_password=None,
                           reset_password_required=False):
        """
        Associate a customization script with a guest OS and execute the script.
        The VMware tools must be installed in the Guest OS.

        :param vm_name: (str): The name of the vm to be customized.
        :param customization_script: (str, Optional): The path to a file on the local file system containing the customization script.
        :param computer_name: (str, Optional): A new value for the the computer name. A default value for the template is used if a value is not set.
        :param admin_password: (str, Optional): A password value for the admin/root user. A password is autogenerated if a value is not supplied.
        :param reset_password_required: (bool): Force the user to reset the password on first login.
        :return: (TaskType) a :class:`pyvcloud.schema.vcd.v1_5.schemas.admin.vCloudEntities.TaskType` object that can be used to monitor the request. \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()
                customization_section = [section for section in sections
                         if (section.__class__.__name__ ==
                             "GuestCustomizationSectionType")
                         ][0]
                customization_section.set_Enabled(True)
                customization_section.set_ResetPasswordRequired(
                    reset_password_required)
                customization_section.set_AdminAutoLogonEnabled(False)
                customization_section.set_AdminAutoLogonCount(0)
                if customization_script:
                    customization_section.set_CustomizationScript(
                        customization_script)
                if computer_name:
                    customization_section.set_ComputerName(computer_name)
                if admin_password:
                    customization_section.set_AdminPasswordEnabled(True)
                    customization_section.set_AdminPasswordAuto(False)
                    customization_section.set_AdminPassword(admin_password)
                output = StringIO()
                customization_section.export(output,
                    0,
                    name_ = 'GuestCustomizationSection',
                    namespacedef_ = 'xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"',
                    pretty_print = True)
                body = output.getvalue().\
                    replace("vmw:", "").replace('Info xmlns:vmw="http://www.vmware.com/vcloud/v1.5" msgid=""', "ovf:Info").\
                    replace("/Info", "/ovf:Info")
                headers = self.headers
                headers['Content-type'] = 'application/vnd.vmware.vcloud.guestcustomizationsection+xml'
                self.response = Http.put(customization_section.Link[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, "failed; response status=%d, content=%s" % (self.response.status_code, self.response.text))
开发者ID:kostya13,项目名称:pyvcloud,代码行数:57,代码来源:vapp.py

示例5: modify_vm_memory

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
    def modify_vm_memory(self, vm_name, new_size):
        """
        Modify the virtual Memory allocation for VM.

        :param vm_name: (str): The name of the vm to be customized.
        :param new_size: (int): The new memory allocation in MB.
        :return: (TaskType) a :class:`pyvcloud.schema.vcd.v1_5.schemas.admin.vCloudEntities.TaskType` object that can be used to monitor the request. \n
                            if the task cannot be created a debug level log message is generated detailing the reason.

        :raises: Exception: If the named VM cannot be located or another error occured.
        """
        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 = vm.get_Section()
                virtualHardwareSection = filter(lambda section: section.__class__.__name__== "VirtualHardwareSection_Type", sections)[0]
                items = virtualHardwareSection.get_Item()
                memory = filter(lambda item: item.get_Description().get_valueOf_() == "Memory Size", items)[0]
                href = memory.get_anyAttributes_().get('{http://www.vmware.com/vcloud/v1.5}href')
                en = memory.get_ElementName()
                en.set_valueOf_('%s MB of memory' % new_size)
                memory.set_ElementName(en)
                vq = memory.get_VirtualQuantity()
                vq.set_valueOf_(new_size)
                memory.set_VirtualQuantity(vq)
                weight = memory.get_Weight()
                weight.set_valueOf_(str(int(new_size)*10))
                memory.set_Weight(weight)
                memory_string = CommonUtils.convertPythonObjToStr(memory, 'Memory')
                Log.debug(self.logger, "memory: \n%s" % memory_string)
                output = StringIO()
                memory.export(output,
                    0,
                    name_ = 'Item',
                    namespacedef_ = 'xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"',
                    pretty_print = True)
                body = output.getvalue().\
                    replace('Info msgid=""', "ovf:Info").replace("/Info", "/ovf:Info").\
                    replace("vmw:", "").replace("class:", "rasd:").replace("ResourceType", "rasd:ResourceType")
                headers = self.headers
                headers['Content-type'] = 'application/vnd.vmware.vcloud.rasdItem+xml'
                self.response = Http.put(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:
                    raise Exception(self.response.status_code)
        raise Exception('can\'t find vm')
开发者ID:kostya13,项目名称:pyvcloud,代码行数:50,代码来源:vapp.py

示例6: delete_vapp

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
 def delete_vapp(self, vdc_name, vapp_name):
     self.vdc = self.get_vdc(vdc_name)
     if not self.vcloud_session or not self.vcloud_session.organization or not self.vdc: return False
     vapp = self.get_vapp(self.vdc, vapp_name)
     if not vapp: return False
     #undeploy and remove
     if vapp.me.deployed:
         task = vapp.undeploy()
         if task:
             self.block_until_completed(task)
         else:
             Log.debug(self.logger, "vapp.undeploy() didn't return a task")
             return False
     vapp = self.get_vapp(self.vdc, vapp_name)
     if vapp: return vapp.delete()
     Log.debug(self.logger, "no vApp")
开发者ID:nmishkin,项目名称:pyvcloud,代码行数:18,代码来源:vcloudair.py

示例7: customize_guest_os

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
 def customize_guest_os(self, vm_name, customization_script=None,
                        computer_name=None, admin_password=None,
                        reset_password_required=False):
     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()
             customization_section = [section for section in sections
                      if (section.__class__.__name__ ==
                          "GuestCustomizationSectionType")
                      ][0]
             customization_section.set_Enabled(True)
             customization_section.set_ResetPasswordRequired(
                 reset_password_required)
             customization_section.set_AdminAutoLogonEnabled(False)
             customization_section.set_AdminAutoLogonCount(0)
             if customization_script:
                 customization_section.set_CustomizationScript(
                     customization_script)
             if computer_name:
                 customization_section.set_ComputerName(computer_name)
             if admin_password:
                 customization_section.set_AdminPasswordEnabled(True)
                 customization_section.set_AdminPasswordAuto(False)
                 customization_section.set_AdminPassword(admin_password)
             output = StringIO()
             customization_section.export(output,
                 0,
                 name_ = 'GuestCustomizationSection',
                 namespacedef_ = 'xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"',
                 pretty_print = False)
             body = output.getvalue().\
                 replace("vmw:", "").replace('Info xmlns:vmw="http://www.vmware.com/vcloud/v1.5" msgid=""', "ovf:Info").\
                 replace("/Info", "/ovf:Info")
             headers = self.headers
             headers['Content-type'] = 'application/vnd.vmware.vcloud.guestcustomizationsection+xml'
             self.response = Http.put(customization_section.Link[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, "failed; response status=%d, content=%s" % (self.response.status_code, self.response.text))
开发者ID:nmishkin,项目名称:pyvcloud,代码行数:44,代码来源:vapp.py

示例8: get_vms_details

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
    def get_vms_details(self):
        """
        Return a list the details for all VMs contained in the vApp.

        :return: (list) a list, one entry per vm containing a (dict) of properties for the VM. \n
         Dictionary keys 'name','status','cpus','memory','memory_mb','os','owner','admin_password','reset_password_required'
        """

        result = []
        children = self.me.get_Children()
        if children:
            vms = children.get_Vm()
            for vm in vms:
                name = vm.get_name()
                status = VCLOUD_STATUS_MAP[vm.get_status()]
                owner = self.me.get_Owner().get_User().get_name()
                sections = vm.get_Section()
                virtualHardwareSection = filter(lambda section: section.__class__.__name__== "VirtualHardwareSection_Type", sections)[0]
                items = virtualHardwareSection.get_Item()
                cpu = filter(lambda item: item.get_Description().get_valueOf_() == "Number of Virtual CPUs", items)[0]
                cpu_capacity = int(cpu.get_ElementName().get_valueOf_().split(" virtual CPU(s)")[0])
                memory = filter(lambda item: item.get_Description().get_valueOf_() == "Memory Size", items)[0]
                memory_capacity_mb = int(memory.get_ElementName().get_valueOf_().split(" MB of memory")[0])
                memory_capacity = memory_capacity_mb / 1024
                operatingSystemSection = filter(lambda section: section.__class__.__name__== "OperatingSystemSection_Type", sections)[0]
                os = operatingSystemSection.get_Description().get_valueOf_()
                customization_section = filter(lambda section: section.__class__.__name__== "GuestCustomizationSectionType", sections)[0]
                result.append(
                    {'name': name,
                     'status': status,
                     'cpus': cpu_capacity,
                     'memory': memory_capacity,
                     'memory_mb': memory_capacity_mb,
                     'os': os,
                     'owner': owner,
                     'admin_password': customization_section.get_AdminPassword(),
                     'reset_password_required': customization_section.get_ResetPasswordRequired()
                     }
                )
        Log.debug(self.logger, "details of VMs: %s" % result)
        return result
开发者ID:kostya13,项目名称:pyvcloud,代码行数:43,代码来源:vapp.py

示例9: disconnect_vms

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
    def disconnect_vms(self, network_name=None):
        """
        Disconnect the vm from the vapp network.

        :param network_name: (string): The name of the vApp network. If None, then disconnect from all the networks.
        :return: (bool): True if the user was vApp was successfully deployed, False otherwise.

        """
        children = self.me.get_Children()
        if children:
            vms = children.get_Vm()
            for vm in vms:
                Log.debug(self.logger, "child VM name=%s" % vm.get_name())
                networkConnectionSection = [section for section in vm.get_Section() if isinstance(section, NetworkConnectionSectionType)][0]
                found = -1
                if network_name is None:
                    networkConnectionSection.set_NetworkConnection([])
                    found = 1
                else:
                    for index, networkConnection in enumerate(networkConnectionSection.get_NetworkConnection()):
                        if networkConnection.get_network() == network_name:
                            found = index
                            break
                    if found != -1:
                        networkConnectionSection.NetworkConnection.pop(found)
                if found != -1:
                    output = StringIO()
                    networkConnectionSection.export(output,
                        0,
                        name_ = 'NetworkConnectionSection',
                        namespacedef_ = 'xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:vmw="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"',
                        pretty_print = True)
                    body=output.getvalue().replace("vmw:Info", "ovf:Info")
                    self.response = Http.put(vm.get_href() + "/networkConnectionSection/", data=body, headers=self.headers, verify=self.verify, logger=self.logger)
                    if self.response.status_code == requests.codes.accepted:
                        return taskType.parseString(self.response.content, True)
        task = TaskType()
        task.set_status("success")
        task.set_Progress("100")
        return task
开发者ID:kostya13,项目名称:pyvcloud,代码行数:42,代码来源:vapp.py

示例10: force_customization

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
 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 = 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))
开发者ID:nmishkin,项目名称:pyvcloud,代码行数:24,代码来源:vapp.py

示例11: login

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
 def login(self, host, username, password, instance, org, version,
           save_password=True):
     self.vca = VCA(host=host, username=username, version=version,
                    verify=self.verify, log=self.debug)
     service_type = self.vca.get_service_type()
     if service_type == VCA.VCA_SERVICE_TYPE_UNKNOWN:
         raise Exception('service type unknown')
     self.vca.service_type = service_type
     if VCA.VCA_SERVICE_TYPE_STANDALONE == service_type and \
        org is None:
         self.error_message = 'Org can\'t be null'
         return False
     result = self.vca.login(password=password, org=org)
     if result:
         Log.debug(self.logger, 'logged in, org=%s' % self.vca.org)
         if VCA.VCA_SERVICE_TYPE_STANDALONE == service_type:
             result = self.vca.vcloud_session.login(token=self.vca.
                                                    vcloud_session.token)
             assert result
         if save_password:
             self.password = password
         self.save_config(self.profile, self.profile_file)
     return result
开发者ID:digideskio,项目名称:vca-cli,代码行数:25,代码来源:cmd_proc.py

示例12: execute

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
    def execute(self, operation, http, body=None, targetVM=None):
        """
        Execute an operation against a VM as an Asychronous Task.

        :param operation: (str): The command to execute
        :param http: (str): The http operation.
        :param body: (str, optional): a body for the http request
        :param targetVM: (str, optional): The name of the VM that will be the target of the request.
        :return: (TaskType or Bool) a :class:`pyvcloud.schema.vcd.v1_5.schemas.admin.vCloudEntities.TaskType` object that can be used to monitor the request. \n
                Or False if the request failed, error and debug level messages are logged.

        """
        vApp = targetVM if targetVM else self.me
        link = filter(lambda link: link.get_rel() == operation, vApp.get_Link())
        if not link:
            Log.error(self.logger, "link not found; rel=%s" % operation)
            Log.debug(self.logger, "vApp href=%s, name=%s" % (vApp.get_href(), vApp.get_name()))
            return False
        else:
            if http == "post":
                headers = self.headers
                if body and body.startswith('<DeployVAppParams '):
                    headers['Content-type'] = 'application/vnd.vmware.vcloud.deployVAppParams+xml'
                elif body and body.startswith('<UndeployVAppParams '):
                    headers['Content-type'] = 'application/vnd.vmware.vcloud.undeployVAppParams+xml'
                elif body and body.startswith('<CreateSnapshotParams '):
                    headers['Content-type'] = 'application/vnd.vmware.vcloud.createSnapshotParams+xml'
                self.response = Http.post(link[0].get_href(), data=body, headers=headers, verify=self.verify, logger=self.logger)
            elif http == "put":
                self.response = Http.put(link[0].get_href(), data=body, headers=self.headers, verify=self.verify, logger=self.logger)
            else:
                self.response = Http.delete(link[0].get_href(), headers=self.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, "failed; response status=%d, content=%s" % (self.response.status_code, self.response.text))
                return False
开发者ID:kostya13,项目名称:pyvcloud,代码行数:39,代码来源:vapp.py

示例13: force_customization

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
    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))
开发者ID:kostya13,项目名称:pyvcloud,代码行数:39,代码来源:vapp.py

示例14: modify_vm_name

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
    def modify_vm_name(self, vm_index, vm_name):
        """
        Modify the name of a VM in a vApp

        :param vm_index: (int):The index of the VM in the vApp 1==first VM
        :param vm_name: (str): The new name of the VM.
        :return: (TaskType) a :class:`pyvcloud.schema.vcd.v1_5.schemas.admin.vCloudEntities.TaskType` object that can be used to monitor the request. \n
                            if the task cannot be created a debug level log message is generated detailing the reason.

        :raises: Exception: If the named VM cannot be located or another error occured.
        """
        children = self.me.get_Children()
        if children:
            assert len(children.get_Vm()) >= vm_index
            vm = children.get_Vm()[vm_index-1]
            assert vm
            href = vm.get_href()
            vm_name_old = vm.get_name()
            Log.debug(self.logger, "VM name change (%s) %s -> %s" % (vm_index, vm_name_old, vm_name))
            vm.set_name(vm_name)
            vm.set_Section([])
            output = StringIO()
            vm.export(output,
                0,
                name_ = 'Vm',
                namespacedef_ = 'xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:vmw="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"',
                pretty_print = True)
            body = output.getvalue()
            headers = self.headers
            headers['Content-type'] = 'application/vnd.vmware.vcloud.vm+xml'
            self.response = Http.post(href+'/action/reconfigureVm', 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:
                raise Exception(self.response.status_code)
        raise Exception('can\'t find vm')
开发者ID:kostya13,项目名称:pyvcloud,代码行数:38,代码来源:vapp.py

示例15: execute

# 需要导入模块: from pyvcloud import Log [as 别名]
# 或者: from pyvcloud.Log import debug [as 别名]
 def execute(self, operation, http, body=None, targetVM=None):
     vApp = targetVM if targetVM else self.me
     link = filter(lambda link: link.get_rel() == operation, vApp.get_Link())
     if not link:
         Log.error(self.logger, "link not found; rel=%s" % operation)
         Log.debug(self.logger, "vApp href=%s, name=%s" % (vApp.get_href(), vApp.get_name()))
         return False
     else:
         if http == "post":
             headers = self.headers
             if body and body.startswith('<DeployVAppParams '):
                 headers['Content-type'] = 'application/vnd.vmware.vcloud.deployVAppParams+xml'
             elif body and body.startswith('<UndeployVAppParams '):
                 headers['Content-type'] = 'application/vnd.vmware.vcloud.undeployVAppParams+xml'
             self.response = Http.post(link[0].get_href(), data = body, headers=headers, verify=self.verify, logger=self.logger)
         elif http == "put":
             self.response = Http.put(link[0].get_href(), data = body, headers=self.headers, verify=self.verify, logger=self.logger)
         else:
             self.response = Http.delete(link[0].get_href(), headers=self.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, "failed; response status=%d, content=%s" % (self.response.status_code, response.text))
             return False
开发者ID:nmishkin,项目名称:pyvcloud,代码行数:26,代码来源:vapp.py


注:本文中的pyvcloud.Log.debug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。