コード例 #1
0
def authorize(context, action_name):
    extensions.extension_authorizer('volume', action_name)(context)
コード例 #2
0
ファイル: scheduler_stats.py プロジェクト: NetApp/cinder
def authorize(context, action_name):
    action = 'scheduler_stats:%s' % action_name
    extensions.extension_authorizer('scheduler', action)(context)
コード例 #3
0
from oslo_config import cfg
from oslo_log import log as logging
from webob import exc

from cinder.api.contrib import resource_common_manage
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.views import manageable_snapshots as list_manageable_view
from cinder.api.views import snapshots as snapshot_views
from cinder.i18n import _
from cinder import volume as cinder_volume

LOG = logging.getLogger(__name__)
CONF = cfg.CONF
authorize_manage = extensions.extension_authorizer("snapshot", "snapshot_manage")
authorize_list_manageable = extensions.extension_authorizer("snapshot", "list_manageable")


class SnapshotManageController(wsgi.Controller):
    """The /os-snapshot-manage controller for the OpenStack API."""

    _view_builder_class = snapshot_views.ViewBuilder

    def __init__(self, *args, **kwargs):
        super(SnapshotManageController, self).__init__(*args, **kwargs)
        self.volume_api = cinder_volume.API()
        self._list_manageable_view = list_manageable_view.ViewBuilder()

    @wsgi.response(202)
    def create(self, req, body):
コード例 #4
0
ファイル: used_limits.py プロジェクト: carriercomm/cinder
#
#         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 import extensions
from cinder.api.openstack import wsgi
from cinder import quota

QUOTAS = quota.QUOTAS

authorize = extensions.extension_authorizer('limits', 'used_limits')


class UsedLimitsController(wsgi.Controller):

    @wsgi.extends
    def index(self, req, resp_obj):
        context = req.environ['cinder.context']
        authorize(context)

        quotas = QUOTAS.get_project_quotas(context, context.project_id,
                                           usages=True)

        quota_map = {
            'totalVolumesUsed': 'volumes',
            'totalGigabytesUsed': 'gigabytes',
コード例 #5
0
ファイル: qos_specs_manage.py プロジェクト: NetApp/cinder
import webob

from cinder.api import common
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.views import qos_specs as view_qos_specs
from cinder import exception
from cinder.i18n import _
from cinder import rpc
from cinder import utils
from cinder.volume import qos_specs


LOG = logging.getLogger(__name__)

authorize = extensions.extension_authorizer('volume', 'qos_specs_manage')


def _check_specs(context, specs_id):
    # Not found exception will be handled at the wsgi level
    qos_specs.get_qos_specs(context, specs_id)


class QoSSpecsController(wsgi.Controller):
    """The volume type extra specs API controller for the OpenStack API."""

    _view_builder_class = view_qos_specs.ViewBuilder

    @staticmethod
    def _notify_qos_specs_error(context, method, payload):
        rpc.get_notifier('QoSSpecs').error(context,
コード例 #6
0
ファイル: hosts.py プロジェクト: ArikaChen/cinder
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder import exception
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder import utils
from cinder.volume import api as volume_api


CONF = cfg.CONF

LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('volume', 'hosts')


class HostIndexTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.TemplateElement('hosts')
        elem = xmlutil.SubTemplateElement(root, 'host', selector='hosts')
        elem.set('service-status')
        elem.set('service')
        elem.set('zone')
        elem.set('service-state')
        elem.set('host_name')
        elem.set('last-update')

        return xmlutil.MasterTemplate(root, 1)
コード例 #7
0
ファイル: qos_specs_manage.py プロジェクト: mshabdiz/cinder
import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.views import qos_specs as view_qos_specs
from cinder.api import xmlutil
from cinder import exception
from cinder.openstack.common import log as logging
from cinder.openstack.common.notifier import api as notifier_api
from cinder.openstack.common import strutils
from cinder.volume import qos_specs

LOG = logging.getLogger(__name__)

authorize = extensions.extension_authorizer('volume', 'qos_specs_manage')


def make_qos_specs(elem):
    elem.set('id')
    elem.set('name')
    elem.set('consumer')
    elem.append(SpecsTemplate())


def make_associations(elem):
    elem.set('association_type')
    elem.set('name')
    elem.set('id')

コード例 #8
0
#    under the License.

"""The volume types encryption extension."""

import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder import db
from cinder import exception
from cinder.i18n import _
from cinder import rpc
from cinder import utils
from cinder.volume import volume_types

authorize = extensions.extension_authorizer('volume',
                                            'volume_type_encryption')

CONTROL_LOCATION = ['front-end', 'back-end']


class VolumeTypeEncryptionController(wsgi.Controller):
    """The volume type encryption API controller for the OpenStack API."""

    def _get_volume_type_encryption(self, context, type_id):
        encryption_ref = db.volume_type_encryption_get(context, type_id)
        encryption_specs = {}
        if not encryption_ref:
            return encryption_specs
        for key, value in encryption_ref.items():
            encryption_specs[key] = value
        return encryption_specs
コード例 #9
0
#   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 oslo_log import log as logging
import webob
from webob import exc

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder import exception
from cinder.i18n import _, _LI
from cinder import volume

LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('volume', 'volume_unmanage')


class VolumeUnmanageController(wsgi.Controller):
    def __init__(self, *args, **kwargs):
        super(VolumeUnmanageController, self).__init__(*args, **kwargs)
        self.volume_api = volume.API()

    @wsgi.response(202)
    @wsgi.action('os-unmanage')
    def unmanage(self, req, id, body):
        """Stop managing a volume.

        This action is very much like a delete, except that a different
        method (unmanage) is called on the Cinder driver.  This has the effect
        of removing the volume from Cinder management without actually
コード例 #10
0
"""The volume type access extension."""

from oslo_utils import uuidutils
import six
from six.moves import http_client
import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder import exception
from cinder.i18n import _
from cinder.volume import volume_types

soft_authorize = extensions.soft_extension_authorizer('volume',
                                                      'volume_type_access')
authorize = extensions.extension_authorizer('volume', 'volume_type_access')


def _marshall_volume_type_access(vol_type):
    rval = []
    for project_id in vol_type['projects']:
        rval.append({
            'volume_type_id': vol_type['id'],
            'project_id': project_id
        })

    return {'volume_type_access': rval}


class VolumeTypeAccessController(object):
    """The volume type access API controller for the OpenStack API."""
コード例 #11
0
import six
from six.moves import http_client
import webob

from oslo_utils import strutils

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.views import types as views_types
from cinder import exception
from cinder.i18n import _
from cinder import rpc
from cinder import utils
from cinder.volume import volume_types

authorize = extensions.extension_authorizer('volume', 'types_manage')


class VolumeTypesManageController(wsgi.Controller):
    """The volume types API controller for the OpenStack API."""

    _view_builder_class = views_types.ViewBuilder

    @utils.if_notifications_enabled
    def _notify_volume_type_error(self,
                                  context,
                                  method,
                                  err,
                                  volume_type=None,
                                  id=None,
                                  name=None):
コード例 #12
0
#   under the License.

from oslo_log import log as logging
from six.moves import http_client
from webob import exc

from cinder.api.contrib import resource_common_manage
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.views import manageable_snapshots as list_manageable_view
from cinder.api.views import snapshots as snapshot_views
from cinder.i18n import _
from cinder import volume as cinder_volume

LOG = logging.getLogger(__name__)
authorize_manage = extensions.extension_authorizer('snapshot',
                                                   'snapshot_manage')
authorize_list_manageable = extensions.extension_authorizer(
    'snapshot', 'list_manageable')


class SnapshotManageController(wsgi.Controller):
    """The /os-snapshot-manage controller for the OpenStack API."""

    _view_builder_class = snapshot_views.ViewBuilder

    def __init__(self, *args, **kwargs):
        super(SnapshotManageController, self).__init__(*args, **kwargs)
        self.volume_api = cinder_volume.API()
        self._list_manageable_view = list_manageable_view.ViewBuilder()

    @wsgi.response(http_client.ACCEPTED)
コード例 #13
0
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
"""The volume types extra specs extension"""

import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder import exception
from cinder.openstack.common.notifier import api as notifier_api
from cinder.volume import volume_types

authorize = extensions.extension_authorizer('volume', 'types_extra_specs')


class VolumeTypeExtraSpecsTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.make_flat_dict('extra_specs', selector='extra_specs')
        return xmlutil.MasterTemplate(root, 1)


class VolumeTypeExtraSpecTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        tagname = xmlutil.Selector('key')

        def extraspec_sel(obj, do_raise=False):
            # Have to extract the key and value for later use...
            key, value = obj.items()[0]
コード例 #14
0
#
#         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.

"""The volume encryption metadata extension."""

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder import db

authorize = extensions.extension_authorizer('volume',
                                            'volume_encryption_metadata')


class VolumeEncryptionMetadataController(wsgi.Controller):
    """The volume encryption metadata API extension."""

    def index(self, req, volume_id):
        """Returns the encryption metadata for a given volume."""
        context = req.environ['cinder.context']
        authorize(context)
        return db.volume_encryption_metadata_get(context, volume_id)

    def show(self, req, volume_id, id):
        """Return a single encryption item."""
        encryption_item = self.index(req, volume_id)
        if encryption_item is not None:
コード例 #15
0
ファイル: hosts.py プロジェクト: wputra/MOS-centos
from xml.parsers import expat

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder import exception
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder import utils
from cinder.volume import api as volume_api

CONF = cfg.CONF

LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('volume', 'hosts')


class HostIndexTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.TemplateElement('hosts')
        elem = xmlutil.SubTemplateElement(root, 'host', selector='hosts')
        elem.set('service-status')
        elem.set('service')
        elem.set('zone')
        elem.set('service-state')
        elem.set('host_name')
        elem.set('last-update')

        return xmlutil.MasterTemplate(root, 1)
コード例 #16
0
ファイル: quotas.py プロジェクト: TelekomCloud/cinder
import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder.db.sqlalchemy import api as sqlalchemy_api
from cinder import exception
from cinder import quota


QUOTAS = quota.QUOTAS


authorize_update = extensions.extension_authorizer("volume", "quotas:update")
authorize_show = extensions.extension_authorizer("volume", "quotas:show")


class QuotaTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.TemplateElement("quota_set", selector="quota_set")
        root.set("id")

        for resource in QUOTAS.resources:
            elem = xmlutil.SubTemplateElement(root, resource)
            elem.text = resource

        return xmlutil.MasterTemplate(root, 1)

コード例 #17
0
def authorize(context, action_name):
    action = 'snapshot_actions:%s' % action_name
    extensions.extension_authorizer('snapshot', action)(context)
コード例 #18
0
ファイル: services.py プロジェクト: ebalduf/cinder-backports
from cinder.api.openstack import wsgi
from cinder.backup import rpcapi as backup_rpcapi
from cinder.common import constants
from cinder import exception
from cinder.i18n import _
from cinder import objects
from cinder.scheduler import rpcapi as scheduler_rpcapi
from cinder import utils
from cinder import volume
from cinder.volume import rpcapi as volume_rpcapi


CONF = cfg.CONF

LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('volume', 'services')


class ServiceController(wsgi.Controller):
    LOG_BINARIES = (constants.SCHEDULER_BINARY, constants.VOLUME_BINARY,
                    constants.BACKUP_BINARY, constants.API_BINARY)

    def __init__(self, ext_mgr=None):
        self.ext_mgr = ext_mgr
        super(ServiceController, self).__init__()
        self.volume_api = volume.API()
        self.rpc_apis = {
            constants.SCHEDULER_BINARY: scheduler_rpcapi.SchedulerAPI(),
            constants.VOLUME_BINARY: volume_rpcapi.VolumeAPI(),
            constants.BACKUP_BINARY: backup_rpcapi.BackupAPI(),
        }
コード例 #19
0
from oslo_utils import timeutils
import webob.exc

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder import exception
from cinder.i18n import _
from cinder import utils


CONF = cfg.CONF

LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('volume', 'services')


class ServicesIndexTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.TemplateElement('services')
        elem = xmlutil.SubTemplateElement(root, 'service', selector='services')
        elem.set('binary')
        elem.set('host')
        elem.set('zone')
        elem.set('status')
        elem.set('state')
        elem.set('update_at')
        elem.set('disabled_reason')

        return xmlutil.MasterTemplate(root, 1)
コード例 #20
0
def authorize(context, action_name):
    action = 'volume_actions:%s' % action_name
    extensions.extension_authorizer('volume', action)(context)
コード例 #21
0
from oslo_utils import strutils

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder import db
from cinder.db.sqlalchemy import api as sqlalchemy_api
from cinder import exception
from cinder.i18n import _
from cinder import quota
from cinder import quota_utils
from cinder import utils

QUOTAS = quota.QUOTAS
NON_QUOTA_KEYS = ['tenant_id', 'id']

authorize_update = extensions.extension_authorizer('volume', 'quotas:update')
authorize_show = extensions.extension_authorizer('volume', 'quotas:show')
authorize_delete = extensions.extension_authorizer('volume', 'quotas:delete')


class QuotaSetsController(wsgi.Controller):
    def _format_quota_set(self, project_id, quota_set):
        """Convert the quota object to a result dict."""

        quota_set['id'] = str(project_id)

        return dict(quota_set=quota_set)

    def _validate_existing_resource(self, key, value, quota_values):
        # -1 limit will always be greater than the existing value
        if key == 'per_volume_gigabytes' or value == -1:
コード例 #22
0
 def _set_resource_type(self, resource):
     self._authorizer = extensions.extension_authorizer(
         resource, 'list_manageable')
     self.get_manageable = getattr(self.volume_api,
                                   'get_manageable_%ss' % resource)
コード例 #23
0
def authorize(context, action_name):
    action = 'volume_actions:%s' % action_name
    extensions.extension_authorizer('volume', action)(context)
コード例 #24
0
ファイル: volume_manage.py プロジェクト: Hopebaytech/cinder
from oslo_utils import uuidutils
from webob import exc

from cinder.api.contrib import resource_common_manage
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.v2.views import volumes as volume_views
from cinder.api.views import manageable_volumes as list_manageable_view
from cinder import exception
from cinder.i18n import _
from cinder import utils
from cinder import volume as cinder_volume
from cinder.volume import volume_types

LOG = logging.getLogger(__name__)
authorize_manage = extensions.extension_authorizer('volume', 'volume_manage')
authorize_list_manageable = extensions.extension_authorizer('volume',
                                                            'list_manageable')


class VolumeManageController(wsgi.Controller):
    """The /os-volume-manage controller for the OpenStack API."""

    _view_builder_class = volume_views.ViewBuilder

    def __init__(self, *args, **kwargs):
        super(VolumeManageController, self).__init__(*args, **kwargs)
        self.volume_api = cinder_volume.API()
        self._list_manageable_view = list_manageable_view.ViewBuilder()

    @wsgi.response(202)
コード例 #25
0
from webob import exc

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder import db
from cinder import exception
from cinder.i18n import _

try:
    from oslo_log import log as logging
except ImportError:
    from cinder.openstack.common import log as logging

LOG = logging.getLogger(__name__)

authorize = extensions.extension_authorizer('volume', 'snapshot_progress')


class SnapshotProgressController(wsgi.Controller):
    """Controller for updating snapshot progress field."""

    collection = 'snapshots'

    def __init__(self, *args, **kwargs):
        super(SnapshotProgressController, self).__init__(*args, **kwargs)

    @wsgi.action('os-update_progress')
    def _update_progress(self, req, id, body):
        """Update snapshot progress."""
        context = req.environ['cinder.context']
        authorize(context)
コード例 #26
0
ファイル: snapshot_actions.py プロジェクト: CloudVPS/cinder
def authorize(context, action_name):
    action = 'snapshot_actions:%s' % action_name
    extensions.extension_authorizer('snapshot', action)(context)
コード例 #27
0
ファイル: admin_actions.py プロジェクト: medlefsen/cinder
 def authorize(self, context, action_name):
     # e.g. "snapshot_admin_actions:reset_status"
     action = '%s_admin_actions:%s' % (self.resource_name, action_name)
     extensions.extension_authorizer('volume', action)(context)
コード例 #28
0
ファイル: qos_specs_manage.py プロジェクト: jcru/cinder
import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.views import qos_specs as view_qos_specs
from cinder.api import xmlutil
from cinder import exception
from cinder.openstack.common import log as logging
from cinder.openstack.common.notifier import api as notifier_api
from cinder.openstack.common import strutils
from cinder.volume import qos_specs


LOG = logging.getLogger(__name__)

authorize = extensions.extension_authorizer("volume", "qos_specs_manage")


class QoSSpecsTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.make_flat_dict("qos_specs", selector="qos_specs")
        return xmlutil.MasterTemplate(root, 1)


class QoSSpecTemplate(xmlutil.TemplateBuilder):
    # FIXME(zhiteng) Need to handle consumer
    def construct(self):
        tagname = xmlutil.Selector("key")

        def qosspec_sel(obj, do_raise=False):
            # Have to extract the key and value for later use...
コード例 #29
0
import six
import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import exception
from cinder.i18n import _
from cinder.openstack.common import uuidutils
from cinder.volume import volume_types


soft_authorize = extensions.soft_extension_authorizer('volume',
                                                      'volume_type_access')
authorize = extensions.extension_authorizer('volume', 'volume_type_access')


def make_volume_type(elem):
    elem.set('{%s}is_public' % Volume_type_access.namespace,
             '%s:is_public' % Volume_type_access.alias)


def make_volume_type_access(elem):
    elem.set('volume_type_id')
    elem.set('project_id')


class VolumeTypeTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.TemplateElement('volume_type', selector='volume_type')
コード例 #30
0
ファイル: types_manage.py プロジェクト: jbranen/cinder
#    under the License.

"""The volume types manage extension."""

import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.v1 import types
from cinder.api.views import types as views_types
from cinder import exception
from cinder.openstack.common.notifier import api as notifier_api
from cinder.volume import volume_types


authorize = extensions.extension_authorizer("volume", "types_manage")


class VolumeTypesManageController(wsgi.Controller):
    """The volume types API controller for the OpenStack API."""

    _view_builder_class = views_types.ViewBuilder

    def _notify_volume_type_error(self, context, method, payload):
        notifier_api.notify(context, "volumeType", method, notifier_api.ERROR, payload)

    @wsgi.action("create")
    @wsgi.serializers(xml=types.VolumeTypeTemplate)
    def _create(self, req, body):
        """Creates a new volume type."""
        context = req.environ["cinder.context"]
コード例 #31
0
import lunrclient
from lunrclient import client
from lunrclient.client import LunrClient
import requests
from webob import exc


lunr_opts = [
    cfg.StrOpt('lunr_api_version', default='v1.0'),
]

CONF = cfg.CONF
CONF.register_opts(lunr_opts)

LOG = logging.getLogger(__name__)
authorize_quota_usage = extensions.extension_authorizer('rax-admin', 'quota-usage')
authorize_top_usage = extensions.extension_authorizer('rax-admin', 'top-usage')
authorize_list_nodes = extensions.extension_authorizer('rax-admin', 'list-nodes')
authorize_list_nodes_out_rotation = extensions.extension_authorizer('rax-admin', 'list-nodes-out-rotation')
authorize_list_volumes = extensions.extension_authorizer('rax-admin', 'list-volumes')
authorize_list_lunr_volumes = extensions.extension_authorizer('rax-admin', 'list-lunr-volumes')
authorize_get_node = extensions.extension_authorizer('rax-admin', 'get-node')
authorize_get_volume = extensions.extension_authorizer('rax-admin', 'get-volume')
authorize_status_volumes_all = extensions.extension_authorizer('rax-admin', 'status-volumes-all')


class SafeDict(dict):
    def get(self, key, default=None):
        """ If the value of the get is None, return the default, if the value
        is a dict, always return a SafeDict instead
        """
コード例 #32
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.

"""The volume encryption metadata extension."""

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder.volume import volume_types

authorize = extensions.extension_authorizer("volume", "volume_encryption_metadata")


class VolumeEncryptionMetadataTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.make_flat_dict("encryption", selector="encryption")
        return xmlutil.MasterTemplate(root, 1)


class VolumeEncryptionMetadataController(wsgi.Controller):
    """The volume encryption metadata API extension."""

    def _get_volume_encryption_metadata(self, context, volume_id):
        return db.volume_encryption_metadata_get(context, volume_id)

    def _is_volume_type_encrypted(self, context, volume_id):
コード例 #33
0
ファイル: quotas.py プロジェクト: CiscoAS/cinder
import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder.db.sqlalchemy import api as sqlalchemy_api
from cinder import exception
from cinder import quota


QUOTAS = quota.QUOTAS


authorize_update = extensions.extension_authorizer('compute', 'quotas:update')
authorize_show = extensions.extension_authorizer('compute', 'quotas:show')


class QuotaTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.TemplateElement('quota_set', selector='quota_set')
        root.set('id')

        for resource in QUOTAS.resources:
            elem = xmlutil.SubTemplateElement(root, resource)
            elem.text = resource

        return xmlutil.MasterTemplate(root, 1)

コード例 #34
0
ファイル: quota_classes.py プロジェクト: JohnHaan/cinder
#    under the License.

import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder import exception
from cinder import quota


QUOTAS = quota.QUOTAS


authorize = extensions.extension_authorizer('volume', 'quota_classes')


class QuotaClassTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.TemplateElement('quota_class_set',
                                       selector='quota_class_set')
        root.set('id')

        for resource in QUOTAS.resources:
            elem = xmlutil.SubTemplateElement(root, resource)
            elem.text = resource

        return xmlutil.MasterTemplate(root, 1)

コード例 #35
0
def authorize(context, action_name):
    action = "volume_actions:%s" % action_name
    extensions.extension_authorizer("volume", action)(context)
コード例 #36
0
ファイル: snapshot_unmanage.py プロジェクト: Datera/cinder
#   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 oslo_log import log as logging
import webob
from webob import exc

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder import exception
from cinder.i18n import _LI
from cinder import volume

LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('snapshot', 'snapshot_unmanage')


class SnapshotUnmanageController(wsgi.Controller):
    def __init__(self, *args, **kwargs):
        super(SnapshotUnmanageController, self).__init__(*args, **kwargs)
        self.volume_api = volume.API()

    @wsgi.response(202)
    @wsgi.action('os-unmanage')
    def unmanage(self, req, id, body):
        """Stop managing a snapshot.

        This action is very much like a delete, except that a different
        method (unmanage) is called on the Cinder driver.  This has the effect
        of removing the snapshot from Cinder management without actually
コード例 #37
0
ファイル: snapshot_manage.py プロジェクト: bravandi/cinder
from oslo_config import cfg
from oslo_log import log as logging
from webob import exc

from cinder.api.contrib import resource_common_manage
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.views import manageable_snapshots as list_manageable_view
from cinder.api.views import snapshots as snapshot_views
from cinder import exception
from cinder.i18n import _
from cinder import volume as cinder_volume

LOG = logging.getLogger(__name__)
CONF = cfg.CONF
authorize_manage = extensions.extension_authorizer('snapshot',
                                                   'snapshot_manage')
authorize_list_manageable = extensions.extension_authorizer('snapshot',
                                                            'list_manageable')


class SnapshotManageController(wsgi.Controller):
    """The /os-snapshot-manage controller for the OpenStack API."""

    _view_builder_class = snapshot_views.ViewBuilder

    def __init__(self, *args, **kwargs):
        super(SnapshotManageController, self).__init__(*args, **kwargs)
        self.volume_api = cinder_volume.API()
        self._list_manageable_view = list_manageable_view.ViewBuilder()

    @wsgi.response(202)
コード例 #38
0
ファイル: quotas.py プロジェクト: dims/cinder
from cinder.db.sqlalchemy import api as sqlalchemy_api
from cinder import exception
from cinder.i18n import _
from cinder import quota
from cinder import quota_utils
from cinder import utils

from oslo_config import cfg
from oslo_utils import strutils


CONF = cfg.CONF
QUOTAS = quota.QUOTAS
NON_QUOTA_KEYS = ['tenant_id', 'id']

authorize_update = extensions.extension_authorizer('volume', 'quotas:update')
authorize_show = extensions.extension_authorizer('volume', 'quotas:show')
authorize_delete = extensions.extension_authorizer('volume', 'quotas:delete')


class QuotaTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.TemplateElement('quota_set', selector='quota_set')
        root.set('id')

        for resource in QUOTAS.resources:
            elem = xmlutil.SubTemplateElement(root, resource)
            elem.text = resource

        return xmlutil.MasterTemplate(root, 1)
コード例 #39
0
ファイル: services.py プロジェクト: shishirng/cinder
from oslo_utils import timeutils
import webob.exc

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder import exception
from cinder.i18n import _
from cinder import utils


CONF = cfg.CONF

LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer("volume", "services")


class ServicesIndexTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.TemplateElement("services")
        elem = xmlutil.SubTemplateElement(root, "service", selector="services")
        elem.set("binary")
        elem.set("host")
        elem.set("zone")
        elem.set("status")
        elem.set("state")
        elem.set("update_at")
        elem.set("disabled_reason")

        return xmlutil.MasterTemplate(root, 1)
コード例 #40
0
ファイル: types_extra_specs.py プロジェクト: asvignesh/cinder
#    under the License.

"""The volume types extra specs extension"""

import webob

from cinder.api import common
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder import exception
from cinder.openstack.common.notifier import api as notifier_api
from cinder.volume import volume_types

authorize = extensions.extension_authorizer('volume', 'types_extra_specs')


class VolumeTypeExtraSpecsTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.make_flat_dict('extra_specs', selector='extra_specs')
        return xmlutil.MasterTemplate(root, 1)


class VolumeTypeExtraSpecTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        tagname = xmlutil.Selector('key')

        def extraspec_sel(obj, do_raise=False):
            # Have to extract the key and value for later use...
            key, value = obj.items()[0]
コード例 #41
0
#    License for the specific language governing permissions and limitations
#    under the License.

"""The volume types encryption extension."""

import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder import exception
from cinder.openstack.common.notifier import api as notifier_api
from cinder.volume import volume_types

authorize = extensions.extension_authorizer("volume", "volume_type_encryption")

CONTROL_LOCATION = ["front-end", "back-end"]


class VolumeTypeEncryptionTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.make_flat_dict("encryption", selector="encryption")
        return xmlutil.MasterTemplate(root, 1)


class VolumeTypeEncryptionController(wsgi.Controller):
    """The volume type encryption API controller for the OpenStack API."""

    def _get_volume_type_encryption(self, context, type_id):
        encryption_ref = db.volume_type_encryption_get(context, type_id)
コード例 #42
0
ファイル: volume_manage.py プロジェクト: bpankaj/cinder
from oslo_log import log as logging
from oslo_utils import uuidutils
from webob import exc

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.v2.views import volumes as volume_views
from cinder.api.v2 import volumes
from cinder import exception
from cinder.i18n import _
from cinder import utils
from cinder import volume as cinder_volume
from cinder.volume import volume_types

LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('volume', 'volume_manage')


class VolumeManageController(wsgi.Controller):
    """The /os-volume-manage controller for the OpenStack API."""

    _view_builder_class = volume_views.ViewBuilder

    def __init__(self, *args, **kwargs):
        super(VolumeManageController, self).__init__(*args, **kwargs)
        self.volume_api = cinder_volume.API()

    @wsgi.response(202)
    @wsgi.serializers(xml=volumes.VolumeTemplate)
    @wsgi.deserializers(xml=volumes.CreateDeserializer)
    def create(self, req, body):
コード例 #43
0
def authorize(context, action_name):
    action = "snapshot_actions:%s" % action_name
    extensions.extension_authorizer("snapshot", action)(context)
コード例 #44
0
 def authorize(self, context, action_name):
     # e.g. "snapshot_admin_actions:reset_status"
     action = '%s_admin_actions:%s' % (self.resource_name, action_name)
     extensions.extension_authorizer('volume', action)(context)
コード例 #45
0
ファイル: quota_classes.py プロジェクト: jjacob512/cinder-1
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import webob

from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api import xmlutil
from cinder import db
from cinder import exception
from cinder import quota

QUOTAS = quota.QUOTAS

authorize = extensions.extension_authorizer('volume', 'quota_classes')


class QuotaClassTemplate(xmlutil.TemplateBuilder):
    def construct(self):
        root = xmlutil.TemplateElement('quota_class_set',
                                       selector='quota_class_set')
        root.set('id')

        for resource in QUOTAS.resources:
            elem = xmlutil.SubTemplateElement(root, resource)
            elem.text = resource

        return xmlutil.MasterTemplate(root, 1)