當前位置: 首頁>>代碼示例>>Python>>正文


Python ConfigDict.lower方法代碼示例

本文整理匯總了Python中cloudmesh_client.common.ConfigDict.ConfigDict.lower方法的典型用法代碼示例。如果您正苦於以下問題:Python ConfigDict.lower方法的具體用法?Python ConfigDict.lower怎麽用?Python ConfigDict.lower使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cloudmesh_client.common.ConfigDict.ConfigDict的用法示例。


在下文中一共展示了ConfigDict.lower方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: boot_vm

# 需要導入模塊: from cloudmesh_client.common.ConfigDict import ConfigDict [as 別名]
# 或者: from cloudmesh_client.common.ConfigDict.ConfigDict import lower [as 別名]
    def boot_vm(self,
                name,
                group=None,
                image=None,
                flavor=None,
                cloud=None,
                cert_thumbprint=None,
                pub_key_path=None,
                cert_path=None,
                pfx_path=None,
                secgroup=None,
                meta=None,
                nics=None,
                **kwargs):
        """
            Boots up a new VM Instance.
            Steps involved: creating a hosted(Cloud) Service, adding the PFX certificate file,
            get default storage name, creating a configuration set, adding an endpoint(SSH by default),
            and finally creating a VM deployment

        :param name: Hosted Service Name and VM instance name
        :param group:
        :param image:
        :param flavor:
        :param cloud:
        :param cert_thumbprint:
        :param pub_key_path:
        :param cert_path:
        :param pfx_path:
        :param secgroup:
        :param meta:
        :param nics:
        :param kwargs:
        :return:
        """

        location = ConfigDict(filename="cloudmesh.yaml")["cloudmesh"]["clouds"]["azure"]["default"]["location"] or 'Central US'
        try:
            self.provider.create_hosted_service(service_name=name,
                                    label=name,
                                    location=location)
        except:
            Console.error("Failed to create hosted service in Azure: {0}".format(traceback.format_exc()))

        try:
            Console.info("service name: " + name)
            Console.info("location name: " + location)
            Console.info("cert_thumbprint: " + cert_thumbprint)
            Console.info("pub_key_path: " + pub_key_path)
            Console.info("cert_path: " + cert_path)
            Console.info("pfx_path:" + pfx_path)
            Console.info("Image:" + image)
            Console.info("Flavor:" + flavor)
            #Console.info("Certificate adding")
            # Disabled - not required to start Virtual Machine
            #self.add_certificate(name, pfx_path)
            #Console.info("Certificate added")
        except Exception as e:
            Console.warning("Console.info error: {0}".format(traceback.format_exc()))
        storage_name = self._get_storage_name()
        if storage_name is None:
            self._create_storage_account()
            storage_name = self._get_storage_name()
        media_link = 'https://{0}.blob.core.windows.net/vhds/{1}.vhd'.format(
                        storage_name, name)
        os_hd = OSVirtualHardDisk(image, media_link)

        username = ConfigDict(filename="cloudmesh.yaml")["cloudmesh"]["clouds"]["azure"]["default"]["username"]
        password = ConfigDict(filename="cloudmesh.yaml")["cloudmesh"]["clouds"]["azure"]["default"]["password"]
        # Auto-generated Password in case of TBD
        if username.lower() in ["tbd"]:
            username = "azure";
        if password.lower() in ["tbd"]:
            password = generate_password(16)

        Console.info("Username: "+username)
        Console.info("password: "+password)

        # TODO: current case handles only for linux guest VMs, implementation needed for Windows VMs
        # SSH key configuration does not work properly - DISABLED
        linux_config = LinuxConfigurationSet(name, username, password, False)
        linux_config.ssh = SSH()
        public_key = PublicKey(cert_thumbprint, pub_key_path)
        #linux_config.ssh.public_keys.public_keys.append(public_key)
        pair = KeyPair(cert_thumbprint, cert_path)
        #linux_config.ssh.key_pairs.key_pairs.append(pair)

        # Endpoint configuration
        network = ConfigurationSet()
        network.configuration_set_type = 'NetworkConfiguration'
        network.input_endpoints.input_endpoints.append(
            ConfigurationSetInputEndpoint('SSH', 'tcp', '22', '22'))

        Console.info("blob storage location: {0} ".format(media_link))
        try:
            vm_create_result = self.provider.create_virtual_machine_deployment(service_name=name,
            deployment_name=name,
            deployment_slot='production',
            label=name,
            role_name=name,
#.........這裏部分代碼省略.........
開發者ID:cloudmesh,項目名稱:client,代碼行數:103,代碼來源:CloudProviderAzureAPI.py


注:本文中的cloudmesh_client.common.ConfigDict.ConfigDict.lower方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。