Removed v2 api.
Moved shares and snapshots from contrib to v1
This commit is contained in:
parent
68cbc773de
commit
1a253971c2
|
@ -20,6 +20,9 @@ from manila import exception
|
|||
from manila import share
|
||||
|
||||
|
||||
authorize = extensions.extension_authorizer('share', 'services')
|
||||
|
||||
|
||||
class ShareActionsController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ShareActionsController, self).__init__(*args, **kwargs)
|
||||
|
@ -65,6 +68,10 @@ class ShareActionsController(wsgi.Controller):
|
|||
return {'access_list': access_list}
|
||||
|
||||
|
||||
# def create_resource():
|
||||
# return wsgi.Resource(ShareActionsController())
|
||||
|
||||
|
||||
class Share_actions(extensions.ExtensionDescriptor):
|
||||
"""Enable share actions."""
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@ from manila.api import extensions
|
|||
import manila.api.openstack
|
||||
from manila.api.v1 import limits
|
||||
from manila.api import versions
|
||||
|
||||
from manila.api.v1 import shares
|
||||
from manila.api.v1 import share_actions
|
||||
from manila.api.v1 import share_snapshots
|
||||
|
||||
from manila.openstack.common import log as logging
|
||||
|
||||
|
||||
|
@ -45,3 +50,24 @@ class APIRouter(manila.api.openstack.APIRouter):
|
|||
action='show')
|
||||
|
||||
mapper.redirect("", "/")
|
||||
|
||||
self.resources['shares'] = shares.create_resource()
|
||||
mapper.resource("share", "shares",
|
||||
controller=self.resources['shares'],
|
||||
collection={'detail': 'GET'},
|
||||
member={'action': 'POST'})
|
||||
|
||||
self.resources['share-snapshots'] = share_snapshots.create_resource()
|
||||
mapper.resource("share-snapshot", "share-snapshots",
|
||||
controller=self.resources['share-snapshots'],
|
||||
collection={'detail': 'GET'},
|
||||
member={'action': 'POST'})
|
||||
#
|
||||
# self.resources['shares'] = share_actions.create_resource()
|
||||
# mapper.resource("share", "shares",
|
||||
# controller=self.resources['shares'])
|
||||
|
||||
self.resources['limits'] = limits.create_resource()
|
||||
mapper.resource("limit", "limits",
|
||||
controller=self.resources['limits'])
|
||||
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
# Copyright 2013 NetApp.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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 manila.api import extensions
|
||||
from manila.api.openstack import wsgi
|
||||
from manila import exception
|
||||
from manila import share
|
||||
|
||||
|
||||
class ShareActionsController(wsgi.Controller):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ShareActionsController, self).__init__(*args, **kwargs)
|
||||
self.share_api = share.API()
|
||||
|
||||
@wsgi.action('os-allow_access')
|
||||
def _allow_access(self, req, id, body):
|
||||
"""Add share access rule."""
|
||||
context = req.environ['manila.context']
|
||||
|
||||
share = self.share_api.get(context, id)
|
||||
|
||||
access_type = body['os-allow_access']['access_type']
|
||||
access_to = body['os-allow_access']['access_to']
|
||||
|
||||
self.share_api.allow_access(context, share, access_type, access_to)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@wsgi.action('os-deny_access')
|
||||
def _deny_access(self, req, id, body):
|
||||
"""Remove access rule."""
|
||||
context = req.environ['manila.context']
|
||||
|
||||
access_id = body['os-deny_access']['access_id']
|
||||
|
||||
try:
|
||||
access = self.share_api.access_get(context, access_id)
|
||||
if access.share_id != id:
|
||||
raise exception.NotFound()
|
||||
share = self.share_api.get(context, id)
|
||||
except exception.NotFound, error:
|
||||
raise webob.exc.HTTPNotFound(explanation=unicode(error))
|
||||
self.share_api.deny_access(context, share, access)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@wsgi.action('os-access_list')
|
||||
def _access_list(self, req, id, body):
|
||||
"""list access rules."""
|
||||
context = req.environ['manila.context']
|
||||
|
||||
share = self.share_api.get(context, id)
|
||||
access_list = self.share_api.access_get_all(context, share)
|
||||
return {'access_list': access_list}
|
||||
|
||||
|
||||
def create_resource():
|
||||
return wsgi.Resource(ShareActionsController())
|
||||
#
|
||||
#
|
||||
# class Share_actions(extensions.ExtensionDescriptor):
|
||||
# """Enable share actions."""
|
||||
#
|
||||
# name = 'ShareActions'
|
||||
# alias = 'share-actions'
|
||||
# namespace = ''
|
||||
# updated = '2012-08-14T00:00:00+00:00'
|
||||
#
|
||||
# def get_controller_extensions(self):
|
||||
# controller = ShareActionsController()
|
||||
# extension = extensions.ControllerExtension(self, 'shares',
|
||||
# controller)
|
||||
# return [extension]
|
|
@ -19,7 +19,7 @@ import webob
|
|||
from webob import exc
|
||||
|
||||
from manila.api import common
|
||||
from manila.api.contrib import shares
|
||||
from manila.api.v1 import shares
|
||||
from manila.api import extensions
|
||||
from manila.api.openstack import wsgi
|
||||
from manila.api.views import share_snapshots as snapshot_views
|
||||
|
@ -166,16 +166,20 @@ class ShareSnapshotsController(wsgi.Controller):
|
|||
return self._view_builder.summary(req, dict(new_snapshot.iteritems()))
|
||||
|
||||
|
||||
class Share_snapshots(extensions.ExtensionDescriptor):
|
||||
"""Enable share snapshtos API."""
|
||||
name = 'ShareSnapshots'
|
||||
alias = 'share-snapshots'
|
||||
namespace = ''
|
||||
updated = '2013-03-01T00:00:00+00:00'
|
||||
def create_resource():
|
||||
return wsgi.Resource(ShareSnapshotsController())
|
||||
|
||||
def get_resources(self):
|
||||
controller = ShareSnapshotsController()
|
||||
resource = extensions.ResourceExtension(
|
||||
'share-snapshots', controller,
|
||||
collection_actions={'detail': 'GET'})
|
||||
return [resource]
|
||||
#
|
||||
# class Share_snapshots(extensions.ExtensionDescriptor):
|
||||
# """Enable share snapshtos API."""
|
||||
# name = 'ShareSnapshots'
|
||||
# alias = 'share-snapshots'
|
||||
# namespace = ''
|
||||
# updated = '2013-03-01T00:00:00+00:00'
|
||||
#
|
||||
# def get_resources(self):
|
||||
# controller = ShareSnapshotsController()
|
||||
# resource = extensions.ResourceExtension(
|
||||
# 'share-snapshots', controller,
|
||||
# collection_actions={'detail': 'GET'})
|
||||
# return [resource]
|
|
@ -200,16 +200,19 @@ class ShareController(wsgi.Controller):
|
|||
return self._view_builder.summary(req, dict(new_share.iteritems()))
|
||||
|
||||
|
||||
class Shares(extensions.ExtensionDescriptor):
|
||||
"""Enable share API."""
|
||||
name = 'Shares'
|
||||
alias = 'shares'
|
||||
namespace = ''
|
||||
updated = '2013-01-29T00:00:00+00:00'
|
||||
def create_resource():
|
||||
return wsgi.Resource(ShareController())
|
||||
|
||||
def get_resources(self):
|
||||
controller = ShareController()
|
||||
resource = extensions.ResourceExtension(
|
||||
'shares', controller, collection_actions={'detail': 'GET'},
|
||||
member_actions={'action': 'POST'})
|
||||
return [resource]
|
||||
# class Shares(extensions.ExtensionDescriptor):
|
||||
# """Enable share API."""
|
||||
# name = 'Shares'
|
||||
# alias = 'shares'
|
||||
# namespace = ''
|
||||
# updated = '2013-01-29T00:00:00+00:00'
|
||||
#
|
||||
# def get_resources(self):
|
||||
# controller = ShareController()
|
||||
# resource = extensions.ResourceExtension(
|
||||
# 'shares', controller, collection_actions={'detail': 'GET'},
|
||||
# member_actions={'action': 'POST'})
|
||||
# return [resource]
|
Loading…
Reference in New Issue