def _push_metadata_software_deployments(
            self, cnxt, server_id, stack_user_project_id):
        rs = db_api.resource_get_by_physical_resource_id(cnxt, server_id)
        if not rs:
            return
        deployments = self.metadata_software_deployments(cnxt, server_id)
        md = rs.rsrc_metadata or {}
        md['deployments'] = deployments
        rows_updated = db_api.resource_update(
            cnxt, rs.id, {'rsrc_metadata': md}, rs.atomic_key)
        if not rows_updated:
            action = "deployments of server %s" % server_id
            raise exception.ConcurrentTransaction(action=action)

        metadata_put_url = None
        metadata_queue_id = None
        for rd in rs.data:
            if rd.key == 'metadata_put_url':
                metadata_put_url = rd.value
            if rd.key == 'metadata_queue_id':
                metadata_queue_id = rd.value
        if metadata_put_url:
            json_md = jsonutils.dumps(md)
            requests.put(metadata_put_url, json_md)
        if metadata_queue_id:
            project = stack_user_project_id
            token = self._get_user_token(cnxt, rs, project)
            zaqar_plugin = cnxt.clients.client_plugin('zaqar')
            zaqar = zaqar_plugin.create_for_tenant(project, token)
            queue = zaqar.queue(metadata_queue_id)
            queue.post({'body': md, 'ttl': zaqar_plugin.DEFAULT_TTL})
Exemple #2
0
    def _push_metadata_software_deployments(
            self, cnxt, server_id, stack_user_project_id):
        rs = db_api.resource_get_by_physical_resource_id(cnxt, server_id)
        if not rs:
            return
        deployments = self.metadata_software_deployments(cnxt, server_id)
        md = rs.rsrc_metadata or {}
        md['deployments'] = deployments
        rows_updated = db_api.resource_update(
            cnxt, rs.id, {'rsrc_metadata': md}, rs.atomic_key)
        if not rows_updated:
            action = _('deployments of server %s') % server_id
            raise exception.ConcurrentTransaction(action=action)

        metadata_put_url = None
        metadata_queue_id = None
        for rd in rs.data:
            if rd.key == 'metadata_put_url':
                metadata_put_url = rd.value
            if rd.key == 'metadata_queue_id':
                metadata_queue_id = rd.value
        if metadata_put_url:
            json_md = jsonutils.dumps(md)
            requests.put(metadata_put_url, json_md)
        if metadata_queue_id:
            project = stack_user_project_id
            queue = self._get_zaqar_queue(cnxt, rs, project, metadata_queue_id)
            zaqar_plugin = cnxt.clients.client_plugin('zaqar')
            queue.post({'body': md, 'ttl': zaqar_plugin.DEFAULT_TTL})
    def _push_metadata_software_deployments(self, cnxt, server_id, sd):
        rs = db_api.resource_get_by_physical_resource_id(cnxt, server_id)
        if not rs:
            return
        deployments = self.metadata_software_deployments(cnxt, server_id)
        md = rs.rsrc_metadata or {}
        md["deployments"] = deployments
        rows_updated = db_api.resource_update(cnxt, rs.id, {"rsrc_metadata": md}, rs.atomic_key)
        if not rows_updated:
            raise db_exc.RetryRequest(exception.DeploymentConcurrentTransaction(server=server_id))

        metadata_put_url = None
        metadata_queue_id = None
        for rd in rs.data:
            if rd.key == "metadata_put_url":
                metadata_put_url = rd.value
            if rd.key == "metadata_queue_id":
                metadata_queue_id = rd.value
        if metadata_put_url:
            json_md = jsonutils.dumps(md)
            requests.put(metadata_put_url, json_md)
        if metadata_queue_id:
            project = sd.stack_user_project_id
            token = self._get_user_token(cnxt, rs, project)
            zaqar_plugin = cnxt.clients.client_plugin("zaqar")
            zaqar = zaqar_plugin.create_for_tenant(project, token)
            queue = zaqar.queue(metadata_queue_id)
            queue.post({"body": md, "ttl": zaqar_plugin.DEFAULT_TTL})
    def _push_metadata_software_deployments(self, cnxt, server_id, sd):
        rs = db_api.resource_get_by_physical_resource_id(cnxt, server_id)
        if not rs:
            return
        deployments = self.metadata_software_deployments(cnxt, server_id)
        md = rs.rsrc_metadata or {}
        md['deployments'] = deployments
        rows_updated = db_api.resource_update(cnxt, rs.id,
                                              {'rsrc_metadata': md},
                                              rs.atomic_key)
        if not rows_updated:
            raise db_exc.RetryRequest(
                exception.DeploymentConcurrentTransaction(server=server_id))

        metadata_put_url = None
        metadata_queue_id = None
        for rd in rs.data:
            if rd.key == 'metadata_put_url':
                metadata_put_url = rd.value
            if rd.key == 'metadata_queue_id':
                metadata_queue_id = rd.value
        if metadata_put_url:
            json_md = jsonutils.dumps(md)
            requests.put(metadata_put_url, json_md)
        if metadata_queue_id:
            project = sd.stack_user_project_id
            token = self._get_user_token(cnxt, rs, project)
            zaqar_plugin = cnxt.clients.client_plugin('zaqar')
            zaqar = zaqar_plugin.create_for_tenant(project, token)
            queue = zaqar.queue(metadata_queue_id)
            queue.post({'body': md, 'ttl': zaqar_plugin.DEFAULT_TTL})
Exemple #5
0
 def select_and_update(self, values, expected_engine_id=None, atomic_key=0):
     return db_api.resource_update(self._context,
                                   self.id,
                                   values,
                                   atomic_key=atomic_key,
                                   expected_engine_id=expected_engine_id)
Exemple #6
0
 def select_and_update(self, values, expected_engine_id=None,
                       atomic_key=0):
     return db_api.resource_update(self._context, self.id, values,
                                   atomic_key=atomic_key,
                                   expected_engine_id=expected_engine_id)