本文整理汇总了Python中profitbricks.client.ProfitBricksService.update_datacenter方法的典型用法代码示例。如果您正苦于以下问题:Python ProfitBricksService.update_datacenter方法的具体用法?Python ProfitBricksService.update_datacenter怎么用?Python ProfitBricksService.update_datacenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profitbricks.client.ProfitBricksService
的用法示例。
在下文中一共展示了ProfitBricksService.update_datacenter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDatacenter
# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import update_datacenter [as 别名]
class TestDatacenter(unittest.TestCase):
def setUp(self):
self.datacenter = ProfitBricksService(username="username", password="password")
def test_get_all(self):
datacenters = self.datacenter.list_datacenters()
self.assertEqual(len(datacenters), 4)
self.assertEqual(datacenters["items"][0]["id"], datacenter_id)
# self.assertEqual(
# datacenters['items'][0]['properties']['name'], 'datacenter1')
# self.assertEqual(
# datacenters['items'][0]['properties']['description'], 'Description of my DC')
# self.assertEqual(
# datacenters['items'][0]['properties']['location'], 'de/fkb')
# self.assertEqual(
# datacenters['items'][0]['properties']['version'], 4)
def test_get(self):
datacenter = self.datacenter.get_datacenter(datacenter_id=datacenter_id)
self.assertEqual(datacenter["id"], datacenter_id)
self.assertEqual(datacenter["properties"]["name"], "datacenter1")
self.assertEqual(datacenter["properties"]["description"], "Description of my DC")
self.assertEqual(datacenter["properties"]["version"], 4)
self.assertEqual(datacenter["properties"]["location"], "de/fkb")
def test_delete(self):
datacenter = self.datacenter.delete_datacenter(datacenter_id=datacenter_id)
self.assertTrue(datacenter)
def test_update(self):
datacenter = self.datacenter.update_datacenter(
datacenter_id=datacenter_id, name="Partially updated datacenter name"
)
self.assertEqual(datacenter["id"], datacenter_id)
self.assertEqual(datacenter["properties"]["name"], "datacenter1")
self.assertEqual(datacenter["properties"]["description"], "Description of my DC")
self.assertEqual(datacenter["properties"]["version"], 4)
self.assertEqual(datacenter["properties"]["location"], "de/fkb")
def test_create_simple(self):
i = Datacenter(name="datacenter1", description="My New Datacenter", location="de/fkb")
response = self.datacenter.create_datacenter(datacenter=i)
self.assertEqual(response["id"], datacenter_id)
self.assertEqual(response["properties"]["name"], "datacenter1")
self.assertEqual(response["properties"]["description"], "My New Datacenter")
self.assertEqual(response["properties"]["version"], 4)
self.assertEqual(response["properties"]["location"], "de/fkb")
def test_create_complex(self):
"""
Creates a complex Datacenter in a single request.
"""
fwrule1 = FirewallRule(
name="Open SSH port", protocol="TCP", source_mac="01:23:45:67:89:00", port_range_start=22
)
fwrule2 = FirewallRule(name="Allow PING", protocol="ICMP", icmp_type=8, icmp_code=0)
fw_rules = [fwrule1, fwrule2]
nic1 = NIC(name="nic1", ips=["10.2.2.3"], dhcp="true", lan=1, firewall_active=True, firewall_rules=fw_rules)
nic2 = NIC(name="nic2", ips=["10.2.3.4"], dhcp="true", lan=1, firewall_active=True, firewall_rules=fw_rules)
nics = [nic1, nic2]
volume1 = Volume(name="volume1", size=56, image="<IMAGE/SNAPSHOT-ID>", bus="VIRTIO")
volume2 = Volume(name="volume2", size=56, image="<IMAGE/SNAPSHOT-ID>", bus="VIRTIO")
volumes = [volume2]
server1 = Server(name="server1", ram=4096, cores=4, nics=nics, create_volumes=[volume1])
servers = [server1]
balancednics = ["<NIC-ID-1>", "<NIC-ID-2>"]
loadbalancer1 = LoadBalancer(name="My LB", balancednics=balancednics)
loadbalancers = [loadbalancer1]
lan1 = LAN(name="public Lan 4", public=True)
lan2 = LAN(name="public Lan 4", public=True)
lans = [lan1, lan2]
d = Datacenter(
name="datacenter1",
description="my DC",
location="de/fkb",
servers=servers,
#.........这里部分代码省略.........
示例2: TestDatacenter
# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import update_datacenter [as 别名]
class TestDatacenter(unittest.TestCase):
@classmethod
def setUpClass(self):
self.resource = resource()
self.client = ProfitBricksService(
username=configuration.USERNAME,
password=configuration.PASSWORD,
headers=configuration.HEADERS)
# Create test datacenter.
self.datacenter = self.client.create_datacenter(
datacenter=Datacenter(**self.resource['datacenter']))
@classmethod
def tearDownClass(self):
self.client.delete_datacenter(datacenter_id=self.datacenter['id'])
def test_list(self):
datacenters = self.client.list_datacenters()
self.assertGreater(len(datacenters), 0)
self.assertEqual(datacenters['items'][0]['type'], 'datacenter')
def test_get(self):
datacenter = self.client.get_datacenter(
datacenter_id=self.datacenter['id'])
assertRegex(self, datacenter['id'], self.resource['uuid_match'])
self.assertEqual(datacenter['type'], 'datacenter')
self.assertEqual(datacenter['id'], self.datacenter['id'])
self.assertEqual(datacenter['properties']['name'], self.resource['datacenter']['name'])
self.assertEqual(datacenter['properties']['description'], self.resource['datacenter']['description'])
self.assertEqual(datacenter['properties']['location'], self.resource['datacenter']['location'])
def test_delete(self):
datacenter = self.client.create_datacenter(
datacenter=Datacenter(**self.resource['datacenter']))
wait_for_completion(self.client, datacenter, 'create_datacenter')
response = self.client.delete_datacenter(
datacenter_id=datacenter['id'])
self.assertTrue(response)
def test_update(self):
datacenter = self.client.update_datacenter(
datacenter_id=self.datacenter['id'],
description=self.resource['datacenter']['name']+' - RENAME')
wait_for_completion(self.client, datacenter, 'update_datacenter')
datacenter = self.client.get_datacenter(datacenter_id=self.datacenter['id'])
assertRegex(self, datacenter['id'], self.resource['uuid_match'])
self.assertEqual(datacenter['id'], self.datacenter['id'])
self.assertEqual(datacenter['properties']['name'], self.resource['datacenter']['name'])
self.assertEqual(datacenter['properties']['description'], self.resource['datacenter']['name']+' - RENAME')
self.assertEqual(datacenter['properties']['location'], self.resource['datacenter']['location'])
self.assertGreater(datacenter['properties']['version'], 1)
def test_create_simple(self):
datacenter = self.client.create_datacenter(
datacenter=Datacenter(**self.resource['datacenter']))
wait_for_completion(self.client, datacenter, 'create_datacenter')
assertRegex(self, datacenter['id'], self.resource['uuid_match'])
self.assertEqual(datacenter['properties']['name'], self.resource['datacenter']['name'])
self.assertEqual(datacenter['properties']['description'], self.resource['datacenter']['description'])
self.assertEqual(datacenter['properties']['location'], self.resource['datacenter']['location'])
response = self.client.delete_datacenter(
datacenter_id=datacenter['id'])
self.assertTrue(response)
示例3: TestDatacenter
# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import update_datacenter [as 别名]
class TestDatacenter(unittest.TestCase):
def setUp(self):
self.datacenter = ProfitBricksService(
username='username', password='password')
def test_get_all(self):
datacenters = self.datacenter.list_datacenters()
self.assertEqual(len(datacenters), 4)
self.assertEqual(datacenters['items'][0]['id'], datacenter_id)
# self.assertEqual(
# datacenters['items'][0]['properties']['name'], 'datacenter1')
# self.assertEqual(
# datacenters['items'][0]['properties']['description'], 'Description of my DC')
# self.assertEqual(
# datacenters['items'][0]['properties']['location'], 'de/fkb')
# self.assertEqual(
# datacenters['items'][0]['properties']['version'], 4)
def test_get(self):
datacenter = self.datacenter.get_datacenter(
datacenter_id=datacenter_id)
self.assertEqual(datacenter['id'], datacenter_id)
self.assertEqual(datacenter['properties']['name'], 'datacenter1')
self.assertEqual(datacenter['properties']['description'], 'Description of my DC')
self.assertEqual(datacenter['properties']['version'], 4)
self.assertEqual(datacenter['properties']['location'], 'de/fkb')
def test_delete(self):
datacenter = self.datacenter.delete_datacenter(
datacenter_id=datacenter_id)
self.assertTrue(datacenter)
def test_update(self):
datacenter = self.datacenter.update_datacenter(
datacenter_id=datacenter_id,
name='Partially updated datacenter name')
self.assertEqual(datacenter['id'], datacenter_id)
self.assertEqual(datacenter['properties']['name'], 'datacenter1')
self.assertEqual(datacenter['properties']['description'], 'Description of my DC')
self.assertEqual(datacenter['properties']['version'], 4)
self.assertEqual(datacenter['properties']['location'], 'de/fkb')
def test_create_simple(self):
i = Datacenter(
name='datacenter1',
description='My New Datacenter',
location='de/fkb'
)
response = self.datacenter.create_datacenter(datacenter=i)
self.assertEqual(response['id'], datacenter_id)
self.assertEqual(response['properties']['name'], 'My New Datacenter')
self.assertEqual(response['properties']['description'], 'Production environment')
self.assertEqual(response['properties']['version'], 4)
self.assertEqual(response['properties']['location'], 'de/fkb')
def test_create_complex(self):
"""
Creates a complex Datacenter in a single request.
"""
fwrule1 = FirewallRule(
name='Open SSH port',
protocol='TCP',
source_mac='01:23:45:67:89:00',
port_range_start=22
)
fwrule2 = FirewallRule(
name='Allow PING',
protocol='ICMP',
icmp_type=8,
icmp_code=0
)
fw_rules = [fwrule1, fwrule2]
nic1 = NIC(
name='nic1',
ips=['10.2.2.3'],
dhcp='true',
lan=1,
firewall_active=True,
firewall_rules=fw_rules
)
nic2 = NIC(
name='nic2',
ips=['10.2.3.4'],
dhcp='true',
lan=1,
firewall_active=True,
firewall_rules=fw_rules
)
#.........这里部分代码省略.........