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


Python network.NetworkManagementClient方法代碼示例

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


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

示例1: create_azure_session

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def create_azure_session(token, service):
    assert service in ['compute', 'network', 'security', 'storage', 'resource']
    assert isinstance(token, ServicePrincipalCredentials)
    platform = config.profile.get('platform')
    if 'subscription' in platform and platform['subscription']:
        sub_id = platform['subscription']
    else:
        raise ValueError("Subscription ID not in Azure Platform Definition")
    if service == 'compute':
        from azure.mgmt.compute import ComputeManagementClient
        return ComputeManagementClient(token, sub_id)
    if service == 'network':
        from azure.mgmt.network import NetworkManagementClient
        return NetworkManagementClient(token, sub_id)
    if service == 'storage':
        from azure.mgmt.storage import StorageManagementClient
        return StorageManagementClient(token, sub_id)
    if service == 'resource':
        from azure.mgmt.resource import ResourceManagementClient
        return ResourceManagementClient(token, sub_id) 
開發者ID:Chaffelson,項目名稱:whoville,代碼行數:22,代碼來源:infra.py

示例2: setIPs

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def setIPs(vm, network_profile, credentials, subscription_id):
        """
        Set the information about the IPs of the VM
        """

        private_ips = []
        public_ips = []

        network_client = NetworkManagementClient(credentials, subscription_id)

        for ni in network_profile.network_interfaces:
            name = " ".join(ni.id.split('/')[-1:])
            sub = "".join(ni.id.split('/')[4])

            ip_conf = network_client.network_interfaces.get(sub, name).ip_configurations

            for ip in ip_conf:
                if ip.private_ip_address:
                    private_ips.append(ip.private_ip_address)
                if ip.public_ip_address:
                    name = " ".join(ip.public_ip_address.id.split('/')[-1:])
                    sub = "".join(ip.public_ip_address.id.split('/')[4])
                    public_ip_info = network_client.public_ip_addresses.get(sub, name)
                    public_ips.append(public_ip_info.ip_address)

        vm.setIps(public_ips, private_ips) 
開發者ID:grycap,項目名稱:im,代碼行數:28,代碼來源:Azure.py

示例3: get_client

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def get_client(self, subscription_id: str):
        return NetworkManagementClient(self.credentials.get_credentials('arm'),
                                       subscription_id=subscription_id) 
開發者ID:nccgroup,項目名稱:ScoutSuite,代碼行數:5,代碼來源:network.py

示例4: __init__

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def __init__(self, connect: bool = False):
        """Initialize connector for Azure Python SDK."""
        self.connected = False
        self.credentials: Optional[ServicePrincipalCredentials] = None
        self.sub_client: Optional[SubscriptionClient] = None
        self.resource_client: Optional[ResourceManagementClient] = None
        self.network_client: Optional[NetworkManagementClient] = None
        self.monitoring_client: Optional[MonitorManagementClient] = None
        self.compute_client: Optional[ComputeManagementClient] = None
        if connect is True:
            self.connect() 
開發者ID:microsoft,項目名稱:msticpy,代碼行數:13,代碼來源:azure_data.py

示例5: __init__

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def __init__(self):
        os.environ['AZURE_AUTH_LOCATION'] = '/root/azure_auth.json'
        self.compute_client = get_client_from_auth_file(ComputeManagementClient)
        self.resource_client = get_client_from_auth_file(ResourceManagementClient)
        self.network_client = get_client_from_auth_file(NetworkManagementClient)
        self.storage_client = get_client_from_auth_file(StorageManagementClient)
        self.datalake_client = get_client_from_auth_file(DataLakeStoreAccountManagementClient)
        self.authorization_client = get_client_from_auth_file(AuthorizationManagementClient)
        self.sp_creds = json.loads(open(os.environ['AZURE_AUTH_LOCATION']).read())
        self.dl_filesystem_creds = lib.auth(tenant_id=json.dumps(self.sp_creds['tenantId']).replace('"', ''),
                                            client_secret=json.dumps(self.sp_creds['clientSecret']).replace('"', ''),
                                            client_id=json.dumps(self.sp_creds['clientId']).replace('"', ''),
                                            resource='https://datalake.azure.net/') 
開發者ID:apache,項目名稱:incubator-dlab,代碼行數:15,代碼來源:actions_lib.py

示例6: network_client

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def network_client(self):
        self.log('Getting network client')
        if not self._network_client:
            self._network_client = self.get_mgmt_svc_client(NetworkManagementClient,
                                                            self._cloud_environment.endpoints.resource_manager,
                                                            '2017-06-01')
            self._register('Microsoft.Network')
        return self._network_client 
開發者ID:hortonworks,項目名稱:ansible-hortonworks,代碼行數:10,代碼來源:azure_rm.py

示例7: network_management_client

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def network_management_client(self):
        if not self._network_management_client:
            self._network_management_client = NetworkManagementClient(
                self._credentials, self.subscription_id)
        return self._network_management_client 
開發者ID:CloudVE,項目名稱:cloudbridge,代碼行數:7,代碼來源:azure_client.py

示例8: network_client

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def network_client(self):
        """
        Uses client from cli so that users can use az login to get their credentials

        Returns:
             Network Client
        """
        if not self.client:
            self.client = get_client_from_cli_profile(NetworkManagementClient)
        return self.client 
開發者ID:capitalone,項目名稱:Particle-Cloud-Framework,代碼行數:12,代碼來源:azure_resource.py

示例9: network_client

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def network_client(self):
        return NetworkManagementClient(self.credentials, self.subscription_id) 
開發者ID:RedHatQE,項目名稱:wrapanapi,代碼行數:4,代碼來源:msazure.py

示例10: create_connection_from_config

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def create_connection_from_config():
    """ Creates a new Azure api connection """
    resource_client = None
    compute_client = None
    network_client = None
    try:
        os.environ['AZURE_AUTH_LOCATION']
    except KeyError:
        try:
            subscription_id = os.environ['AZURE_SUBSCRIPTION_ID']
            credentials = ServicePrincipalCredentials(
                client_id=os.environ['AZURE_CLIENT_ID'],
                secret=os.environ['AZURE_CLIENT_SECRET'],
                tenant=os.environ['AZURE_TENANT_ID']
            )
        except KeyError:
            sys.exit("No Azure Connection Defined")
        else:
           resource_client = ResourceManagementClient(credentials, subscription_id)
           compute_client = ComputeManagementClient(credentials, subscription_id)
           network_client = NetworkManagementClient(credentials, subscription_id)
    else:
        resource_client = get_client_from_auth_file(ResourceManagementClient)
        compute_client = get_client_from_auth_file(ComputeManagementClient)
        network_client = get_client_from_auth_file(NetworkManagementClient)

    return resource_client, compute_client, network_client 
開發者ID:bloomberg,項目名稱:powerfulseal,代碼行數:29,代碼來源:azure_driver.py

示例11: __init__

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def __init__(self, location: str, subscription_id: str, client_id: str, client_secret: str, tenant_id: str):
        self.credentials = ServicePrincipalCredentials(
            client_id=client_id,
            secret=client_secret,
            tenant=tenant_id)
        self.rmc = ResourceManagementClient(self.credentials, subscription_id)
        self.nmc = NetworkManagementClient(self.credentials, subscription_id)
        self.mc = MonitorClient(self.credentials, subscription_id)
        # location is included to keep a similar model as dcos_launch.platforms.aws.BotoWrapper
        self.location = location 
開發者ID:dcos,項目名稱:dcos-launch,代碼行數:12,代碼來源:arm.py

示例12: network_client

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def network_client(self):
        self.log('Getting network client')
        if not self._network_client:
            self._network_client = NetworkManagementClient(
                self.azure_credentials,
                self.subscription_id,
                base_url=self._cloud_environment.endpoints.resource_manager,
                api_version='2017-06-01'
            )
            self._register('Microsoft.Network')
        return self._network_client 
開發者ID:PacktPublishing,項目名稱:Ansible-2-Cloud-Automation-Cookbook,代碼行數:13,代碼來源:azure_rm.py

示例13: __init__

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def __init__(self, provider_config, cluster_name):
        NodeProvider.__init__(self, provider_config, cluster_name)
        kwargs = {}
        if "subscription_id" in provider_config:
            kwargs["subscription_id"] = provider_config["subscription_id"]
        try:
            self.compute_client = get_client_from_cli_profile(
                client_class=ComputeManagementClient, **kwargs)
            self.network_client = get_client_from_cli_profile(
                client_class=NetworkManagementClient, **kwargs)
            self.resource_client = get_client_from_cli_profile(
                client_class=ResourceManagementClient, **kwargs)
        except CLIError as e:
            if str(e) != "Please run 'az login' to setup account.":
                raise
            else:
                logger.info("CLI profile authentication failed. Trying MSI")

                credentials = MSIAuthentication()
                self.compute_client = ComputeManagementClient(
                    credentials=credentials, **kwargs)
                self.network_client = NetworkManagementClient(
                    credentials=credentials, **kwargs)
                self.resource_client = ResourceManagementClient(
                    credentials=credentials, **kwargs)

        self.lock = RLock()

        # cache node objects
        self.cached_nodes = {} 
開發者ID:ray-project,項目名稱:ray,代碼行數:32,代碼來源:node_provider.py

示例14: get_nics

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def get_nics(options):
    cli = get_client_from_json_dict(NetworkManagementClient, options)
    return [nic.as_dict() for nic in cli.network_interfaces.list_all()] 
開發者ID:snowflakedb,項目名稱:SnowAlert,代碼行數:5,代碼來源:azure_vm.py

示例15: get_clients

# 需要導入模塊: from azure.mgmt import network [as 別名]
# 或者: from azure.mgmt.network import NetworkManagementClient [as 別名]
def get_clients(self):
        """
        Set up access to Azure API clients
        """
        credentials, subscription_id = self.get_credentials()
        self.resource_client = ResourceManagementClient(
            credentials, subscription_id)
        self.compute_client = ComputeManagementClient(credentials,
                                                      subscription_id)
        self.network_client = NetworkManagementClient(credentials,
                                                      subscription_id) 
開發者ID:Parsl,項目名稱:parsl,代碼行數:13,代碼來源:azure.py


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