本文整理汇总了Python中gns3.cloud.rackspace_ctrl.RackspaceCtrl.list_images方法的典型用法代码示例。如果您正苦于以下问题:Python RackspaceCtrl.list_images方法的具体用法?Python RackspaceCtrl.list_images怎么用?Python RackspaceCtrl.list_images使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gns3.cloud.rackspace_ctrl.RackspaceCtrl
的用法示例。
在下文中一共展示了RackspaceCtrl.list_images方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRackspaceCtrlDriver
# 需要导入模块: from gns3.cloud.rackspace_ctrl import RackspaceCtrl [as 别名]
# 或者: from gns3.cloud.rackspace_ctrl.RackspaceCtrl import list_images [as 别名]
class TestRackspaceCtrlDriver(unittest.TestCase):
""" Test the libcloud Rackspace driver. """
class StubObject(object):
def __init__(self, **kwargs):
for arg in kwargs:
setattr(self, arg, kwargs[arg])
def setUp(self):
""" Set up the objects used by most of the tests. """
self.ctrl = RackspaceCtrl('valid_user', 'valid_api_key', 'http://foo.bar:8888')
self.ctrl.post_fn = stub_rackspace_identity_post
self.ctrl.driver_cls = MockLibCloudDriver
self.ctrl.authenticate()
self.ctrl.set_region('iad')
self.ctrl.get_image = mock.MagicMock()
self.ctrl.get_image.return_value = ''
self.key_pair = TestRackspaceCtrlDriver.StubObject(public_key='keystr')
def test_create_instance_over_limit(self):
""" Ensure '413 Over Limit' error is handled properly. """
self.assertRaises(OverLimit, self.ctrl.create_instance,
'over_limit', 'size', 'image', self.key_pair)
def test_create_instance_bad_request(self):
""" Ensure '400 Bad Request' error is handled properly. """
self.assertRaises(BadRequest, self.ctrl.create_instance,
'bad_request', 'size', 'image', self.key_pair)
def test_delete_instance_nonexistant(self):
""" Ensure '404 Instance not found' error is handled properly. """
instance = TestRackspaceCtrlDriver.StubObject(name='nonexistant')
self.assertRaises(ItemNotFound, self.ctrl.delete_instance,
instance)
def test_create_key_pair_duplicate_name(self):
""" Ensure '409 Key Pair exists' error is handled properly. """
self.assertRaises(KeyPairExists, self.ctrl.create_key_pair,
'duplicate_name')
def test_service_uavailable(self):
""" Ensure '503 Service Unavailable' error is handled properly. """
self.assertRaises(ServiceUnavailable, self.ctrl.create_instance,
'service_unavailable', 'size', 'image',
self.key_pair)
def test_unauthorized(self):
""" Ensure '401 Unauthroized' error is handled properly. """
self.assertRaises(Unauthorized, self.ctrl.create_instance,
'unauthorized', 'size', 'image', self.key_pair)
def test_api_error(self):
""" Ensure '500 ...' error is handled properly. """
self.assertRaises(ApiError, self.ctrl.create_instance, 'api_error',
'size', 'image', self.key_pair)
def test_list_images(self):
self.ctrl.tenant_id = '1234567890'
self.ctrl._get_shared_images = mock.MagicMock()
self.ctrl._get_shared_images.return_value = [
{
"image_name": "foo",
"schema": "/v2/schemas/member",
"status": "pending",
"image_id": "1c6ba38d-5960-4cc1-a3db-bab521e99afa",
"member_id": "user_foo",
"created_at": "2014-06-25T13:49:56Z",
"updated_at": "2014-06-25T13:49:56Z"
},
{
"image_name": "foo2",
"schema": "/v2/schemas/member",
"status": "pending",
"image_id": "a44a6c31-a437-498e-b4e4-3a6cb9d1d733",
"member_id": "user_foo",
"created_at": "2014-06-25T13:49:59Z",
"updated_at": "2014-06-25T13:49:59Z"
},
{
"image_name": "foo3",
"member_id": "user_foo",
"image_id": "64c3b6e5-05c1-4407-82b9-5690cdfaa887",
"status": "ALREADYREQUESTED"
},
{
"image_name": "foo4",
"member_id": "user_foo",
"image_id": "a6893756-b108-4667-9bf3-7a02d076b3e2",
#.........这里部分代码省略.........