def _update_instance(self, payload, instance_id, timestamp):
        try:
            serialized_payload = serialize_nova_server(instance_id)
            self.index_helper.save_document(
                serialized_payload,
                version=self.get_version(serialized_payload, timestamp))
        except novaclient.exceptions.NotFound:
            LOG.warning(_LW("Instance %s not found; deleting") % instance_id)

            # Where a notification represents an in-progress delete, we will
            # also receive an 'instance.delete' notification shortly
            deleted = (payload.get('state_description') == 'deleting' or
                       payload.get('state') == 'deleted')
            if not deleted:
                self.delete(payload, timestamp)
 def _update_instance(self, instance_id, timestamp):
     try:
         payload = serialize_nova_server(instance_id)
         self.index_helper.save_document(
             payload,
             version=self.get_version(payload, timestamp))
     except novaclient.exceptions.NotFound:
         LOG.warning(_LW("Instance %s not found; deleting") % instance_id)
         try:
             self.index_helper.delete_document_by_id(instance_id)
         except Exception as exc:
             LOG.error(_LE(
                 'Error deleting instance %(instance_id)s '
                 'from index: %(exc)s') %
                 {'instance_id': instance_id, 'exc': exc})
    def _update_instance(self, payload, instance_id, timestamp):
        try:
            serialized_payload = serialize_nova_server(instance_id)
            self.index_helper.save_document(
                serialized_payload,
                version=self.get_version(serialized_payload, timestamp))
        except novaclient.exceptions.NotFound:
            LOG.warning(_LW("Instance %s not found; deleting") % instance_id)

            # Where a notification represents an in-progress delete, we will
            # also receive an 'instance.delete' notification shortly
            deleted = (payload.get('state_description') == 'deleting' or
                       payload.get('state') == 'deleted')
            if not deleted:
                self.delete(payload, timestamp)
    def index_from_api(self, payload, timestamp):
        """Index from the nova API"""
        instance_id = payload['instance_id']
        LOG.debug("Updating nova server information for %s", instance_id)
        try:
            serialized_payload = serialize_nova_server(instance_id)
            self.index_helper.save_document(
                serialized_payload,
                version=self.get_version(serialized_payload, timestamp))
        except novaclient.exceptions.NotFound:
            LOG.warning(_LW("Instance %s not found; deleting") % instance_id)

            # Where a notification represents an in-progress delete, we will
            # also receive an 'instance.delete' notification shortly
            deleted = (payload.get('state_description') == 'deleting' or
                       payload.get('state') == 'deleted')
            if not deleted:
                self.delete(payload, timestamp)
示例#5
0
    def index_from_api(self, payload, timestamp):
        """Index from the nova API"""
        instance_id = payload['instance_id']
        LOG.debug("Updating nova server information for %s", instance_id)
        try:
            serialized_payload = serialize_nova_server(instance_id)
            self.index_helper.save_document(serialized_payload,
                                            version=self.get_version(
                                                serialized_payload, timestamp))
        except novaclient.exceptions.NotFound:
            LOG.warning(_LW("Instance %s not found; deleting") % instance_id)

            # Where a notification represents an in-progress delete, we will
            # also receive an 'instance.delete' notification shortly
            deleted = (payload.get('state_description') == 'deleting'
                       or payload.get('state') == 'deleted')
            if not deleted:
                self.delete(payload, timestamp)
    def _update_instance(self, instance_id):
        try:
            payload = serialize_nova_server(instance_id)
        except novaclient.exceptions.NotFound:
            LOG.warning(_LW("Instance %s not found; deleting") % instance_id)
            try:
                self.engine.delete(
                    index=self.index_name,
                    doc_type=self.document_type,
                    id=instance_id
                )
            except Exception as e:
                LOG.error(_LE(
                    'Error deleting instance %(instance_id)s '
                    'from index: %(exc)s') % (instance_id, e))
            return

        self.engine.index(
            index=self.index_name,
            doc_type=self.document_type,
            body=payload,
            id=instance_id
        )
示例#7
0
 def serialize(self, server):
     return serialize_nova_server(server)