예제 #1
0
 def setUp(self):
     """Run before each test."""
     super(ImagesTest, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     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)
     fakes.stub_out_glance(self.stubs)
예제 #2
0
파일: test_images.py 프로젝트: NetApp/nova
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTest, 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)
        fakes.stub_out_glance(self.stubs)

        self.controller = images.Controller()
예제 #3
0
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTest, 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)
        fakes.stub_out_glance(self.stubs)

        self.controller = images.Controller()
예제 #4
0
    def setUp(self):
        super(CreateBackupTests, self).setUp()

        self.stubs.Set(compute_api.API, 'get', fake_compute_api_get)
        self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)
        self.app = compute.APIRouter(init_only=('servers',))
        self.uuid = uuidutils.generate_uuid()
예제 #5
0
    def setUp(self):
        super(CreateBackupTests, self).setUp()

        self.stubs.Set(compute.API, 'get', fake_compute_api_get)
        self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)
        self.app = compute_api.APIRouter()
        self.uuid = utils.gen_uuid()
예제 #6
0
    def setUp(self):
        super(CreateBackupTests, self).setUp()

        self.stubs.Set(compute.API, "get", fake_compute_api_get)
        self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)
        self.app = compute_api.APIRouter()
        self.uuid = utils.gen_uuid()
예제 #7
0
    def setUp(self):
        self.maxDiff = None
        super(ServerActionsControllerTest, self).setUp()

        self.stubs = stubout.StubOutForTesting()
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(nova.db, 'instance_get', return_server_by_id)
        self.stubs.Set(nova.db, 'instance_get_by_uuid', return_server_by_uuid)
        self.stubs.Set(nova.db, 'instance_update', instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        self.snapshot = fakes.stub_out_compute_api_snapshot(self.stubs)
        self.backup = fakes.stub_out_compute_api_backup(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = utils.import_object(service_class)
        self.context = context.RequestContext(1, None)
        self.service.delete_all()
        self.sent_to_glance = {}
        fakes.stub_out_glance_add_image(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True)
        self.uuid = FAKE_UUID
        self.url = '/v2/fake/servers/%s/action' % self.uuid

        self.controller = servers.Controller()
예제 #8
0
    def setUp(self):
        super(CreateBackupTests, self).setUp()

        self.stubs.Set(compute_api.API, "get", fake_compute_api_get)
        self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)
        self.app = compute.APIRouter(init_only=("servers",))
        self.uuid = uuid.uuid4()
예제 #9
0
    def setUp(self):
        self.maxDiff = None
        super(ServerActionsControllerTest, self).setUp()

        self.stubs = stubout.StubOutForTesting()
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(nova.db, 'instance_get', return_server_by_id)
        self.stubs.Set(nova.db, 'instance_get_by_uuid', return_server_by_uuid)
        self.stubs.Set(nova.db, 'instance_update', instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        self.snapshot = fakes.stub_out_compute_api_snapshot(self.stubs)
        self.backup = fakes.stub_out_compute_api_backup(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = utils.import_object(service_class)
        self.context = context.RequestContext(1, None)
        self.service.delete_all()
        self.sent_to_glance = {}
        fakes.stub_out_glance_add_image(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True)
        self.uuid = FAKE_UUID
        self.url = '/v1.1/fake/servers/%s/action' % self.uuid

        self.controller = servers.Controller()
    def setUp(self):
        super(CreateBackupTests, self).setUp()

        self.stubs.Set(compute_api.API, 'get', fake_compute_api_get)
        self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)
        self.app = compute.APIRouterV3(init_only=('servers',
                                                  'os-admin-actions'))
        self.uuid = uuid.uuid4()
    def setUp(self):
        super(CreateBackupTests, self).setUp()

        self.stubs.Set(compute_api.API, 'get', fake_compute_api_get)
        self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)
        self.app = compute.APIRouterV3(init_only=('servers',
                                                  'os-admin-actions'))
        self.uuid = uuid.uuid4()
예제 #12
0
    def setUp(self):
        super(CreateBackupTests, self).setUp()

        self.stubs.Set(compute.API, 'get', fake_compute_api_get)
        self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)

        self.flags(allow_admin_api=True)
        self.app = compute_api.APIRouter()

        self.uuid = utils.gen_uuid()
예제 #13
0
    def setUp(self):
        super(CreateBackupTests, self).setUp()

        self.stubs.Set(compute.API, 'get', fake_compute_api_get)
        self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)

        router = compute_api.APIRouter()
        ext_middleware = extensions.ExtensionMiddleware(router)
        self.app = wsgi.LazySerializationMiddleware(ext_middleware)

        self.uuid = utils.gen_uuid()
예제 #14
0
    def setUp(self):
        super(CreateBackupTests, self).setUp()

        self.stubs.Set(compute.API, 'get', fake_compute_api_get)
        self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)

        router = compute_api.APIRouter()
        ext_middleware = extensions.ExtensionMiddleware(router)
        self.app = wsgi.LazySerializationMiddleware(ext_middleware)

        self.uuid = utils.gen_uuid()
예제 #15
0
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTest, 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)
        fakes.stub_out_glance(self.stubs)

        self.controller = images.Controller()
        self.uuid = 'fa95aaf5-ab3b-4cd8-88c0-2be7dd051aaf'
        self.url = '/v2/fake/images/detail?server=' + self.uuid
        self.server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
        self.server_href = (
            "http://localhost/v2/fake/servers/" + self.server_uuid)
        self.server_bookmark = (
            "http://localhost/fake/servers/" + self.server_uuid)
        self.alternate = "%s/fake/images/%s"
        self.fake_req = fakes.HTTPRequest.blank('/v2/fake/images/123')
        self.actual_image = self.controller.show(self.fake_req, '124')

        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":
                                        "http://localhost/v2/fake/images/123",
                                },
                                {
                                    "rel": "bookmark",
                                    "href":
                                        "http://localhost/fake/images/123",
                                },
                                {
                                    "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":
                                        "http://localhost/v2/fake/images/124",
                                },
                                {
                                    "rel": "bookmark",
                                    "href":
                                        "http://localhost/fake/images/124",
                                },
                                {
                                    "rel": "alternate",
                                    "type":
                                        "application/vnd.openstack.image",
                                    "href": self.alternate %
                                            (glance.generate_glance_url(),
                                             124),
                                }],
            },
        }

        self.image_service = self.mox.CreateMockAnything()
예제 #16
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),
                                }],
            },
        }
예제 #17
0
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTest, 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)
        fakes.stub_out_glance(self.stubs)

        self.controller = images.Controller()
        self.uuid = 'fa95aaf5-ab3b-4cd8-88c0-2be7dd051aaf'
        self.url = '/v2/fake/images/detail?server=' + self.uuid
        self.server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
        self.server_href = ("http://localhost/v2/fake/servers/" +
                            self.server_uuid)
        self.server_bookmark = ("http://localhost/fake/servers/" +
                                self.server_uuid)
        self.alternate = "%s/fake/images/%s"
        self.fake_req = fakes.HTTPRequest.blank('/v2/fake/images/123')
        self.actual_image = self.controller.show(self.fake_req, '124')

        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": "http://localhost/v2/fake/images/123",
                }, {
                    "rel": "bookmark",
                    "href": "http://localhost/fake/images/123",
                }, {
                    "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": "http://localhost/v2/fake/images/124",
                }, {
                    "rel": "bookmark",
                    "href": "http://localhost/fake/images/124",
                }, {
                    "rel":
                    "alternate",
                    "type":
                    "application/vnd.openstack.image",
                    "href":
                    self.alternate % (glance.generate_glance_url(), 124),
                }],
            },
        }

        self.image_service = self.mox.CreateMockAnything()