Merge "Enable admin access to EC2 API server"
This commit is contained in:
commit
82460d4a79
@ -391,6 +391,10 @@ class Executor(wsgi.Application):
|
|||||||
LOG.info(_('NotAuthorized raised: %s'), unicode(ex),
|
LOG.info(_('NotAuthorized raised: %s'), unicode(ex),
|
||||||
context=context)
|
context=context)
|
||||||
return self._error(req, context, type(ex).__name__, unicode(ex))
|
return self._error(req, context, type(ex).__name__, unicode(ex))
|
||||||
|
except exception.InvalidRequest as ex:
|
||||||
|
LOG.debug(_('InvalidRequest raised: %s'), unicode(ex),
|
||||||
|
context=context)
|
||||||
|
return self._error(req, context, type(ex).__name__, unicode(ex))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
extra = {'environment': req.environ}
|
extra = {'environment': req.environ}
|
||||||
LOG.exception(_('Unexpected error raised: %s'), unicode(ex),
|
LOG.exception(_('Unexpected error raised: %s'), unicode(ex),
|
||||||
|
@ -24,10 +24,14 @@ import datetime
|
|||||||
# TODO(termie): replace minidom with etree
|
# TODO(termie): replace minidom with etree
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
|
|
||||||
|
from nova import flags
|
||||||
from nova import log as logging
|
from nova import log as logging
|
||||||
|
from nova import exception
|
||||||
from nova.api.ec2 import ec2utils
|
from nova.api.ec2 import ec2utils
|
||||||
|
from nova.api.ec2.admin import AdminController
|
||||||
|
|
||||||
LOG = logging.getLogger("nova.api.request")
|
LOG = logging.getLogger("nova.api.request")
|
||||||
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
|
|
||||||
def _underscore_to_camelcase(str):
|
def _underscore_to_camelcase(str):
|
||||||
@ -53,6 +57,14 @@ class APIRequest(object):
|
|||||||
|
|
||||||
def invoke(self, context):
|
def invoke(self, context):
|
||||||
try:
|
try:
|
||||||
|
# Raise NotImplemented exception for Admin specific request if
|
||||||
|
# admin flag is set to false in nova.conf
|
||||||
|
if (isinstance(self.controller, AdminController) and
|
||||||
|
(not FLAGS.allow_ec2_admin_api)):
|
||||||
|
## Raise InvalidRequest exception for EC2 Admin interface ##
|
||||||
|
LOG.exception("Unsupported API request")
|
||||||
|
raise exception.InvalidRequest()
|
||||||
|
|
||||||
method = getattr(self.controller,
|
method = getattr(self.controller,
|
||||||
ec2utils.camelcase_to_underscore(self.action))
|
ec2utils.camelcase_to_underscore(self.action))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -63,7 +75,7 @@ class APIRequest(object):
|
|||||||
LOG.exception(_error)
|
LOG.exception(_error)
|
||||||
# TODO: Raise custom exception, trap in apiserver,
|
# TODO: Raise custom exception, trap in apiserver,
|
||||||
# and reraise as 400 error.
|
# and reraise as 400 error.
|
||||||
raise Exception(_error)
|
raise exception.InvalidRequest()
|
||||||
|
|
||||||
args = ec2utils.dict_from_dotted_str(self.args.items())
|
args = ec2utils.dict_from_dotted_str(self.args.items())
|
||||||
|
|
||||||
|
@ -206,6 +206,10 @@ class Invalid(NovaException):
|
|||||||
message = _("Unacceptable parameters.")
|
message = _("Unacceptable parameters.")
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidRequest(Invalid):
|
||||||
|
message = _("The request is invalid.")
|
||||||
|
|
||||||
|
|
||||||
class InvalidSignature(Invalid):
|
class InvalidSignature(Invalid):
|
||||||
message = _("Invalid signature %(signature)s for user %(user)s.")
|
message = _("Invalid signature %(signature)s for user %(user)s.")
|
||||||
|
|
||||||
|
@ -474,3 +474,5 @@ DEFINE_integer('reclaim_instance_interval', 0,
|
|||||||
DEFINE_integer('zombie_instance_updated_at_window', 172800,
|
DEFINE_integer('zombie_instance_updated_at_window', 172800,
|
||||||
'Limit in seconds that a zombie instance can exist before '
|
'Limit in seconds that a zombie instance can exist before '
|
||||||
'being cleaned up.')
|
'being cleaned up.')
|
||||||
|
|
||||||
|
DEFINE_boolean('allow_ec2_admin_api', False, 'Enable/Disable EC2 Admin API')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user