Exemplo n.º 1
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['patron.context']
Exemplo n.º 2
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),
                }],
            },
        }
Exemplo n.º 3
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),
                                }],
            },
        }