本文整理汇总了Python中gns3.cloud.rackspace_ctrl.RackspaceCtrl._get_shared_images方法的典型用法代码示例。如果您正苦于以下问题:Python RackspaceCtrl._get_shared_images方法的具体用法?Python RackspaceCtrl._get_shared_images怎么用?Python RackspaceCtrl._get_shared_images使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gns3.cloud.rackspace_ctrl.RackspaceCtrl
的用法示例。
在下文中一共展示了RackspaceCtrl._get_shared_images方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRackspaceCtrl
# 需要导入模块: from gns3.cloud.rackspace_ctrl import RackspaceCtrl [as 别名]
# 或者: from gns3.cloud.rackspace_ctrl.RackspaceCtrl import _get_shared_images [as 别名]
#.........这里部分代码省略.........
{'ORD': 'ord'},
{'HKG': 'hkg'}
]
self.assertCountEqual(regions, expected_regions)
def test_list_instances(self):
name = "%slist_instances" % self.object_prefix
image = self.ctrl.driver.list_images()[0]
size = self.ctrl.driver.list_sizes()[0]
key_pair = self.ctrl.create_key_pair(name)
instance = self.ctrl.create_instance(name, size, image, key_pair)
if self.run_instances:
self.ctrl.driver.wait_until_running([instance])
instances = self.ctrl.list_instances()
self.assertIsInstance(instances, list)
self.assertIsInstance(instances[0], Node)
def test_list_sizes(self):
sizes = self.ctrl.list_sizes()
self.assertIsInstance(sizes, list)
self.assertIsInstance(sizes[0], NodeSize)
def test_token_parsed(self):
""" Ensure that the token is set. """
self.assertIsNotNone(self.ctrl.token)
def test__get_shared_image_not_found(self):
self.assertRaises(ItemNotFound, self.ctrl._get_shared_images, 'user_foo', 'IAD', 'foo_ver')
def test__get_shared_image(self):
name = "%s_get_shared_image" % self.object_prefix
images = self.ctrl.driver.list_images()
# use the smallest image available on Rackspace
image = [i for i in images if 'boot.rackspace.com' in i.name][0]
size = self.ctrl.driver.list_sizes()[0]
key_pair = self.ctrl.create_key_pair(name)
print("Creating an instance...")
instance = self.ctrl.create_instance(name, size, image, key_pair)
# we cannot create images until the build is over
self.ctrl.driver.wait_until_running([instance])
print("Instance up and running.")
print("Creating an image...")
gns3_image1 = self.ctrl.driver.ex_save_image(instance, 'gns3_3.0a', metadata=None)
# wait until image is active or gns3-ias will ignore it
while self.ctrl.driver.ex_get_image(gns3_image1.id).extra['status'] != 'ACTIVE':
time.sleep(2)
print("Image created.")
# wait to avoid Exception: 409 Conflict Cannot 'createImage' while instance is in task_state image_uploading
self.ctrl.driver.wait_until_running([instance])
print("Creating another image...")
gns3_image2 = self.ctrl.driver.ex_save_image(instance, 'gns3_3.0b', metadata=None)
# wait until image is active or gns3-ias will ignore it
while self.ctrl.driver.ex_get_image(gns3_image2.id).extra['status'] != 'ACTIVE':
time.sleep(2)
print("Image created.")
print("Getting shared images...")
r_images = self.ctrl._get_shared_images('user_foo', 'ORD', '3.0')
self.assertTrue('image_id' in r_images[0])
self.assertTrue('image_id' in r_images[1])
self.assertTrue('member_id' in r_images[0])
self.assertTrue('member_id' in r_images[1])
self.assertTrue('status' in r_images[0])
self.assertTrue('status' in r_images[1])
self.assertEqual(r_images[0]['status'], 'pending')
self.assertEqual(r_images[1]['status'], 'pending')
print("Done.")
print("Getting shared images...")
r_images2 = self.ctrl._get_shared_images('user_foo', 'ORD', '3.0')
self.assertTrue('image_id' in r_images2[0])
self.assertTrue('image_id' in r_images2[1])
self.assertEqual(r_images[0]['image_id'], r_images2[0]['image_id'])
self.assertEqual(r_images[1]['image_id'], r_images2[1]['image_id'])
self.assertTrue('member_id' in r_images2[0])
self.assertTrue('member_id' in r_images2[1])
self.assertEqual(r_images[0]['member_id'], r_images2[0]['member_id'])
self.assertEqual(r_images[1]['member_id'], r_images2[1]['member_id'])
self.assertTrue('status' in r_images2[0])
self.assertTrue('status' in r_images2[1])
self.assertEqual(r_images2[0]['status'], 'ALREADYREQUESTED')
self.assertEqual(r_images2[1]['status'], 'ALREADYREQUESTED')
print("Done.")
示例2: TestRackspaceCtrl
# 需要导入模块: from gns3.cloud.rackspace_ctrl import RackspaceCtrl [as 别名]
# 或者: from gns3.cloud.rackspace_ctrl.RackspaceCtrl import _get_shared_images [as 别名]
#.........这里部分代码省略.........
self.assertCountEqual(regions, expected_regions)
def test_list_instances(self):
name = "%slist_instances" % self.object_prefix
image = self.ctrl.driver.list_images()[0]
size = self.ctrl.driver.list_sizes()[0]
key_pair = self.ctrl.create_key_pair(name)
instance = self.ctrl.create_instance(name, size, image, key_pair)
if self.run_instances:
self.ctrl.driver.wait_until_running([instance])
instances = self.ctrl.list_instances()
self.assertIsInstance(instances, list)
self.assertIsInstance(instances[0], Node)
def test_list_sizes(self):
sizes = self.ctrl.list_sizes()
self.assertIsInstance(sizes, list)
self.assertIsInstance(sizes[0], NodeSize)
def test_token_parsed(self):
""" Ensure that the token is set. """
self.assertIsNotNone(self.ctrl.token)
def test__get_shared_image_not_found(self):
self.assertRaises(ItemNotFound, self.ctrl._get_shared_images, "user_foo", "IAD", "foo_ver")
def test__get_shared_image(self):
name = "%s_get_shared_image" % self.object_prefix
images = self.ctrl.driver.list_images()
# use the smallest image available on Rackspace
image = [i for i in images if "boot.rackspace.com" in i.name][0]
size = self.ctrl.driver.list_sizes()[0]
key_pair = self.ctrl.create_key_pair(name)
print("Creating an instance...")
instance = self.ctrl.create_instance(name, size, image, key_pair)
# we cannot create images until the build is over
self.ctrl.driver.wait_until_running([instance])
print("Instance up and running.")
print("Creating an image...")
gns3_image1 = self.ctrl.driver.ex_save_image(instance, "gns3_3.0a", metadata=None)
# wait until image is active or gns3-ias will ignore it
while self.ctrl.driver.ex_get_image(gns3_image1.id).extra["status"] != "ACTIVE":
time.sleep(2)
print("Image created.")
# wait to avoid Exception: 409 Conflict Cannot 'createImage' while instance is in task_state image_uploading
self.ctrl.driver.wait_until_running([instance])
print("Creating another image...")
gns3_image2 = self.ctrl.driver.ex_save_image(instance, "gns3_3.0b", metadata=None)
# wait until image is active or gns3-ias will ignore it
while self.ctrl.driver.ex_get_image(gns3_image2.id).extra["status"] != "ACTIVE":
time.sleep(2)
print("Image created.")