예제 #1
0
파일: service.py 프로젝트: vdialani/trove
    def create(self, req, body, tenant_id):
        LOG.debug("req : '%s'\n\n" % req)
        LOG.debug("body : '%s'\n\n" % req)

        name = body['configuration']['name']
        description = body['configuration'].get('description')
        values = body['configuration']['values']

        msg = _("Creating configuration group on tenant "
                "%(tenant_id)s with name: %(cfg_name)s")
        LOG.info(msg % {"tenant_id": tenant_id, "cfg_name": name})

        datastore_args = body['configuration'].get('datastore', {})
        datastore, datastore_version = (ds_models.get_datastore_version(
            **datastore_args))

        configItems = []
        if values:
            # validate that the values passed in are permitted by the operator.
            ConfigurationsController._validate_configuration(
                body['configuration']['values'],
                datastore_version=datastore_version)

            for k, v in values.iteritems():
                configItems.append(
                    DBConfigurationParameter(configuration_key=k,
                                             configuration_value=v))

        cfg_group = models.Configuration.create(name, description, tenant_id,
                                                datastore.id,
                                                datastore_version.id)
        cfg_group_items = models.Configuration.create_items(
            cfg_group.id, values)
        view_data = views.DetailedConfigurationView(cfg_group, cfg_group_items)
        return wsgi.Result(view_data.data(), 200)
예제 #2
0
파일: service.py 프로젝트: vdialani/trove
 def _configuration_items_list(self, group, configuration):
     ds_version_id = group.datastore_version_id
     ds_version = ds_models.DatastoreVersion.load_by_uuid(ds_version_id)
     items = []
     if 'values' in configuration:
         # validate that the values passed in are permitted by the operator.
         ConfigurationsController._validate_configuration(
             configuration['values'], datastore_version=ds_version)
         for k, v in configuration['values'].iteritems():
             items.append(
                 DBConfigurationParameter(configuration_id=group.id,
                                          configuration_key=k,
                                          configuration_value=v,
                                          deleted=False))
     return items
예제 #3
0
    def create(self, req, body, tenant_id):
        LOG.debug("req : '%s'\n\n" % req)
        LOG.debug("body : '%s'\n\n" % req)

        context = req.environ[wsgi.CONTEXT_KEY]
        policy.authorize_on_tenant(context, 'configuration:create')
        context.notification = notification.DBaaSConfigurationCreate(
            context, request=req)
        name = body['configuration']['name']
        description = body['configuration'].get('description')
        values = body['configuration']['values']

        msg = _("Creating configuration group on tenant "
                "%(tenant_id)s with name: %(cfg_name)s")
        LOG.info(msg % {"tenant_id": tenant_id, "cfg_name": name})

        datastore_args = body['configuration'].get('datastore', {})
        datastore, datastore_version = (
            ds_models.get_datastore_version(**datastore_args))

        with StartNotification(context, name=name, datastore=datastore.name,
                               datastore_version=datastore_version.name):
            configItems = []
            if values:
                # validate that the values passed in are permitted by the
                # operator.
                ConfigurationsController._validate_configuration(
                    body['configuration']['values'],
                    datastore_version,
                    models.DatastoreConfigurationParameters.load_parameters(
                        datastore_version.id))

                for k, v in values.items():
                    configItems.append(DBConfigurationParameter(
                        configuration_key=k,
                        configuration_value=v))

            cfg_group = models.Configuration.create(name, description,
                                                    tenant_id, datastore.id,
                                                    datastore_version.id)
            with EndNotification(context, configuration_id=cfg_group.id):
                cfg_group_items = models.Configuration.create_items(
                    cfg_group.id, values)

        view_data = views.DetailedConfigurationView(cfg_group,
                                                    cfg_group_items)
        return wsgi.Result(view_data.data(), 200)