本文整理汇总了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)
示例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)
示例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)
示例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()
示例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/')
示例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
示例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
示例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
示例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)
示例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
示例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
示例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
示例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 = {}
示例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()]
示例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)