use http code constant instead of int

Change-Id: I71f3271bd0cfaac61f8e86e8fa373257ce22681e
This commit is contained in:
wangqi 2018-03-19 05:14:02 +00:00
parent 623f988b87
commit 896c88d6b7
19 changed files with 51 additions and 32 deletions

View File

@ -22,6 +22,7 @@ from oslo_log import log
from oslo_serialization import jsonutils
from oslo_utils import strutils
import six
from six.moves import http_client
import webob
import webob.exc
@ -1241,7 +1242,7 @@ class AdminActionsMixin(object):
self._update(context, id, update)
except exception.NotFound as e:
raise webob.exc.HTTPNotFound(six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
@Controller.authorize('force_delete')
def _force_delete(self, req, id, body):
@ -1252,7 +1253,7 @@ class AdminActionsMixin(object):
except exception.NotFound as e:
raise webob.exc.HTTPNotFound(six.text_type(e))
self._delete(context, resource, force=True)
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
class Fault(webob.exc.HTTPException):

View File

@ -16,6 +16,7 @@
"""The security service api."""
from oslo_log import log
from six.moves import http_client
import webob
from webob import exc
@ -72,7 +73,7 @@ class SecurityServiceController(wsgi.Controller):
'delete', security_service)
db.security_service_delete(context, id)
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def index(self, req):
"""Returns a summary list of security services."""

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from six.moves import http_client
import webob
from webob import exc
@ -144,7 +145,7 @@ class ShareMetadataController(object):
except exception.NotFound:
msg = _('share does not exist')
raise exc.HTTPNotFound(explanation=msg)
return webob.Response(status_int=200)
return webob.Response(status_int=http_client.OK)
def create_resource():

View File

@ -15,6 +15,7 @@
from oslo_log import log
import six
from six.moves import http_client
import webob
from webob import exc
@ -112,7 +113,7 @@ class ShareServerController(wsgi.Controller):
self.share_api.delete_share_server(context, share_server)
except exception.ShareServerInUse as e:
raise exc.HTTPConflict(explanation=six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def create_resource():

View File

@ -16,6 +16,7 @@
"""The share snapshots api."""
from oslo_log import log
from six.moves import http_client
import webob
from webob import exc
@ -68,7 +69,7 @@ class ShareSnapshotMixin(object):
self.share_api.delete_snapshot(context, snapshot)
except exception.NotFound:
raise exc.HTTPNotFound()
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def index(self, req):
"""Returns a summary list of snapshots."""

View File

@ -14,6 +14,7 @@
# under the License.
import six
from six.moves import http_client
import webob
from manila.api import common
@ -173,7 +174,7 @@ class ShareTypeExtraSpecsController(wsgi.Controller):
notifier_info = dict(type_id=type_id, id=id)
notifier = rpc.get_notifier('shareTypeExtraSpecs')
notifier.info(context, 'share_type_extra_specs.delete', notifier_info)
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def _check_key_names(self, keys):
if not common.validate_key_names(keys):

View File

@ -14,6 +14,7 @@
from oslo_log import log
import six
from six.moves import http_client
import webob
from webob import exc
@ -64,7 +65,7 @@ class ShareUnmanageMixin(object):
except (exception.InvalidShare, exception.PolicyNotAuthorized) as e:
raise exc.HTTPForbidden(explanation=six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
class ShareUnmanageController(ShareUnmanageMixin, wsgi.Controller):

View File

@ -21,6 +21,7 @@ from oslo_log import log
from oslo_utils import strutils
from oslo_utils import uuidutils
import six
from six.moves import http_client
import webob
from webob import exc
@ -97,7 +98,7 @@ class ShareMixin(object):
except exception.Conflict as e:
raise exc.HTTPConflict(explanation=six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def index(self, req):
"""Returns a summary list of shares."""
@ -440,7 +441,7 @@ class ShareMixin(object):
except exception.NotFound as error:
raise webob.exc.HTTPNotFound(explanation=six.text_type(error))
self.share_api.deny_access(context, share, access)
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def _access_list(self, req, id, body):
"""List share access rules."""
@ -464,7 +465,7 @@ class ShareMixin(object):
except exception.ShareSizeExceedsAvailableQuota as e:
raise webob.exc.HTTPForbidden(explanation=six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def _shrink(self, req, id, body):
"""Shrink size of a share."""
@ -477,7 +478,7 @@ class ShareMixin(object):
except (exception.InvalidInput, exception.InvalidShare) as e:
raise webob.exc.HTTPBadRequest(explanation=six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def _get_valid_resize_parameters(self, context, id, body, action):
try:

View File

@ -18,6 +18,7 @@ GET /messages/<message_id>
DELETE /messages/<message_id>
"""
from six.moves import http_client
import webob
from webob import exc
@ -66,7 +67,7 @@ class MessagesController(wsgi.Controller):
except exception.MessageNotFound as error:
raise exc.HTTPNotFound(explanation=error.msg)
return webob.Response(status_int=204)
return webob.Response(status_int=http_client.NO_CONTENT)
@wsgi.Controller.api_version(MESSAGES_BASE_MICRO_VERSION)
@wsgi.Controller.authorize('get_all')

View File

@ -16,6 +16,7 @@
from oslo_log import log
from oslo_utils import strutils
from six.moves import http_client
from six.moves.urllib import parse
import webob
@ -257,7 +258,7 @@ class QuotaSetsMixin(object):
context, id, share_type_id)
else:
QUOTAS.destroy_all_by_project(context, id)
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
except exception.NotAuthorized:
raise webob.exc.HTTPForbidden()

View File

@ -16,6 +16,7 @@
from oslo_log import log
from oslo_utils import uuidutils
import six
from six.moves import http_client
import webob
from webob import exc
@ -70,7 +71,7 @@ class ShareGroupSnapshotController(wsgi.Controller, wsgi.AdminActionsMixin):
context, sg_snapshot)
except exception.InvalidShareGroupSnapshot as e:
raise exc.HTTPConflict(explanation=six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.Controller.api_version('2.31', experimental=True)
@wsgi.Controller.authorize('get_all')

View File

@ -12,6 +12,7 @@
import copy
import six
from six.moves import http_client
import webob
from manila.api import common
@ -119,7 +120,7 @@ class ShareGroupTypeSpecsController(wsgi.Controller):
db.share_group_type_specs_delete(context, id, key)
except exception.ShareGroupTypeSpecsNotFound as error:
raise webob.exc.HTTPNotFound(explanation=error.msg)
return webob.Response(status_int=204)
return webob.Response(status_int=http_client.NO_CONTENT)
def _check_key_names(self, keys):
if not common.validate_key_names(keys):

View File

@ -15,6 +15,7 @@
from oslo_utils import strutils
from oslo_utils import uuidutils
import six
from six.moves import http_client
import webob
from webob import exc
@ -166,7 +167,7 @@ class ShareGroupTypesController(wsgi.Controller):
raise webob.exc.HTTPBadRequest(explanation=msg % id)
except exception.NotFound:
raise webob.exc.HTTPNotFound()
return webob.Response(status_int=204)
return webob.Response(status_int=http_client.NO_CONTENT)
@wsgi.Controller.api_version('2.31', experimental=True)
@wsgi.Controller.authorize('list_project_access')
@ -204,7 +205,7 @@ class ShareGroupTypesController(wsgi.Controller):
context, id, project)
except exception.ShareGroupTypeAccessExists as err:
raise webob.exc.HTTPConflict(explanation=six.text_type(err))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.Controller.api_version('2.31', experimental=True)
@wsgi.action('removeProjectAccess')
@ -219,7 +220,7 @@ class ShareGroupTypesController(wsgi.Controller):
context, id, project)
except exception.ShareGroupTypeAccessNotFound as err:
raise webob.exc.HTTPNotFound(explanation=six.text_type(err))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def _assert_non_public_share_group_type(self, context, type_id):
try:

View File

@ -16,6 +16,7 @@
from oslo_log import log
from oslo_utils import uuidutils
import six
from six.moves import http_client
import webob
from webob import exc
@ -71,7 +72,7 @@ class ShareGroupController(wsgi.Controller, wsgi.AdminActionsMixin):
self.share_group_api.delete(context, share_group)
except exception.InvalidShareGroup as e:
raise exc.HTTPConflict(explanation=six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.Controller.api_version('2.31', experimental=True)
@wsgi.Controller.authorize('get_all')

View File

@ -19,6 +19,7 @@ from oslo_db import exception as db_exception
from oslo_log import log
from oslo_utils import timeutils
import six
from six.moves import http_client
import webob
from webob import exc
@ -104,7 +105,7 @@ class ShareNetworkController(wsgi.Controller):
QUOTAS.commit(context, reservations,
project_id=share_network['project_id'],
user_id=share_network['user_id'])
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def _get_share_networks(self, req, is_detail=True):
"""Returns a list of share networks."""

View File

@ -16,6 +16,7 @@
"""The Share Replication API."""
import six
from six.moves import http_client
import webob
from webob import exc
@ -157,7 +158,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin):
except exception.ReplicationException as e:
raise exc.HTTPBadRequest(explanation=six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.Controller.api_version(MIN_SUPPORTED_API_VERSION, experimental=True)
@wsgi.action('promote')
@ -176,7 +177,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin):
replica_state = replica.get('replica_state')
if replica_state == constants.REPLICA_STATE_ACTIVE:
return webob.Response(status_int=200)
return webob.Response(status_int=http_client.OK)
try:
replica = self.share_api.promote_share_replica(context, replica)
@ -222,7 +223,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin):
replica_state = replica.get('replica_state')
if replica_state == constants.REPLICA_STATE_ACTIVE:
return webob.Response(status_int=200)
return webob.Response(status_int=http_client.OK)
try:
self.share_api.update_share_replica(context, replica)

View File

@ -18,6 +18,7 @@
from oslo_log import log
import six
from six.moves import http_client
import webob
from webob import exc
@ -77,7 +78,7 @@ class ShareSnapshotsController(share_snapshots.ShareSnapshotMixin,
except (exception.ShareSnapshotNotFound, exception.ShareNotFound) as e:
raise exc.HTTPNotFound(explanation=six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.Controller.authorize('manage_snapshot')
def _manage(self, req, body):
@ -220,7 +221,7 @@ class ShareSnapshotsController(share_snapshots.ShareSnapshotMixin,
raise webob.exc.HTTPBadRequest(explanation=msg)
self.share_api.snapshot_deny_access(context, snapshot, access)
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def _check_mount_snapshot_support(self, context, snapshot):
share = self.share_api.get(context, snapshot['share_id'])

View File

@ -19,6 +19,7 @@ from oslo_log import log
from oslo_utils import strutils
from oslo_utils import uuidutils
import six
from six.moves import http_client
import webob
from webob import exc
@ -250,7 +251,7 @@ class ShareTypesController(wsgi.Controller):
raise webob.exc.HTTPNotFound()
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.Controller.authorize('list_project_access')
def share_type_access(self, req, id):
@ -289,7 +290,7 @@ class ShareTypesController(wsgi.Controller):
except exception.ShareTypeAccessExists as err:
raise webob.exc.HTTPConflict(explanation=six.text_type(err))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.action('removeProjectAccess')
@wsgi.Controller.authorize('remove_project_access')
@ -304,7 +305,7 @@ class ShareTypesController(wsgi.Controller):
share_types.remove_share_type_access(context, id, project)
except exception.ShareTypeAccessNotFound as err:
raise webob.exc.HTTPNotFound(explanation=six.text_type(err))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def _verify_if_non_public_share_type(self, context, share_type_id):
try:

View File

@ -15,6 +15,7 @@
from oslo_log import log
import six
from six.moves import http_client
import webob
from webob import exc
@ -157,7 +158,7 @@ class ShareController(shares.ShareMixin,
except exception.ReplicationException as e:
raise exc.HTTPBadRequest(explanation=six.text_type(e))
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
def _validate_revert_parameters(self, context, body):
if not (body and self.is_valid_body(body, 'revert')):
@ -287,7 +288,7 @@ class ShareController(shares.ShareMixin,
msg = _("Share %s not found.") % id
raise exc.HTTPNotFound(explanation=msg)
self.share_api.migration_complete(context, share)
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.Controller.api_version('2.22', experimental=True)
@wsgi.action("migration_cancel")
@ -301,7 +302,7 @@ class ShareController(shares.ShareMixin,
msg = _("Share %s not found.") % id
raise exc.HTTPNotFound(explanation=msg)
self.share_api.migration_cancel(context, share)
return webob.Response(status_int=202)
return webob.Response(status_int=http_client.ACCEPTED)
@wsgi.Controller.api_version('2.22', experimental=True)
@wsgi.action("migration_get_progress")