def test_os_compute_api_authorizer_throws_exception_if_policy_fails(self):
     authorize = base_extensions.os_compute_authorizer(
         'used_limits_for_admin')
     self._test_extension_authorizer_throws_exception_if_policy_fails(
         "os_compute_api:used_limits_for_admin",
         authorize)
Esempio n. 2
0
#    License for the specific language governing permissions and limitations
#    under the License.

import webob.exc

from nova.api.openstack.compute.schemas.v3 import services
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api import validation
from nova import compute
from nova import exception
from nova.i18n import _
from nova import servicegroup

ALIAS = "os-services"
authorize = extensions.os_compute_authorizer(ALIAS)


class ServiceController(wsgi.Controller):

    def __init__(self):
        self.host_api = compute.HostAPI()
        self.servicegroup_api = servicegroup.API()

    def _get_services(self, req):
        context = req.environ['nova.context']
        authorize(context)
        _services = self.host_api.service_get_all(context, set_zones=True)

        host = ''
        if 'host' in req.GET:
Esempio n. 3
0
#   License for the specific language governing permissions and limitations
#   under the License.

"""The shelved mode extension."""

from webob import exc

from nova.api.openstack import common
from nova.api.openstack import extensions as exts
from nova.api.openstack import wsgi
from nova import compute
from nova import exception


ALIAS = 'os-shelve'
authorize = exts.os_compute_authorizer(ALIAS)


class ShelveController(wsgi.Controller):
    def __init__(self, *args, **kwargs):
        super(ShelveController, self).__init__(*args, **kwargs)
        self.compute_api = compute.API(skip_policy_check=True)

    @wsgi.response(202)
    @exts.expected_errors((404, 409))
    @wsgi.action('shelve')
    def _shelve(self, req, id, body):
        """Move an instance into shelved mode."""
        context = req.environ["nova.context"]
        authorize(context, action='shelve')
Esempio n. 4
0
from oslo_utils import strutils
from webob import exc

from nova.api.openstack import common
from nova.api.openstack.compute.schemas import volumes as volumes_schema
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api import validation
from nova import compute
from nova import exception
from nova.i18n import _
from nova import objects
from nova import volume

ALIAS = "os-volumes"
authorize = extensions.os_compute_authorizer(ALIAS)
authorize_attach = extensions.os_compute_authorizer('os-volumes-attachments')


def _translate_volume_detail_view(context, vol):
    """Maps keys for volumes details view."""

    d = _translate_volume_summary_view(context, vol)

    # No additional data / lookups at the moment

    return d


def _translate_volume_summary_view(context, vol):
    """Maps keys for volumes summary view."""
Esempio n. 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 shelved mode extension."""

from webob import exc

from nova.api.openstack import common
from nova.api.openstack import extensions as exts
from nova.api.openstack import wsgi
from nova import compute
from nova import exception

ALIAS = 'os-shelve'
authorize = exts.os_compute_authorizer(ALIAS)


class ShelveController(wsgi.Controller):
    def __init__(self, *args, **kwargs):
        super(ShelveController, self).__init__(*args, **kwargs)
        self.compute_api = compute.API()

    @wsgi.response(202)
    @exts.expected_errors((404, 409))
    @wsgi.action('shelve')
    def _shelve(self, req, id, body):
        """Move an instance into shelved mode."""
        context = req.environ["nova.context"]
        authorize(context, action='shelve')
"""The virtual interfaces extension."""

import webob

from nova.api.openstack import api_version_request
from nova.api.openstack import common
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova import compute
from nova.i18n import _
from nova import network


ALIAS = 'os-virtual-interfaces'
authorize = extensions.os_compute_authorizer(ALIAS)


def _translate_vif_summary_view(req, vif):
    """Maps keys for VIF summary view."""
    d = {}
    d['id'] = vif.uuid
    d['mac_address'] = vif.address
    if api_version_request.is_supported(req, min_version='2.12'):
        d['net_id'] = vif.net_uuid
    # NOTE(gmann): This is for v2.1 compatible mode where response should be
    # same as v2 one.
    if req.is_legacy_v2():
        d['OS-EXT-VIF-NET:net_id'] = vif.net_uuid
    return d
Esempio n. 7
0
def authorize(context, action_name):
    extensions.os_compute_authorizer(ALIAS)(context, action=action_name)
Esempio n. 8
0
 def test_os_compute_api_authorizer_throws_exception_if_policy_fails(self):
     authorize = base_extensions.os_compute_authorizer(
         'used_limits_for_admin')
     self._test_extension_authorizer_throws_exception_if_policy_fails(
         "os_compute_api:used_limits_for_admin", authorize)
Esempio n. 9
0
from nova.api.openstack import api_version_request
from nova.api.openstack import common
from nova.api.openstack.compute.schemas import volumes as volumes_schema
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api import validation
from nova import compute
from nova.compute import vm_states
from nova import exception
from nova.i18n import _
from nova import objects
from nova import volume

ALIAS = "os-volumes"
authorize = extensions.os_compute_authorizer(ALIAS)
authorize_attach = extensions.os_compute_authorizer('os-volumes-attachments')


def _translate_volume_detail_view(context, vol):
    """Maps keys for volumes details view."""

    d = _translate_volume_summary_view(context, vol)

    # No additional data / lookups at the moment

    return d


def _translate_volume_summary_view(context, vol):
    """Maps keys for volumes summary view."""