예제 #1
0
    def setUp(self):
        super(ServerActionsControllerTest, self).setUp()

        CONF.set_override('host', 'localhost', group='glance')
        self.stubs.Set(db, 'instance_get_by_uuid',
                       fakes.fake_instance_get(vm_state=vm_states.ACTIVE,
                                               host='fake_host'))
        self.stubs.Set(db, 'instance_update_and_get_original',
                       instance_update_and_get_original)

        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fake.stub_out_image_service(self.stubs)
        self.flags(allow_instance_snapshots=True,
                   enable_instance_password=True)
        self.uuid = FAKE_UUID
        self.url = '/servers/%s/action' % self.uuid
        self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'

        ext_info = plugins.LoadedExtensionInfo()
        self.controller = servers.ServersController(extension_info=ext_info)
        self.compute_api = self.controller.compute_api
        self.context = context.RequestContext('fake', 'fake')
        self.app = fakes.wsgi_app_v21(init_only=('servers',),
                                      fake_auth_context=self.context)
    def setUp(self):
        super(ServerActionsControllerTest, self).setUp()

        CONF.set_override('host', 'localhost', group='glance')
        self.stubs.Set(
            db, 'instance_get_by_uuid',
            fakes.fake_instance_get(vm_state=vm_states.ACTIVE,
                                    host='fake_host'))
        self.stubs.Set(db, 'instance_update_and_get_original',
                       instance_update_and_get_original)

        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fake.stub_out_image_service(self.stubs)
        self.flags(allow_instance_snapshots=True,
                   enable_instance_password=True)
        self.uuid = FAKE_UUID
        self.url = '/servers/%s/action' % self.uuid
        self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'

        ext_info = plugins.LoadedExtensionInfo()
        self.controller = servers.ServersController(extension_info=ext_info)
        self.compute_api = self.controller.compute_api
        self.context = context.RequestContext('fake', 'fake')
        self.app = fakes.wsgi_app_v21(init_only=('servers', ),
                                      fake_auth_context=self.context)
예제 #3
0
    def setUp(self):
        super(ServerActionsControllerTestV21, self).setUp()

        CONF.set_override("host", "localhost", group="glance")
        self.stubs.Set(db, "instance_get_by_uuid", fakes.fake_instance_get(vm_state=vm_states.ACTIVE, host="fake_host"))
        self.stubs.Set(db, "instance_update_and_get_original", instance_update_and_get_original)

        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fake.stub_out_image_service(self.stubs)
        self.flags(allow_instance_snapshots=True, enable_instance_password=True)
        self._image_href = "155d900f-4e14-4e4c-a73d-069cbf4541e6"

        self.controller = self._get_controller()
        self.compute_api = self.controller.compute_api
        self.req = fakes.HTTPRequest.blank("")
        self.context = self.req.environ["nova.context"]
    def setUp(self):
        super(ServerActionsControllerTestV21, self).setUp()
        self.flags(group='glance', api_servers=['http://localhost:9292'])
        self.stub_out('nova.compute.api.API.get',
                      fakes.fake_compute_get(vm_state=vm_states.ACTIVE,
                                             host='fake_host'))
        self.stub_out('nova.objects.Instance.save', lambda *a, **kw: None)

        fakes.stub_out_compute_api_snapshot(self)
        fake.stub_out_image_service(self)
        self.flags(enable_instance_password=True, group='api')
        self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'

        self.controller = self._get_controller()
        self.compute_api = self.controller.compute_api
        # We don't care about anything getting as far as hitting the compute
        # RPC API so we just mock it out here.
        mock_rpcapi = mock.patch.object(self.compute_api, 'compute_rpcapi')
        mock_rpcapi.start()
        self.addCleanup(mock_rpcapi.stop)
        # The project_id here matches what is used by default in
        # fake_compute_get which need to match for policy checks.
        self.req = fakes.HTTPRequest.blank('', project_id='fake_project')
        self.context = self.req.environ['nova.context']

        self.image_api = image.API()
        # Assume that anything that hits the compute API and looks for a
        # RequestSpec doesn't care about it, since testing logic that deep
        # should be done in nova.tests.unit.compute.test_compute_api.
        mock_reqspec = mock.patch('nova.objects.RequestSpec')
        mock_reqspec.start()
        self.addCleanup(mock_reqspec.stop)
        # Similarly we shouldn't care about anything hitting conductor from
        # these tests.
        mock_conductor = mock.patch.object(
            self.controller.compute_api, 'compute_task_api')
        mock_conductor.start()
        self.addCleanup(mock_conductor.stop)
        # Assume that none of the tests are using ports with resource requests.
        self.mock_list_port = self.useFixture(
            fixtures.MockPatch(
                'nova.network.neutronv2.api.API.list_ports')).mock
        self.mock_list_port.return_value = {'ports': []}
예제 #5
0
    def setUp(self):
        super(ServerActionsControllerTestV21, self).setUp()
        self.flags(group='glance', api_servers=['http://localhost:9292'])
        self.stub_out('nova.db.instance_get_by_uuid',
                      fakes.fake_instance_get(vm_state=vm_states.ACTIVE,
                                               host='fake_host'))
        self.stub_out('nova.db.instance_update_and_get_original',
                      instance_update_and_get_original)

        fakes.stub_out_nw_api(self)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fake.stub_out_image_service(self)
        self.flags(allow_instance_snapshots=True,
                   enable_instance_password=True)
        self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'

        self.controller = self._get_controller()
        self.compute_api = self.controller.compute_api
        self.req = fakes.HTTPRequest.blank('')
        self.context = self.req.environ['nova.context']
예제 #6
0
    def setUp(self):
        super(ServerActionsControllerTestV21, self).setUp()
        self.flags(group='glance', api_servers=['http://localhost:9292'])
        self.stub_out('nova.db.instance_get_by_uuid',
                      fakes.fake_instance_get(vm_state=vm_states.ACTIVE,
                                               host='fake_host'))
        self.stub_out('nova.db.instance_update_and_get_original',
                      instance_update_and_get_original)

        fakes.stub_out_nw_api(self)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fake.stub_out_image_service(self)
        self.flags(allow_instance_snapshots=True,
                   enable_instance_password=True)
        self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'

        self.controller = self._get_controller()
        self.compute_api = self.controller.compute_api
        self.req = fakes.HTTPRequest.blank('')
        self.context = self.req.environ['nova.context']
예제 #7
0
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTestV21, self).setUp()
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_key_pair_funcs(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fakes.stub_out_compute_api_backup(self.stubs)

        self.controller = self.image_controller_class()
        self.url_prefix = "http://localhost%s/images" % self.url_base
        self.bookmark_prefix = "http://localhost%s/images" % self.bookmark_base
        self.uuid = 'fa95aaf5-ab3b-4cd8-88c0-2be7dd051aaf'
        self.server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
        self.server_href = ("http://localhost%s/servers/%s" %
                            (self.url_base, self.server_uuid))
        self.server_bookmark = ("http://localhost%s/servers/%s" %
                                (self.bookmark_base, self.server_uuid))
        self.alternate = "%s/images/%s"

        self.expected_image_123 = {
            "image": {
                'id':
                '123',
                'name':
                'public image',
                'metadata': {
                    'key1': 'value1'
                },
                'updated':
                NOW_API_FORMAT,
                'created':
                NOW_API_FORMAT,
                'status':
                'ACTIVE',
                'minDisk':
                10,
                'progress':
                100,
                'minRam':
                128,
                "links": [{
                    "rel": "self",
                    "href": "%s/123" % self.url_prefix
                }, {
                    "rel": "bookmark",
                    "href": "%s/123" % self.bookmark_prefix
                }, {
                    "rel":
                    "alternate",
                    "type":
                    "application/vnd.openstack.image",
                    "href":
                    self.alternate % (glance.generate_glance_url(), 123),
                }],
            },
        }

        self.expected_image_124 = {
            "image": {
                'id':
                '124',
                'name':
                'queued snapshot',
                'metadata': {
                    u'instance_uuid': self.server_uuid,
                    u'user_id': u'fake',
                },
                'updated':
                NOW_API_FORMAT,
                'created':
                NOW_API_FORMAT,
                'status':
                'SAVING',
                'progress':
                25,
                'minDisk':
                0,
                'minRam':
                0,
                'server': {
                    'id':
                    self.server_uuid,
                    "links": [{
                        "rel": "self",
                        "href": self.server_href,
                    }, {
                        "rel": "bookmark",
                        "href": self.server_bookmark,
                    }],
                },
                "links": [{
                    "rel": "self",
                    "href": "%s/124" % self.url_prefix
                }, {
                    "rel": "bookmark",
                    "href": "%s/124" % self.bookmark_prefix
                }, {
                    "rel":
                    "alternate",
                    "type":
                    "application/vnd.openstack.image",
                    "href":
                    self.alternate % (glance.generate_glance_url(), 124),
                }],
            },
        }
예제 #8
0
파일: test_images.py 프로젝트: Juniper/nova
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTestV21, self).setUp()
        self.flags(api_servers=['http://localhost:9292'], group='glance')
        fakes.stub_out_networking(self)
        fakes.stub_out_key_pair_funcs(self)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fakes.stub_out_compute_api_backup(self.stubs)

        self.controller = self.image_controller_class()
        self.url_prefix = "http://localhost%s/images" % self.url_base
        self.bookmark_prefix = "http://localhost%s/images" % self.bookmark_base
        self.uuid = 'fa95aaf5-ab3b-4cd8-88c0-2be7dd051aaf'
        self.server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
        self.server_href = (
            "http://localhost%s/servers/%s" % (self.url_base,
                                               self.server_uuid))
        self.server_bookmark = (
             "http://localhost%s/servers/%s" % (self.bookmark_base,
                                                self.server_uuid))
        self.alternate = "%s/images/%s"

        self.expected_image_123 = {
            "image": {'id': '123',
                      'name': 'public image',
                      'metadata': {'key1': 'value1'},
                      'updated': NOW_API_FORMAT,
                      'created': NOW_API_FORMAT,
                      'status': 'ACTIVE',
                      'minDisk': 10,
                      'progress': 100,
                      'minRam': 128,
                      "links": [{
                                    "rel": "self",
                                    "href": "%s/123" % self.url_prefix
                                },
                                {
                                    "rel": "bookmark",
                                    "href":
                                        "%s/123" % self.bookmark_prefix
                                },
                                {
                                    "rel": "alternate",
                                    "type": "application/vnd.openstack.image",
                                    "href": self.alternate %
                                            (glance.generate_glance_url(),
                                             123),
                                }],
            },
        }

        self.expected_image_124 = {
            "image": {'id': '124',
                      'name': 'queued snapshot',
                      'metadata': {
                          u'instance_uuid': self.server_uuid,
                          u'user_id': u'fake',
                      },
                      'updated': NOW_API_FORMAT,
                      'created': NOW_API_FORMAT,
                      'status': 'SAVING',
                      'progress': 25,
                      'minDisk': 0,
                      'minRam': 0,
                      'server': {
                          'id': self.server_uuid,
                          "links": [{
                                        "rel": "self",
                                        "href": self.server_href,
                                    },
                                    {
                                        "rel": "bookmark",
                                        "href": self.server_bookmark,
                                    }],
                      },
                      "links": [{
                                    "rel": "self",
                                    "href": "%s/124" % self.url_prefix
                                },
                                {
                                    "rel": "bookmark",
                                    "href":
                                        "%s/124" % self.bookmark_prefix
                                },
                                {
                                    "rel": "alternate",
                                    "type":
                                        "application/vnd.openstack.image",
                                    "href": self.alternate %
                                            (glance.generate_glance_url(),
                                             124),
                                }],
            },
        }
예제 #9
0
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTestV21, self).setUp()
        self.flags(api_servers=["http://localhost:9292"], group="glance")
        fakes.stub_out_networking(self)
        fakes.stub_out_key_pair_funcs(self)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fakes.stub_out_compute_api_backup(self.stubs)

        self.controller = self.image_controller_class()
        self.url_prefix = "http://localhost%s/images" % self.url_base
        self.bookmark_prefix = "http://localhost%s/images" % self.bookmark_base
        self.uuid = "fa95aaf5-ab3b-4cd8-88c0-2be7dd051aaf"
        self.server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
        self.server_href = "http://localhost%s/servers/%s" % (self.url_base, self.server_uuid)
        self.server_bookmark = "http://localhost%s/servers/%s" % (self.bookmark_base, self.server_uuid)
        self.alternate = "%s/images/%s"

        self.expected_image_123 = {
            "image": {
                "id": "123",
                "name": "public image",
                "metadata": {"key1": "value1"},
                "updated": NOW_API_FORMAT,
                "created": NOW_API_FORMAT,
                "status": "ACTIVE",
                "minDisk": 10,
                "progress": 100,
                "minRam": 128,
                "links": [
                    {"rel": "self", "href": "%s/123" % self.url_prefix},
                    {"rel": "bookmark", "href": "%s/123" % self.bookmark_prefix},
                    {
                        "rel": "alternate",
                        "type": "application/vnd.openstack.image",
                        "href": self.alternate % (glance.generate_glance_url(), 123),
                    },
                ],
            }
        }

        self.expected_image_124 = {
            "image": {
                "id": "124",
                "name": "queued snapshot",
                "metadata": {u"instance_uuid": self.server_uuid, u"user_id": u"fake"},
                "updated": NOW_API_FORMAT,
                "created": NOW_API_FORMAT,
                "status": "SAVING",
                "progress": 25,
                "minDisk": 0,
                "minRam": 0,
                "server": {
                    "id": self.server_uuid,
                    "links": [
                        {"rel": "self", "href": self.server_href},
                        {"rel": "bookmark", "href": self.server_bookmark},
                    ],
                },
                "links": [
                    {"rel": "self", "href": "%s/124" % self.url_prefix},
                    {"rel": "bookmark", "href": "%s/124" % self.bookmark_prefix},
                    {
                        "rel": "alternate",
                        "type": "application/vnd.openstack.image",
                        "href": self.alternate % (glance.generate_glance_url(), 124),
                    },
                ],
            }
        }