本文整理汇总了Python中profitbricks.client.ProfitBricksService.get_attached_volume方法的典型用法代码示例。如果您正苦于以下问题:Python ProfitBricksService.get_attached_volume方法的具体用法?Python ProfitBricksService.get_attached_volume怎么用?Python ProfitBricksService.get_attached_volume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profitbricks.client.ProfitBricksService
的用法示例。
在下文中一共展示了ProfitBricksService.get_attached_volume方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestServer
# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import get_attached_volume [as 别名]
#.........这里部分代码省略.........
composite_server = self.client.get_server(
datacenter_id=self.datacenter['id'],
server_id=composite_server['id'])
assertRegex(self, composite_server['id'], self.resource['uuid_match'])
self.assertEqual(composite_server['properties']['name'], self.resource['server']['name'])
self.assertEqual(composite_server['properties']['cores'], self.resource['server']['cores'])
self.assertEqual(composite_server['properties']['ram'], self.resource['server']['ram'])
self.assertEqual(composite_server['properties']['availabilityZone'], 'AUTO')
self.assertIn(composite_server['properties']['vmState'], self.resource['vm_states'])
def test_start_server(self):
server = self.client.start_server(
datacenter_id=self.datacenter['id'],
server_id=self.server['id'])
self.assertTrue(server)
def test_stop_server(self):
server = self.client.stop_server(
datacenter_id=self.datacenter['id'],
server_id=self.server['id'])
self.assertTrue(server)
def test_reboot_server(self):
server = self.client.reboot_server(
datacenter_id=self.datacenter['id'],
server_id=self.server['id'])
self.assertTrue(server)
def test_get_attached_volumes(self):
servers = self.client.get_attached_volumes(
datacenter_id=self.datacenter['id'],
server_id=self.server['id'])
self.assertGreater(len(servers), 0)
self.assertEqual(servers['items'][0]['id'], self.volume1['id'])
self.assertEqual(servers['items'][0]['properties']['name'], self.resource['volume']['name'])
self.assertEqual(servers['items'][0]['properties']['size'], self.resource['volume']['size'])
self.assertEqual(servers['items'][0]['properties']['bus'], self.resource['volume']['bus'])
self.assertEqual(servers['items'][0]['properties']['type'], self.resource['volume']['type'])
self.assertEqual(servers['items'][0]['properties']['licenceType'], 'UNKNOWN')
self.assertIsNone(servers['items'][0]['properties']['image'])
self.assertIsNone(servers['items'][0]['properties']['imagePassword'])
self.assertFalse(servers['items'][0]['properties']['cpuHotPlug'])
self.assertFalse(servers['items'][0]['properties']['cpuHotUnplug'])
self.assertFalse(servers['items'][0]['properties']['ramHotPlug'])
self.assertFalse(servers['items'][0]['properties']['ramHotUnplug'])
self.assertFalse(servers['items'][0]['properties']['nicHotPlug'])
self.assertFalse(servers['items'][0]['properties']['nicHotUnplug'])
self.assertFalse(servers['items'][0]['properties']['discVirtioHotPlug'])
self.assertFalse(servers['items'][0]['properties']['discVirtioHotUnplug'])
self.assertFalse(servers['items'][0]['properties']['discScsiHotPlug'])
self.assertFalse(servers['items'][0]['properties']['discScsiHotUnplug'])
def test_get_attached_volume(self):
server = self.client.get_attached_volume(
datacenter_id=self.datacenter['id'],
server_id=self.server['id'],
volume_id=self.volume1['id'])
self.assertEqual(server['id'], self.volume1['id'])
self.assertEqual(server['properties']['name'], self.resource['volume']['name'])
示例2: TestServer
# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import get_attached_volume [as 别名]
#.........这里部分代码省略.........
firewall_active=True,
)
nic2 = NIC(
name='nic2',
ips=['10.2.3.4'],
dhcp='true',
lan=1,
firewall_active=True,
)
nics = [nic1, nic2]
i = Server(
name='server1',
ram=4096,
cores=4,
boot_volume_id=boot_volume_id,
attach_volumes=attach_volumes,
nics=nics
)
response = self.server.create_server(
datacenter_id=datacenter_id,
server=i)
self.assertEqual(response['id'], server_id)
self.assertEqual(response['properties']['name'], 'New Server')
self.assertEqual(response['properties']['cores'], '4')
self.assertEqual(response['properties']['ram'], '4096')
self.assertEqual(response['properties']['availabilityZone'], 'ZONE_1')
self.assertEqual(response['properties']['vmState'], 'SHUTOFF')
def test_get_attached_volumes(self):
servers = self.server.get_attached_volumes(
datacenter_id=datacenter_id,
server_id=server_id)
self.assertEqual(len(servers), 4)
self.assertEqual(servers['items'][0]['id'], '700e1cab-99b2-4c30-ba8c-1d273ddba025')
self.assertEqual(servers['items'][0]['properties']['name'], 'my boot volume for server 1')
self.assertEqual(servers['items'][0]['properties']['size'], 80)
self.assertEqual(servers['items'][0]['properties']['bus'], 'VIRTIO')
self.assertEqual(servers['items'][0]['properties']['image'], None)
self.assertEqual(servers['items'][0]['properties']['imagePassword'], None)
self.assertEqual(servers['items'][0]['properties']['type'], 'HDD')
self.assertEqual(servers['items'][0]['properties']['licenceType'], 'WINDOWS')
self.assertFalse(servers['items'][0]['properties']['cpuHotPlug'])
self.assertFalse(servers['items'][0]['properties']['cpuHotUnplug'])
self.assertFalse(servers['items'][0]['properties']['ramHotPlug'])
self.assertFalse(servers['items'][0]['properties']['ramHotUnplug'])
self.assertFalse(servers['items'][0]['properties']['nicHotPlug'])
self.assertFalse(servers['items'][0]['properties']['nicHotUnplug'])
self.assertFalse(servers['items'][0]['properties']['discVirtioHotPlug'])
self.assertFalse(servers['items'][0]['properties']['discVirtioHotUnplug'])
self.assertFalse(servers['items'][0]['properties']['discScsiHotPlug'])
self.assertFalse(servers['items'][0]['properties']['discScsiHotUnplug'])
def test_get_attached_volume(self):
volume_id = '700e1cab-99b2-4c30-ba8c-1d273ddba025'
server = self.server.get_attached_volume(
datacenter_id=datacenter_id,
server_id=server_id,
volume_id=volume_id)