Example #1
0
from xml.parsers import expat

from monitor.api import extensions
from monitor.api.openstack import wsgi
from monitor.api import xmlutil
from monitor import db
from monitor import exception
from monitor import flags
from monitor.openstack.common import log as logging
from monitor.openstack.common import timeutils
from monitor import utils
from monitor.servicemanage import api as servicemanage_api

FLAGS = flags.FLAGS
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('servicemanage', '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)
Example #2
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 monitor.api import extensions
from monitor.api.openstack import wsgi
from monitor.api import xmlutil
from monitor import db
from monitor import exception
from monitor import quota

QUOTAS = quota.QUOTAS

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

Example #3
0
def authorize(context, action_name):
    action = 'servicemanage_actions:%s' % action_name
    extensions.extension_authorizer('servicemanage', action)(context)
Example #4
0
#    License for the specific language governing permissions and limitations
#    under the License.

"""The servicemanage types extra specs extension"""

import webob

from monitor.api import extensions
from monitor.api.openstack import wsgi
from monitor.api import xmlutil
from monitor import db
from monitor import exception
from monitor.servicemanage import servicemanage_types


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


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


class ServiceManageTypeExtraSpecTemplate(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]
Example #5
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 servicemanage types extra specs extension"""

import webob

from monitor.api import extensions
from monitor.api.openstack import wsgi
from monitor.api import xmlutil
from monitor import db
from monitor import exception
from monitor.servicemanage import servicemanage_types

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


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


class ServiceManageTypeExtraSpecTemplate(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]
Example #6
0
#    under the License.

import webob

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


QUOTAS = quota.QUOTAS


authorize = extensions.extension_authorizer("servicemanage", "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):
Example #7
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('servicemanage', action)(context)
Example #8
0
import webob

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

Example #9
0
#    License for the specific language governing permissions and limitations
#    under the License.

"""The servicemanage types manage extension."""

import webob

from monitor.api import extensions
from monitor.api.openstack import wsgi
from monitor.api.v1 import types
from monitor.api.views import types as views_types
from monitor import exception
from monitor.servicemanage import servicemanage_types


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


class ServiceManageTypesManageController(wsgi.Controller):
    """The servicemanage types API controller for the OpenStack API."""

    _view_builder_class = views_types.ViewBuilder

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

        if not self.is_valid_body(body, 'servicemanage_type'):
Example #10
0

import webob.exc

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


LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('servicemanage', '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)
Example #11
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('servicemanage', action)(context)
Example #12
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 servicemanage types manage extension."""

import webob

from monitor.api import extensions
from monitor.api.openstack import wsgi
from monitor.api.v1 import types
from monitor.api.views import types as views_types
from monitor import exception
from monitor.servicemanage import servicemanage_types

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


class ServiceManageTypesManageController(wsgi.Controller):
    """The servicemanage types API controller for the OpenStack API."""

    _view_builder_class = views_types.ViewBuilder

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

        if not self.is_valid_body(body, 'servicemanage_type'):
Example #13
0
def authorize(context, action_name):
    action = 'servicemanage_actions:%s' % action_name
    extensions.extension_authorizer('servicemanage', action)(context)