python3 has disable LOG.warn.

python3 has disable LOG.warn.
So replace LOG.warn with LOG.warning

Closes-Bug: #1650457

Change-Id: I532d9faf60a5d6cd84502dc71f9516d6fcad972e
This commit is contained in:
deepakmourya 2017-06-01 10:42:44 +05:30 committed by Zhijiang Hu
parent c42a46cf80
commit 62b51cb975
46 changed files with 1036 additions and 1037 deletions

View File

@ -113,7 +113,7 @@ class API(driver.DeploymentDriver):
discover_host_meta) discover_host_meta)
msg = (_("Do trustme.sh %s failed!" % msg = (_("Do trustme.sh %s failed!" %
discover_host_meta['ip'])) discover_host_meta['ip']))
LOG.warn(_(msg)) LOG.warning(_(msg))
fp.write(msg) fp.write(msg)
elif 'is unreachable' in trustme_result: elif 'is unreachable' in trustme_result:
# when host ip was unreachable # when host ip was unreachable
@ -126,7 +126,7 @@ class API(driver.DeploymentDriver):
discover_host_meta) discover_host_meta)
msg = (_("Do trustme.sh %s failed!" % msg = (_("Do trustme.sh %s failed!" %
discover_host_meta['ip'])) discover_host_meta['ip']))
LOG.warn(_(msg)) LOG.warning(_(msg))
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
update_info = {} update_info = {}
update_info['status'] = 'DISCOVERY_FAILED' update_info['status'] = 'DISCOVERY_FAILED'

View File

@ -1204,7 +1204,7 @@ def upgrade(self, req, cluster_id, version_id, version_patch_id,
target_host_os = _get_host_os_version( target_host_os = _get_host_os_version(
host_ip, host_meta['root_pwd']) host_ip, host_meta['root_pwd'])
if _cmp_os_version(update_file, target_host_os, host_ip) == -1: if _cmp_os_version(update_file, target_host_os, host_ip) == -1:
LOG.warn( LOG.warning(
_("new os version is lower than or equal to " _("new os version is lower than or equal to "
"host %s, don't need to upgrade!" % host_ip)) "host %s, don't need to upgrade!" % host_ip))
host_meta['messages'] = "New os version is lower than" \ host_meta['messages'] = "New os version is lower than" \
@ -1264,7 +1264,7 @@ def upgrade_os(req, version_id, version_patch_id, update_file,
for t in threads: for t in threads:
t.join() t.join()
except: except:
LOG.warn(_("Join upgrade thread %s failed!" % t)) LOG.warning(_("Join upgrade thread %s failed!" % t))
else: else:
for host_info in upgrade_hosts: for host_info in upgrade_hosts:
host = host_info.values()[0] host = host_info.values()[0]

View File

@ -51,7 +51,7 @@ class BaseContextMiddleware(wsgi.Middleware):
try: try:
request_id = resp.request.context.request_id request_id = resp.request.context.request_id
except AttributeError: except AttributeError:
LOG.warn(_('Unable to retrieve request id from context')) LOG.warning(_('Unable to retrieve request id from context'))
else: else:
resp.headers['x-openstack-request-id'] = 'req-%s' % request_id resp.headers['x-openstack-request-id'] = 'req-%s' % request_id
return resp return resp

View File

@ -594,14 +594,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find cluster to delete: %s") % msg = (_("Failed to find cluster to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete cluster: %s") % msg = (_("Forbidden to delete cluster: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -609,7 +609,7 @@ class Controller(controller.BaseController):
msg = (_("cluster %(id)s could not be deleted because " msg = (_("cluster %(id)s could not be deleted because "
"it is in use: " "it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -715,26 +715,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update cluster metadata. Got error: %s") % msg = (_("Failed to update cluster metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find cluster to update: %s") % msg = (_("Failed to find cluster to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update cluster: %s") % msg = (_("Forbidden to update cluster: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('Cluster operation conflicts'), raise HTTPConflict(body=_('Cluster operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -156,14 +156,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find component to delete: %s") % msg = (_("Failed to find component to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete component: %s") % msg = (_("Forbidden to delete component: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -171,7 +171,7 @@ class Controller(controller.BaseController):
msg = (_("component %(id)s could not be " msg = (_("component %(id)s could not be "
"deleted because it is in use: " "deleted because it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -246,26 +246,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update component metadata. Got error: %s") % msg = (_("Failed to update component metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find component to update: %s") % msg = (_("Failed to find component to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update component: %s") % msg = (_("Forbidden to update component: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('Host operation conflicts'), raise HTTPConflict(body=_('Host operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -155,14 +155,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find config_file to delete: %s") % msg = (_("Failed to find config_file to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete config_file: %s") % msg = (_("Forbidden to delete config_file: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -170,7 +170,7 @@ class Controller(controller.BaseController):
msg = (_("config_file %(id)s could not be " msg = (_("config_file %(id)s could not be "
"deleted because it is in use: " "deleted because it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -245,26 +245,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update config_file metadata. Got error: %s") % msg = (_("Failed to update config_file metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find config_file to update: %s") % msg = (_("Failed to find config_file to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update config_file: %s") % msg = (_("Forbidden to update config_file: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('config_file operation conflicts'), raise HTTPConflict(body=_('config_file operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -161,12 +161,12 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find config_set to delete: %s") % msg = (_("Failed to find config_set to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
LOG.warn(e) LOG.warning(e)
raise HTTPForbidden(explanation=e, raise HTTPForbidden(explanation=e,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -174,7 +174,7 @@ class Controller(controller.BaseController):
msg = (_("config_set %(id)s could not be " msg = (_("config_set %(id)s could not be "
"deleted because it is in use: " "deleted because it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -249,26 +249,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update config_set metadata. Got error: %s") % msg = (_("Failed to update config_set metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find config_set to update: %s") % msg = (_("Failed to find config_set to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update config_set: %s") % msg = (_("Forbidden to update config_set: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('config_set operation conflicts'), raise HTTPConflict(body=_('config_set operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -227,14 +227,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find config to delete: %s") % msg = (_("Failed to find config to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete config: %s") % msg = (_("Forbidden to delete config: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -242,7 +242,7 @@ class Controller(controller.BaseController):
msg = (_("config %(id)s could not be " msg = (_("config %(id)s could not be "
"deleted because it is in use: " "deleted because it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")

View File

@ -132,7 +132,7 @@ class Controller(controller.BaseController):
% pxe_server_ip % pxe_server_ip
(status, output) = commands.getstatusoutput(if_addr_nic_cmd) (status, output) = commands.getstatusoutput(if_addr_nic_cmd)
if status: if status:
LOG.warn("get_pxe_server_port error %s." % status) LOG.warning("get_pxe_server_port error %s." % status)
return return
return str(output).split(":")[0].split(".")[0] return str(output).split(":")[0].split(".")[0]

View File

@ -365,14 +365,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find service_disk to delete: %s") % msg = (_("Failed to find service_disk to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete service_disk: %s") % msg = (_("Forbidden to delete service_disk: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -380,7 +380,7 @@ class Controller(controller.BaseController):
msg = (_("service_disk %(id)s could not be deleted " msg = (_("service_disk %(id)s could not be deleted "
"because it is in use: " "because it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -398,26 +398,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update role metadata. Got error: %s") % msg = (_("Failed to update role metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find role to update: %s") % msg = (_("Failed to find role to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update role: %s") % msg = (_("Forbidden to update role: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('Host operation conflicts'), raise HTTPConflict(body=_('Host operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')
@ -593,14 +593,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find cinder volume to delete: %s") % msg = (_("Failed to find cinder volume to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete cinder volume: %s") % msg = (_("Forbidden to delete cinder volume: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -608,7 +608,7 @@ class Controller(controller.BaseController):
msg = (_("cindre volume %(id)s could not " msg = (_("cindre volume %(id)s could not "
"be deleted because it is in use: " "be deleted because it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -682,26 +682,26 @@ class Controller(controller.BaseController):
msg = ( msg = (
_("Failed to update cinder_volume metadata. Got error: %s") % _("Failed to update cinder_volume metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find cinder_volume to update: %s") % msg = (_("Failed to find cinder_volume to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update cinder_volume: %s") % msg = (_("Forbidden to update cinder_volume: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('cinder_volume operation conflicts'), raise HTTPConflict(body=_('cinder_volume operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')
@ -838,21 +838,21 @@ class Controller(controller.BaseController):
msg = ( msg = (
_("Failed to update optical_switch metadata. " _("Failed to update optical_switch metadata. "
"Got error: %s") % utils.exception_to_str(e)) "Got error: %s") % utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find optical_switch to update: %s") % msg = (_("Failed to find optical_switch to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update cinder_volume: %s") % msg = (_("Forbidden to update cinder_volume: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -878,14 +878,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find optical switch to delete: %s") % msg = (_("Failed to find optical switch to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete optical switch: %s") % msg = (_("Forbidden to delete optical switch: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")

View File

@ -189,26 +189,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update template metadata. Got error: %s") % msg = (_("Failed to update template metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find host_template to update: %s") % msg = (_("Failed to find host_template to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update host_template: %s") % msg = (_("Forbidden to update host_template: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('host_template operation conflicts'), raise HTTPConflict(body=_('host_template operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -198,7 +198,7 @@ class Controller(controller.BaseController):
ether_nic_names_list: [name1, name2, ...] ether_nic_names_list: [name1, name2, ...]
''' '''
for bond_slaves in bond_slaves_lists: for bond_slaves in bond_slaves_lists:
LOG.warn('bond_slaves: %s' % bond_slaves) LOG.warning('bond_slaves: %s' % bond_slaves)
if len(set(bond_slaves)) != 2: if len(set(bond_slaves)) != 2:
LOG.error('set(bond_slaves: %s' % set(bond_slaves)) LOG.error('set(bond_slaves: %s' % set(bond_slaves))
msg = ( msg = (
@ -889,7 +889,7 @@ class Controller(controller.BaseController):
"The nic name of interface [%s] with same mac," "The nic name of interface [%s] with same mac,"
"please check!" % "please check!" %
",".join(same_mac_list)) ",".join(same_mac_list))
LOG.warn(msg) LOG.warning(msg)
# 1----------------------------------------------------------------- # 1-----------------------------------------------------------------
# if interface with same 'pci', raise exception # if interface with same 'pci', raise exception
@ -1995,7 +1995,7 @@ class Controller(controller.BaseController):
discover_host_meta) discover_host_meta)
msg = (_("Do trustme.sh %s failed!" % msg = (_("Do trustme.sh %s failed!" %
discover_host_meta['ip'])) discover_host_meta['ip']))
LOG.warn(msg) LOG.warning(msg)
fp.write(msg) fp.write(msg)
else: else:
mac_info = re.search(r'"mac": ([^,\n]*)', exc_result) mac_info = re.search(r'"mac": ([^,\n]*)', exc_result)
@ -2112,7 +2112,7 @@ class Controller(controller.BaseController):
for t in threads: for t in threads:
t.join() t.join()
except Exception: except Exception:
LOG.warn(_("Join discover host thread %s failed!" % t)) LOG.warning(_("Join discover host thread %s failed!" % t))
@utils.mutating @utils.mutating
def discover_host(self, req, host_meta): def discover_host(self, req, host_meta):
@ -2154,7 +2154,7 @@ class Controller(controller.BaseController):
:raises HTTPBadRequest if x-host-name is missing :raises HTTPBadRequest if x-host-name is missing
""" """
self._enforce(req, 'add_discover_host') self._enforce(req, 'add_discover_host')
LOG.warn("host_meta: %s" % host_meta) LOG.warning("host_meta: %s" % host_meta)
if not host_meta.get('ip', None): if not host_meta.get('ip', None):
msg = "IP parameter can not be None." msg = "IP parameter can not be None."
LOG.error(msg) LOG.error(msg)
@ -2418,7 +2418,7 @@ class Controller(controller.BaseController):
:raises HTTPBadRequest if x-host-name is missing :raises HTTPBadRequest if x-host-name is missing
""" """
self._enforce(req, 'add_pxe_host') self._enforce(req, 'add_pxe_host')
LOG.warn("host_meta: %s" % host_meta) LOG.warning("host_meta: %s" % host_meta)
if not host_meta.get('mac'): if not host_meta.get('mac'):
msg = "MAC parameter can not be None." msg = "MAC parameter can not be None."
LOG.error(msg) LOG.error(msg)

View File

@ -365,7 +365,7 @@ class Controller(controller.BaseController):
os_install_thread.start() os_install_thread.start()
return {"status": "begin install"} return {"status": "begin install"}
else: else:
LOG.warn(_("the cluster %s is installing" % cluster_id)) LOG.warning(_("the cluster %s is installing" % cluster_id))
return {"status": "Cluster %s is already installing" % cluster_id} return {"status": "Cluster %s is already installing" % cluster_id}
def _get_uninstall_hosts(self, req, install_meta): def _get_uninstall_hosts(self, req, install_meta):

View File

@ -76,11 +76,11 @@ class Controller(controller.BaseController):
# req.context, cluster_id, host_id) # req.context, cluster_id, host_id)
# except exception.NotFound: # except exception.NotFound:
# msg = _("Project with identifier %s not found") % cluster_id # msg = _("Project with identifier %s not found") % cluster_id
# LOG.warn(msg) # LOG.warning(msg)
# raise webob.exc.HTTPNotFound(msg) # raise webob.exc.HTTPNotFound(msg)
# except exception.Forbidden: # except exception.Forbidden:
# msg = _("Unauthorized project access") # msg = _("Unauthorized project access")
# LOG.warn(msg) # LOG.warning(msg)
# raise webob.exc.HTTPForbidden(msg) # raise webob.exc.HTTPForbidden(msg)
# return dict(members=members) # return dict(members=members)

View File

@ -312,7 +312,7 @@ class Controller(controller.BaseController):
msg = ( msg = (
_("When ip range was specified, the CIDR parameter " _("When ip range was specified, the CIDR parameter "
"can not be empty.")) "can not be empty."))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(msg) raise HTTPForbidden(msg)
else: else:
ip_ranges = eval(network_meta['ip_ranges']) ip_ranges = eval(network_meta['ip_ranges'])
@ -325,7 +325,7 @@ class Controller(controller.BaseController):
msg = ( msg = (
_("IP range was not start with 'start:' or " _("IP range was not start with 'start:' or "
"end with 'end:'.")) "end with 'end:'."))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(msg) raise HTTPForbidden(msg)
ip_start = ip_pair['start'] ip_start = ip_pair['start']
ip_end = ip_pair['end'] ip_end = ip_pair['end']
@ -389,14 +389,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find network to delete: %s") % msg = (_("Failed to find network to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete network: %s") % msg = (_("Forbidden to delete network: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -404,7 +404,7 @@ class Controller(controller.BaseController):
msg = (_("Network %(id)s could not be deleted " msg = (_("Network %(id)s could not be deleted "
"because it is in use: " "because it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -604,7 +604,7 @@ class Controller(controller.BaseController):
msg = ( msg = (
_("When ip range was specified, " _("When ip range was specified, "
"the CIDR parameter can not be empty.")) "the CIDR parameter can not be empty."))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(msg) raise HTTPForbidden(msg)
ip_ranges = eval(network_meta['ip_ranges']) ip_ranges = eval(network_meta['ip_ranges'])
if dataplane_type != 'DATAPLANE': if dataplane_type != 'DATAPLANE':
@ -614,7 +614,7 @@ class Controller(controller.BaseController):
msg = ( msg = (
_("IP range was not start with 'start:' or " _("IP range was not start with 'start:' or "
"end with 'end:'.")) "end with 'end:'."))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(msg) raise HTTPForbidden(msg)
ip_start = ip_pair['start'] ip_start = ip_pair['start']
ip_end = ip_pair['end'] ip_end = ip_pair['end']
@ -637,22 +637,22 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update network metadata. Got error: %s") % msg = (_("Failed to update network metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find network to update: %s") % msg = (_("Failed to find network to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
LOG.warn(e) LOG.warning(e)
raise HTTPForbidden(e) raise HTTPForbidden(e)
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('Network operation conflicts'), raise HTTPConflict(body=_('Network operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -193,7 +193,7 @@ class Controller(controller.BaseController):
host_disk_size_m = host_disk_size_m + disk_size_m host_disk_size_m = host_disk_size_m + disk_size_m
host_disk_except_os_disk_lists = host_disk_size_m - os_disk_m - \ host_disk_except_os_disk_lists = host_disk_size_m - os_disk_m - \
swap_size_m - boot_partition_m - redundant_partiton_m swap_size_m - boot_partition_m - redundant_partiton_m
LOG.warn( LOG.warning(
'----start----host_disk_except_os_disk_lists: %s -----end--' % '----start----host_disk_except_os_disk_lists: %s -----end--' %
host_disk_except_os_disk_lists) host_disk_except_os_disk_lists)
return host_disk_except_os_disk_lists return host_disk_except_os_disk_lists
@ -203,7 +203,7 @@ class Controller(controller.BaseController):
paras['db_lv_size'], paras['glance_lv_size'] , paras['disk_size'] paras['db_lv_size'], paras['glance_lv_size'] , paras['disk_size']
''' '''
disk_size = paras.get('disk_size', None) disk_size = paras.get('disk_size', None)
LOG.warn('--------disk_size:----- %s' % disk_size) LOG.warning('--------disk_size:----- %s' % disk_size)
if disk_size: if disk_size:
disk_size_m = int(disk_size) disk_size_m = int(disk_size)
else: else:
@ -337,7 +337,7 @@ class Controller(controller.BaseController):
else: else:
argws['nova_lv_size'] = nova_lv_size argws['nova_lv_size'] = nova_lv_size
argws['disk_size'] = host_disk_db_glance_nova_size['disk_size'] argws['disk_size'] = host_disk_db_glance_nova_size['disk_size']
LOG.warn( LOG.warning(
'--------host(%s) check_host_validity argws:----- %s' % '--------host(%s) check_host_validity argws:----- %s' %
(host_id, argws)) (host_id, argws))
self._check_host_validity(**argws) self._check_host_validity(**argws)
@ -511,8 +511,8 @@ class Controller(controller.BaseController):
host_disk_db_glance_nova_size['nova_lv_size'] = max(nova_lv_size) host_disk_db_glance_nova_size['nova_lv_size'] = max(nova_lv_size)
else: else:
host_disk_db_glance_nova_size['nova_lv_size'] = 0 host_disk_db_glance_nova_size['nova_lv_size'] = 0
LOG.warn('--------host(%s)disk_db_glance_nova_size:----- %s' % LOG.warning('--------host(%s)disk_db_glance_nova_size:----- %s' %
(host_id, host_disk_db_glance_nova_size)) (host_id, host_disk_db_glance_nova_size))
return host_disk_db_glance_nova_size return host_disk_db_glance_nova_size
def check_cluster_role_name_repetition(self, req, role_name, cluster_id): def check_cluster_role_name_repetition(self, req, role_name, cluster_id):
@ -681,21 +681,21 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find role to delete: %s") % msg = (_("Failed to find role to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete role: %s") % msg = (_("Forbidden to delete role: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.InUseByStore as e: except exception.InUseByStore as e:
msg = (_("role %(id)s could not be deleted because it is in use: " msg = (_("role %(id)s could not be deleted because it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -878,26 +878,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update role metadata. Got error: %s") % msg = (_("Failed to update role metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find role to update: %s") % msg = (_("Failed to find role to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update role: %s") % msg = (_("Forbidden to update role: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('Host operation conflicts'), raise HTTPConflict(body=_('Host operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -160,14 +160,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find service to delete: %s") % msg = (_("Failed to find service to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete service: %s") % msg = (_("Forbidden to delete service: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -175,7 +175,7 @@ class Controller(controller.BaseController):
msg = (_("service %(id)s could not be deleted " msg = (_("service %(id)s could not be deleted "
"because it is in use: " "because it is in use: "
"%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -250,26 +250,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update service metadata. Got error: %s") % msg = (_("Failed to update service metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find service to update: %s") % msg = (_("Failed to find service to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update service: %s") % msg = (_("Forbidden to update service: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('Host operation conflicts'), raise HTTPConflict(body=_('Host operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -163,26 +163,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update template metadata. Got error: %s") % msg = (_("Failed to update template metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find template to update: %s") % msg = (_("Failed to find template to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update template: %s") % msg = (_("Forbidden to update template: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('template operation conflicts'), raise HTTPConflict(body=_('template operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -152,14 +152,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find version patch to delete: %s") % msg = (_("Failed to find version patch to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete version patch: %s") % msg = (_("Forbidden to delete version patch: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -167,7 +167,7 @@ class Controller(controller.BaseController):
msg = (_("version patch %(id)s could not be deleted " msg = (_("version patch %(id)s could not be deleted "
"because it is in use: " "%(exc)s") "because it is in use: " "%(exc)s")
% {"id": id, "exc": utils.exception_to_str(e)}) % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -255,26 +255,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update version patch. Got error: %s") msg = (_("Failed to update version patch. Got error: %s")
% utils.exception_to_str(e)) % utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find version patch to update: %s") % msg = (_("Failed to find version patch to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update version patch: %s") % msg = (_("Forbidden to update version patch: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('Host operation conflicts'), raise HTTPConflict(body=_('Host operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -152,14 +152,14 @@ class Controller(controller.BaseController):
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find version to delete: %s") % msg = (_("Failed to find version to delete: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to delete role: %s") % msg = (_("Forbidden to delete role: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -168,7 +168,7 @@ class Controller(controller.BaseController):
_("version %(id)s could not be deleted because " _("version %(id)s could not be deleted because "
"it is in use: " "%(exc)s") "it is in use: " "%(exc)s")
% {"id": id, "exc": utils.exception_to_str(e)}) % {"id": id, "exc": utils.exception_to_str(e)})
LOG.warn(msg) LOG.warning(msg)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
@ -241,26 +241,26 @@ class Controller(controller.BaseController):
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update version metadata. Got error: %s") % msg = (_("Failed to update version metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPBadRequest(explanation=msg, raise HTTPBadRequest(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.NotFound as e: except exception.NotFound as e:
msg = (_("Failed to find version to update: %s") % msg = (_("Failed to find version to update: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPNotFound(explanation=msg, raise HTTPNotFound(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except exception.Forbidden as e: except exception.Forbidden as e:
msg = (_("Forbidden to update version: %s") % msg = (_("Forbidden to update version: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.warn(msg) LOG.warning(msg)
raise HTTPForbidden(explanation=msg, raise HTTPForbidden(explanation=msg,
request=req, request=req,
content_type="text/plain") content_type="text/plain")
except (exception.Conflict, exception.Duplicate) as e: except (exception.Conflict, exception.Duplicate) as e:
LOG.warn(utils.exception_to_str(e)) LOG.warning(utils.exception_to_str(e))
raise HTTPConflict(body=_('Host operation conflicts'), raise HTTPConflict(body=_('Host operation conflicts'),
request=req, request=req,
content_type='text/plain') content_type='text/plain')

View File

@ -278,7 +278,7 @@ def get_endpoint(service_catalog, service_type='image', endpoint_region=None,
s_type = service['type'] s_type = service['type']
except KeyError: except KeyError:
msg = _('Encountered service with no "type": %s') % s_type msg = _('Encountered service with no "type": %s') % s_type
LOG.warn(msg) LOG.warning(msg)
continue continue
if s_type == service_type: if s_type == service_type:

View File

@ -660,13 +660,13 @@ def validate_key_cert(key_file, cert_file):
data = str(uuid.uuid4()) data = str(uuid.uuid4())
digest = CONF.digest_algorithm digest = CONF.digest_algorithm
if digest == 'sha1': if digest == 'sha1':
LOG.warn('The FIPS (FEDERAL INFORMATION PROCESSING STANDARDS)' LOG.warning('The FIPS (FEDERAL INFORMATION PROCESSING STANDARDS)'
' state that the SHA-1 is not suitable for' ' state that the SHA-1 is not suitable for'
' general-purpose digital signature applications (as' ' general-purpose digital signature applications (as'
' specified in FIPS 186-3) that require 112 bits of' ' specified in FIPS 186-3) that require 112 bits of'
' security. The default value is sha1 in Kilo for a' ' security. The default value is sha1 in Kilo for a'
' smooth upgrade process, and it will be updated' ' smooth upgrade process, and it will be updated'
' with sha256 in next release(L).') ' with sha256 in next release(L).')
out = crypto.sign(key, data, digest) out = crypto.sign(key, data, digest)
crypto.verify(cert, out, data, digest) crypto.verify(cert, out, data, digest)
except crypto.Error as ce: except crypto.Error as ce:
@ -888,12 +888,12 @@ def valid_cidr(cidr):
try: try:
netmask_cidr = int(cidr_division[1]) netmask_cidr = int(cidr_division[1])
except ValueError: except ValueError:
LOG.warn(netmask_err_msg) LOG.warning(netmask_err_msg)
raise exc.HTTPBadRequest(explanation=netmask_err_msg) raise exc.HTTPBadRequest(explanation=netmask_err_msg)
if (netmask_cidr < 0 and if (netmask_cidr < 0 and
netmask_cidr > 32): netmask_cidr > 32):
LOG.warn(netmask_err_msg) LOG.warning(netmask_err_msg)
raise exc.HTTPBadRequest(explanation=netmask_err_msg) raise exc.HTTPBadRequest(explanation=netmask_err_msg)
validate_ip_format(cidr_division[0]) validate_ip_format(cidr_division[0])

View File

@ -315,7 +315,7 @@ class Server(object):
self.stale_children.remove(pid) self.stale_children.remove(pid)
LOG.info(_LI('Removed stale child %s') % pid) LOG.info(_LI('Removed stale child %s') % pid)
else: else:
LOG.warn(_LW('Unrecognised child %s') % pid) LOG.warning(_LW('Unrecognised child %s') % pid)
def _verify_and_respawn_children(self, pid, status): def _verify_and_respawn_children(self, pid, status):
if len(self.stale_children) == 0: if len(self.stale_children) == 0:

View File

@ -72,7 +72,7 @@ def _retry_on_deadlock(exc):
"""Decorator to retry a DB API call if Deadlock was received.""" """Decorator to retry a DB API call if Deadlock was received."""
if isinstance(exc, db_exception.DBDeadlock): if isinstance(exc, db_exception.DBDeadlock):
LOG.warn(_LW("Deadlock detected. Retrying...")) LOG.warning(_LW("Deadlock detected. Retrying..."))
return True return True
return False return False
@ -352,7 +352,7 @@ def check_ip_ranges(ip_ranges_one,available_ip_list):
if inter_tmp > ip_ranges_end_inter: if inter_tmp > ip_ranges_end_inter:
msg = "warning:The IP address assigned \ msg = "warning:The IP address assigned \
by IP ranges is already insufficient." by IP ranges is already insufficient."
LOG.warn(msg) LOG.warning(msg)
break break
else: else:
return [True, ip_tmp] return [True, ip_tmp]
@ -3193,7 +3193,7 @@ def _paginate_query(query, model, limit, sort_keys, marker=None,
if 'id' not in sort_keys: if 'id' not in sort_keys:
# TODO(justinsb): If this ever gives a false-positive, check # TODO(justinsb): If this ever gives a false-positive, check
# the actual primary key, rather than assuming its id # the actual primary key, rather than assuming its id
LOG.warn(_LW('Id not in sort_keys; is sort_keys unique?')) LOG.warning(_LW('Id not in sort_keys; is sort_keys unique?'))
assert(not (sort_dir and sort_dirs)) assert(not (sort_dir and sort_dirs))

View File

@ -49,11 +49,11 @@ class OrchestrationManager():
host_list = [host for host in host_list_generator if hasattr( host_list = [host for host in host_list_generator if hasattr(
host, "role_status") and host.role_status == "active"] host, "role_status") and host.role_status == "active"]
if not host_list: if not host_list:
LOG.warn("No installed active node in cluster") LOG.warning("No installed active node in cluster")
host_list = [host for host in host_list host_list = [host for host in host_list
if host.discover_mode == "PXE"] if host.discover_mode == "PXE"]
if not host_list: if not host_list:
LOG.warn("No pxe discover successful node in cluster") LOG.warning("No pxe discover successful node in cluster")
for host in host_list: for host in host_list:
host_info = daisy_client.hosts.get(host.id) host_info = daisy_client.hosts.get(host.id)
if hasattr(host_info, "role") and ["COMPUTER"] == host_info.role \ if hasattr(host_info, "role") and ["COMPUTER"] == host_info.role \
@ -97,7 +97,7 @@ class OrchestrationManager():
host_info.virtio_queue_size = active_compute_host.virtio_queue_size host_info.virtio_queue_size = active_compute_host.virtio_queue_size
host_info.dvs_config_type = active_compute_host.dvs_config_type host_info.dvs_config_type = active_compute_host.dvs_config_type
else: else:
LOG.warn("No installed active computer node in cluster") LOG.warning("No installed active computer node in cluster")
return None return None
if active_compute_host: if active_compute_host:
@ -144,19 +144,19 @@ class OrchestrationManager():
if new_interface_count != compute_interface_count: if new_interface_count != compute_interface_count:
msg = "%s and new host interface number are different" %\ msg = "%s and new host interface number are different" %\
(compute_host.name) (compute_host.name)
LOG.warn(msg) LOG.warning(msg)
continue continue
if host_info.cpu['total'] != compute_host.cpu['total']: if host_info.cpu['total'] != compute_host.cpu['total']:
msg = "%s and new host cpu total numbers are different" %\ msg = "%s and new host cpu total numbers are different" %\
(compute_host.name) (compute_host.name)
LOG.warn(msg) LOG.warning(msg)
continue continue
compute_numa_cpus = utils.get_numa_node_cpus( compute_numa_cpus = utils.get_numa_node_cpus(
(compute_host.cpu or {})) (compute_host.cpu or {}))
if compute_numa_cpus != host_numa_cpus: if compute_numa_cpus != host_numa_cpus:
msg = "%s and new host numa cpus are different" %\ msg = "%s and new host numa cpus are different" %\
compute_host.name compute_host.name
LOG.warn(msg) LOG.warning(msg)
continue continue
active_compu_memory_str = str(compute_host.memory['total']) active_compu_memory_str = str(compute_host.memory['total'])
active_compu_memory_size =\ active_compu_memory_size =\
@ -164,7 +164,7 @@ class OrchestrationManager():
# host memory can't be lower than the installed host memory size-1G # host memory can't be lower than the installed host memory size-1G
if memory_size_b_int < active_compu_memory_size - 1024 * 1024: if memory_size_b_int < active_compu_memory_size - 1024 * 1024:
msg = "new host memory is lower than %s" % compute_host.name msg = "new host memory is lower than %s" % compute_host.name
LOG.warn(msg) LOG.warning(msg)
continue continue
is_isomorphic = self._check_interface_isomorphic( is_isomorphic = self._check_interface_isomorphic(
new_interfaces, compute_host) new_interfaces, compute_host)
@ -190,13 +190,13 @@ class OrchestrationManager():
and (interface['max_speed'] != max_speed): and (interface['max_speed'] != max_speed):
msg = "%s and new host %s max speed are different" \ msg = "%s and new host %s max speed are different" \
% (active_host.name, interface['name']) % (active_host.name, interface['name'])
LOG.warn(msg) LOG.warning(msg)
return False return False
elif (interface['name'] == compute_interface['name']) and\ elif (interface['name'] == compute_interface['name']) and\
(interface['pci'] != compute_interface['pci']): (interface['pci'] != compute_interface['pci']):
msg = "%s and new host %s pci are different" \ msg = "%s and new host %s pci are different" \
% (active_host.name, interface['name']) % (active_host.name, interface['name'])
LOG.warn(msg) LOG.warning(msg)
return False return False
if not is_isomorphic: if not is_isomorphic:
return False return False

View File

@ -62,13 +62,13 @@ class Controller(object):
return self.db_api.config_file_get_all(context, filters=filters, return self.db_api.config_file_get_all(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Config_file %(id)s could not be " LOG.warning(_LW("Invalid marker. Config_file %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Config_file could not be found.") msg = _("Invalid marker. Config_file could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to config_file %(id)s but returning " LOG.warning(_LW("Access denied to config_file %(id)s but returned "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. config_file could not be found.") msg = _("Invalid marker. config_file could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -251,7 +251,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = _("config_file with identifier %s already exists!") % \ msg = _("config_file with identifier %s already exists!") % \
config_file_id config_file_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add config_file metadata. " msg = (_("Failed to add config_file metadata. "

View File

@ -62,13 +62,13 @@ class Controller(object):
return self.db_api.config_set_get_all(context, filters=filters, return self.db_api.config_set_get_all(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Config_set %(id)s could not be " LOG.warning(_LW("Invalid marker. Config_set %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Config_set could not be found.") msg = _("Invalid marker. Config_set could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to config_set %(id)s but returning " LOG.warning(_LW("Access denied to config_set %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. config_set could not be found.") msg = _("Invalid marker. config_set could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -251,7 +251,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = _("config_set with identifier %s already exists!") % \ msg = _("config_set with identifier %s already exists!") % \
config_set_id config_set_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add config_set metadata. " msg = (_("Failed to add config_set metadata. "

View File

@ -62,13 +62,13 @@ class Controller(object):
return self.db_api.config_get_all(context, filters=filters, return self.db_api.config_get_all(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Config %(id)s could not be " LOG.warning(_LW("Invalid marker. Config %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Config could not be found.") msg = _("Invalid marker. Config could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to config %(id)s but returning " LOG.warning(_LW("Access denied to config %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. config could not be found.") msg = _("Invalid marker. config could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -248,7 +248,7 @@ class Controller(object):
return config_data return config_data
except exception.Duplicate: except exception.Duplicate:
msg = _("config with identifier %s already exists!") % config_id msg = _("config with identifier %s already exists!") % config_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add config metadata. " msg = (_("Failed to add config metadata. "

View File

@ -233,7 +233,7 @@ class Controller(object):
return service_disk_data return service_disk_data
except exception.Duplicate: except exception.Duplicate:
msg = _("node with identifier %s already exists!") % id msg = _("node with identifier %s already exists!") % id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add node metadata. " msg = (_("Failed to add node metadata. "
@ -359,13 +359,13 @@ class Controller(object):
return self.db_api.service_disk_list(context, filters=filters, return self.db_api.service_disk_list(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. service_disk %(id)s could not be " LOG.warning(_LW("Invalid marker. service_disk %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. service_disk could not be found.") msg = _("Invalid marker. service_disk could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to service_disk %(id)s but returning " LOG.warning(_LW("Access denied service_disk %(id)s but returned "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. service_disk could not be found.") msg = _("Invalid marker. service_disk could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -431,7 +431,7 @@ class Controller(object):
return cinder_volume_data return cinder_volume_data
except exception.Duplicate: except exception.Duplicate:
msg = _("cinder_volume with identifier %s already exists!") % id msg = _("cinder_volume with identifier %s already exists!") % id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add cinder_volume metadata. " msg = (_("Failed to add cinder_volume metadata. "
@ -565,13 +565,13 @@ class Controller(object):
return self.db_api.cinder_volume_list(context, filters=filters, return self.db_api.cinder_volume_list(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. cinder_volume %(id)s could not be " LOG.warning(_LW("Invalid marker.cinder_volume %(id)s not "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. cinder_volume could not be found.") msg = _("Invalid marker. cinder_volume could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to cinder_volume %(id)s but returning " LOG.warning(_LW("Access denied cinder_volume %(id)s but returned "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. cinder_volume could not be found.") msg = _("Invalid marker. cinder_volume could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -584,16 +584,16 @@ class Controller(object):
return self.db_api.optical_switch_list(context, filters=filters, return self.db_api.optical_switch_list(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. optical switch %(id)s " LOG.warning(_LW("Invalid marker. optical switch %(id)s "
"could not be found.") % "could not be found.") %
{'id': params.get('marker')}) {'id': params.get('marker')})
msg = _("Invalid marker. optical switch " msg = _("Invalid marker. optical switch "
"could not be found.") "could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to optical_switch %(id)s " LOG.warning(_LW("Access denied to optical_switch %(id)s "
"but returning 'not found'") % "but returning 'not found'") %
{'id': params.get('marker')}) {'id': params.get('marker')})
msg = _("Invalid marker. optical_switch " msg = _("Invalid marker. optical_switch "
"could not be found.") "could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)

View File

@ -70,13 +70,13 @@ class Controller(object):
return self.db_api.host_get_all(context, filters=filters, return self.db_api.host_get_all(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Host %(id)s could not be " LOG.warning(_LW("Invalid marker. Host %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Host could not be found.") msg = _("Invalid marker. Host could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to host %(id)s but returning " LOG.warning(_LW("Access denied to host %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. Host could not be found.") msg = _("Invalid marker. Host could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -89,13 +89,13 @@ class Controller(object):
return self.db_api.cluster_get_all(context, filters=filters, return self.db_api.cluster_get_all(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Cluster %(id)s could not be " LOG.warning(_LW("Invalid marker. Cluster %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Cluster could not be found.") msg = _("Invalid marker. Cluster could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to cluster %(id)s but returning " LOG.warning(_LW("Access denied to cluster %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. Cluster could not be found.") msg = _("Invalid marker. Cluster could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -307,7 +307,7 @@ class Controller(object):
return host_data return host_data
except exception.Duplicate: except exception.Duplicate:
msg = _("node with identifier %s already exists!") % host_id msg = _("node with identifier %s already exists!") % host_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add node metadata. " msg = (_("Failed to add node metadata. "
@ -514,13 +514,13 @@ class Controller(object):
req.context, filters) req.context, filters)
return host_interfaces return host_interfaces
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. template %(id)s could not be " LOG.warning(_LW("Invalid marker. template %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. template could not be found.") msg = _("Invalid marker. template could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to template %(id)s but returning " LOG.warning(_LW("Access denied to template %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. template could not be found.") msg = _("Invalid marker. template could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -535,16 +535,16 @@ class Controller(object):
req.context, req.context,
interface_id, network_id) interface_id, network_id)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Assigned_network with interface %(" LOG.warning(_LW("Invalid marker.Assigned_network with if %("
"interface_id)s and network %(network_id)s" "interface_id)s and network %(network_id)s"
" could not be found.") % { " could not be found.") % {
'interface_id': interface_id, 'network_id': network_id}) 'interface_id': interface_id, 'network_id': network_id})
msg = _("Invalid marker. Assigned_network could not be found.") msg = _("Invalid marker. Assigned_network could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied for assigned_network with interface %(" LOG.warning(_LW("Access denied for assigned_network with if %("
"interface_id)s " "interface_id)s "
"and network %(network_id)s") % { "and network %(network_id)s") % {
'interface_id': interface_id, 'network_id': network_id}) 'interface_id': interface_id, 'network_id': network_id})
msg = _("Invalid marker. Assigned_network denied to get.") msg = _("Invalid marker. Assigned_network denied to get.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
@ -592,7 +592,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = _("node with identifier %s already exists!") % \ msg = _("node with identifier %s already exists!") % \
discover_host_id discover_host_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add node metadata. " msg = (_("Failed to add node metadata. "
@ -646,13 +646,13 @@ class Controller(object):
nodes = self.db_api.discover_host_get_all(req.context, nodes = self.db_api.discover_host_get_all(req.context,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Host %(id)s could not be " LOG.warning(_LW("Invalid marker. Host %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Host could not be found.") msg = _("Invalid marker. Host could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to host %(id)s but returning " LOG.warning(_LW("Access denied to host %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. Host could not be found.") msg = _("Invalid marker. Host could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -787,7 +787,7 @@ class Controller(object):
return cluster_data return cluster_data
except exception.Duplicate: except exception.Duplicate:
msg = _("cluster with identifier %s already exists!") % cluster_id msg = _("cluster with identifier %s already exists!") % cluster_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add cluster metadata. " msg = (_("Failed to add cluster metadata. "
@ -974,7 +974,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = (_("component with identifier %s already exists!") msg = (_("component with identifier %s already exists!")
% component_id) % component_id)
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add component metadata. " msg = (_("Failed to add component metadata. "
@ -1025,13 +1025,13 @@ class Controller(object):
return self.db_api.component_get_all(context, filters=filters, return self.db_api.component_get_all(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Project %(id)s could not be " LOG.warning(_LW("Invalid marker. Project %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Project could not be found.") msg = _("Invalid marker. Project could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to component %(id)s but returning " LOG.warning(_LW("Access denied to component %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. Project could not be found.") msg = _("Invalid marker. Project could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -1168,7 +1168,7 @@ class Controller(object):
return service_data return service_data
except exception.Duplicate: except exception.Duplicate:
msg = _("service with identifier %s already exists!") % service_id msg = _("service with identifier %s already exists!") % service_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add service metadata. " msg = (_("Failed to add service metadata. "
@ -1219,13 +1219,13 @@ class Controller(object):
return self.db_api.service_get_all(context, filters=filters, return self.db_api.service_get_all(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Project %(id)s could not be " LOG.warning(_LW("Invalid marker. Project %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Project could not be found.") msg = _("Invalid marker. Project could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to service %(id)s but returning " LOG.warning(_LW("Access denied to service %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. Project could not be found.") msg = _("Invalid marker. Project could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -1362,7 +1362,7 @@ class Controller(object):
return role_data return role_data
except exception.Duplicate: except exception.Duplicate:
msg = _("role with identifier %s already exists!") % role_id msg = _("role with identifier %s already exists!") % role_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add role metadata. " msg = (_("Failed to add role metadata. "
@ -1413,13 +1413,13 @@ class Controller(object):
return self.db_api.role_get_all(context, filters=filters, return self.db_api.role_get_all(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Project %(id)s could not be " LOG.warning(_LW("Invalid marker. Project %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Project could not be found.") msg = _("Invalid marker. Project could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to role %(id)s but returning " LOG.warning(_LW("Access denied to role %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. Project could not be found.") msg = _("Invalid marker. Project could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:

View File

@ -1,355 +1,355 @@
# Copyright 2010-2011 OpenStack Foundation # Copyright 2010-2011 OpenStack Foundation
# All Rights Reserved. # All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # 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 # not use this file except in compliance with the License. You may obtain
# a copy of the License at # a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
""" """
Reference implementation registry server WSGI controller Reference implementation registry server WSGI controller
""" """
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import strutils from oslo_utils import strutils
from oslo_utils import timeutils from oslo_utils import timeutils
from webob import exc from webob import exc
from daisy.common import exception from daisy.common import exception
from daisy.common import utils from daisy.common import utils
from daisy.common import wsgi from daisy.common import wsgi
import daisy.db import daisy.db
from daisy import i18n from daisy import i18n
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_ = i18n._ _ = i18n._
_LE = i18n._LE _LE = i18n._LE
_LI = i18n._LI _LI = i18n._LI
_LW = i18n._LW _LW = i18n._LW
CONF = cfg.CONF CONF = cfg.CONF
DISPLAY_FIELDS_IN_INDEX = ['id', 'description'] DISPLAY_FIELDS_IN_INDEX = ['id', 'description']
SUPPORTED_FILTERS = ['name', 'description'] SUPPORTED_FILTERS = ['name', 'description']
SUPPORTED_SORT_KEYS = ('name', 'description''id', 'created_at', 'updated_at') SUPPORTED_SORT_KEYS = ('name', 'description''id', 'created_at', 'updated_at')
SUPPORTED_SORT_DIRS = ('asc', 'desc') SUPPORTED_SORT_DIRS = ('asc', 'desc')
SUPPORTED_PARAMS = ('limit', 'marker', 'sort_key', 'sort_dir', 'name', SUPPORTED_PARAMS = ('limit', 'marker', 'sort_key', 'sort_dir', 'name',
'description') 'description')
class Controller(object): class Controller(object):
def __init__(self): def __init__(self):
self.db_api = daisy.db.get_api() self.db_api = daisy.db.get_api()
def _get_query_params(self, req): def _get_query_params(self, req):
"""Extract necessary query parameters from http request. """Extract necessary query parameters from http request.
:param req: the Request object coming from the wsgi layer :param req: the Request object coming from the wsgi layer
:retval dictionary of filters to apply to list of templates :retval dictionary of filters to apply to list of templates
""" """
params = { params = {
'filters': self._get_filters(req), 'filters': self._get_filters(req),
'limit': self._get_limit(req), 'limit': self._get_limit(req),
'sort_key': [self._get_sort_key(req)], 'sort_key': [self._get_sort_key(req)],
'sort_dir': [self._get_sort_dir(req)], 'sort_dir': [self._get_sort_dir(req)],
'marker': self._get_marker(req), 'marker': self._get_marker(req),
} }
for key, value in params.items(): for key, value in params.items():
if value is None: if value is None:
del params[key] del params[key]
return params return params
def _get_filters(self, req): def _get_filters(self, req):
"""Return a dictionary of query param filters from the request """Return a dictionary of query param filters from the request
:param req: the Request object coming from the wsgi layer :param req: the Request object coming from the wsgi layer
:retval a dict of key/value filters :retval a dict of key/value filters
""" """
filters = {} filters = {}
properties = {} properties = {}
for param in req.params: for param in req.params:
if param in SUPPORTED_FILTERS: if param in SUPPORTED_FILTERS:
filters[param] = req.params.get(param) filters[param] = req.params.get(param)
if param.startswith('property-'): if param.startswith('property-'):
_param = param[9:] _param = param[9:]
properties[_param] = req.params.get(param) properties[_param] = req.params.get(param)
if 'changes-since' in filters: if 'changes-since' in filters:
isotime = filters['changes-since'] isotime = filters['changes-since']
try: try:
filters['changes-since'] = timeutils.parse_isotime(isotime) filters['changes-since'] = timeutils.parse_isotime(isotime)
except ValueError: except ValueError:
raise exc.HTTPBadRequest(_("Unrecognized changes-since value")) raise exc.HTTPBadRequest(_("Unrecognized changes-since value"))
if 'protected' in filters: if 'protected' in filters:
value = self._get_bool(filters['protected']) value = self._get_bool(filters['protected'])
if value is None: if value is None:
raise exc.HTTPBadRequest(_("protected must be True, or " raise exc.HTTPBadRequest(_("protected must be True, or "
"False")) "False"))
filters['protected'] = value filters['protected'] = value
# only allow admins to filter on 'deleted' # only allow admins to filter on 'deleted'
if req.context.is_admin: if req.context.is_admin:
deleted_filter = self._parse_deleted_filter(req) deleted_filter = self._parse_deleted_filter(req)
if deleted_filter is not None: if deleted_filter is not None:
filters['deleted'] = deleted_filter filters['deleted'] = deleted_filter
elif 'changes-since' not in filters: elif 'changes-since' not in filters:
filters['deleted'] = False filters['deleted'] = False
elif 'changes-since' not in filters: elif 'changes-since' not in filters:
filters['deleted'] = False filters['deleted'] = False
if properties: if properties:
filters['properties'] = properties filters['properties'] = properties
return filters return filters
def _get_limit(self, req): def _get_limit(self, req):
"""Parse a limit query param into something usable.""" """Parse a limit query param into something usable."""
try: try:
limit = int(req.params.get('limit', CONF.limit_param_default)) limit = int(req.params.get('limit', CONF.limit_param_default))
except ValueError: except ValueError:
raise exc.HTTPBadRequest(_("limit param must be an integer")) raise exc.HTTPBadRequest(_("limit param must be an integer"))
if limit < 0: if limit < 0:
raise exc.HTTPBadRequest(_("limit param must be positive")) raise exc.HTTPBadRequest(_("limit param must be positive"))
return min(CONF.api_limit_max, limit) return min(CONF.api_limit_max, limit)
def _get_marker(self, req): def _get_marker(self, req):
"""Parse a marker query param into something usable.""" """Parse a marker query param into something usable."""
marker = req.params.get('marker', None) marker = req.params.get('marker', None)
if marker and not utils.is_uuid_like(marker): if marker and not utils.is_uuid_like(marker):
msg = _('Invalid marker format') msg = _('Invalid marker format')
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
return marker return marker
def _get_sort_key(self, req): def _get_sort_key(self, req):
"""Parse a sort key query param from the request object.""" """Parse a sort key query param from the request object."""
sort_key = req.params.get('sort_key', 'created_at') sort_key = req.params.get('sort_key', 'created_at')
if sort_key is not None and sort_key not in SUPPORTED_SORT_KEYS: if sort_key is not None and sort_key not in SUPPORTED_SORT_KEYS:
_keys = ', '.join(SUPPORTED_SORT_KEYS) _keys = ', '.join(SUPPORTED_SORT_KEYS)
msg = _("Unsupported sort_key. Acceptable values: %s") % (_keys,) msg = _("Unsupported sort_key. Acceptable values: %s") % (_keys,)
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
return sort_key return sort_key
def _get_sort_dir(self, req): def _get_sort_dir(self, req):
"""Parse a sort direction query param from the request object.""" """Parse a sort direction query param from the request object."""
sort_dir = req.params.get('sort_dir', 'desc') sort_dir = req.params.get('sort_dir', 'desc')
if sort_dir is not None and sort_dir not in SUPPORTED_SORT_DIRS: if sort_dir is not None and sort_dir not in SUPPORTED_SORT_DIRS:
_keys = ', '.join(SUPPORTED_SORT_DIRS) _keys = ', '.join(SUPPORTED_SORT_DIRS)
msg = _("Unsupported sort_dir. Acceptable values: %s") % (_keys,) msg = _("Unsupported sort_dir. Acceptable values: %s") % (_keys,)
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
return sort_dir return sort_dir
def _get_bool(self, value): def _get_bool(self, value):
value = value.lower() value = value.lower()
if value == 'true' or value == '1': if value == 'true' or value == '1':
return True return True
elif value == 'false' or value == '0': elif value == 'false' or value == '0':
return False return False
return None return None
def _parse_deleted_filter(self, req): def _parse_deleted_filter(self, req):
"""Parse deleted into something usable.""" """Parse deleted into something usable."""
deleted = req.params.get('deleted') deleted = req.params.get('deleted')
if deleted is None: if deleted is None:
return None return None
return strutils.bool_from_string(deleted) return strutils.bool_from_string(deleted)
@utils.mutating @utils.mutating
def add_hwm(self, req, body): def add_hwm(self, req, body):
"""Registers a new hwm with the registry. """Registers a new hwm with the registry.
:param req: wsgi Request object :param req: wsgi Request object
:param body: Dictionary of information about the templatae :param body: Dictionary of information about the templatae
:retval Returns the newly-created template information as a mapping, :retval Returns the newly-created template information as a mapping,
which will include the newly-created template's internal id which will include the newly-created template's internal id
in the 'id' field in the 'id' field
""" """
hwm_data = body["hwm"] hwm_data = body["hwm"]
id = hwm_data.get('id') id = hwm_data.get('id')
if id and not utils.is_uuid_like(id): if id and not utils.is_uuid_like(id):
msg = _LI("Rejecting hwm creation request for invalid hwm " msg = _LI("Rejecting hwm creation request for invalid hwm "
"id '%(bad_id)s'") % {'bad_id': id} "id '%(bad_id)s'") % {'bad_id': id}
LOG.info(msg) LOG.info(msg)
msg = _("Invalid hwm id format") msg = _("Invalid hwm id format")
return exc.HTTPBadRequest(explanation=msg) return exc.HTTPBadRequest(explanation=msg)
try: try:
hwm_data = self.db_api.hwm_add(req.context, hwm_data) hwm_data = self.db_api.hwm_add(req.context, hwm_data)
msg = (_LI("Successfully created hwm %s") % msg = (_LI("Successfully created hwm %s") %
hwm_data["id"]) hwm_data["id"])
LOG.info(msg) LOG.info(msg)
if 'hwm' not in hwm_data: if 'hwm' not in hwm_data:
hwm_data = dict(hwm=hwm_data) hwm_data = dict(hwm=hwm_data)
return hwm_data return hwm_data
except exception.Duplicate: except exception.Duplicate:
msg = _("hwm with identifier %s already exists!") % id msg = _("hwm with identifier %s already exists!") % id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add hwm metadata. " msg = (_("Failed to add hwm metadata. "
"Got error: %s") % utils.exception_to_str(e)) "Got error: %s") % utils.exception_to_str(e))
LOG.error(msg) LOG.error(msg)
return exc.HTTPBadRequest(msg) return exc.HTTPBadRequest(msg)
except Exception: except Exception:
LOG.exception(_LE("Unable to create hwm %s"), id) LOG.exception(_LE("Unable to create hwm %s"), id)
raise raise
@utils.mutating @utils.mutating
def update_hwm(self, req, id, body): def update_hwm(self, req, id, body):
"""Registers a new hwm with the registry. """Registers a new hwm with the registry.
:param req: wsgi Request object :param req: wsgi Request object
:param body: Dictionary of information about the template :param body: Dictionary of information about the template
:retval Returns the newly-created template information as a mapping, :retval Returns the newly-created template information as a mapping,
which will include the newly-created template's internal id which will include the newly-created template's internal id
in the 'id' field in the 'id' field
""" """
hwm_data = body["hwm"] hwm_data = body["hwm"]
if id and not utils.is_uuid_like(id): if id and not utils.is_uuid_like(id):
msg = _LI("Rejecting cluster hwm creation request for invalid " msg = _LI("Rejecting cluster hwm creation request for invalid "
"hwm id '%(bad_id)s'") % {'bad_id': id} "hwm id '%(bad_id)s'") % {'bad_id': id}
LOG.info(msg) LOG.info(msg)
msg = _("Invalid hwm id format") msg = _("Invalid hwm id format")
return exc.HTTPBadRequest(explanation=msg) return exc.HTTPBadRequest(explanation=msg)
try: try:
hwm_data = self.db_api.hwm_update(req.context, id, hwm_data) hwm_data = self.db_api.hwm_update(req.context, id, hwm_data)
msg = (_LI("Successfully updated hwm %s") % msg = (_LI("Successfully updated hwm %s") %
hwm_data["id"]) hwm_data["id"])
LOG.info(msg) LOG.info(msg)
if 'hwm' not in hwm_data: if 'hwm' not in hwm_data:
hwm_data = dict(hwm=hwm_data) hwm_data = dict(hwm=hwm_data)
return hwm_data return hwm_data
except exception.Duplicate: except exception.Duplicate:
msg = _("hwm with identifier %s already exists!") % id msg = _("hwm with identifier %s already exists!") % id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update hwm metadata.Got error: %s") % msg = (_("Failed to update hwm metadata.Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.error(msg) LOG.error(msg)
return exc.HTTPBadRequest(msg) return exc.HTTPBadRequest(msg)
except Exception: except Exception:
LOG.exception(_LE("Unable to update hwm %s"), id) LOG.exception(_LE("Unable to update hwm %s"), id)
raise raise
@utils.mutating @utils.mutating
def delete_hwm(self, req, id): def delete_hwm(self, req, id):
"""Registers a new hwm with the registry. """Registers a new hwm with the registry.
:param req: wsgi Request object :param req: wsgi Request object
:param body: Dictionary of information about the template :param body: Dictionary of information about the template
:retval Returns the newly-created template information as a mapping, :retval Returns the newly-created template information as a mapping,
which will include the newly-created template's internal id which will include the newly-created template's internal id
in the 'id' field in the 'id' field
""" """
if id and not utils.is_uuid_like(id): if id and not utils.is_uuid_like(id):
msg = _LI("Rejecting hwm delete request for invalid hwm " msg = _LI("Rejecting hwm delete request for invalid hwm "
"id '%(bad_id)s'") % {'bad_id': id} "id '%(bad_id)s'") % {'bad_id': id}
LOG.info(msg) LOG.info(msg)
msg = _("Invalid hwm id format") msg = _("Invalid hwm id format")
return exc.HTTPBadRequest(explanation=msg) return exc.HTTPBadRequest(explanation=msg)
try: try:
hwm_data = self.db_api.hwm_destroy(req.context, id) hwm_data = self.db_api.hwm_destroy(req.context, id)
msg = (_LI("Successfully deleted hwm %s") % id) msg = (_LI("Successfully deleted hwm %s") % id)
LOG.info(msg) LOG.info(msg)
if 'hwm' not in hwm_data: if 'hwm' not in hwm_data:
hwm_data = dict(hwm=hwm_data) hwm_data = dict(hwm=hwm_data)
return hwm_data return hwm_data
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to delete hwm metadata. " msg = (_("Failed to delete hwm metadata. "
"Got error: %s") % utils.exception_to_str(e)) "Got error: %s") % utils.exception_to_str(e))
LOG.error(msg) LOG.error(msg)
return exc.HTTPBadRequest(msg) return exc.HTTPBadRequest(msg)
except Exception: except Exception:
LOG.exception(_LE("Unable to delete hwm %s"), id) LOG.exception(_LE("Unable to delete hwm %s"), id)
raise raise
@utils.mutating @utils.mutating
def hwm_list(self, req): def hwm_list(self, req):
params = self._get_query_params(req) params = self._get_query_params(req)
try: try:
filters = params.pop('filters') filters = params.pop('filters')
marker = params.get('marker') marker = params.get('marker')
limit = params.get('limit') limit = params.get('limit')
sort_key = params.get('sort_key') sort_key = params.get('sort_key')
sort_dir = params.get('sort_dir') sort_dir = params.get('sort_dir')
return self.db_api.hwm_get_all( return self.db_api.hwm_get_all(
req.context, filters=filters, marker=marker, limit=limit, req.context, filters=filters, marker=marker, limit=limit,
sort_key=sort_key, sort_dir=sort_dir) sort_key=sort_key, sort_dir=sort_dir)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. hwm %(id)s could not be " LOG.warning(_LW("Invalid marker. hwm %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. hwm could not be found.") msg = _("Invalid marker. hwm could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to hwm %(id)s but returning " LOG.warning(_LW("Access denied to hwm %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. hwm could not be found.") msg = _("Invalid marker. hwm could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
LOG.exception(_LE("Unable to list hwm")) LOG.exception(_LE("Unable to list hwm"))
raise raise
@utils.mutating @utils.mutating
def detail(self, req, id): def detail(self, req, id):
"""Registers a new hwm with the registry. """Registers a new hwm with the registry.
:param req: wsgi Request object :param req: wsgi Request object
:param body: Dictionary of information about the template :param body: Dictionary of information about the template
:retval Returns the newly-created template information as a mapping, :retval Returns the newly-created template information as a mapping,
which will include the newly-created template's internal id which will include the newly-created template's internal id
in the 'id' field in the 'id' field
""" """
if id and not utils.is_uuid_like(id): if id and not utils.is_uuid_like(id):
msg = _LI("Rejecting hwm delete request for invalid hwm " msg = _LI("Rejecting hwm delete request for invalid hwm "
"id '%(bad_id)s'") % {'bad_id': id} "id '%(bad_id)s'") % {'bad_id': id}
LOG.info(msg) LOG.info(msg)
msg = _("Invalid hwm id format") msg = _("Invalid hwm id format")
return exc.HTTPBadRequest(explanation=msg) return exc.HTTPBadRequest(explanation=msg)
try: try:
hwm_data = self.db_api.hwm_get(req.context, id) hwm_data = self.db_api.hwm_get(req.context, id)
msg = (_LI("Successfully get hwm information:%s") % id) msg = (_LI("Successfully get hwm information:%s") % id)
LOG.info(msg) LOG.info(msg)
if 'hwm' not in hwm_data: if 'hwm' not in hwm_data:
hwm_data = dict(hwm=hwm_data) hwm_data = dict(hwm=hwm_data)
return hwm_data return hwm_data
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to get hwm metadata. Got error: %s") % msg = (_("Failed to get hwm metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.error(msg) LOG.error(msg)
return exc.HTTPBadRequest(msg) return exc.HTTPBadRequest(msg)
except Exception: except Exception:
LOG.exception(_LE("Unable to get hwm %s"), id) LOG.exception(_LE("Unable to get hwm %s"), id)
raise raise
def create_resource(): def create_resource():
"""Hwms resource factory method.""" """Hwms resource factory method."""
deserializer = wsgi.JSONRequestDeserializer() deserializer = wsgi.JSONRequestDeserializer()
serializer = wsgi.JSONResponseSerializer() serializer = wsgi.JSONResponseSerializer()
return wsgi.Resource(Controller(), deserializer, serializer) return wsgi.Resource(Controller(), deserializer, serializer)

View File

@ -42,14 +42,14 @@ class Controller(object):
self.db_api.cluster_get(req.context, cluster_id) self.db_api.cluster_get(req.context, cluster_id)
except exception.NotFound: except exception.NotFound:
msg = _("Project %(id)s not found") % {'id': cluster_id} msg = _("Project %(id)s not found") % {'id': cluster_id}
LOG.warn(msg) LOG.warning(msg)
raise webob.exc.HTTPNotFound(msg) raise webob.exc.HTTPNotFound(msg)
except exception.Forbidden: except exception.Forbidden:
# If it's private and doesn't belong to them, don't let on # If it's private and doesn't belong to them, don't let on
# that it exists # that it exists
msg = _LW("Access denied to cluster %(id)s but returning" msg = _LW("Access denied to cluster %(id)s but returning"
" 'not found'") % {'id': cluster_id} " 'not found'") % {'id': cluster_id}
LOG.warn(msg) LOG.warning(msg)
raise webob.exc.HTTPNotFound() raise webob.exc.HTTPNotFound()
members = self.db_api.cluster_host_member_find( members = self.db_api.cluster_host_member_find(
@ -70,14 +70,14 @@ class Controller(object):
self.db_api.cluster_get(req.context, cluster_id) self.db_api.cluster_get(req.context, cluster_id)
except exception.NotFound: except exception.NotFound:
msg = _("Project %(id)s not found") % {'id': cluster_id} msg = _("Project %(id)s not found") % {'id': cluster_id}
LOG.warn(msg) LOG.warning(msg)
raise webob.exc.HTTPNotFound(msg) raise webob.exc.HTTPNotFound(msg)
except exception.Forbidden: except exception.Forbidden:
# If it's private and doesn't belong to them, don't let on # If it's private and doesn't belong to them, don't let on
# that it exists # that it exists
msg = _LW("Access denied to cluster %(id)s but returning" msg = _LW("Access denied to cluster %(id)s but returning"
" 'not found'") % {'id': cluster_id} " 'not found'") % {'id': cluster_id}
LOG.warn(msg) LOG.warning(msg)
raise webob.exc.HTTPNotFound() raise webob.exc.HTTPNotFound()
# Make sure the host exists # Make sure the host exists
@ -85,14 +85,14 @@ class Controller(object):
self.db_api.host_get(req.context, host_id) self.db_api.host_get(req.context, host_id)
except exception.NotFound: except exception.NotFound:
msg = _("Host %(id)s not found") % {'id': host_id} msg = _("Host %(id)s not found") % {'id': host_id}
LOG.warn(msg) LOG.warning(msg)
raise webob.exc.HTTPNotFound(msg) raise webob.exc.HTTPNotFound(msg)
except exception.Forbidden: except exception.Forbidden:
# If it's private and doesn't belong to them, don't let on # If it's private and doesn't belong to them, don't let on
# that it exists # that it exists
msg = _LW("Access denied to host %(id)s but returning" msg = _LW("Access denied to host %(id)s but returning"
" 'not found'") % {'id': host_id} " 'not found'") % {'id': host_id}
LOG.warn(msg) LOG.warning(msg)
raise webob.exc.HTTPNotFound() raise webob.exc.HTTPNotFound()
# Look up an existing membership... # Look up an existing membership...
@ -123,14 +123,14 @@ class Controller(object):
self.db_api.cluster_get(req.context, cluster_id) self.db_api.cluster_get(req.context, cluster_id)
except exception.NotFound: except exception.NotFound:
msg = _("Project %(id)s not found") % {'id': cluster_id} msg = _("Project %(id)s not found") % {'id': cluster_id}
LOG.warn(msg) LOG.warning(msg)
raise webob.exc.HTTPNotFound(msg) raise webob.exc.HTTPNotFound(msg)
except exception.Forbidden: except exception.Forbidden:
# If it's private and doesn't belong to them, don't let on # If it's private and doesn't belong to them, don't let on
# that it exists # that it exists
msg = _LW("Access denied to cluster %(id)s but returning" msg = _LW("Access denied to cluster %(id)s but returning"
" 'not found'") % {'id': cluster_id} " 'not found'") % {'id': cluster_id}
LOG.warn(msg) LOG.warning(msg)
raise webob.exc.HTTPNotFound() raise webob.exc.HTTPNotFound()
# Make sure the host exists # Make sure the host exists
@ -138,14 +138,14 @@ class Controller(object):
self.db_api.host_get(req.context, host_id) self.db_api.host_get(req.context, host_id)
except exception.NotFound: except exception.NotFound:
msg = _("Host %(id)s not found") % {'id': host_id} msg = _("Host %(id)s not found") % {'id': host_id}
LOG.warn(msg) LOG.warning(msg)
raise webob.exc.HTTPNotFound(msg) raise webob.exc.HTTPNotFound(msg)
except exception.Forbidden: except exception.Forbidden:
# If it's private and doesn't belong to them, don't let on # If it's private and doesn't belong to them, don't let on
# that it exists # that it exists
msg = _LW("Access denied to host %(id)s but returning" msg = _LW("Access denied to host %(id)s but returning"
" 'not found'") % {'id': host_id} " 'not found'") % {'id': host_id}
LOG.warn(msg) LOG.warning(msg)
raise webob.exc.HTTPNotFound() raise webob.exc.HTTPNotFound()
# Look up an existing membership # Look up an existing membership
@ -185,7 +185,7 @@ class Controller(object):
req.context, host_id=host_id) req.context, host_id=host_id)
except exception.NotFound: except exception.NotFound:
msg = _LW("Host %(id)s not found") % {'id': host_id} msg = _LW("Host %(id)s not found") % {'id': host_id}
LOG.warn(msg) LOG.warning(msg)
msg = _("Membership could not be found.") msg = _("Membership could not be found.")
raise webob.exc.HTTPBadRequest(explanation=msg) raise webob.exc.HTTPBadRequest(explanation=msg)

View File

@ -66,13 +66,13 @@ class Controller(object):
filters=filters, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. Network %(id)s could not be " LOG.warning(_LW("Invalid marker. Network %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Network could not be found.") msg = _("Invalid marker. Network could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to network %(id)s but returning " LOG.warning(_LW("Access denied to network %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. Network could not be found.") msg = _("Invalid marker. Network could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -274,7 +274,7 @@ class Controller(object):
return network_data return network_data
except exception.Duplicate: except exception.Duplicate:
msg = _("node with identifier %s already exists!") % network_id msg = _("node with identifier %s already exists!") % network_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add node metadata. " msg = (_("Failed to add node metadata. "

View File

@ -1,384 +1,384 @@
# Copyright 2010-2011 OpenStack Foundation # Copyright 2010-2011 OpenStack Foundation
# All Rights Reserved. # All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # 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 # not use this file except in compliance with the License. You may obtain
# a copy of the License at # a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
""" """
Reference implementation registry server WSGI controller Reference implementation registry server WSGI controller
""" """
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import strutils from oslo_utils import strutils
from oslo_utils import timeutils from oslo_utils import timeutils
from webob import exc from webob import exc
from daisy.common import exception from daisy.common import exception
from daisy.common import utils from daisy.common import utils
from daisy.common import wsgi from daisy.common import wsgi
import daisy.db import daisy.db
from daisy import i18n from daisy import i18n
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_ = i18n._ _ = i18n._
_LE = i18n._LE _LE = i18n._LE
_LI = i18n._LI _LI = i18n._LI
_LW = i18n._LW _LW = i18n._LW
CONF = cfg.CONF CONF = cfg.CONF
DISPLAY_FIELDS_IN_INDEX = ['id', 'role_id', 'user_name', 'user_pwd', DISPLAY_FIELDS_IN_INDEX = ['id', 'role_id', 'user_name', 'user_pwd',
'controller_ip', 'neutron_backends_type', 'controller_ip', 'neutron_backends_type',
'sdn_type', 'port'] 'sdn_type', 'port']
SUPPORTED_FILTERS = ['role_id', 'user_name', 'user_pwd', SUPPORTED_FILTERS = ['role_id', 'user_name', 'user_pwd',
'controller_ip', 'neutron_backends_type', 'controller_ip', 'neutron_backends_type',
'sdn_type', 'port'] 'sdn_type', 'port']
SUPPORTED_SORT_KEYS = ('id', 'role_id', 'user_name', 'user_pwd', SUPPORTED_SORT_KEYS = ('id', 'role_id', 'user_name', 'user_pwd',
'controller_ip', 'neutron_backends_type', 'controller_ip', 'neutron_backends_type',
'sdn_type', 'port', 'created_at', 'updated_at') 'sdn_type', 'port', 'created_at', 'updated_at')
SUPPORTED_SORT_DIRS = ('asc', 'desc') SUPPORTED_SORT_DIRS = ('asc', 'desc')
SUPPORTED_PARAMS = ('limit', 'marker', 'sort_key', 'sort_dir', 'name', SUPPORTED_PARAMS = ('limit', 'marker', 'sort_key', 'sort_dir', 'name',
'description') 'description')
class Controller(object): class Controller(object):
def __init__(self): def __init__(self):
self.db_api = daisy.db.get_api() self.db_api = daisy.db.get_api()
def _get_query_params(self, req): def _get_query_params(self, req):
"""Extract necessary query parameters from http request. """Extract necessary query parameters from http request.
:param req: the Request object coming from the wsgi layer :param req: the Request object coming from the wsgi layer
:retval dictionary of filters to apply to list of templates :retval dictionary of filters to apply to list of templates
""" """
params = { params = {
'filters': self._get_filters(req), 'filters': self._get_filters(req),
'limit': self._get_limit(req), 'limit': self._get_limit(req),
'sort_key': [self._get_sort_key(req)], 'sort_key': [self._get_sort_key(req)],
'sort_dir': [self._get_sort_dir(req)], 'sort_dir': [self._get_sort_dir(req)],
'marker': self._get_marker(req), 'marker': self._get_marker(req),
} }
for key, value in params.items(): for key, value in params.items():
if value is None: if value is None:
del params[key] del params[key]
return params return params
def _get_filters(self, req): def _get_filters(self, req):
"""Return a dictionary of query param filters from the request """Return a dictionary of query param filters from the request
:param req: the Request object coming from the wsgi layer :param req: the Request object coming from the wsgi layer
:retval a dict of key/value filters :retval a dict of key/value filters
""" """
filters = {} filters = {}
properties = {} properties = {}
for param in req.params: for param in req.params:
if param in SUPPORTED_FILTERS: if param in SUPPORTED_FILTERS:
filters[param] = req.params.get(param) filters[param] = req.params.get(param)
if param.startswith('property-'): if param.startswith('property-'):
_param = param[9:] _param = param[9:]
properties[_param] = req.params.get(param) properties[_param] = req.params.get(param)
if 'changes-since' in filters: if 'changes-since' in filters:
isotime = filters['changes-since'] isotime = filters['changes-since']
try: try:
filters['changes-since'] = timeutils.parse_isotime(isotime) filters['changes-since'] = timeutils.parse_isotime(isotime)
except ValueError: except ValueError:
raise exc.HTTPBadRequest(_("Unrecognized changes-since value")) raise exc.HTTPBadRequest(_("Unrecognized changes-since value"))
if 'protected' in filters: if 'protected' in filters:
value = self._get_bool(filters['protected']) value = self._get_bool(filters['protected'])
if value is None: if value is None:
raise exc.HTTPBadRequest(_("protected must be True, or " raise exc.HTTPBadRequest(_("protected must be True, or "
"False")) "False"))
filters['protected'] = value filters['protected'] = value
# only allow admins to filter on 'deleted' # only allow admins to filter on 'deleted'
if req.context.is_admin: if req.context.is_admin:
deleted_filter = self._parse_deleted_filter(req) deleted_filter = self._parse_deleted_filter(req)
if deleted_filter is not None: if deleted_filter is not None:
filters['deleted'] = deleted_filter filters['deleted'] = deleted_filter
elif 'changes-since' not in filters: elif 'changes-since' not in filters:
filters['deleted'] = False filters['deleted'] = False
elif 'changes-since' not in filters: elif 'changes-since' not in filters:
filters['deleted'] = False filters['deleted'] = False
if properties: if properties:
filters['properties'] = properties filters['properties'] = properties
return filters return filters
def _get_limit(self, req): def _get_limit(self, req):
"""Parse a limit query param into something usable.""" """Parse a limit query param into something usable."""
try: try:
limit = int(req.params.get('limit', CONF.limit_param_default)) limit = int(req.params.get('limit', CONF.limit_param_default))
except ValueError: except ValueError:
raise exc.HTTPBadRequest(_("limit param must be an integer")) raise exc.HTTPBadRequest(_("limit param must be an integer"))
if limit < 0: if limit < 0:
raise exc.HTTPBadRequest(_("limit param must be positive")) raise exc.HTTPBadRequest(_("limit param must be positive"))
return min(CONF.api_limit_max, limit) return min(CONF.api_limit_max, limit)
def _get_marker(self, req): def _get_marker(self, req):
"""Parse a marker query param into something usable.""" """Parse a marker query param into something usable."""
marker = req.params.get('marker', None) marker = req.params.get('marker', None)
if marker and not utils.is_uuid_like(marker): if marker and not utils.is_uuid_like(marker):
msg = _('Invalid marker format') msg = _('Invalid marker format')
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
return marker return marker
def _get_sort_key(self, req): def _get_sort_key(self, req):
"""Parse a sort key query param from the request object.""" """Parse a sort key query param from the request object."""
sort_key = req.params.get('sort_key', 'created_at') sort_key = req.params.get('sort_key', 'created_at')
if sort_key is not None and sort_key not in SUPPORTED_SORT_KEYS: if sort_key is not None and sort_key not in SUPPORTED_SORT_KEYS:
_keys = ', '.join(SUPPORTED_SORT_KEYS) _keys = ', '.join(SUPPORTED_SORT_KEYS)
msg = _("Unsupported sort_key. Acceptable values: %s") % (_keys,) msg = _("Unsupported sort_key. Acceptable values: %s") % (_keys,)
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
return sort_key return sort_key
def _get_sort_dir(self, req): def _get_sort_dir(self, req):
"""Parse a sort direction query param from the request object.""" """Parse a sort direction query param from the request object."""
sort_dir = req.params.get('sort_dir', 'desc') sort_dir = req.params.get('sort_dir', 'desc')
if sort_dir is not None and sort_dir not in SUPPORTED_SORT_DIRS: if sort_dir is not None and sort_dir not in SUPPORTED_SORT_DIRS:
_keys = ', '.join(SUPPORTED_SORT_DIRS) _keys = ', '.join(SUPPORTED_SORT_DIRS)
msg = _("Unsupported sort_dir. Acceptable values: %s") % (_keys,) msg = _("Unsupported sort_dir. Acceptable values: %s") % (_keys,)
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
return sort_dir return sort_dir
def _get_bool(self, value): def _get_bool(self, value):
value = value.lower() value = value.lower()
if value == 'true' or value == '1': if value == 'true' or value == '1':
return True return True
elif value == 'false' or value == '0': elif value == 'false' or value == '0':
return False return False
return None return None
def _parse_deleted_filter(self, req): def _parse_deleted_filter(self, req):
"""Parse deleted into something usable.""" """Parse deleted into something usable."""
deleted = req.params.get('deleted') deleted = req.params.get('deleted')
if deleted is None: if deleted is None:
return None return None
return strutils.bool_from_string(deleted) return strutils.bool_from_string(deleted)
@utils.mutating @utils.mutating
def neutron_backend_add(self, req, body): def neutron_backend_add(self, req, body):
"""Registers a new neutron_backend with the registry. """Registers a new neutron_backend with the registry.
:param req: wsgi Request object :param req: wsgi Request object
:param body: Dictionary of information about the templatae :param body: Dictionary of information about the templatae
:retval Returns the newly-created template information as a mapping, :retval Returns the newly-created template information as a mapping,
which will include the newly-created template's internal id which will include the newly-created template's internal id
in the 'id' field in the 'id' field
""" """
neutron_backend_data = body["neutron_backend"] neutron_backend_data = body["neutron_backend"]
id = neutron_backend_data.get('id') id = neutron_backend_data.get('id')
if id and not utils.is_uuid_like(id): if id and not utils.is_uuid_like(id):
msg = _LI("Rejecting neutron_backend creation " msg = _LI("Rejecting neutron_backend creation "
"request for invalid neutron_backend " "request for invalid neutron_backend "
"id '%(bad_id)s'") % {'bad_id': id} "id '%(bad_id)s'") % {'bad_id': id}
LOG.info(msg) LOG.info(msg)
msg = _("Invalid neutron_backend id format") msg = _("Invalid neutron_backend id format")
return exc.HTTPBadRequest(explanation=msg) return exc.HTTPBadRequest(explanation=msg)
try: try:
neutron_backend_data = self.db_api.neutron_backend_add( neutron_backend_data = self.db_api.neutron_backend_add(
req.context, neutron_backend_data) req.context, neutron_backend_data)
msg = (_LI("Successfully created neutron_backend %s") % msg = (_LI("Successfully created neutron_backend %s") %
neutron_backend_data["id"]) neutron_backend_data["id"])
LOG.info(msg) LOG.info(msg)
if 'neutron_backend' not in neutron_backend_data: if 'neutron_backend' not in neutron_backend_data:
neutron_backend_data = dict( neutron_backend_data = dict(
neutron_backend=neutron_backend_data) neutron_backend=neutron_backend_data)
return neutron_backend_data return neutron_backend_data
except exception.Duplicate: except exception.Duplicate:
msg = _("neutron_backend with identifier %s already exists!") % id msg = _("neutron_backend with identifier %s already exists!") % id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add neutron_backend metadata. " msg = (_("Failed to add neutron_backend metadata. "
"Got error: %s") % utils.exception_to_str(e)) "Got error: %s") % utils.exception_to_str(e))
LOG.error(msg) LOG.error(msg)
return exc.HTTPBadRequest(msg) return exc.HTTPBadRequest(msg)
except Exception: except Exception:
LOG.exception(_LE("Unable to create neutron_backend %s"), id) LOG.exception(_LE("Unable to create neutron_backend %s"), id)
raise raise
@utils.mutating @utils.mutating
def neutron_backend_update(self, req, id, body): def neutron_backend_update(self, req, id, body):
"""Registers a new neutron_backend with the registry. """Registers a new neutron_backend with the registry.
:param req: wsgi Request object :param req: wsgi Request object
:param body: Dictionary of information about the template :param body: Dictionary of information about the template
:retval Returns the newly-created template information as a mapping, :retval Returns the newly-created template information as a mapping,
which will include the newly-created template's internal id which will include the newly-created template's internal id
in the 'id' field in the 'id' field
""" """
neutron_backend_data = body["neutron_backend"] neutron_backend_data = body["neutron_backend"]
if id and not utils.is_uuid_like(id): if id and not utils.is_uuid_like(id):
msg = _LI("Rejecting cluster neutron_backend " msg = _LI("Rejecting cluster neutron_backend "
"creation request for invalid " "creation request for invalid "
"neutron_backend id '%(bad_id)s'") % {'bad_id': id} "neutron_backend id '%(bad_id)s'") % {'bad_id': id}
LOG.info(msg) LOG.info(msg)
msg = _("Invalid neutron_backend id format") msg = _("Invalid neutron_backend id format")
return exc.HTTPBadRequest(explanation=msg) return exc.HTTPBadRequest(explanation=msg)
try: try:
neutron_backend_data = self.db_api.neutron_backend_update( neutron_backend_data = self.db_api.neutron_backend_update(
req.context, id, neutron_backend_data) req.context, id, neutron_backend_data)
msg = (_LI("Successfully updated neutron_backend %s") % msg = (_LI("Successfully updated neutron_backend %s") %
neutron_backend_data["id"]) neutron_backend_data["id"])
LOG.info(msg) LOG.info(msg)
if 'neutron_backend' not in neutron_backend_data: if 'neutron_backend' not in neutron_backend_data:
neutron_backend_data = dict( neutron_backend_data = dict(
neutron_backend=neutron_backend_data) neutron_backend=neutron_backend_data)
return neutron_backend_data return neutron_backend_data
except exception.Duplicate: except exception.Duplicate:
msg = _("neutron_backend with identifier %s already exists!") % id msg = _("neutron_backend with identifier %s already exists!") % id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update neutron_backend " msg = (_("Failed to update neutron_backend "
"metadata.Got error: %s") % utils.exception_to_str(e)) "metadata.Got error: %s") % utils.exception_to_str(e))
LOG.error(msg) LOG.error(msg)
return exc.HTTPBadRequest(msg) return exc.HTTPBadRequest(msg)
except Exception: except Exception:
LOG.exception(_LE("Unable to update neutron_backend %s"), id) LOG.exception(_LE("Unable to update neutron_backend %s"), id)
raise raise
@utils.mutating @utils.mutating
def neutron_backend_delete(self, req, id): def neutron_backend_delete(self, req, id):
"""Registers a new neutron_backend with the registry. """Registers a new neutron_backend with the registry.
:param req: wsgi Request object :param req: wsgi Request object
:param body: Dictionary of information about the template :param body: Dictionary of information about the template
:retval Returns the newly-created template information as a mapping, :retval Returns the newly-created template information as a mapping,
which will include the newly-created template's internal id which will include the newly-created template's internal id
in the 'id' field in the 'id' field
""" """
if id and not utils.is_uuid_like(id): if id and not utils.is_uuid_like(id):
msg = _LI("Rejecting neutron_backend delete " msg = _LI("Rejecting neutron_backend delete "
"request for invalid neutron_backend " "request for invalid neutron_backend "
"id '%(bad_id)s'") % {'bad_id': id} "id '%(bad_id)s'") % {'bad_id': id}
LOG.info(msg) LOG.info(msg)
msg = _("Invalid neutron_backend id format") msg = _("Invalid neutron_backend id format")
return exc.HTTPBadRequest(explanation=msg) return exc.HTTPBadRequest(explanation=msg)
try: try:
neutron_backend_data = self.db_api.neutron_backend_destroy( neutron_backend_data = self.db_api.neutron_backend_destroy(
req.context, id) req.context, id)
msg = (_LI("Successfully deleted neutron_backend %s") % id) msg = (_LI("Successfully deleted neutron_backend %s") % id)
LOG.info(msg) LOG.info(msg)
if 'neutron_backend' not in neutron_backend_data: if 'neutron_backend' not in neutron_backend_data:
neutron_backend_data = dict( neutron_backend_data = dict(
neutron_backend=neutron_backend_data) neutron_backend=neutron_backend_data)
return neutron_backend_data return neutron_backend_data
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to delete neutron_backend metadata. " msg = (_("Failed to delete neutron_backend metadata. "
"Got error: %s") % utils.exception_to_str(e)) "Got error: %s") % utils.exception_to_str(e))
LOG.error(msg) LOG.error(msg)
return exc.HTTPBadRequest(msg) return exc.HTTPBadRequest(msg)
except Exception: except Exception:
LOG.exception(_LE("Unable to delete neutron_backend %s"), id) LOG.exception(_LE("Unable to delete neutron_backend %s"), id)
raise raise
def _list_neutron_backends(self, context, filters, params): def _list_neutron_backends(self, context, filters, params):
"""Get neutron_backends, wrapping in exception if necessary.""" """Get neutron_backends, wrapping in exception if necessary."""
try: try:
return self.db_api.neutron_backend_list(context, filters=filters, return self.db_api.neutron_backend_list(context, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. neutron_backend %(id)s could not be " LOG.warning(_LW("Invalid marker. neutron_backend %(id)s not"
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. neutron_backend could not be found.") msg = _("Invalid marker. neutron_backend could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to neutron_backend " LOG.warning(_LW("Access denied to neutron_backend "
"%(id)s but returning " "%(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. neutron_backend could not be found.") msg = _("Invalid marker. neutron_backend could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
LOG.exception(_LE("Unable to get neutron_backends")) LOG.exception(_LE("Unable to get neutron_backends"))
raise raise
def neutron_backend_list(self, req): def neutron_backend_list(self, req):
"""Return a filtered list of non-deleted neutron_backends in detail """Return a filtered list of non-deleted neutron_backends in detail
:param req: the Request object coming from the wsgi layer :param req: the Request object coming from the wsgi layer
:retval a mapping of the following form:: :retval a mapping of the following form::
dict(neutron_backends=[neutron_backend_list]) dict(neutron_backends=[neutron_backend_list])
Where neutron_backend_list is a sequence of mappings containing Where neutron_backend_list is a sequence of mappings containing
all neutron_backend model fields. all neutron_backend model fields.
""" """
params = self._get_query_params(req) params = self._get_query_params(req)
filters = params.pop('filters') filters = params.pop('filters')
neutron_backends = self._list_neutron_backends( neutron_backends = self._list_neutron_backends(
req.context, filters, params) req.context, filters, params)
return dict(neutron_backends=neutron_backends) return dict(neutron_backends=neutron_backends)
@utils.mutating @utils.mutating
def neutron_backend_detail(self, req, id): def neutron_backend_detail(self, req, id):
"""Registers a new neutron_backend with the registry. """Registers a new neutron_backend with the registry.
:param req: wsgi Request object :param req: wsgi Request object
:param body: Dictionary of information about the template :param body: Dictionary of information about the template
:retval Returns the newly-created template information as a mapping, :retval Returns the newly-created template information as a mapping,
which will include the newly-created template's internal id which will include the newly-created template's internal id
in the 'id' field in the 'id' field
""" """
if id and not utils.is_uuid_like(id): if id and not utils.is_uuid_like(id):
msg = _LI("Rejecting neutron_backend delete " msg = _LI("Rejecting neutron_backend delete "
"request for invalid neutron_backend " "request for invalid neutron_backend "
"id '%(bad_id)s'") % {'bad_id': id} "id '%(bad_id)s'") % {'bad_id': id}
LOG.info(msg) LOG.info(msg)
msg = _("Invalid neutron_backend id format") msg = _("Invalid neutron_backend id format")
return exc.HTTPBadRequest(explanation=msg) return exc.HTTPBadRequest(explanation=msg)
try: try:
neutron_backend_data = self.db_api.neutron_backend_detail( neutron_backend_data = self.db_api.neutron_backend_detail(
req.context, id) req.context, id)
msg = (_LI("Successfully get neutron_backend information:%s") % id) msg = (_LI("Successfully get neutron_backend information:%s") % id)
LOG.info(msg) LOG.info(msg)
if 'neutron_backend' not in neutron_backend_data: if 'neutron_backend' not in neutron_backend_data:
neutron_backend_data = dict( neutron_backend_data = dict(
neutron_backend=neutron_backend_data) neutron_backend=neutron_backend_data)
return neutron_backend_data return neutron_backend_data
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to get neutron_backend metadata. Got error: %s") % msg = (_("Failed to get neutron_backend metadata. Got error: %s") %
utils.exception_to_str(e)) utils.exception_to_str(e))
LOG.error(msg) LOG.error(msg)
return exc.HTTPBadRequest(msg) return exc.HTTPBadRequest(msg)
except Exception: except Exception:
LOG.exception(_LE("Unable to get neutron_backend %s"), id) LOG.exception(_LE("Unable to get neutron_backend %s"), id)
raise raise
def create_resource(): def create_resource():
"""neutron_backends resource factory method.""" """neutron_backends resource factory method."""
deserializer = wsgi.JSONRequestDeserializer() deserializer = wsgi.JSONRequestDeserializer()
serializer = wsgi.JSONResponseSerializer() serializer = wsgi.JSONResponseSerializer()
return wsgi.Resource(Controller(), deserializer, serializer) return wsgi.Resource(Controller(), deserializer, serializer)

View File

@ -207,6 +207,7 @@ class Controller(object):
if id and not utils.is_uuid_like(id): if id and not utils.is_uuid_like(id):
msg = _LI("Rejecting template creation request for " msg = _LI("Rejecting template creation request for "
"invalid template " "invalid template "
"id '%(bad_id)s'") % {'bad_id': id} "id '%(bad_id)s'") % {'bad_id': id}
LOG.info(msg) LOG.info(msg)
msg = _("Invalid template id format") msg = _("Invalid template id format")
@ -223,7 +224,7 @@ class Controller(object):
return template_data return template_data
except exception.Duplicate: except exception.Duplicate:
msg = _("template with identifier %s already exists!") % id msg = _("template with identifier %s already exists!") % id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add template metadata. " msg = (_("Failed to add template metadata. "
@ -266,7 +267,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = _("template with identifier %s already exists!") % \ msg = _("template with identifier %s already exists!") % \
template_id template_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update template metadata. " msg = (_("Failed to update template metadata. "
@ -327,13 +328,13 @@ class Controller(object):
sort_key=sort_key, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. template %(id)s could not be " LOG.warning(_LW("Invalid marker. template %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. template could not be found.") msg = _("Invalid marker. template could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to template %(id)s but returning " LOG.warning(_LW("Access denied to template %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. template could not be found.") msg = _("Invalid marker. template could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -421,7 +422,7 @@ class Controller(object):
return template_data return template_data
except exception.Duplicate: except exception.Duplicate:
msg = _("node with identifier %s already exists!") % id msg = _("node with identifier %s already exists!") % id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add node metadata. " msg = (_("Failed to add node metadata. "
@ -468,7 +469,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = _("template with identifier %s already exists!") % \ msg = _("template with identifier %s already exists!") % \
template_id template_id
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to update template metadata. " msg = (_("Failed to update template metadata. "
@ -533,13 +534,13 @@ class Controller(object):
sort_key=sort_key, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. template %(id)s could not be " LOG.warning(_LW("Invalid marker. template %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. template could not be found.") msg = _("Invalid marker. template could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to template %(id)s but returning " LOG.warning(_LW("Access denied to template %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. template could not be found.") msg = _("Invalid marker. template could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:

View File

@ -63,14 +63,14 @@ class Controller(object):
filters=filters, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. template config %(id)s could not be " LOG.warning(_LW("Invalid marker.template config %(id)s not"
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. template config could not be found.") msg = _("Invalid marker. template config could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to template config %(id)s but " LOG.warning(_LW("Access denied to template config %(id)s but "
"returning 'not found'") % "returning 'not found'") %
{'id': params.get('marker')}) {'id': params.get('marker')})
msg = _("Invalid marker. template config could not be found.") msg = _("Invalid marker. template config could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -253,7 +253,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = (_("template function with identifier %s already exists!") % msg = (_("template function with identifier %s already exists!") %
template_config_data) template_config_data)
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add template function metadata. " msg = (_("Failed to add template function metadata. "

View File

@ -61,14 +61,14 @@ class Controller(object):
filters=filters, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. template function %(id)s could not " LOG.warning(_LW("Invalid marker. template function %(id)s not"
"be found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. template function could not be found.") msg = _("Invalid marker. template function could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to template function %(id)s but " LOG.warning(_LW("Access denied to template function %(id)s but "
"returning 'not found'") % "returning 'not found'") %
{'id': params.get('marker')}) {'id': params.get('marker')})
msg = _("Invalid marker. template function could not be found.") msg = _("Invalid marker. template function could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -264,7 +264,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = (_("template function with identifier %s already exists!") % msg = (_("template function with identifier %s already exists!") %
template_func_data) template_func_data)
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add template function metadata. " msg = (_("Failed to add template function metadata. "

View File

@ -60,14 +60,14 @@ class Controller(object):
filters=filters, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. template function %(id)s could not " LOG.warning(_LW("Invalid marker.template function %(id)s not "
"be found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. template function could not be found.") msg = _("Invalid marker. template function could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to template func %(id)s but" LOG.warning(_LW("Access denied to template func %(id)s but"
"returning 'not found'") % "returning 'not found'") %
{'id': params.get('marker')}) {'id': params.get('marker')})
msg = _("Invalid marker. template function could not be found.") msg = _("Invalid marker. template function could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:

View File

@ -187,13 +187,13 @@ class Controller(object):
filters=filters, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker patch history %(id)s could not be " LOG.warning(_LW("Invalid marker patch history %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. Host could not be found.") msg = _("Invalid marker. Host could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to patch history %(id)s but returning " LOG.warning(_LW("Access denied patch history %(id)s but returned "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. Host could not be found.") msg = _("Invalid marker. Host could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -234,7 +234,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = (_("version patch with identifier %s" msg = (_("version patch with identifier %s"
" already exists!") % version_patch_id) " already exists!") % version_patch_id)
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add version patch metadata. " msg = (_("Failed to add version patch metadata. "
@ -386,7 +386,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = (_("patch history with identifier %s already exists!") % msg = (_("patch history with identifier %s already exists!") %
patch_history_meta['patch_name']) patch_history_meta['patch_name'])
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add patch history metadata. " msg = (_("Failed to add patch history metadata. "

View File

@ -64,13 +64,13 @@ class Controller(object):
filters=filters, filters=filters,
**params) **params)
except exception.NotFound: except exception.NotFound:
LOG.warn(_LW("Invalid marker. version %(id)s could not be " LOG.warning(_LW("Invalid marker. version %(id)s could not be "
"found.") % {'id': params.get('marker')}) "found.") % {'id': params.get('marker')})
msg = _("Invalid marker. version could not be found.") msg = _("Invalid marker. version could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.Forbidden: except exception.Forbidden:
LOG.warn(_LW("Access denied to version %(id)s but returning " LOG.warning(_LW("Access denied to version %(id)s but returning "
"'not found'") % {'id': params.get('marker')}) "'not found'") % {'id': params.get('marker')})
msg = _("Invalid marker. version could not be found.") msg = _("Invalid marker. version could not be found.")
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except Exception: except Exception:
@ -246,7 +246,7 @@ class Controller(object):
except exception.Duplicate: except exception.Duplicate:
msg = (_("version with identifier %s already exists!") % msg = (_("version with identifier %s already exists!") %
version_data['name']) version_data['name'])
LOG.warn(msg) LOG.warning(msg)
return exc.HTTPConflict(msg) return exc.HTTPConflict(msg)
except exception.Invalid as e: except exception.Invalid as e:
msg = (_("Failed to add version metadata. " msg = (_("Failed to add version metadata. "

View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order # The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
pbr>=0.6,!=0.7,<1.0 #pbr>=0.6,!=0.7,<1.0
Babel>=1.3 Babel>=1.3
argparse argparse
PrettyTable>=0.7,<0.8 PrettyTable>=0.7,<0.8
@ -9,6 +9,6 @@ python-keystoneclient>=1.0.0
pyOpenSSL>=0.11 pyOpenSSL>=0.11
requests>=2.2.0,!=2.4.0 requests>=2.2.0,!=2.4.0
warlock>=1.0.1,<2 warlock>=1.0.1,<2
six>=1.7.0 #six>=1.7.0
oslo.utils>=1.2.0 # Apache-2.0 oslo.utils>=1.2.0 # Apache-2.0
oslo.i18n>=1.3.0 # Apache-2.0 oslo.i18n>=1.3.0 # Apache-2.0

View File

@ -245,7 +245,7 @@ class Enforcer(object):
try: try:
path = self._get_policy_path(path) path = self._get_policy_path(path)
except cfg.ConfigFilesNotFoundError: except cfg.ConfigFilesNotFoundError:
LOG.warn(_LW("Can not find policy directories %s"), path) LOG.warning(_LW("Can not find policy directories %s"), path)
continue continue
self._walk_through_policy_directory(path, self._walk_through_policy_directory(path,
self._load_policy_file, self._load_policy_file,

View File

@ -49,8 +49,8 @@ def _get_enforcer():
LOG.debug("adding enforcer for service: %s" % service) LOG.debug("adding enforcer for service: %s" % service)
_ENFORCER[service] = enforcer _ENFORCER[service] = enforcer
else: else:
LOG.warn("policy file for service: %s not found at %s" % LOG.warning("policy file for service: %s not found at %s" %
(service, enforcer.policy_path)) (service, enforcer.policy_path))
return _ENFORCER return _ENFORCER

View File

@ -8,11 +8,10 @@ License: ASL 2.0
Group: System Environment/Base Group: System Environment/Base
URL: https://pypi.python.org/pypi/ironic-discoverd URL: https://pypi.python.org/pypi/ironic-discoverd
Source0: https://pypi.python.org/packages/source/i/ironic-discoverd/ironic-discoverd-%{version}.tar.gz Source0: https://pypi.python.org/packages/source/i/ironic-discoverd/ironic-discoverd-%{version}.tar.gz
Source1: openstack-ironic-discoverd.service Source1: openstack-ironic-discoverd.service
Source2: openstack-ironic-discoverd-dnsmasq.service Source2: openstack-ironic-discoverd-dnsmasq.service
Source3: dnsmasq.conf Source3: dnsmasq.conf
Patch0: 0001-default-database-location.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: python-setuptools BuildRequires: python-setuptools
@ -75,7 +74,7 @@ This package contains Python modules and documentation.
%files -n python-ironic-discoverd %files -n python-ironic-discoverd
%doc README.rst CONTRIBUTING.rst %doc README.rst CONTRIBUTING.rst
%license LICENSE %license LICENSE
%{python_sitelib}/ironic_discoverd* %{python2_sitelib}/ironic_discoverd*
%description %description
@ -141,6 +140,5 @@ This package contains main executable and service files.
* Thu Oct 16 2014 Dmitry Tantsur <dtantsur@redhat.com> - 0.2.1-1 * Thu Oct 16 2014 Dmitry Tantsur <dtantsur@redhat.com> - 0.2.1-1
- Upstream bugfix release - Upstream bugfix release
* Wed Oct 8 2014 Dmitry Tantsur <dtantsur@redhat.com> - 0.2.0-1 * Wed Oct 8 2014 Dmitry Tantsur <dtantsur@redhat.com> - 0.2.0-1- Initial package build
- Initial package build - Initial package build

View File

@ -51,9 +51,9 @@ def get_network_from_name(name, compute_networks_client):
else: else:
msg = "Network with name: %s not found" % name msg = "Network with name: %s not found" % name
if caller: if caller:
LOG.warn('(%s) %s' % (caller, msg)) LOG.warning('(%s) %s' % (caller, msg))
else: else:
LOG.warn(msg) LOG.warning(msg)
raise lib_exc.NotFound() raise lib_exc.NotFound()
# To be consistent with network isolation, add name is only # To be consistent with network isolation, add name is only
# label is available # label is available
@ -125,6 +125,6 @@ def set_networks_kwarg(network, kwargs=None):
if 'id' in network.keys(): if 'id' in network.keys():
params.update({"networks": [{'uuid': network['id']}]}) params.update({"networks": [{'uuid': network['id']}]})
else: else:
LOG.warn('The provided network dict: %s was invalid and did not ' LOG.warning('provided network dict: %s was invalid, did not '
' contain an id' % network) ' contain an id' % network)
return params return params

View File

@ -348,24 +348,24 @@ class IsolatedCreds(cred_provider.CredentialProvider):
try: try:
net_client.delete_router(router_id) net_client.delete_router(router_id)
except lib_exc.NotFound: except lib_exc.NotFound:
LOG.warn('router with name: %s not found for delete' % LOG.warning('router with name: %s not found for delete' %
router_name) router_name)
def _clear_isolated_subnet(self, subnet_id, subnet_name): def _clear_isolated_subnet(self, subnet_id, subnet_name):
net_client = self.network_admin_client net_client = self.network_admin_client
try: try:
net_client.delete_subnet(subnet_id) net_client.delete_subnet(subnet_id)
except lib_exc.NotFound: except lib_exc.NotFound:
LOG.warn('subnet with name: %s not found for delete' % LOG.warning('subnet with name: %s not found for delete' %
subnet_name) subnet_name)
def _clear_isolated_network(self, network_id, network_name): def _clear_isolated_network(self, network_id, network_name):
net_client = self.network_admin_client net_client = self.network_admin_client
try: try:
net_client.delete_network(network_id) net_client.delete_network(network_id)
except lib_exc.NotFound: except lib_exc.NotFound:
LOG.warn('network with name: %s not found for delete' % LOG.warning('network with name: %s not found for delete' %
network_name) network_name)
def _cleanup_default_secgroup(self, tenant): def _cleanup_default_secgroup(self, tenant):
net_client = self.network_admin_client net_client = self.network_admin_client
@ -376,8 +376,8 @@ class IsolatedCreds(cred_provider.CredentialProvider):
try: try:
net_client.delete_security_group(secgroup['id']) net_client.delete_security_group(secgroup['id'])
except lib_exc.NotFound: except lib_exc.NotFound:
LOG.warn('Security group %s, id %s not found for clean-up' % LOG.warning('Security group %s, id %s not found for clean-up' %
(secgroup['name'], secgroup['id'])) (secgroup['name'], secgroup['id']))
def _clear_isolated_net_resources(self): def _clear_isolated_net_resources(self):
net_client = self.network_admin_client net_client = self.network_admin_client
@ -396,8 +396,8 @@ class IsolatedCreds(cred_provider.CredentialProvider):
net_client.remove_router_interface_with_subnet_id( net_client.remove_router_interface_with_subnet_id(
creds.router['id'], creds.subnet['id']) creds.router['id'], creds.subnet['id'])
except lib_exc.NotFound: except lib_exc.NotFound:
LOG.warn('router with name: %s not found for delete' % LOG.warning('router with name: %s not found for delete' %
creds.router['name']) creds.router['name'])
self._clear_isolated_router(creds.router['id'], self._clear_isolated_router(creds.router['id'],
creds.router['name']) creds.router['name'])
if (not self.network_resources or if (not self.network_resources or
@ -417,15 +417,15 @@ class IsolatedCreds(cred_provider.CredentialProvider):
try: try:
self.creds_client.delete_user(creds.user_id) self.creds_client.delete_user(creds.user_id)
except lib_exc.NotFound: except lib_exc.NotFound:
LOG.warn("user with name: %s not found for delete" % LOG.warning("user with name: %s not found for delete" %
creds.username) creds.username)
try: try:
if CONF.service_available.neutron: if CONF.service_available.neutron:
self._cleanup_default_secgroup(creds.tenant_id) self._cleanup_default_secgroup(creds.tenant_id)
self.creds_client.delete_project(creds.tenant_id) self.creds_client.delete_project(creds.tenant_id)
except lib_exc.NotFound: except lib_exc.NotFound:
LOG.warn("tenant with name: %s not found for delete" % LOG.warning("tenant with name: %s not found for delete" %
creds.tenant_name) creds.tenant_name)
self.isolated_creds = {} self.isolated_creds = {}
def is_multi_user(self): def is_multi_user(self):