本文整理汇总了Python中profitbricks.client.ProfitBricksService.list_images方法的典型用法代码示例。如果您正苦于以下问题:Python ProfitBricksService.list_images方法的具体用法?Python ProfitBricksService.list_images怎么用?Python ProfitBricksService.list_images使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profitbricks.client.ProfitBricksService
的用法示例。
在下文中一共展示了ProfitBricksService.list_images方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestImage
# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import list_images [as 别名]
class TestImage(unittest.TestCase):
@classmethod
def setUpClass(self):
self.resource = resource()
self.client = ProfitBricksService(
username=configuration.USERNAME,
password=configuration.PASSWORD,
headers=configuration.HEADERS)
# Find an Ubuntu image for testing.
for item in self.client.list_images()['items']:
if 'Ubuntu-15' in item['properties']['name'] and item['properties']['location'] == configuration.LOCATION:
self.image = item
def test_list_images(self):
images = self.client.list_images()
self.assertGreater(len(images), 0)
self.assertEqual(images['items'][0]['type'], 'image')
assertRegex(self, images['items'][0]['id'], self.resource['uuid_match'])
def test_get_image(self):
image = self.client.get_image(self.image['id'])
self.assertEqual(image['type'], 'image')
self.assertEqual(image['id'], self.image['id'])
self.assertIn(image['properties']['imageType'], ['HDD', 'CDROM'])
示例2: TestImage
# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import list_images [as 别名]
class TestImage(unittest.TestCase):
def setUp(self):
self.image = ProfitBricksService(
username='username', password='password')
def test_list_images(self):
images = self.image.list_images()
self.assertEqual(len(images), 4)
self.assertEqual(
images['items'][0]['id'], '7df81087-5835-41c6-a10b-3e098593bbd2')
def test_get_image(self):
image_id = '7df81087-5835-41c6-a10b-3e098593bbd2'
image = self.image.get_image(image_id)
self.assertEqual(image['properties']['name'], 'Ubuntu 14.04')
def test_delete_image(self):
image_id = '7df81087-5835-41c6-a10b-3e098593bbd2'
image = self.image.delete_image(image_id)
self.assertTrue(image)
def test_update_image(self):
image_id = '7df81087-5835-41c6-a10b-3e098593bbd2'
image = self.image.update_image(
image_id,
name='New name')
self.assertEqual(image['properties']['name'], 'New name')
示例3: TestServer
# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import list_images [as 别名]
class TestServer(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']))
wait_for_completion(self.client, self.datacenter, 'create_datacenter')
# Create test volume1.
self.volume1 = self.client.create_volume(
datacenter_id=self.datacenter['id'],
volume=Volume(**self.resource['volume']))
wait_for_completion(self.client, self.volume1, 'create_volume')
# Create test volume2 (attach volume test).
self.volume2 = self.client.create_volume(
datacenter_id=self.datacenter['id'],
volume=Volume(**self.resource['volume']))
wait_for_completion(self.client, self.volume2, 'create_volume')
# Create test server.
server = Server(**self.resource['server'])
server.attach_volumes = [self.volume1['id']]
self.server = self.client.create_server(
datacenter_id=self.datacenter['id'],
server=server)
wait_for_completion(self.client, self.server, 'create_server')
# Create test NIC.
self.nic = self.client.create_nic(
datacenter_id=self.datacenter['id'],
server_id=self.server['id'],
nic=NIC(**self.resource['nic']))
wait_for_completion(self.client, self.nic, 'create_nic')
# Find an Ubuntu image for testing.
for item in self.client.list_images()['items']:
if 'Ubuntu-15' in item['properties']['name'] and item['properties']['location'] == configuration.LOCATION:
self.image = item
@classmethod
def tearDownClass(self):
self.client.delete_datacenter(datacenter_id=self.datacenter['id'])
def test_list(self):
servers = self.client.list_servers(datacenter_id=self.datacenter['id'])
self.assertGreater(len(servers), 0)
self.assertEqual(servers['items'][0]['type'], 'server')
assertRegex(self, servers['items'][0]['id'], self.resource['uuid_match'])
def test_get(self):
server = self.client.get_server(
datacenter_id=self.datacenter['id'],
server_id=self.server['id']
)
self.assertEqual(server['type'], 'server')
self.assertEqual(server['id'], self.server['id'])
self.assertEqual(server['properties']['name'], self.resource['server']['name'])
self.assertEqual(server['properties']['cores'], self.resource['server']['cores'])
self.assertEqual(server['properties']['ram'], self.resource['server']['ram'])
def test_delete(self):
server = self.client.create_server(
datacenter_id=self.datacenter['id'],
server=Server(**self.resource['server'])
)
wait_for_completion(self.client, server, 'create_server')
response = self.client.delete_server(
datacenter_id=self.datacenter['id'],
server_id=server['id']
)
self.assertTrue(response)
def test_update(self):
server = self.client.update_server(
datacenter_id=self.datacenter['id'],
server_id=self.server['id'],
name=self.resource['server']['name'] + ' RENAME')
wait_for_completion(self.client, server, 'update_server')
server = self.client.get_server(
datacenter_id=self.datacenter['id'],
server_id=self.server['id']
)
self.assertEqual(server['id'], self.server['id'])
self.assertEqual(server['properties']['name'], self.resource['server']['name'] + ' RENAME')
self.assertEqual(server['properties']['cores'], self.resource['server']['cores'])
self.assertEqual(server['properties']['ram'], self.resource['server']['ram'])
def test_create_simple(self):
#.........这里部分代码省略.........
示例4: ProfitBricksService
# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import list_images [as 别名]
"""List Images
"""
from profitbricks.client import ProfitBricksService
client = ProfitBricksService(
username='username', password='password')
images = client.list_images()
print(images)
"""
Update Image
Valid image parameters are:
* name (str)
* description (str)
* licence_type (one of 'LINUX', 'WINDOWS' or 'UNKNOWN')
* cpu_hot_plug (bool)
* ram_hot_plug (bool)
* nic_hot_plug (bool)
* nic_hot_unplug (bool)
* disc_virtio_hot_plug (bool)
* disc_virtio_hot_unplug (bool)
* disc_scsi_hot_plug (bool)
* disc_scsi_hot_unplug (bool)
"""
from profitbricks.client import ProfitBricksService