def test_serialize(self): with mock.patch('cinderclient.v2.volumes.VolumeManager.get', return_value=self.volume1): serialized = serialize_cinder_volume(ID1) self.assertNotIn('_info', serialized) self.assertNotIn('_loaded', serialized) self.assertNotIn('manager', serialized) self.assertNotIn('links', serialized)
def create_or_update(self, payload, timestamp): volume_id = payload['volume_id'] LOG.debug("Updating cinder volume information for %s", volume_id) try: payload = serialize_cinder_volume(volume_id) version = self.get_version(payload, timestamp) self.index_helper.save_document(payload, version=version) except cinderclient.exceptions.NotFound: LOG.warning(_LW("Volume %s not found; deleting") % volume_id) self.delete(payload, timestamp)
def create_or_update(self, event_type, payload, timestamp): volume_id = payload['volume_id'] LOG.debug("Updating cinder volume information for %s", volume_id) try: volume_payload = serialize_cinder_volume(volume_id) version = self.get_version(volume_payload, timestamp) self.index_helper.save_document(volume_payload, version=version) return pipeline.IndexItem(self.index_helper.plugin, event_type, payload, volume_payload) except cinderclient.exceptions.NotFound: LOG.warning("Volume %s not found; deleting" % volume_id) self.delete(payload, timestamp)
def serialize(self, volume): return serialize_cinder_volume(volume)