コード例 #1
0
ファイル: instance_actions.py プロジェクト: 2Exception/patron
#    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 webob import exc

from patron.api.openstack import common
from patron.api.openstack import extensions
from patron.api.openstack import wsgi
from patron import compute
from patron.i18n import _

ALIAS = "os-instance-actions"
authorize = extensions.os_compute_authorizer(ALIAS)
soft_authorize = extensions.os_compute_soft_authorizer(ALIAS)

ACTION_KEYS = [
    'action', 'instance_uuid', 'request_id', 'user_id', 'project_id',
    'start_time', 'message'
]
EVENT_KEYS = ['event', 'start_time', 'finish_time', 'result', 'traceback']


class InstanceActionsController(wsgi.Controller):
    def __init__(self):
        super(InstanceActionsController, self).__init__()
        self.compute_api = compute.API()
        self.action_api = compute.InstanceActionAPI()
コード例 #2
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 patron.api.openstack import common
from patron.api.openstack import extensions as exts
from patron.api.openstack import wsgi
from patron import compute
from patron 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["patron.context"]
        authorize(context, action='shelve')
コード例 #3
0
ファイル: console_auth_tokens.py プロジェクト: hsluoyz/patron
#
#    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.

import webob

from patron.api.openstack import extensions
from patron.api.openstack import wsgi
from patron.consoleauth import rpcapi as consoleauth_rpcapi
from patron.i18n import _

ALIAS = "os-console-auth-tokens"
authorize = extensions.os_compute_authorizer(ALIAS)


class ConsoleAuthTokensController(wsgi.Controller):
    def __init__(self, *args, **kwargs):
        self._consoleauth_rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
        super(ConsoleAuthTokensController, self).__init__(*args, **kwargs)

    @extensions.expected_errors((400, 401, 404))
    def show(self, req, id):
        """Checks a console auth token and returns the related connect info."""
        context = req.environ['patron.context']
        authorize(context)

        token = id
        if not token:
コード例 #4
0
ファイル: shelve.py プロジェクト: hsluoyz/patron
#   License for the specific language governing permissions and limitations
#   under the License.

"""The shelved mode extension."""

from webob import exc

from patron.api.openstack import common
from patron.api.openstack import extensions as exts
from patron.api.openstack import wsgi
from patron import compute
from patron 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["patron.context"]
        authorize(context, action="shelve")
コード例 #5
0
ファイル: migrations.py プロジェクト: 2Exception/patron
def authorize(context, action_name):
    extensions.os_compute_authorizer(ALIAS)(context, action=action_name)
コード例 #6
0
ファイル: test_extensions.py プロジェクト: 2Exception/patron
 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)
コード例 #7
0
from oslo_utils import strutils
from webob import exc

from patron.api.openstack import common
from patron.api.openstack.compute.schemas.v3 import volumes as volumes_schema
from patron.api.openstack import extensions
from patron.api.openstack import wsgi
from patron.api import validation
from patron import compute
from patron import exception
from patron.i18n import _
from patron import objects
from patron 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."""
コード例 #8
0
ファイル: test_extensions.py プロジェクト: hsluoyz/patron
 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)