示例#1
0
    def test_get_flavor_list_with_OnMetal(self):
        """
        Test to verify :func:`get_flavor_list` on ``GET /v2.0/<tenant_id>/flavors``
        """
        nova_api = NovaApi(['IAD'])
        self.helper = APIMockHelper(self, [nova_api])
        self.root = self.helper.root
        self.uri = self.helper.uri
        get_flavor_list_response_body = self.get_server_flavor('/flavors')
        flavor_list = get_flavor_list_response_body['flavors']
        self.assertTrue(len(flavor_list) == 38)
        for flavor in flavor_list:
            if 'onmetal' in flavor['id']:
                self.assertTrue('onmetal' in flavor['id'])
                self.assertEqual(
                    sorted(flavor.keys()),
                    sorted(['id', 'name', 'links']))

        get_flavor_list_response_body = self.get_server_flavor('/flavors/detail')
        flavor_list = get_flavor_list_response_body['flavors']
        self.assertTrue(len(flavor_list) == 38)
        for flavor in flavor_list:
            if 'onmetal' in flavor['id']:
                self.assertEqual('onmetal_flavor',
                                 flavor['OS-FLV-WITH-EXT-SPECS:extra_specs']['policy_class'])
                self.assertEqual(
                    sorted(flavor.keys()),
                    sorted(['id', 'name', 'links', 'ram', 'OS-FLV-WITH-EXT-SPECS:extra_specs',
                            'vcpus', 'swap', 'rxtx_factor', 'OS-FLV-EXT-DATA:ephemeral', 'disk']))
示例#2
0
 def setUp(self):
     """
     Create a :obj:`MimicCore` with :obj:`NovaApi` as the only plugin.
     """
     nova_api = NovaApi(['DFW'])
     self.helper = APIMockHelper(self, [nova_api])
     self.root = self.helper.root
     self.uri = self.helper.uri
示例#3
0
 def setUp(self):
     """
     Create a :obj:`MimicCore` with :obj:`NovaApi` as the only plugin,
     and create a server
     """
     helper = APIMockHelper(self, [NovaApi(["ORD", "MIMIC"])])
     self.root = helper.root
     self.uri = helper.uri
     self.helper = helper
示例#4
0
 def setUp(self):
     """
     Create a :obj:`MimicCore` with :obj:`NovaApi` as the only plugin.
     """
     nova_api = NovaApi(["ORD"])
     self.helper = self.helper = APIMockHelper(
         self, [nova_api, NovaControlApi(nova_api=nova_api)])
     self.root = self.helper.root
     self.uri = self.helper.uri
示例#5
0
 def setUp(self):
     """
     Create a :obj:`MimicCore` with :obj:`NovaApi` as the only plugin,
     and create a server
     """
     nova_api = NovaApi(["ORD", "MIMIC"])
     nova_control_api = NovaControlApi(nova_api=nova_api)
     helper = APIMockHelper(self, [nova_api, nova_control_api])
     self.nova_control_endpoint = helper.auth.get_service_endpoint(
         "cloudServersBehavior", "ORD")
     self.root = helper.root
     self.uri = helper.uri
     self.helper = helper
示例#6
0
 def setUp(self):
     """
     Create a :obj:`MimicCore` with :obj:`NovaApi` as the only plugin
     """
     nova_api = NovaApi(["ORD", "MIMIC"])
     self.helper = APIMockHelper(
         self, [nova_api, NovaControlApi(nova_api=nova_api)])
     self.root = self.helper.root
     self.clock = self.helper.clock
     self.uri = self.helper.uri
     self.create_keypair_response, self.create_keypair_response_body = (
         self.create_keypair())
     self.keypair_name = self.create_keypair_response_body['keypair'][
         'name']
示例#7
0
 def setUp(self):
     """
     Create a :obj:`MimicCore` with :obj:`NovaApi` as the only plugin,
     and create a server
     """
     helper = APIMockHelper(self, [NovaApi(["ORD", "MIMIC"])])
     self.root = helper.root
     self.uri = helper.uri
     self.server_name = 'test_server'
     create_server = request(
         self, self.root, "POST", self.uri + '/servers',
         json.dumps({
             "server": {
                 "name": self.server_name,
                 "imageRef": "test-image",
                 "flavorRef": "test-flavor"
             }
         }))
     self.create_server_response = self.successResultOf(create_server)
     self.create_server_response_body = self.successResultOf(
         treq.json_content(self.create_server_response))
     self.server_id = self.create_server_response_body['server']['id']
     self.nth_endpoint_public = helper.nth_endpoint_public
示例#8
0
文件: test_nova.py 项目: jirwin/mimic
 def setUp(self):
     """
     Create a :obj:`MimicCore` with :obj:`NovaApi` as the only plugin,
     and create a server
     """
     self.core = MimicCore(Clock(), [NovaApi()])
     self.root = MimicRoot(self.core).app.resource()
     self.response = request(
         self, self.root, "POST", "/identity/v2.0/tokens",
         json.dumps({
             "auth": {
                 "passwordCredentials": {
                     "username": "******",
                     "password": "******",
                 },
             }
         }))
     self.auth_response = self.successResultOf(self.response)
     self.json_body = self.successResultOf(
         treq.json_content(self.auth_response))
     self.uri = self.json_body['access']['serviceCatalog'][0]['endpoints'][
         0]['publicURL']
     self.server_name = 'test_server'
     self.create_server = request(
         self, self.root, "POST", self.uri + '/servers',
         json.dumps({
             "server": {
                 "name": self.server_name,
                 "imageRef": "test-image",
                 "flavorRef": "test-flavor"
             }
         }))
     self.create_server_response = self.successResultOf(self.create_server)
     self.create_server_response_body = self.successResultOf(
         treq.json_content(self.create_server_response))
     self.server_id = self.create_server_response_body['server']['id']
示例#9
0
"""
Plugin for OpenStack compute / Rackspace cloud server mock.
"""
from mimic.rest.nova_api import NovaApi

nova = NovaApi()