Esempio n. 1
0
    def update(self, req, body, tenant_id, id):
        msg = _("Updating configuration group %(cfg_id)s for tenant "
                "id %(tenant_id)s")
        LOG.info(msg % {"tenant_id": tenant_id, "cfg_id": id})

        context = req.environ[wsgi.CONTEXT_KEY]
        group = models.Configuration.load(context, id)

        # if name/description are provided in the request body, update the
        # model with these values as well.
        if 'name' in body['configuration']:
            group.name = body['configuration']['name']

        if 'description' in body['configuration']:
            group.description = body['configuration']['description']

        context.notification = notification.DBaaSConfigurationUpdate(
            context, request=req)
        with StartNotification(context,
                               configuration_id=id,
                               name=group.name,
                               description=group.description):
            items = self._configuration_items_list(group,
                                                   body['configuration'])
            deleted_at = datetime.utcnow()
            models.Configuration.remove_all_items(context, group.id,
                                                  deleted_at)
            models.Configuration.save(group, items)
            self._refresh_on_all_instances(context, id)
        return wsgi.Result(None, 202)
Esempio n. 2
0
    def update(self, req, body, tenant_id, id):
        msg = ("Updating configuration group %(cfg_id)s for tenant "
               "id %(tenant_id)s")
        LOG.info(msg, {"tenant_id": tenant_id, "cfg_id": id})

        context = req.environ[wsgi.CONTEXT_KEY]
        group = models.Configuration.load(context, id)
        # Note that changing the configuration group will also
        # indirectly affect all the instances which attach it.
        #
        # The Trove instance itself won't be changed (the same group is still
        # attached) but the configuration values will.
        #
        # The operator needs to keep this in mind when defining the related
        # policies.
        self.authorize_config_action(context, 'update', group)

        # if name/description are provided in the request body, update the
        # model with these values as well.
        if 'name' in body['configuration']:
            group.name = body['configuration']['name']

        if 'description' in body['configuration']:
            group.description = body['configuration']['description']

        context.notification = notification.DBaaSConfigurationUpdate(
            context, request=req)
        with StartNotification(context,
                               configuration_id=id,
                               name=group.name,
                               description=group.description):
            items = self._configuration_items_list(group,
                                                   body['configuration'])
            deleted_at = timeutils.utcnow()
            models.Configuration.remove_all_items(context, group.id,
                                                  deleted_at)
            models.Configuration.save(group, items)
            self._refresh_on_all_instances(context, id)
            self._refresh_on_all_clusters(context, id)

        return wsgi.Result(None, 202)