Пример #1
0
    def test_update_datastore_version(self, mock_get_rpc_client,
                                      mock_create_nova_client):
        # Create an instance in db.
        instance = ins_models.DBInstance.create(
            name=self.random_name('instance'),
            flavor_id=self.random_uuid(),
            tenant_id=self.random_uuid(),
            volume_size=1,
            datastore_version_id=self.ds_version_imageid.id,
            task_status=ins_models.InstanceTasks.BUILDING,
            compute_instance_id=self.random_uuid())
        ins_models.InstanceServiceStatus.create(
            instance_id=instance.id, status=srvstatus.ServiceStatuses.NEW)

        # Create a new datastore version in db.
        new_version_name = self.random_name('version')
        ds_models.update_datastore_version(self.ds_name,
                                           new_version_name, 'mysql',
                                           self.random_uuid(), [], '', 1)
        new_ds_version = ds_models.DatastoreVersion.load(
            self.ds, new_version_name)

        body = {'instance': {'datastore_version': new_ds_version.id}}
        self.controller.update(mock.MagicMock(), instance.id, body, mock.ANY)

        rpc_ctx = mock_get_rpc_client.return_value.prepare.return_value
        rpc_ctx.cast.assert_called_once_with(
            mock.ANY,
            "upgrade",
            instance_id=instance.id,
            datastore_version_id=new_ds_version.id)
Пример #2
0
 def setUp(self):
     util.init_db()
     self.fake_tenantid = 'fake_fore_1231242345'
     self.fake_context = fake()
     self.fake_context.limit = 1000
     self.fake_context.is_admin = False
     self.fake_context.marker = None
     self.fake_context['tenant'] = self.fake_tenantid 
     self.fake_environ = {wsgi.CONTEXT_KEY : self.fake_context}
     self.fake_request = fake()
     self.fake_request.url = "http://fore.com/***"
     self.fake_request.environ = self.fake_environ
     
     self.cnf_controller = conf_service.ConfigurationsController()
     self.para_controller = conf_service.ParametersController()
     self.base_body = {
                         "configuration": {
                             "values": {},
                             "name": "test",
                             "description":"desc....",
                             "datastore": {
                                 "type": "test_type",
                                 "version": "test_version"
                             }
                         }
                       }
     
     self.fake_dsname = "test_type"
     self.fake_dsversion = "test_version"
     ds_models.update_datastore(self.fake_dsname)
     ds = ds_models.Datastore.load(self.fake_dsname)
     ds_models.update_datastore_version(ds.name, self.fake_dsversion, "mysql", "None","None", '1','1')
Пример #3
0
    def setUp(self):
        # Basic setup and mock/fake structures for testing only
        super(TestDatastoreBase, self).setUp()
        util.init_db()
        self.rand_id = str(uuid.uuid4())
        self.ds_name = "my-test-datastore" + self.rand_id
        self.ds_version = "my-test-version" + self.rand_id
        self.capability_name = "root_on_create" + self.rand_id
        self.capability_desc = "Enables root on create"
        self.capability_enabled = True

        datastore_models.update_datastore(self.ds_name, False)
        self.datastore = Datastore.load(self.ds_name)

        datastore_models.update_datastore_version(
            self.ds_name, self.ds_version, "mysql", "", "", True)

        self.datastore_version = DatastoreVersion.load(self.datastore,
                                                       self.ds_version)
        self.test_id = self.datastore_version.id

        self.cap1 = Capability.create(self.capability_name,
                                      self.capability_desc, True)
        self.cap2 = Capability.create("require_volume" + self.rand_id,
                                      "Require external volume", True)
        self.cap3 = Capability.create("test_capability" + self.rand_id,
                                      "Test capability", False)
Пример #4
0
    def setUpClass(cls):
        util.init_db()
        cls.controller = ins_service.MgmtInstanceController()

        cls.ds_name = cls.random_name('datastore')
        ds_models.update_datastore(name=cls.ds_name, default_version=None)
        ds_models.update_datastore_version(cls.ds_name,
                                           'test_version', 'mysql',
                                           cls.random_uuid(), '', '', 1)
        cls.ds = ds_models.Datastore.load(cls.ds_name)
        cls.ds_version = ds_models.DatastoreVersion.load(
            cls.ds, 'test_version')

        cls.ins_name = cls.random_name('instance')
        cls.project_id = cls.random_uuid()
        cls.server_id = cls.random_uuid()
        cls.instance = ins_models.DBInstance.create(
            name=cls.ins_name,
            flavor_id=cls.random_uuid(),
            tenant_id=cls.project_id,
            volume_size=1,
            datastore_version_id=cls.ds_version.id,
            task_status=ins_models.InstanceTasks.BUILDING,
            compute_instance_id=cls.server_id)
        ins_models.InstanceServiceStatus.create(
            instance_id=cls.instance.id, status=srvstatus.ServiceStatuses.NEW)

        super(TestMgmtInstanceController, cls).setUpClass()
Пример #5
0
    def setUpClass(cls):
        util.init_db()

        cls.ds_name = cls.random_name('datastore',
                                      prefix='TestConfigurationsController')
        ds_models.update_datastore(name=cls.ds_name, default_version=None)
        cls.ds = ds_models.Datastore.load(cls.ds_name)

        ds_version_name = cls.random_name(
            'version', prefix='TestConfigurationsController')
        ds_models.update_datastore_version(cls.ds_name,
                                           ds_version_name,
                                           'mysql',
                                           '', ['trove'],
                                           '',
                                           1,
                                           version='5.7.29')
        cls.ds_version = ds_models.DatastoreVersion.load(cls.ds,
                                                         ds_version_name,
                                                         version='5.7.29')

        cls.tenant_id = cls.random_uuid()
        cls.config = config_models.Configuration.create(
            cls.random_name('configuration'), '', cls.tenant_id, None,
            cls.ds_version.id)
        cls.config_id = cls.config.id

        cls.controller = service.ConfigurationsController()

        super(TestConfigurationsController, cls).setUpClass()
Пример #6
0
    def setUp(self):
        # Basic setup and mock/fake structures for testing only
        super(TestDatastoreBase, self).setUp()
        util.init_db()
        self.rand_id = str(uuid.uuid4())
        self.ds_name = "my-test-datastore" + self.rand_id
        self.ds_version = "my-test-version" + self.rand_id
        self.capability_name = "root_on_create" + self.rand_id
        self.capability_desc = "Enables root on create"
        self.capability_enabled = True
        self.datastore_version_id = str(uuid.uuid4())
        self.flavor_id = 1

        datastore_models.update_datastore(self.ds_name, False)
        self.datastore = Datastore.load(self.ds_name)

        datastore_models.update_datastore_version(self.ds_name, self.ds_version, "mysql", "", "", True)
        DatastoreVersionMetadata.add_datastore_version_flavor_association(
            self.ds_name, self.ds_version, [self.flavor_id]
        )

        self.datastore_version = DatastoreVersion.load(self.datastore, self.ds_version)
        self.test_id = self.datastore_version.id

        self.cap1 = Capability.create(self.capability_name, self.capability_desc, True)
        self.cap2 = Capability.create("require_volume" + self.rand_id, "Require external volume", True)
        self.cap3 = Capability.create("test_capability" + self.rand_id, "Test capability", False)
Пример #7
0
 def datastore_version_update(self, datastore, version_name, manager,
                              image_id, packages, active):
     try:
         datastore_models.update_datastore_version(datastore, version_name,
                                                   manager, image_id,
                                                   packages, active)
         print("Datastore version '%s' updated." % version_name)
     except exception.DatastoreNotFound as e:
         print(e)
Пример #8
0
 def datastore_version_update(self, datastore, version_name, manager,
                              image_id, packages, active):
     try:
         datastore_models.update_datastore_version(datastore,
                                                   version_name,
                                                   manager,
                                                   image_id,
                                                   packages, active)
         print("Datastore version '%s' updated." % version_name)
     except exception.DatastoreNotFound as e:
         print(e)
Пример #9
0
    def create(self, req, body, tenant_id):
        """Adds a new datastore version."""
        context = req.environ[wsgi.CONTEXT_KEY]
        datastore_name = body['version']['datastore_name']
        version_name = body['version']['name']
        manager = body['version']['datastore_manager']
        image_id = body['version'].get('image')
        image_tags = body['version'].get('image_tags')
        packages = body['version'].get('packages')
        if type(packages) is list:
            packages = ','.join(packages)
        active = body['version']['active']
        default = body['version'].get('default', False)
        # For backward compatibility, use name as default value for version if
        # not specified
        version_str = body['version'].get('version', version_name)

        LOG.info("Tenant: '%(tenant)s' is adding the datastore "
                 "version: '%(version)s' to datastore: '%(datastore)s'",
                 {'tenant': tenant_id, 'version': version_name,
                  'datastore': datastore_name})

        if not image_id and not image_tags:
            raise exception.BadRequest("Image must be specified.")

        client = clients.create_glance_client(context)
        common_glance.get_image_id(client, image_id, image_tags)

        try:
            datastore = models.Datastore.load(datastore_name)
        except exception.DatastoreNotFound:
            # Create the datastore if datastore_name does not exists.
            LOG.info("Creating datastore %s", datastore_name)
            datastore = models.DBDatastore()
            datastore.id = utils.generate_uuid()
            datastore.name = datastore_name
            datastore.save()

        try:
            models.DatastoreVersion.load(datastore, version_name,
                                         version=version_str)
            raise exception.DatastoreVersionAlreadyExists(
                name=version_name, version=version_str)
        except exception.DatastoreVersionNotFound:
            models.update_datastore_version(datastore.name, version_name,
                                            manager, image_id, image_tags,
                                            packages, active,
                                            version=version_str)

        if default:
            models.update_datastore(datastore.name, version_name)

        return wsgi.Result(None, 202)
Пример #10
0
    def test_show_image_tags(self):
        ver_name = self.random_name('dsversion')
        tags = ['trove', 'mysql']
        models.update_datastore_version(self.ds_name, ver_name, 'mysql', '',
                                        tags, '', 1)
        ver = models.DatastoreVersion.load(self.ds, ver_name)

        output = self.version_controller.show(MagicMock(), mock.ANY, ver.id)
        self.assertEqual(200, output.status)

        data = output.data(None)
        self.assertEqual(tags, data['version']['image_tags'])
Пример #11
0
    def edit(self, req, body, tenant_id, id):
        """Updates the attributes of a datastore version."""
        context = req.environ[wsgi.CONTEXT_KEY]
        datastore_version = models.DatastoreVersion.load_by_uuid(id)

        LOG.info("Tenant: '%(tenant)s' is updating the datastore "
                 "version: '%(id)s' for datastore: '%(datastore)s'",
                 {'tenant': tenant_id, 'id': id,
                  'datastore': datastore_version.datastore_name})

        name = body.get('name', datastore_version.name)
        manager = body.get('datastore_manager', datastore_version.manager)
        image_id = body.get('image')
        image_tags = body.get('image_tags')
        active = body.get('active', datastore_version.active)
        default = body.get('default', None)
        packages = body.get('packages', datastore_version.packages)
        if type(packages) is list:
            packages = ','.join(packages)

        if image_id or image_tags:
            client = clients.create_glance_client(context)
            common_glance.get_image_id(client, image_id, image_tags)

        if not image_id and image_tags:
            # Remove the image ID from the datastore version.
            image_id = ""

        if image_id is None:
            image_id = datastore_version.image_id
        if image_tags is None:
            image_tags = datastore_version.image_tags
            if type(image_tags) is str:
                image_tags = image_tags.split(',')

        if not image_id and not image_tags:
            raise exception.BadRequest("Image must be specified.")

        models.update_datastore_version(datastore_version.datastore_name,
                                        datastore_version.name,
                                        manager, image_id, image_tags,
                                        packages, active,
                                        version=datastore_version.version,
                                        new_name=name)

        if default:
            models.update_datastore(datastore_version.datastore_name,
                                    datastore_version.name)
        elif (default is False and datastore_version.default is True):
            models.update_datastore(datastore_version.datastore_name, None)

        return wsgi.Result(None, 202)
Пример #12
0
    def create(self, req, body, tenant_id):
        """Adds a new datastore version."""
        context = req.environ[wsgi.CONTEXT_KEY]
        datastore_name = body['version']['datastore_name']
        version_name = body['version']['name']
        manager = body['version']['datastore_manager']
        image_id = body['version']['image']
        packages = body['version']['packages']
        if type(packages) is list:
            packages = ','.join(packages)
        active = body['version']['active']
        default = body['version']['default']

        LOG.info(
            "Tenant: '%(tenant)s' is adding the datastore "
            "version: '%(version)s' to datastore: '%(datastore)s'", {
                'tenant': tenant_id,
                'version': version_name,
                'datastore': datastore_name
            })

        client = clients.create_glance_client(context)
        try:
            client.images.get(image_id)
        except glance_exceptions.HTTPNotFound:
            raise exception.ImageNotFound(uuid=image_id)

        try:
            datastore = models.Datastore.load(datastore_name)
        except exception.DatastoreNotFound:
            # Create the datastore if datastore_name does not exists.
            LOG.info("Creating datastore %s", datastore_name)
            datastore = models.DBDatastore()
            datastore.id = utils.generate_uuid()
            datastore.name = datastore_name
            datastore.save()

        try:
            models.DatastoreVersion.load(datastore, version_name)
            raise exception.DatastoreVersionAlreadyExists(name=version_name)
        except exception.DatastoreVersionNotFound:
            models.update_datastore_version(datastore.name, version_name,
                                            manager, image_id, packages,
                                            active)

        if default:
            models.update_datastore(datastore.name, version_name)

        return wsgi.Result(None, 202)
Пример #13
0
    def setUpClass(cls):
        util.init_db()

        cls.ds_name = cls.random_name('datastore',
                                      prefix='TestBackupController')
        ds_models.update_datastore(name=cls.ds_name, default_version=None)
        cls.ds = ds_models.Datastore.load(cls.ds_name)

        ds_models.update_datastore_version(cls.ds_name, 'fake-ds-version',
                                           'mysql', '', ['trove', 'mysql'], '',
                                           1)
        cls.ds_version = ds_models.DatastoreVersion.load(
            cls.ds, 'fake-ds-version')

        cls.controller = service.BackupController()

        super(TestBackupController, cls).setUpClass()
Пример #14
0
    def create(self, req, body, tenant_id):
        """Adds a new datastore version."""
        context = req.environ[wsgi.CONTEXT_KEY]
        datastore_name = body['version']['datastore_name']
        version_name = body['version']['name']
        manager = body['version']['datastore_manager']
        image_id = body['version']['image']
        packages = body['version']['packages']
        if type(packages) is list:
            packages = ','.join(packages)
        active = body['version']['active']
        default = body['version']['default']

        LOG.info(_("Tenant: '%(tenant)s' is adding the datastore "
                   "version: '%(version)s' to datastore: '%(datastore)s'") %
                 {'tenant': tenant_id, 'version': version_name,
                  'datastore': datastore_name})

        client = remote.create_nova_client(context)
        try:
            client.images.get(image_id)
        except nova_exceptions.NotFound:
            raise exception.ImageNotFound(uuid=image_id)

        try:
            datastore = models.Datastore.load(datastore_name)
        except exception.DatastoreNotFound:
            # Create the datastore if datastore_name does not exists.
            LOG.info(_("Creating datastore %s") % datastore_name)
            datastore = models.DBDatastore()
            datastore.id = utils.generate_uuid()
            datastore.name = datastore_name
            datastore.save()

        try:
            models.DatastoreVersion.load(datastore, version_name)
            raise exception.DatastoreVersionAlreadyExists(name=version_name)
        except exception.DatastoreVersionNotFound:
            models.update_datastore_version(datastore.name, version_name,
                                            manager, image_id, packages,
                                            active)

        if default:
            models.update_datastore(datastore.name, version_name)

        return wsgi.Result(None, 202)
Пример #15
0
 def setUp(self):
     util.init_db()
     
     ds_models.update_datastore("mysql")
     self.datastore = ds_models.Datastore.load("mysql")
     
     ds_models.update_datastore_version(self.datastore.id, "mysql-55", "mysql", "None", "None", True) 
     self.ds_version = ds_models.DatastoreVersion.load(self.datastore, "mysql-55")
     
     test_time = utils.utcnow()
     self.conf_name = "test_name_%s " %test_time
     self.conf_desc = "test_desc_%s " %test_time
     self.configuration = None
     self.defaultConfiguration = None
     
     self.tanant_id = "fake_fore_1231242345"
     self.context = TroveContext(tenant = self.tanant_id)
     self.default_tanant_id = CONF.default_template_tenant_id
Пример #16
0
    def test_update_image_tags(self, mock_create_client):
        name = self.random_name('dsversion')
        models.update_datastore_version(self.ds_name, name, 'mysql',
                                        self.random_uuid(), '', '', 1)
        ver = models.DatastoreVersion.load(self.ds, name)

        mock_client = MagicMock()
        mock_client.images.list.return_value = [{"id": self.random_uuid()}]
        mock_create_client.return_value = mock_client

        body = {"image_tags": ['trove', 'mysql']}

        output = self.version_controller.edit(MagicMock(), body, mock.ANY,
                                              ver.id)
        self.assertEqual(202, output.status)

        updated_ver = models.DatastoreVersion.load(self.ds, ver.id)
        self.assertEqual("", updated_ver.image_id)
        self.assertEqual("trove,mysql", updated_ver.image_tags)
Пример #17
0
    def setUp(self):
        super(TestDatastoreVersion, self).setUp()
        util.init_db()
        models.update_datastore(name='test_ds', default_version=None)
        models.update_datastore_version(
            'test_ds', 'test_vr1', 'mysql',
            '154b350d-4d86-4214-9067-9c54b230c0da', 'pkg-1', '1')
        models.update_datastore_version(
            'test_ds', 'test_vr2', 'mysql',
            '154b350d-4d86-4214-9067-9c54b230c0da', 'pkg-1', '1')
        self.ds = models.Datastore.load('test_ds')
        self.ds_version2 = models.DatastoreVersion.load(self.ds, 'test_vr2')

        self.context = Mock()
        self.req = Mock()
        self.req.environ = Mock()
        self.req.environ.__getitem__ = Mock(return_value=self.context)
        self.tenant_id = Mock()
        self.version_controller = DatastoreVersionController()
Пример #18
0
    def setUp(self):
        super(TestDatastoreVersion, self).setUp()
        util.init_db()
        models.update_datastore(name='test_ds', default_version=None)
        models.update_datastore_version(
            'test_ds', 'test_vr1', 'mysql',
            '154b350d-4d86-4214-9067-9c54b230c0da', 'pkg-1', 1)
        models.update_datastore_version(
            'test_ds', 'test_vr2', 'mysql',
            '154b350d-4d86-4214-9067-9c54b230c0da', 'pkg-1', 1)
        self.ds = models.Datastore.load('test_ds')
        self.ds_version2 = models.DatastoreVersion.load(self.ds, 'test_vr2')

        self.context = trove_testtools.TroveTestContext(self)
        self.req = Mock()
        self.req.environ = Mock()
        self.req.environ.__getitem__ = Mock(return_value=self.context)
        self.tenant_id = Mock()
        self.version_controller = DatastoreVersionController()
Пример #19
0
    def test_delete(self):
        name = self.random_name('dsversion')
        models.update_datastore_version(self.ds_name, name, 'mysql',
                                        self.random_uuid(), '', '', 1)
        ver = models.DatastoreVersion.load(self.ds, name)

        # Add config param for the datastore version. Should be automatically
        # removed.
        param_name = self.random_name('param')
        config_models.create_or_update_datastore_configuration_parameter(
            param_name, ver.id, False, 'string', None, None)

        output = self.version_controller.delete(MagicMock(), mock.ANY, ver.id)
        self.assertEqual(202, output.status)

        self.assertRaises(exception.DatastoreVersionNotFound,
                          models.DatastoreVersion.load_by_uuid, ver.id)

        config_params_cls = config_models.DatastoreConfigurationParameters
        self.assertRaises(exception.NotFound,
                          config_params_cls.load_parameter_by_name, ver.id,
                          param_name)
Пример #20
0
 def datastore_version_update(self,
                              datastore,
                              version_name,
                              manager,
                              image_id,
                              packages,
                              active,
                              image_tags=None,
                              version=None):
     try:
         datastore_models.update_datastore_version(datastore,
                                                   version_name,
                                                   manager,
                                                   image_id,
                                                   image_tags,
                                                   packages,
                                                   active,
                                                   version=version)
         print("Datastore version '%s(%s)' updated." %
               (version_name, version or version_name))
     except exception.DatastoreNotFound as e:
         print(e)
Пример #21
0
    def edit(self, req, body, tenant_id, id):
        """Updates the attributes of a datastore version."""
        context = req.environ[wsgi.CONTEXT_KEY]
        datastore_version = models.DatastoreVersion.load_by_uuid(id)

        LOG.info(
            "Tenant: '%(tenant)s' is updating the datastore "
            "version: '%(version)s' for datastore: '%(datastore)s'", {
                'tenant': tenant_id,
                'version': datastore_version.name,
                'datastore': datastore_version.datastore_name
            })

        manager = body.get('datastore_manager', datastore_version.manager)
        image_id = body.get('image', datastore_version.image_id)
        active = body.get('active', datastore_version.active)
        default = body.get('default', None)
        packages = body.get('packages', datastore_version.packages)
        if type(packages) is list:
            packages = ','.join(packages)

        client = clients.create_glance_client(context)
        try:
            client.images.get(image_id)
        except glance_exceptions.HTTPNotFound:
            raise exception.ImageNotFound(uuid=image_id)

        models.update_datastore_version(datastore_version.datastore_name,
                                        datastore_version.name, manager,
                                        image_id, packages, active)

        if default:
            models.update_datastore(datastore_version.datastore_name,
                                    datastore_version.name)
        elif (default is False and datastore_version.default is True):
            models.update_datastore(datastore_version.datastore_name, None)

        return wsgi.Result(None, 202)
Пример #22
0
    def setUpClass(cls):
        util.init_db()

        cls.ds_name = cls.random_name(name='test-datastore')
        cls.ds_version_name = cls.random_name(name='test-version')
        cls.capability_name = cls.random_name(name='root_on_create',
                                              prefix='TestDatastoreBase')
        cls.capability_desc = "Enables root on create"
        cls.capability_enabled = True
        cls.flavor_id = 1
        cls.volume_type = 'some-valid-volume-type'

        datastore_models.update_datastore(cls.ds_name, False)
        cls.datastore = Datastore.load(cls.ds_name)

        datastore_models.update_datastore_version(cls.ds_name,
                                                  cls.ds_version_name, "mysql",
                                                  "", "", "", True)
        cls.datastore_version = DatastoreVersion.load(cls.datastore,
                                                      cls.ds_version_name)
        cls.test_id = cls.datastore_version.id

        DatastoreVersionMetadata.add_datastore_version_flavor_association(
            cls.datastore_version.id, [cls.flavor_id])
        DatastoreVersionMetadata.add_datastore_version_volume_type_association(
            cls.datastore_version.id, [cls.volume_type])

        cls.cap1 = Capability.create(cls.capability_name, cls.capability_desc,
                                     True)
        cls.cap2 = Capability.create(
            cls.random_name(name='require_volume', prefix='TestDatastoreBase'),
            "Require external volume", True)
        cls.cap3 = Capability.create(
            cls.random_name(name='test_capability',
                            prefix='TestDatastoreBase'), "Test capability",
            False)

        super(TestDatastoreBase, cls).setUpClass()
Пример #23
0
    def edit(self, req, body, tenant_id, id):
        """Updates the attributes of a datastore version."""
        context = req.environ[wsgi.CONTEXT_KEY]
        datastore_version = models.DatastoreVersion.load_by_uuid(id)

        LOG.info(_("Tenant: '%(tenant)s' is updating the datastore "
                   "version: '%(version)s' for datastore: '%(datastore)s'") %
                 {'tenant': tenant_id, 'version': datastore_version.name,
                  'datastore': datastore_version.datastore_name})

        manager = body.get('datastore_manager', datastore_version.manager)
        image_id = body.get('image', datastore_version.image_id)
        active = body.get('active', datastore_version.active)
        default = body.get('default', None)
        packages = body.get('packages', datastore_version.packages)
        if type(packages) is list:
            packages = ','.join(packages)

        client = remote.create_nova_client(context)
        try:
            client.images.get(image_id)
        except nova_exceptions.NotFound:
            raise exception.ImageNotFound(uuid=image_id)

        models.update_datastore_version(datastore_version.datastore_name,
                                        datastore_version.name,
                                        manager, image_id, packages,
                                        active)

        if default:
            models.update_datastore(datastore_version.datastore_name,
                                    datastore_version.name)
        elif (default is False and datastore_version.default is True):
            models.update_datastore(datastore_version.datastore_name, None)

        return wsgi.Result(None, 202)
Пример #24
0
    def setUpClass(cls):
        util.init_db()
        cls.ds_name = cls.random_name('datastore')
        cls.ds_version_number = '5.7.30'
        models.update_datastore(name=cls.ds_name, default_version=None)

        models.update_datastore_version(cls.ds_name, 'test_vr1', 'mysql',
                                        cls.random_uuid(), '', 'pkg-1', 1)
        models.update_datastore_version(cls.ds_name,
                                        'test_vr2',
                                        'mysql',
                                        cls.random_uuid(),
                                        '',
                                        'pkg-1',
                                        1,
                                        version=cls.ds_version_number)

        cls.ds = models.Datastore.load(cls.ds_name)
        cls.ds_version1 = models.DatastoreVersion.load(cls.ds, 'test_vr1')
        cls.ds_version2 = models.DatastoreVersion.load(
            cls.ds, 'test_vr2', version=cls.ds_version_number)
        cls.version_controller = DatastoreVersionController()

        super(TestDatastoreVersionController, cls).setUpClass()
Пример #25
0
    def setUpClass(cls):
        util.init_db()

        cls.ds_name = cls.random_name('datastore',
                                      prefix='TestInstanceController')
        ds_models.update_datastore(name=cls.ds_name, default_version=None)
        cls.ds = ds_models.Datastore.load(cls.ds_name)

        ds_models.update_datastore_version(cls.ds_name,
                                           'test_image_id', 'mysql',
                                           cls.random_uuid(), [], '', 1)
        ds_models.update_datastore_version(cls.ds_name,
                                           'test_image_tags',
                                           'mysql',
                                           '', ['trove', 'mysql'],
                                           '',
                                           1,
                                           version='test_image_tags version')
        ds_models.update_datastore_version(cls.ds_name,
                                           'test_version',
                                           'mysql',
                                           '', ['trove'],
                                           '',
                                           1,
                                           version='version 1')
        ds_models.update_datastore_version(cls.ds_name,
                                           'test_version',
                                           'mysql',
                                           '', ['trove'],
                                           '',
                                           1,
                                           version='version 2')

        cls.ds_version_imageid = ds_models.DatastoreVersion.load(
            cls.ds, 'test_image_id')
        cls.ds_version_imagetags = ds_models.DatastoreVersion.load(
            cls.ds, 'test_image_tags')

        cls.controller = service.InstanceController()

        super(TestInstanceController, cls).setUpClass()