Ejemplo n.º 1
0
 def test_core_authorizer_throws_exception_if_policy_fails(self):
     target = {"project_id": "1234", "user_id": "5678"}
     self.mox.StubOutWithMock(nova.policy, "enforce")
     nova.policy.enforce(self.fake_context, "compute:used_limits_for_admin", target).AndRaise(
         exception.PolicyNotAuthorized(action="compute:used_limits_for_admin")
     )
     self.mox.ReplayAll()
     authorize = base_extensions.core_authorizer("compute", "used_limits_for_admin")
     self.assertRaises(exception.PolicyNotAuthorized, authorize, self.fake_context, target=target)
Ejemplo n.º 2
0
 def test_core_authorizer_throws_exception_if_policy_fails(self):
     target = {'project_id': '1234', 'user_id': '5678'}
     self.mox.StubOutWithMock(nova.policy, 'enforce')
     nova.policy.enforce(self.fake_context, "compute:used_limits_for_admin",
                         target).AndRaise(
                             exception.PolicyNotAuthorized(
                                 action="compute:used_limits_for_admin"))
     self.mox.ReplayAll()
     authorize = base_extensions.core_authorizer('compute',
                                                 'used_limits_for_admin')
     self.assertRaises(exception.PolicyNotAuthorized,
                       authorize,
                       self.fake_context,
                       target=target)
Ejemplo n.º 3
0
from nova.openstack.common import timeutils
from nova.openstack.common import uuidutils
from nova import policy
from nova import utils


CONF = cfg.CONF
CONF.import_opt('enable_instance_password',
                'nova.api.openstack.compute.servers')
CONF.import_opt('network_api_class', 'nova.network')
CONF.import_opt('reclaim_instance_interval', 'nova.compute.manager')
CONF.import_opt('extensions_blacklist', 'nova.api.openstack', group='osapi_v3')
CONF.import_opt('extensions_whitelist', 'nova.api.openstack', group='osapi_v3')

LOG = logging.getLogger(__name__)
authorizer = extensions.core_authorizer('compute:v3', 'servers')


class ServersController(wsgi.Controller):
    """The Server API base controller class for the OpenStack API."""

    EXTENSION_CREATE_NAMESPACE = 'nova.api.v3.extensions.server.create'
    EXTENSION_DESERIALIZE_EXTRACT_SERVER_NAMESPACE = (
        'nova.api.v3.extensions.server.create.deserialize')

    EXTENSION_REBUILD_NAMESPACE = 'nova.api.v3.extensions.server.rebuild'
    EXTENSION_DESERIALIZE_EXTRACT_REBUILD_NAMESPACE = (
        'nova.api.v3.extensions.server.rebuild.deserialize')

    EXTENSION_UPDATE_NAMESPACE = 'nova.api.v3.extensions.server.update'
 def test_core_authorizer_throws_exception_if_policy_fails(self):
     authorize = base_extensions.core_authorizer('compute',
                                                 'used_limits_for_admin')
     self._test_core_authorizer_throws_exception_if_policy_fails(
         "compute:used_limits_for_admin", authorize)
Ejemplo n.º 5
0
from nova.openstack.common import uuidutils
from nova import policy
from nova import utils

ALIAS = 'servers'

CONF = cfg.CONF
CONF.import_opt('enable_instance_password',
                'nova.api.openstack.compute.servers')
CONF.import_opt('network_api_class', 'nova.network')
CONF.import_opt('reclaim_instance_interval', 'nova.compute.manager')
CONF.import_opt('extensions_blacklist', 'nova.api.openstack', group='osapi_v3')
CONF.import_opt('extensions_whitelist', 'nova.api.openstack', group='osapi_v3')

LOG = logging.getLogger(__name__)
authorizer = extensions.core_authorizer('compute:v3', 'servers')


class ServersController(wsgi.Controller):
    """The Server API base controller class for the OpenStack API."""

    EXTENSION_CREATE_NAMESPACE = 'nova.api.v3.extensions.server.create'
    EXTENSION_DESERIALIZE_EXTRACT_SERVER_NAMESPACE = (
        'nova.api.v3.extensions.server.create.deserialize')

    EXTENSION_REBUILD_NAMESPACE = 'nova.api.v3.extensions.server.rebuild'
    EXTENSION_DESERIALIZE_EXTRACT_REBUILD_NAMESPACE = (
        'nova.api.v3.extensions.server.rebuild.deserialize')

    EXTENSION_UPDATE_NAMESPACE = 'nova.api.v3.extensions.server.update'
Ejemplo n.º 6
0
from nova.openstack.common import strutils
from nova.openstack.common import timeutils
from nova.openstack.common import uuidutils
from nova import policy
from nova import utils


CONF = cfg.CONF
CONF.import_opt("enable_instance_password", "nova.api.openstack.compute.servers")
CONF.import_opt("network_api_class", "nova.network")
CONF.import_opt("reclaim_instance_interval", "nova.compute.manager")
CONF.import_opt("extensions_blacklist", "nova.api.openstack", group="osapi_v3")
CONF.import_opt("extensions_whitelist", "nova.api.openstack", group="osapi_v3")

LOG = logging.getLogger(__name__)
authorizer = extensions.core_authorizer("compute:v3", "servers")


class ServersController(wsgi.Controller):
    """The Server API base controller class for the OpenStack API."""

    EXTENSION_CREATE_NAMESPACE = "nova.api.v3.extensions.server.create"
    EXTENSION_DESERIALIZE_EXTRACT_SERVER_NAMESPACE = "nova.api.v3.extensions.server.create.deserialize"

    EXTENSION_REBUILD_NAMESPACE = "nova.api.v3.extensions.server.rebuild"
    EXTENSION_DESERIALIZE_EXTRACT_REBUILD_NAMESPACE = "nova.api.v3.extensions.server.rebuild.deserialize"

    EXTENSION_UPDATE_NAMESPACE = "nova.api.v3.extensions.server.update"

    _view_builder_class = views_servers.ViewBuilderV3
Ejemplo n.º 7
0
from nova import exception
from nova.openstack.common.gettextutils import _


from nova.openstack.common import timeutils

CONF = cfg.CONF
CONF.import_opt('enable_instance_password',
                'nova.api.openstack.compute.servers')
CONF.import_opt('network_api_class', 'nova.network')
CONF.import_opt('reclaim_instance_interval', 'nova.compute.manager')
CONF.import_opt('extensions_blacklist', 'nova.api.openstack', group='osapi_v3')
CONF.import_opt('extensions_whitelist', 'nova.api.openstack', group='osapi_v3')

LOG = logging.getLogger(__name__)
authorizer = extensions.core_authorizer('compute:v3', 'domains')


def make_server(elem, detailed=False):
    elem.set('name')
    elem.set('id')

    if detailed:
        elem.set('userId', 'user_id')
        elem.set('tenantId', 'tenant_id')
        elem.set('updated')
        elem.set('created')
        elem.set('hostId')
        elem.set('accessIPv4')
        elem.set('accessIPv6')
        elem.set('status')