# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from cinder.api.openstack import extensions from cinder.api.openstack import wsgi from cinder.api.openstack import xmlutil from cinder import volume authorize = extensions.soft_extension_authorizer('volume', 'volume_tenant_attribute') class VolumeTenantAttributeController(wsgi.Controller): def __init__(self, *args, **kwargs): super(VolumeTenantAttributeController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _add_volume_tenant_attribute(self, context, resp_volume): try: db_volume = self.volume_api.get(context, resp_volume['id']) except Exception: return else: key = "%s:tenant_id" % Volume_tenant_attribute.alias resp_volume[key] = db_volume['project_id']
# a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from cinder.api.openstack import extensions from cinder.api.openstack import wsgi from cinder.api.openstack import xmlutil from cinder import volume authorize = extensions.soft_extension_authorizer('volume', 'volume_tenant_attribute') class VolumeTenantAttributeController(wsgi.Controller): def __init__(self, *args, **kwargs): super(VolumeTenantAttributeController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _add_volume_tenant_attribute(self, context, resp_volume): try: db_volume = self.volume_api.get(context, resp_volume['id']) except Exception: return else: key = "%s:tenant_id" % Volume_tenant_attribute.alias resp_volume[key] = db_volume['project_id']
"""The Extended Snapshot Attributes API extension.""" from webob import exc from cinder.api.openstack import extensions from cinder.api.openstack import wsgi from cinder.api.openstack import xmlutil from cinder import volume from cinder import exception from cinder import flags from cinder.openstack.common import log as logging FLAGS = flags.FLAGS LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'extended_snapshot_attributes') class ExtendedSnapshotAttributesController(wsgi.Controller): def __init__(self, *args, **kwargs): super(ExtendedSnapshotAttributesController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _get_snapshots(self, context): snapshots = self.volume_api.get_all_snapshots(context) rval = dict((snapshot['id'], snapshot) for snapshot in snapshots) return rval def _extend_snapshot(self, context, snapshot, data): for attr in ['project_id', 'progress']:
# under the License. """The Extended Snapshot Attributes API extension.""" from webob import exc from cinder.api.openstack import extensions from cinder.api.openstack import wsgi from cinder.api.openstack import xmlutil from cinder import volume from cinder import exception from cinder import flags from cinder.openstack.common import log as logging FLAGS = flags.FLAGS LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer( 'volume', 'extended_snapshot_attributes') class ExtendedSnapshotAttributesController(wsgi.Controller): def __init__(self, *args, **kwargs): super(ExtendedSnapshotAttributesController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _get_snapshots(self, context): snapshots = self.volume_api.get_all_snapshots(context) rval = dict((snapshot['id'], snapshot) for snapshot in snapshots) return rval def _extend_snapshot(self, context, snapshot, data): for attr in ['project_id', 'progress']: