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('storage', action)(context)
Пример #2
0
#    License for the specific language governing permissions and limitations
#    under the License.

import webob

from vsm.api import extensions
from vsm.api.openstack import wsgi
from vsm.api import xmlutil
from vsm import db
from vsm.db.sqlalchemy import api as sqlalchemy_api
from vsm import exception
from vsm 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)

Пример #3
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.

import webob

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

QUOTAS = quota.QUOTAS

authorize = extensions.extension_authorizer('storage', '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)

Пример #4
0
def authorize(context, action_name):
    action = 'storage_actions:%s' % action_name
    extensions.extension_authorizer('storage', action)(context)
Пример #5
0
from xml.parsers import expat

from vsm.api import extensions
from vsm.api.openstack import wsgi
from vsm.api import xmlutil
from vsm import db
from vsm import exception
from vsm import flags
from vsm.openstack.common import log as logging
from vsm.openstack.common import timeutils
from vsm import utils
from vsm.storage import api as storage_api

FLAGS = flags.FLAGS
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('storage', '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)

class HostUpdateTemplate(xmlutil.TemplateBuilder):
Пример #6
0
#    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 storage types extra specs extension"""

import webob

from vsm.api import extensions
from vsm.api.openstack import wsgi
from vsm.api import xmlutil
from vsm import db
from vsm import exception
from vsm.storage import storage_types

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


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


class HardwareTypeExtraSpecTemplate(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]
#    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 storage types extra specs extension"""

import webob

from vsm.api import extensions
from vsm.api.openstack import wsgi
from vsm.api import xmlutil
from vsm import db
from vsm import exception
from vsm.storage import storage_types

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

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

class HardwareTypeExtraSpecTemplate(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]
            return dict(key=key, value=value)
Пример #8
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('storage', action)(context)
#    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 storage types manage extension."""

import webob

from vsm.api import extensions
from vsm.api.openstack import wsgi
from vsm.api.v1 import types
from vsm.api.views import types as views_types
from vsm import exception
from vsm.storage import storage_types

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

class HardwareTypesManageController(wsgi.Controller):
    """The storage types API controller for the OpenStack API."""

    _view_builder_class = views_types.ViewBuilder

    @wsgi.action("create")
    @wsgi.serializers(xml=types.HardwareTypeTemplate)
    def _create(self, req, body):
        """Creates a new storage type."""
        context = req.environ['vsm.context']
        authorize(context)

        if not self.is_valid_body(body, 'storage_type'):
            raise webob.exc.HTTPBadRequest()
Пример #10
0
#    License for the specific language governing permissions and limitations
#    under the License.

import webob

from vsm.api import extensions
from vsm.api.openstack import wsgi
from vsm.api import xmlutil
from vsm import db
from vsm.db.sqlalchemy import api as sqlalchemy_api
from vsm import exception
from vsm 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)

class QuotaSetsController(object):
def authorize(context, action_name):
    action = 'storage_actions:%s' % action_name
    extensions.extension_authorizer('storage', action)(context)
Пример #12
0
#    License for the specific language governing permissions and limitations
#    under the License.

import webob.exc

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

LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('storage', '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')

        return xmlutil.MasterTemplate(root, 1)

class ServicesUpdateTemplate(xmlutil.TemplateBuilder):
#    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 vsm.api import extensions
from vsm.api.openstack import wsgi
from vsm.api import xmlutil
from vsm import db
from vsm import exception
from vsm import quota

QUOTAS = quota.QUOTAS

authorize = extensions.extension_authorizer('storage', '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)

class QuotaClassSetsController(object):
Пример #14
0
#    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 storage types manage extension."""

import webob

from vsm.api import extensions
from vsm.api.openstack import wsgi
from vsm.api.v1 import types
from vsm.api.views import types as views_types
from vsm import exception
from vsm.storage import storage_types

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


class HardwareTypesManageController(wsgi.Controller):
    """The storage types API controller for the OpenStack API."""

    _view_builder_class = views_types.ViewBuilder

    @wsgi.action("create")
    @wsgi.serializers(xml=types.HardwareTypeTemplate)
    def _create(self, req, body):
        """Creates a new storage type."""
        context = req.environ['vsm.context']
        authorize(context)

        if not self.is_valid_body(body, 'storage_type'):
Пример #15
0
#    License for the specific language governing permissions and limitations
#    under the License.

import webob.exc

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

LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('storage', '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')

        return xmlutil.MasterTemplate(root, 1)