本文整理汇总了Python中azure.servicemanagement.ServiceManagementService.set_proxy方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceManagementService.set_proxy方法的具体用法?Python ServiceManagementService.set_proxy怎么用?Python ServiceManagementService.set_proxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.servicemanagement.ServiceManagementService
的用法示例。
在下文中一共展示了ServiceManagementService.set_proxy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AffinityGroupManagementServiceTest
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import set_proxy [as 别名]
class AffinityGroupManagementServiceTest(AzureTestCase):
def setUp(self):
self.sms = ServiceManagementService(credentials.getSubscriptionId(),
credentials.getManagementCertFile())
self.sms.set_proxy(credentials.getProxyHost(),
credentials.getProxyPort(),
credentials.getProxyUser(),
credentials.getProxyPassword())
self.affinity_group_name = getUniqueNameBasedOnCurrentTime('utaffgrp')
self.hosted_service_name = None
self.storage_account_name = None
def tearDown(self):
try:
if self.hosted_service_name is not None:
self.sms.delete_hosted_service(self.hosted_service_name)
except: pass
try:
if self.storage_account_name is not None:
self.sms.delete_storage_account(self.storage_account_name)
except: pass
try:
self.sms.delete_affinity_group(self.affinity_group_name)
except: pass
#--Helpers-----------------------------------------------------------------
def _create_affinity_group(self, name):
result = self.sms.create_affinity_group(name, 'tstmgmtaffgrp', 'West US', 'tstmgmt affinity group')
self.assertIsNone(result)
def _affinity_group_exists(self, name):
try:
props = self.sms.get_affinity_group_properties(name)
return props is not None
except:
return False
#--Test cases for affinity groups ------------------------------------
def test_list_affinity_groups(self):
# Arrange
self._create_affinity_group(self.affinity_group_name)
# Act
result = self.sms.list_affinity_groups()
# Assert
self.assertIsNotNone(result)
self.assertTrue(len(result) > 0)
group = None
for temp in result:
if temp.name == self.affinity_group_name:
group = temp
break
self.assertIsNotNone(group)
self.assertIsNotNone(group.name)
self.assertIsNotNone(group.label)
self.assertIsNotNone(group.description)
self.assertIsNotNone(group.location)
self.assertIsNotNone(group.capabilities)
self.assertTrue(len(group.capabilities) > 0)
def test_get_affinity_group_properties(self):
# Arrange
self.hosted_service_name = getUniqueNameBasedOnCurrentTime('utsvc')
self.storage_account_name = getUniqueNameBasedOnCurrentTime('utstorage')
self._create_affinity_group(self.affinity_group_name)
self.sms.create_hosted_service(self.hosted_service_name, 'affgrptestlabel', 'affgrptestdesc', None, self.affinity_group_name)
self.sms.create_storage_account(self.storage_account_name, self.storage_account_name + 'desc', self.storage_account_name + 'label', self.affinity_group_name)
# Act
result = self.sms.get_affinity_group_properties(self.affinity_group_name)
# Assert
self.assertIsNotNone(result)
self.assertEqual(result.name, self.affinity_group_name)
self.assertIsNotNone(result.label)
self.assertIsNotNone(result.description)
self.assertIsNotNone(result.location)
self.assertIsNotNone(result.hosted_services[0])
self.assertEqual(result.hosted_services[0].service_name, self.hosted_service_name)
self.assertEqual(result.hosted_services[0].hosted_service_properties.affinity_group, self.affinity_group_name)
# not sure why azure does not return any storage service
self.assertTrue(len(result.capabilities) > 0)
def test_create_affinity_group(self):
# Arrange
label = 'tstmgmtaffgrp'
description = 'tstmgmt affinity group'
# Act
result = self.sms.create_affinity_group(self.affinity_group_name, label, 'West US', description)
# Assert
#.........这里部分代码省略.........
示例2: StorageManagementServiceTest
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import set_proxy [as 别名]
class StorageManagementServiceTest(AzureTestCase):
def setUp(self):
proxy_host = credentials.getProxyHost()
proxy_port = credentials.getProxyPort()
self.sms = ServiceManagementService(credentials.getSubscriptionId(), credentials.getManagementCertFile())
if proxy_host:
self.sms.set_proxy(proxy_host, proxy_port)
self.storage_account_name = getUniqueNameBasedOnCurrentTime('utstorage')
def tearDown(self):
try:
self.sms.delete_storage_account(self.storage_account_name)
except: pass
#--Helpers-----------------------------------------------------------------
def _wait_for_async(self, request_id):
count = 0
result = self.sms.get_operation_status(request_id)
while result.status == 'InProgress':
count = count + 1
if count > 120:
self.assertTrue(False, 'Timed out waiting for async operation to complete.')
time.sleep(5)
result = self.sms.get_operation_status(request_id)
self.assertEqual(result.status, 'Succeeded')
def _create_storage_account(self, name):
result = self.sms.create_storage_account(name, name + 'description', name + 'label', None, 'West US', False, {'ext1':'val1', 'ext2':42})
self._wait_for_async(result.request_id)
def _storage_account_exists(self, name):
try:
props = self.sms.get_storage_account_properties(name)
return props is not None
except:
return False
#--Test cases for storage accounts -----------------------------------
def test_list_storage_accounts(self):
# Arrange
self._create_storage_account(self.storage_account_name)
# Act
result = self.sms.list_storage_accounts()
# Assert
self.assertIsNotNone(result)
self.assertTrue(len(result) > 0)
storage = None
for temp in result:
if temp.service_name == self.storage_account_name:
storage = temp
break
self.assertIsNotNone(storage)
self.assertIsNotNone(storage.service_name)
self.assertIsNone(storage.storage_service_keys)
self.assertIsNotNone(storage.storage_service_properties)
self.assertIsNotNone(storage.storage_service_properties.affinity_group)
self.assertIsNotNone(storage.storage_service_properties.description)
self.assertIsNotNone(storage.storage_service_properties.geo_primary_region)
self.assertIsNotNone(storage.storage_service_properties.geo_replication_enabled)
self.assertIsNotNone(storage.storage_service_properties.geo_secondary_region)
self.assertIsNotNone(storage.storage_service_properties.label)
self.assertIsNotNone(storage.storage_service_properties.last_geo_failover_time)
self.assertIsNotNone(storage.storage_service_properties.location)
self.assertIsNotNone(storage.storage_service_properties.status)
self.assertIsNotNone(storage.storage_service_properties.status_of_primary)
self.assertIsNotNone(storage.storage_service_properties.status_of_secondary)
self.assertIsNotNone(storage.storage_service_properties.endpoints)
self.assertTrue(len(storage.storage_service_properties.endpoints) > 0)
self.assertIsNotNone(storage.extended_properties)
self.assertTrue(len(storage.extended_properties) > 0)
def test_get_storage_account_properties(self):
# Arrange
self._create_storage_account(self.storage_account_name)
# Act
result = self.sms.get_storage_account_properties(self.storage_account_name)
# Assert
self.assertIsNotNone(result)
self.assertEqual(result.service_name, self.storage_account_name)
self.assertIsNotNone(result.url)
self.assertIsNone(result.storage_service_keys)
self.assertIsNotNone(result.storage_service_properties)
self.assertIsNotNone(result.storage_service_properties.affinity_group)
self.assertIsNotNone(result.storage_service_properties.description)
self.assertIsNotNone(result.storage_service_properties.geo_primary_region)
self.assertIsNotNone(result.storage_service_properties.geo_replication_enabled)
self.assertIsNotNone(result.storage_service_properties.geo_secondary_region)
self.assertIsNotNone(result.storage_service_properties.label)
self.assertIsNotNone(result.storage_service_properties.last_geo_failover_time)
self.assertIsNotNone(result.storage_service_properties.location)
self.assertIsNotNone(result.storage_service_properties.status)
#.........这里部分代码省略.........
示例3: ManagementCertificateManagementServiceTest
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import set_proxy [as 别名]
class ManagementCertificateManagementServiceTest(AzureTestCase):
def setUp(self):
proxy_host = credentials.getProxyHost()
proxy_port = credentials.getProxyPort()
self.sms = ServiceManagementService(credentials.getSubscriptionId(), credentials.getManagementCertFile())
if proxy_host:
self.sms.set_proxy(proxy_host, proxy_port)
self.management_certificate_name = getUniqueNameBasedOnCurrentTime('utmgmtcert')
def tearDown(self):
try:
self.sms.delete_management_certificate(self.management_certificate_name)
except: pass
#--Helpers-----------------------------------------------------------------
def _create_management_certificate(self, thumbprint):
result = self.sms.add_management_certificate(MANAGEMENT_CERT_PUBLICKEY, thumbprint, MANAGEMENT_CERT_DATA)
self.assertIsNone(result)
def _management_certificate_exists(self, thumbprint):
try:
props = self.sms.get_management_certificate(thumbprint)
return props is not None
except:
return False
#--Test cases for management certificates ----------------------------
def test_list_management_certificates(self):
# Arrange
self._create_management_certificate(self.management_certificate_name)
# Act
result = self.sms.list_management_certificates()
# Assert
self.assertIsNotNone(result)
self.assertTrue(len(result) > 0)
cert = None
for temp in result:
if temp.subscription_certificate_thumbprint == self.management_certificate_name:
cert = temp
break
self.assertIsNotNone(cert)
self.assertIsNotNone(cert.created)
self.assertEqual(cert.subscription_certificate_public_key, MANAGEMENT_CERT_PUBLICKEY)
self.assertEqual(cert.subscription_certificate_data, MANAGEMENT_CERT_DATA)
self.assertEqual(cert.subscription_certificate_thumbprint, self.management_certificate_name)
def test_get_management_certificate(self):
# Arrange
self._create_management_certificate(self.management_certificate_name)
# Act
result = self.sms.get_management_certificate(self.management_certificate_name)
# Assert
self.assertIsNotNone(result)
self.assertIsNotNone(result.created)
self.assertEqual(result.subscription_certificate_public_key, MANAGEMENT_CERT_PUBLICKEY)
self.assertEqual(result.subscription_certificate_data, MANAGEMENT_CERT_DATA)
self.assertEqual(result.subscription_certificate_thumbprint, self.management_certificate_name)
def test_add_management_certificate(self):
# Arrange
public_key = MANAGEMENT_CERT_PUBLICKEY
data = MANAGEMENT_CERT_DATA
# Act
result = self.sms.add_management_certificate(public_key, self.management_certificate_name, data)
# Assert
self.assertIsNone(result)
self.assertTrue(self._management_certificate_exists(self.management_certificate_name))
def test_delete_management_certificate(self):
# Arrange
self._create_management_certificate(self.management_certificate_name)
# Act
result = self.sms.delete_management_certificate(self.management_certificate_name)
# Assert
self.assertIsNone(result)
self.assertFalse(self._management_certificate_exists(self.management_certificate_name))
开发者ID:Bunkerbewohner,项目名称:azure-sdk-for-python,代码行数:91,代码来源:test_managementcertificatemanagementservice.py
示例4: ManagementCertificateManagementServiceTest
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import set_proxy [as 别名]
class ManagementCertificateManagementServiceTest(AzureTestCase):
def setUp(self):
self.sms = ServiceManagementService(credentials.getSubscriptionId(),
credentials.getManagementCertFile())
self.sms.set_proxy(credentials.getProxyHost(),
credentials.getProxyPort(),
credentials.getProxyUser(),
credentials.getProxyPassword())
self.certificate_thumbprints = []
def tearDown(self):
for thumbprint in self.certificate_thumbprints:
try:
self.sms.delete_management_certificate(thumbprint)
except: pass
#--Helpers-----------------------------------------------------------------
def _create_management_certificate(self, cert):
self.certificate_thumbprints.append(cert.thumbprint)
result = self.sms.add_management_certificate(cert.public_key,
cert.thumbprint,
cert.data)
self.assertIsNone(result)
def _management_certificate_exists(self, thumbprint):
try:
props = self.sms.get_management_certificate(thumbprint)
return props is not None
except:
return False
#--Test cases for management certificates ----------------------------
def test_list_management_certificates(self):
# Arrange
local_cert = _local_certificate()
self._create_management_certificate(local_cert)
# Act
result = self.sms.list_management_certificates()
# Assert
self.assertIsNotNone(result)
self.assertTrue(len(result) > 0)
cert = None
for temp in result:
if temp.subscription_certificate_thumbprint == local_cert.thumbprint:
cert = temp
break
self.assertIsNotNone(cert)
self.assertIsNotNone(cert.created)
self.assertEqual(cert.subscription_certificate_public_key, local_cert.public_key)
self.assertEqual(cert.subscription_certificate_data, local_cert.data)
self.assertEqual(cert.subscription_certificate_thumbprint, local_cert.thumbprint)
def test_get_management_certificate(self):
# Arrange
local_cert = _local_certificate()
self._create_management_certificate(local_cert)
# Act
result = self.sms.get_management_certificate(local_cert.thumbprint)
# Assert
self.assertIsNotNone(result)
self.assertIsNotNone(result.created)
self.assertEqual(result.subscription_certificate_public_key, local_cert.public_key)
self.assertEqual(result.subscription_certificate_data, local_cert.data)
self.assertEqual(result.subscription_certificate_thumbprint, local_cert.thumbprint)
def test_add_management_certificate(self):
# Arrange
local_cert = _local_certificate()
# Act
self.certificate_thumbprints.append(local_cert.thumbprint)
result = self.sms.add_management_certificate(local_cert.public_key,
local_cert.thumbprint,
local_cert.data)
# Assert
self.assertIsNone(result)
self.assertTrue(self._management_certificate_exists(local_cert.thumbprint))
def test_delete_management_certificate(self):
# Arrange
local_cert = _local_certificate()
self._create_management_certificate(local_cert)
# Act
result = self.sms.delete_management_certificate(local_cert.thumbprint)
# Assert
self.assertIsNone(result)
self.assertFalse(self._management_certificate_exists(local_cert.thumbprint))