当前位置: 首页>>代码示例>>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;未经允许,请勿转载。