From 62b51cb975bb5676b881777152749e0dd363a8d1 Mon Sep 17 00:00:00 2001 From: deepakmourya Date: Thu, 1 Jun 2017 10:42:44 +0530 Subject: [PATCH] python3 has disable LOG.warn. python3 has disable LOG.warn. So replace LOG.warn with LOG.warning Closes-Bug: #1650457 Change-Id: I532d9faf60a5d6cd84502dc71f9516d6fcad972e --- code/daisy/daisy/api/backends/kolla/api.py | 4 +- .../api/backends/osinstall/pxe/install.py | 4 +- code/daisy/daisy/api/middleware/context.py | 2 +- code/daisy/daisy/api/v1/clusters.py | 14 +- code/daisy/daisy/api/v1/components.py | 14 +- code/daisy/daisy/api/v1/config_files.py | 14 +- code/daisy/daisy/api/v1/config_sets.py | 14 +- code/daisy/daisy/api/v1/configs.py | 6 +- code/daisy/daisy/api/v1/deploy_server.py | 2 +- code/daisy/daisy/api/v1/disk_array.py | 38 +- code/daisy/daisy/api/v1/host_template.py | 8 +- code/daisy/daisy/api/v1/hosts.py | 12 +- code/daisy/daisy/api/v1/install.py | 2 +- code/daisy/daisy/api/v1/members.py | 4 +- code/daisy/daisy/api/v1/networks.py | 22 +- code/daisy/daisy/api/v1/roles.py | 24 +- code/daisy/daisy/api/v1/services.py | 14 +- code/daisy/daisy/api/v1/template.py | 8 +- code/daisy/daisy/api/v1/version_patchs.py | 14 +- code/daisy/daisy/api/v1/versions.py | 14 +- code/daisy/daisy/common/auth.py | 2 +- code/daisy/daisy/common/utils.py | 18 +- code/daisy/daisy/common/wsgi.py | 2 +- code/daisy/daisy/db/sqlalchemy/api.py | 6 +- code/daisy/daisy/orchestration/manager.py | 18 +- .../daisy/registry/api/v1/config_files.py | 10 +- .../daisy/registry/api/v1/config_sets.py | 10 +- code/daisy/daisy/registry/api/v1/configs.py | 10 +- .../daisy/daisy/registry/api/v1/disk_array.py | 32 +- code/daisy/daisy/registry/api/v1/hosts.py | 80 +- code/daisy/daisy/registry/api/v1/hwms.py | 710 ++++++++-------- code/daisy/daisy/registry/api/v1/members.py | 22 +- code/daisy/daisy/registry/api/v1/networks.py | 10 +- .../daisy/registry/api/v1/neutron_backend.py | 768 +++++++++--------- code/daisy/daisy/registry/api/v1/template.py | 25 +- .../daisy/registry/api/v1/template_configs.py | 12 +- .../daisy/registry/api/v1/template_funcs.py | 12 +- .../registry/api/v1/template_services.py | 10 +- .../daisy/registry/api/v1/version_patchs.py | 12 +- code/daisy/daisy/registry/api/v1/versions.py | 10 +- code/daisyclient/requirements.txt | 4 +- .../openstack/common/policy.py | 2 +- .../openstack_dashboard/policy_backend.py | 4 +- rpm/SPECS/openstack-ironic-discoverd.spec | 14 +- test/tempest/tempest/common/fixed_network.py | 8 +- test/tempest/tempest/common/isolated_creds.py | 28 +- 46 files changed, 1036 insertions(+), 1037 deletions(-) diff --git a/code/daisy/daisy/api/backends/kolla/api.py b/code/daisy/daisy/api/backends/kolla/api.py index 94f0bb31..c350a89b 100755 --- a/code/daisy/daisy/api/backends/kolla/api.py +++ b/code/daisy/daisy/api/backends/kolla/api.py @@ -113,7 +113,7 @@ class API(driver.DeploymentDriver): discover_host_meta) msg = (_("Do trustme.sh %s failed!" % discover_host_meta['ip'])) - LOG.warn(_(msg)) + LOG.warning(_(msg)) fp.write(msg) elif 'is unreachable' in trustme_result: # when host ip was unreachable @@ -126,7 +126,7 @@ class API(driver.DeploymentDriver): discover_host_meta) msg = (_("Do trustme.sh %s failed!" % discover_host_meta['ip'])) - LOG.warn(_(msg)) + LOG.warning(_(msg)) except subprocess.CalledProcessError as e: update_info = {} update_info['status'] = 'DISCOVERY_FAILED' diff --git a/code/daisy/daisy/api/backends/osinstall/pxe/install.py b/code/daisy/daisy/api/backends/osinstall/pxe/install.py index e307a6a3..fe707114 100755 --- a/code/daisy/daisy/api/backends/osinstall/pxe/install.py +++ b/code/daisy/daisy/api/backends/osinstall/pxe/install.py @@ -1204,7 +1204,7 @@ def upgrade(self, req, cluster_id, version_id, version_patch_id, target_host_os = _get_host_os_version( host_ip, host_meta['root_pwd']) 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 " "host %s, don't need to upgrade!" % host_ip)) 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: t.join() except: - LOG.warn(_("Join upgrade thread %s failed!" % t)) + LOG.warning(_("Join upgrade thread %s failed!" % t)) else: for host_info in upgrade_hosts: host = host_info.values()[0] diff --git a/code/daisy/daisy/api/middleware/context.py b/code/daisy/daisy/api/middleware/context.py index 112df404..d01e558f 100755 --- a/code/daisy/daisy/api/middleware/context.py +++ b/code/daisy/daisy/api/middleware/context.py @@ -51,7 +51,7 @@ class BaseContextMiddleware(wsgi.Middleware): try: request_id = resp.request.context.request_id except AttributeError: - LOG.warn(_('Unable to retrieve request id from context')) + LOG.warning(_('Unable to retrieve request id from context')) else: resp.headers['x-openstack-request-id'] = 'req-%s' % request_id return resp diff --git a/code/daisy/daisy/api/v1/clusters.py b/code/daisy/daisy/api/v1/clusters.py index d51b93ab..3cabae82 100755 --- a/code/daisy/daisy/api/v1/clusters.py +++ b/code/daisy/daisy/api/v1/clusters.py @@ -594,14 +594,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find cluster to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete cluster: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -609,7 +609,7 @@ class Controller(controller.BaseController): msg = (_("cluster %(id)s could not be deleted because " "it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -715,26 +715,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update cluster metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find cluster to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update cluster: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/api/v1/components.py b/code/daisy/daisy/api/v1/components.py index 791c3165..d41e81ae 100755 --- a/code/daisy/daisy/api/v1/components.py +++ b/code/daisy/daisy/api/v1/components.py @@ -156,14 +156,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find component to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete component: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -171,7 +171,7 @@ class Controller(controller.BaseController): msg = (_("component %(id)s could not be " "deleted because it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -246,26 +246,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update component metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find component to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update component: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/api/v1/config_files.py b/code/daisy/daisy/api/v1/config_files.py index 6bcde27d..f646b674 100755 --- a/code/daisy/daisy/api/v1/config_files.py +++ b/code/daisy/daisy/api/v1/config_files.py @@ -155,14 +155,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find config_file to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete config_file: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -170,7 +170,7 @@ class Controller(controller.BaseController): msg = (_("config_file %(id)s could not be " "deleted because it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -245,26 +245,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update config_file metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find config_file to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update config_file: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/api/v1/config_sets.py b/code/daisy/daisy/api/v1/config_sets.py index 9635e393..262725d4 100644 --- a/code/daisy/daisy/api/v1/config_sets.py +++ b/code/daisy/daisy/api/v1/config_sets.py @@ -161,12 +161,12 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find config_set to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: - LOG.warn(e) + LOG.warning(e) raise HTTPForbidden(explanation=e, request=req, content_type="text/plain") @@ -174,7 +174,7 @@ class Controller(controller.BaseController): msg = (_("config_set %(id)s could not be " "deleted because it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -249,26 +249,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update config_set metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find config_set to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update config_set: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/api/v1/configs.py b/code/daisy/daisy/api/v1/configs.py index fca3b17a..f27574d5 100755 --- a/code/daisy/daisy/api/v1/configs.py +++ b/code/daisy/daisy/api/v1/configs.py @@ -227,14 +227,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find config to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete config: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -242,7 +242,7 @@ class Controller(controller.BaseController): msg = (_("config %(id)s could not be " "deleted because it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") diff --git a/code/daisy/daisy/api/v1/deploy_server.py b/code/daisy/daisy/api/v1/deploy_server.py index c585e9e3..dfb2acd4 100755 --- a/code/daisy/daisy/api/v1/deploy_server.py +++ b/code/daisy/daisy/api/v1/deploy_server.py @@ -132,7 +132,7 @@ class Controller(controller.BaseController): % pxe_server_ip (status, output) = commands.getstatusoutput(if_addr_nic_cmd) if status: - LOG.warn("get_pxe_server_port error %s." % status) + LOG.warning("get_pxe_server_port error %s." % status) return return str(output).split(":")[0].split(".")[0] diff --git a/code/daisy/daisy/api/v1/disk_array.py b/code/daisy/daisy/api/v1/disk_array.py index f10cd46c..17070429 100755 --- a/code/daisy/daisy/api/v1/disk_array.py +++ b/code/daisy/daisy/api/v1/disk_array.py @@ -365,14 +365,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find service_disk to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete service_disk: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -380,7 +380,7 @@ class Controller(controller.BaseController): msg = (_("service_disk %(id)s could not be deleted " "because it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -398,26 +398,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update role metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find role to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update role: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') @@ -593,14 +593,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find cinder volume to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete cinder volume: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -608,7 +608,7 @@ class Controller(controller.BaseController): msg = (_("cindre volume %(id)s could not " "be deleted because it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -682,26 +682,26 @@ class Controller(controller.BaseController): msg = ( _("Failed to update cinder_volume metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find cinder_volume to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update cinder_volume: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') @@ -838,21 +838,21 @@ class Controller(controller.BaseController): msg = ( _("Failed to update optical_switch metadata. " "Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find optical_switch to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update cinder_volume: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -878,14 +878,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find optical switch to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete optical switch: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") diff --git a/code/daisy/daisy/api/v1/host_template.py b/code/daisy/daisy/api/v1/host_template.py index a935346a..c5a30b83 100755 --- a/code/daisy/daisy/api/v1/host_template.py +++ b/code/daisy/daisy/api/v1/host_template.py @@ -189,26 +189,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update template metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find host_template to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update host_template: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/api/v1/hosts.py b/code/daisy/daisy/api/v1/hosts.py index 01cfd9ba..0dd8d52b 100755 --- a/code/daisy/daisy/api/v1/hosts.py +++ b/code/daisy/daisy/api/v1/hosts.py @@ -198,7 +198,7 @@ class Controller(controller.BaseController): ether_nic_names_list: [name1, name2, ...] ''' 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: LOG.error('set(bond_slaves: %s' % set(bond_slaves)) msg = ( @@ -889,7 +889,7 @@ class Controller(controller.BaseController): "The nic name of interface [%s] with same mac," "please check!" % ",".join(same_mac_list)) - LOG.warn(msg) + LOG.warning(msg) # 1----------------------------------------------------------------- # if interface with same 'pci', raise exception @@ -1995,7 +1995,7 @@ class Controller(controller.BaseController): discover_host_meta) msg = (_("Do trustme.sh %s failed!" % discover_host_meta['ip'])) - LOG.warn(msg) + LOG.warning(msg) fp.write(msg) else: mac_info = re.search(r'"mac": ([^,\n]*)', exc_result) @@ -2112,7 +2112,7 @@ class Controller(controller.BaseController): for t in threads: t.join() except Exception: - LOG.warn(_("Join discover host thread %s failed!" % t)) + LOG.warning(_("Join discover host thread %s failed!" % t)) @utils.mutating def discover_host(self, req, host_meta): @@ -2154,7 +2154,7 @@ class Controller(controller.BaseController): :raises HTTPBadRequest if x-host-name is missing """ 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): msg = "IP parameter can not be None." LOG.error(msg) @@ -2418,7 +2418,7 @@ class Controller(controller.BaseController): :raises HTTPBadRequest if x-host-name is missing """ 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'): msg = "MAC parameter can not be None." LOG.error(msg) diff --git a/code/daisy/daisy/api/v1/install.py b/code/daisy/daisy/api/v1/install.py index 34a9bc79..9b2cec70 100755 --- a/code/daisy/daisy/api/v1/install.py +++ b/code/daisy/daisy/api/v1/install.py @@ -365,7 +365,7 @@ class Controller(controller.BaseController): os_install_thread.start() return {"status": "begin install"} 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} def _get_uninstall_hosts(self, req, install_meta): diff --git a/code/daisy/daisy/api/v1/members.py b/code/daisy/daisy/api/v1/members.py index 3067aeaa..167b6d53 100755 --- a/code/daisy/daisy/api/v1/members.py +++ b/code/daisy/daisy/api/v1/members.py @@ -76,11 +76,11 @@ class Controller(controller.BaseController): # req.context, cluster_id, host_id) # except exception.NotFound: # msg = _("Project with identifier %s not found") % cluster_id -# LOG.warn(msg) +# LOG.warning(msg) # raise webob.exc.HTTPNotFound(msg) # except exception.Forbidden: # msg = _("Unauthorized project access") -# LOG.warn(msg) +# LOG.warning(msg) # raise webob.exc.HTTPForbidden(msg) # return dict(members=members) diff --git a/code/daisy/daisy/api/v1/networks.py b/code/daisy/daisy/api/v1/networks.py index 9b2b2e84..c6232363 100755 --- a/code/daisy/daisy/api/v1/networks.py +++ b/code/daisy/daisy/api/v1/networks.py @@ -312,7 +312,7 @@ class Controller(controller.BaseController): msg = ( _("When ip range was specified, the CIDR parameter " "can not be empty.")) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(msg) else: ip_ranges = eval(network_meta['ip_ranges']) @@ -325,7 +325,7 @@ class Controller(controller.BaseController): msg = ( _("IP range was not start with 'start:' or " "end with 'end:'.")) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(msg) ip_start = ip_pair['start'] ip_end = ip_pair['end'] @@ -389,14 +389,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find network to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete network: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -404,7 +404,7 @@ class Controller(controller.BaseController): msg = (_("Network %(id)s could not be deleted " "because it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -604,7 +604,7 @@ class Controller(controller.BaseController): msg = ( _("When ip range was specified, " "the CIDR parameter can not be empty.")) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(msg) ip_ranges = eval(network_meta['ip_ranges']) if dataplane_type != 'DATAPLANE': @@ -614,7 +614,7 @@ class Controller(controller.BaseController): msg = ( _("IP range was not start with 'start:' or " "end with 'end:'.")) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(msg) ip_start = ip_pair['start'] ip_end = ip_pair['end'] @@ -637,22 +637,22 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update network metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find network to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: - LOG.warn(e) + LOG.warning(e) raise HTTPForbidden(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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/api/v1/roles.py b/code/daisy/daisy/api/v1/roles.py index af2a50fc..68eb4e91 100755 --- a/code/daisy/daisy/api/v1/roles.py +++ b/code/daisy/daisy/api/v1/roles.py @@ -193,7 +193,7 @@ class Controller(controller.BaseController): host_disk_size_m = host_disk_size_m + disk_size_m host_disk_except_os_disk_lists = host_disk_size_m - os_disk_m - \ swap_size_m - boot_partition_m - redundant_partiton_m - LOG.warn( + LOG.warning( '----start----host_disk_except_os_disk_lists: %s -----end--' % 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'] ''' disk_size = paras.get('disk_size', None) - LOG.warn('--------disk_size:----- %s' % disk_size) + LOG.warning('--------disk_size:----- %s' % disk_size) if disk_size: disk_size_m = int(disk_size) else: @@ -337,7 +337,7 @@ class Controller(controller.BaseController): else: argws['nova_lv_size'] = nova_lv_size argws['disk_size'] = host_disk_db_glance_nova_size['disk_size'] - LOG.warn( + LOG.warning( '--------host(%s) check_host_validity argws:----- %s' % (host_id, 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) else: host_disk_db_glance_nova_size['nova_lv_size'] = 0 - LOG.warn('--------host(%s)disk_db_glance_nova_size:----- %s' % - (host_id, host_disk_db_glance_nova_size)) + LOG.warning('--------host(%s)disk_db_glance_nova_size:----- %s' % + (host_id, 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): @@ -681,21 +681,21 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find role to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete role: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") except exception.InUseByStore as e: msg = (_("role %(id)s could not be deleted because it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -878,26 +878,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update role metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find role to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update role: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/api/v1/services.py b/code/daisy/daisy/api/v1/services.py index c51a012b..6fae03c2 100755 --- a/code/daisy/daisy/api/v1/services.py +++ b/code/daisy/daisy/api/v1/services.py @@ -160,14 +160,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find service to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete service: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -175,7 +175,7 @@ class Controller(controller.BaseController): msg = (_("service %(id)s could not be deleted " "because it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -250,26 +250,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update service metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find service to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update service: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/api/v1/template.py b/code/daisy/daisy/api/v1/template.py index 36255bb0..8c0f4708 100755 --- a/code/daisy/daisy/api/v1/template.py +++ b/code/daisy/daisy/api/v1/template.py @@ -163,26 +163,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update template metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find template to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update template: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/api/v1/version_patchs.py b/code/daisy/daisy/api/v1/version_patchs.py index 807274d1..c4eadeed 100755 --- a/code/daisy/daisy/api/v1/version_patchs.py +++ b/code/daisy/daisy/api/v1/version_patchs.py @@ -152,14 +152,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find version patch to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete version patch: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -167,7 +167,7 @@ class Controller(controller.BaseController): msg = (_("version patch %(id)s could not be deleted " "because it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -255,26 +255,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update version patch. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find version patch to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update version patch: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/api/v1/versions.py b/code/daisy/daisy/api/v1/versions.py index 07143083..a9081ff0 100644 --- a/code/daisy/daisy/api/v1/versions.py +++ b/code/daisy/daisy/api/v1/versions.py @@ -152,14 +152,14 @@ class Controller(controller.BaseController): except exception.NotFound as e: msg = (_("Failed to find version to delete: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to delete role: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") @@ -168,7 +168,7 @@ class Controller(controller.BaseController): _("version %(id)s could not be deleted because " "it is in use: " "%(exc)s") % {"id": id, "exc": utils.exception_to_str(e)}) - LOG.warn(msg) + LOG.warning(msg) raise HTTPConflict(explanation=msg, request=req, content_type="text/plain") @@ -241,26 +241,26 @@ class Controller(controller.BaseController): except exception.Invalid as e: msg = (_("Failed to update version metadata. Got error: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPBadRequest(explanation=msg, request=req, content_type="text/plain") except exception.NotFound as e: msg = (_("Failed to find version to update: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPNotFound(explanation=msg, request=req, content_type="text/plain") except exception.Forbidden as e: msg = (_("Forbidden to update version: %s") % utils.exception_to_str(e)) - LOG.warn(msg) + LOG.warning(msg) raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") 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'), request=req, content_type='text/plain') diff --git a/code/daisy/daisy/common/auth.py b/code/daisy/daisy/common/auth.py index f0ead1c3..4389c377 100755 --- a/code/daisy/daisy/common/auth.py +++ b/code/daisy/daisy/common/auth.py @@ -278,7 +278,7 @@ def get_endpoint(service_catalog, service_type='image', endpoint_region=None, s_type = service['type'] except KeyError: msg = _('Encountered service with no "type": %s') % s_type - LOG.warn(msg) + LOG.warning(msg) continue if s_type == service_type: diff --git a/code/daisy/daisy/common/utils.py b/code/daisy/daisy/common/utils.py index 10dfe326..405cdada 100755 --- a/code/daisy/daisy/common/utils.py +++ b/code/daisy/daisy/common/utils.py @@ -660,13 +660,13 @@ def validate_key_cert(key_file, cert_file): data = str(uuid.uuid4()) digest = CONF.digest_algorithm if digest == 'sha1': - LOG.warn('The FIPS (FEDERAL INFORMATION PROCESSING STANDARDS)' - ' state that the SHA-1 is not suitable for' - ' general-purpose digital signature applications (as' - ' specified in FIPS 186-3) that require 112 bits of' - ' security. The default value is sha1 in Kilo for a' - ' smooth upgrade process, and it will be updated' - ' with sha256 in next release(L).') + LOG.warning('The FIPS (FEDERAL INFORMATION PROCESSING STANDARDS)' + ' state that the SHA-1 is not suitable for' + ' general-purpose digital signature applications (as' + ' specified in FIPS 186-3) that require 112 bits of' + ' security. The default value is sha1 in Kilo for a' + ' smooth upgrade process, and it will be updated' + ' with sha256 in next release(L).') out = crypto.sign(key, data, digest) crypto.verify(cert, out, data, digest) except crypto.Error as ce: @@ -888,12 +888,12 @@ def valid_cidr(cidr): try: netmask_cidr = int(cidr_division[1]) except ValueError: - LOG.warn(netmask_err_msg) + LOG.warning(netmask_err_msg) raise exc.HTTPBadRequest(explanation=netmask_err_msg) if (netmask_cidr < 0 and netmask_cidr > 32): - LOG.warn(netmask_err_msg) + LOG.warning(netmask_err_msg) raise exc.HTTPBadRequest(explanation=netmask_err_msg) validate_ip_format(cidr_division[0]) diff --git a/code/daisy/daisy/common/wsgi.py b/code/daisy/daisy/common/wsgi.py index 44c95808..14b01ebf 100755 --- a/code/daisy/daisy/common/wsgi.py +++ b/code/daisy/daisy/common/wsgi.py @@ -315,7 +315,7 @@ class Server(object): self.stale_children.remove(pid) LOG.info(_LI('Removed stale child %s') % pid) else: - LOG.warn(_LW('Unrecognised child %s') % pid) + LOG.warning(_LW('Unrecognised child %s') % pid) def _verify_and_respawn_children(self, pid, status): if len(self.stale_children) == 0: diff --git a/code/daisy/daisy/db/sqlalchemy/api.py b/code/daisy/daisy/db/sqlalchemy/api.py index ba58fdb1..bf5e901f 100755 --- a/code/daisy/daisy/db/sqlalchemy/api.py +++ b/code/daisy/daisy/db/sqlalchemy/api.py @@ -72,7 +72,7 @@ def _retry_on_deadlock(exc): """Decorator to retry a DB API call if Deadlock was received.""" if isinstance(exc, db_exception.DBDeadlock): - LOG.warn(_LW("Deadlock detected. Retrying...")) + LOG.warning(_LW("Deadlock detected. Retrying...")) return True return False @@ -352,7 +352,7 @@ def check_ip_ranges(ip_ranges_one,available_ip_list): if inter_tmp > ip_ranges_end_inter: msg = "warning:The IP address assigned \ by IP ranges is already insufficient." - LOG.warn(msg) + LOG.warning(msg) break else: return [True, ip_tmp] @@ -3193,7 +3193,7 @@ def _paginate_query(query, model, limit, sort_keys, marker=None, if 'id' not in sort_keys: # TODO(justinsb): If this ever gives a false-positive, check # 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)) diff --git a/code/daisy/daisy/orchestration/manager.py b/code/daisy/daisy/orchestration/manager.py index 1ddfbbfa..b13d9238 100755 --- a/code/daisy/daisy/orchestration/manager.py +++ b/code/daisy/daisy/orchestration/manager.py @@ -49,11 +49,11 @@ class OrchestrationManager(): host_list = [host for host in host_list_generator if hasattr( host, "role_status") and host.role_status == "active"] 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 if host.discover_mode == "PXE"] 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: host_info = daisy_client.hosts.get(host.id) 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.dvs_config_type = active_compute_host.dvs_config_type else: - LOG.warn("No installed active computer node in cluster") + LOG.warning("No installed active computer node in cluster") return None if active_compute_host: @@ -144,19 +144,19 @@ class OrchestrationManager(): if new_interface_count != compute_interface_count: msg = "%s and new host interface number are different" %\ (compute_host.name) - LOG.warn(msg) + LOG.warning(msg) continue if host_info.cpu['total'] != compute_host.cpu['total']: msg = "%s and new host cpu total numbers are different" %\ (compute_host.name) - LOG.warn(msg) + LOG.warning(msg) continue compute_numa_cpus = utils.get_numa_node_cpus( (compute_host.cpu or {})) if compute_numa_cpus != host_numa_cpus: msg = "%s and new host numa cpus are different" %\ compute_host.name - LOG.warn(msg) + LOG.warning(msg) continue active_compu_memory_str = str(compute_host.memory['total']) active_compu_memory_size =\ @@ -164,7 +164,7 @@ class OrchestrationManager(): # host memory can't be lower than the installed host memory size-1G if memory_size_b_int < active_compu_memory_size - 1024 * 1024: msg = "new host memory is lower than %s" % compute_host.name - LOG.warn(msg) + LOG.warning(msg) continue is_isomorphic = self._check_interface_isomorphic( new_interfaces, compute_host) @@ -190,13 +190,13 @@ class OrchestrationManager(): and (interface['max_speed'] != max_speed): msg = "%s and new host %s max speed are different" \ % (active_host.name, interface['name']) - LOG.warn(msg) + LOG.warning(msg) return False elif (interface['name'] == compute_interface['name']) and\ (interface['pci'] != compute_interface['pci']): msg = "%s and new host %s pci are different" \ % (active_host.name, interface['name']) - LOG.warn(msg) + LOG.warning(msg) return False if not is_isomorphic: return False diff --git a/code/daisy/daisy/registry/api/v1/config_files.py b/code/daisy/daisy/registry/api/v1/config_files.py index 2d5682cf..aed7a82d 100755 --- a/code/daisy/daisy/registry/api/v1/config_files.py +++ b/code/daisy/daisy/registry/api/v1/config_files.py @@ -62,13 +62,13 @@ class Controller(object): return self.db_api.config_file_get_all(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Config_file %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. Config_file %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Config_file could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to config_file %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to config_file %(id)s but returned " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. config_file could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -251,7 +251,7 @@ class Controller(object): except exception.Duplicate: msg = _("config_file with identifier %s already exists!") % \ config_file_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add config_file metadata. " diff --git a/code/daisy/daisy/registry/api/v1/config_sets.py b/code/daisy/daisy/registry/api/v1/config_sets.py index 369fb466..efa97a3c 100755 --- a/code/daisy/daisy/registry/api/v1/config_sets.py +++ b/code/daisy/daisy/registry/api/v1/config_sets.py @@ -62,13 +62,13 @@ class Controller(object): return self.db_api.config_set_get_all(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Config_set %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. Config_set %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Config_set could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to config_set %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to config_set %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. config_set could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -251,7 +251,7 @@ class Controller(object): except exception.Duplicate: msg = _("config_set with identifier %s already exists!") % \ config_set_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add config_set metadata. " diff --git a/code/daisy/daisy/registry/api/v1/configs.py b/code/daisy/daisy/registry/api/v1/configs.py index 50d8e834..d66e6e0c 100755 --- a/code/daisy/daisy/registry/api/v1/configs.py +++ b/code/daisy/daisy/registry/api/v1/configs.py @@ -62,13 +62,13 @@ class Controller(object): return self.db_api.config_get_all(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Config %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. Config %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Config could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to config %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to config %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. config could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -248,7 +248,7 @@ class Controller(object): return config_data except exception.Duplicate: msg = _("config with identifier %s already exists!") % config_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add config metadata. " diff --git a/code/daisy/daisy/registry/api/v1/disk_array.py b/code/daisy/daisy/registry/api/v1/disk_array.py index 5decf76e..aebd4e71 100755 --- a/code/daisy/daisy/registry/api/v1/disk_array.py +++ b/code/daisy/daisy/registry/api/v1/disk_array.py @@ -233,7 +233,7 @@ class Controller(object): return service_disk_data except exception.Duplicate: msg = _("node with identifier %s already exists!") % id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add node metadata. " @@ -359,13 +359,13 @@ class Controller(object): return self.db_api.service_disk_list(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. service_disk %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. service_disk %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. service_disk could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to service_disk %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied service_disk %(id)s but returned " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. service_disk could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -431,7 +431,7 @@ class Controller(object): return cinder_volume_data except exception.Duplicate: msg = _("cinder_volume with identifier %s already exists!") % id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add cinder_volume metadata. " @@ -565,13 +565,13 @@ class Controller(object): return self.db_api.cinder_volume_list(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. cinder_volume %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker.cinder_volume %(id)s not " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. cinder_volume could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to cinder_volume %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied cinder_volume %(id)s but returned " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. cinder_volume could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -584,16 +584,16 @@ class Controller(object): return self.db_api.optical_switch_list(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. optical switch %(id)s " - "could not be found.") % - {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. optical switch %(id)s " + "could not be found.") % + {'id': params.get('marker')}) msg = _("Invalid marker. optical switch " "could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to optical_switch %(id)s " - "but returning 'not found'") % - {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to optical_switch %(id)s " + "but returning 'not found'") % + {'id': params.get('marker')}) msg = _("Invalid marker. optical_switch " "could not be found.") raise exc.HTTPBadRequest(explanation=msg) diff --git a/code/daisy/daisy/registry/api/v1/hosts.py b/code/daisy/daisy/registry/api/v1/hosts.py index 62b73b96..78dd3cb5 100755 --- a/code/daisy/daisy/registry/api/v1/hosts.py +++ b/code/daisy/daisy/registry/api/v1/hosts.py @@ -70,13 +70,13 @@ class Controller(object): return self.db_api.host_get_all(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Host %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. Host %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Host could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to host %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to host %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. Host could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -89,13 +89,13 @@ class Controller(object): return self.db_api.cluster_get_all(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Cluster %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. Cluster %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Cluster could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to cluster %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to cluster %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. Cluster could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -307,7 +307,7 @@ class Controller(object): return host_data except exception.Duplicate: msg = _("node with identifier %s already exists!") % host_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add node metadata. " @@ -514,13 +514,13 @@ class Controller(object): req.context, filters) return host_interfaces except exception.NotFound: - LOG.warn(_LW("Invalid marker. template %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. template %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. template could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to template %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to template %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. template could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -535,16 +535,16 @@ class Controller(object): req.context, interface_id, network_id) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Assigned_network with interface %(" - "interface_id)s and network %(network_id)s" - " could not be found.") % { + LOG.warning(_LW("Invalid marker.Assigned_network with if %(" + "interface_id)s and network %(network_id)s" + " could not be found.") % { 'interface_id': interface_id, 'network_id': network_id}) msg = _("Invalid marker. Assigned_network could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied for assigned_network with interface %(" - "interface_id)s " - "and network %(network_id)s") % { + LOG.warning(_LW("Access denied for assigned_network with if %(" + "interface_id)s " + "and network %(network_id)s") % { 'interface_id': interface_id, 'network_id': network_id}) msg = _("Invalid marker. Assigned_network denied to get.") raise exc.HTTPBadRequest(explanation=msg) @@ -592,7 +592,7 @@ class Controller(object): except exception.Duplicate: msg = _("node with identifier %s already exists!") % \ discover_host_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add node metadata. " @@ -646,13 +646,13 @@ class Controller(object): nodes = self.db_api.discover_host_get_all(req.context, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Host %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. Host %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Host could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to host %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to host %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. Host could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -787,7 +787,7 @@ class Controller(object): return cluster_data except exception.Duplicate: msg = _("cluster with identifier %s already exists!") % cluster_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add cluster metadata. " @@ -974,7 +974,7 @@ class Controller(object): except exception.Duplicate: msg = (_("component with identifier %s already exists!") % component_id) - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add component metadata. " @@ -1025,13 +1025,13 @@ class Controller(object): return self.db_api.component_get_all(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Project %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. Project %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Project could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to component %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to component %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. Project could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -1168,7 +1168,7 @@ class Controller(object): return service_data except exception.Duplicate: msg = _("service with identifier %s already exists!") % service_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add service metadata. " @@ -1219,13 +1219,13 @@ class Controller(object): return self.db_api.service_get_all(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Project %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. Project %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Project could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to service %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to service %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. Project could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -1362,7 +1362,7 @@ class Controller(object): return role_data except exception.Duplicate: msg = _("role with identifier %s already exists!") % role_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add role metadata. " @@ -1413,13 +1413,13 @@ class Controller(object): return self.db_api.role_get_all(context, filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Project %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. Project %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Project could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to role %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to role %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. Project could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: diff --git a/code/daisy/daisy/registry/api/v1/hwms.py b/code/daisy/daisy/registry/api/v1/hwms.py index d39b04a7..9f57f7b7 100644 --- a/code/daisy/daisy/registry/api/v1/hwms.py +++ b/code/daisy/daisy/registry/api/v1/hwms.py @@ -1,355 +1,355 @@ -# Copyright 2010-2011 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Reference implementation registry server WSGI controller -""" - -from oslo_config import cfg -from oslo_log import log as logging -from oslo_utils import strutils -from oslo_utils import timeutils -from webob import exc - -from daisy.common import exception -from daisy.common import utils -from daisy.common import wsgi -import daisy.db -from daisy import i18n - - -LOG = logging.getLogger(__name__) -_ = i18n._ -_LE = i18n._LE -_LI = i18n._LI -_LW = i18n._LW -CONF = cfg.CONF -DISPLAY_FIELDS_IN_INDEX = ['id', 'description'] -SUPPORTED_FILTERS = ['name', 'description'] -SUPPORTED_SORT_KEYS = ('name', 'description''id', 'created_at', 'updated_at') -SUPPORTED_SORT_DIRS = ('asc', 'desc') -SUPPORTED_PARAMS = ('limit', 'marker', 'sort_key', 'sort_dir', 'name', - 'description') - - -class Controller(object): - - def __init__(self): - self.db_api = daisy.db.get_api() - - def _get_query_params(self, req): - """Extract necessary query parameters from http request. - - :param req: the Request object coming from the wsgi layer - :retval dictionary of filters to apply to list of templates - """ - params = { - 'filters': self._get_filters(req), - 'limit': self._get_limit(req), - 'sort_key': [self._get_sort_key(req)], - 'sort_dir': [self._get_sort_dir(req)], - 'marker': self._get_marker(req), - } - - for key, value in params.items(): - if value is None: - del params[key] - - return params - - def _get_filters(self, req): - """Return a dictionary of query param filters from the request - - :param req: the Request object coming from the wsgi layer - :retval a dict of key/value filters - """ - filters = {} - properties = {} - - for param in req.params: - if param in SUPPORTED_FILTERS: - filters[param] = req.params.get(param) - if param.startswith('property-'): - _param = param[9:] - properties[_param] = req.params.get(param) - - if 'changes-since' in filters: - isotime = filters['changes-since'] - try: - filters['changes-since'] = timeutils.parse_isotime(isotime) - except ValueError: - raise exc.HTTPBadRequest(_("Unrecognized changes-since value")) - - if 'protected' in filters: - value = self._get_bool(filters['protected']) - if value is None: - raise exc.HTTPBadRequest(_("protected must be True, or " - "False")) - - filters['protected'] = value - - # only allow admins to filter on 'deleted' - if req.context.is_admin: - deleted_filter = self._parse_deleted_filter(req) - if deleted_filter is not None: - filters['deleted'] = deleted_filter - elif 'changes-since' not in filters: - filters['deleted'] = False - elif 'changes-since' not in filters: - filters['deleted'] = False - - if properties: - filters['properties'] = properties - - return filters - - def _get_limit(self, req): - """Parse a limit query param into something usable.""" - try: - limit = int(req.params.get('limit', CONF.limit_param_default)) - except ValueError: - raise exc.HTTPBadRequest(_("limit param must be an integer")) - - if limit < 0: - raise exc.HTTPBadRequest(_("limit param must be positive")) - - return min(CONF.api_limit_max, limit) - - def _get_marker(self, req): - """Parse a marker query param into something usable.""" - marker = req.params.get('marker', None) - - if marker and not utils.is_uuid_like(marker): - msg = _('Invalid marker format') - raise exc.HTTPBadRequest(explanation=msg) - - return marker - - def _get_sort_key(self, req): - """Parse a sort key query param from the request object.""" - sort_key = req.params.get('sort_key', 'created_at') - if sort_key is not None and sort_key not in SUPPORTED_SORT_KEYS: - _keys = ', '.join(SUPPORTED_SORT_KEYS) - msg = _("Unsupported sort_key. Acceptable values: %s") % (_keys,) - raise exc.HTTPBadRequest(explanation=msg) - return sort_key - - def _get_sort_dir(self, req): - """Parse a sort direction query param from the request object.""" - sort_dir = req.params.get('sort_dir', 'desc') - if sort_dir is not None and sort_dir not in SUPPORTED_SORT_DIRS: - _keys = ', '.join(SUPPORTED_SORT_DIRS) - msg = _("Unsupported sort_dir. Acceptable values: %s") % (_keys,) - raise exc.HTTPBadRequest(explanation=msg) - return sort_dir - - def _get_bool(self, value): - value = value.lower() - if value == 'true' or value == '1': - return True - elif value == 'false' or value == '0': - return False - - return None - - def _parse_deleted_filter(self, req): - """Parse deleted into something usable.""" - deleted = req.params.get('deleted') - if deleted is None: - return None - return strutils.bool_from_string(deleted) - - @utils.mutating - def add_hwm(self, req, body): - """Registers a new hwm with the registry. - - :param req: wsgi Request object - :param body: Dictionary of information about the templatae - - :retval Returns the newly-created template information as a mapping, - which will include the newly-created template's internal id - in the 'id' field - """ - hwm_data = body["hwm"] - id = hwm_data.get('id') - - if id and not utils.is_uuid_like(id): - msg = _LI("Rejecting hwm creation request for invalid hwm " - "id '%(bad_id)s'") % {'bad_id': id} - LOG.info(msg) - msg = _("Invalid hwm id format") - return exc.HTTPBadRequest(explanation=msg) - - try: - hwm_data = self.db_api.hwm_add(req.context, hwm_data) - msg = (_LI("Successfully created hwm %s") % - hwm_data["id"]) - LOG.info(msg) - if 'hwm' not in hwm_data: - hwm_data = dict(hwm=hwm_data) - return hwm_data - except exception.Duplicate: - msg = _("hwm with identifier %s already exists!") % id - LOG.warn(msg) - return exc.HTTPConflict(msg) - except exception.Invalid as e: - msg = (_("Failed to add hwm metadata. " - "Got error: %s") % utils.exception_to_str(e)) - LOG.error(msg) - return exc.HTTPBadRequest(msg) - except Exception: - LOG.exception(_LE("Unable to create hwm %s"), id) - raise - - @utils.mutating - def update_hwm(self, req, id, body): - """Registers a new hwm with the registry. - - :param req: wsgi Request object - :param body: Dictionary of information about the template - - :retval Returns the newly-created template information as a mapping, - which will include the newly-created template's internal id - in the 'id' field - """ - hwm_data = body["hwm"] - if id and not utils.is_uuid_like(id): - msg = _LI("Rejecting cluster hwm creation request for invalid " - "hwm id '%(bad_id)s'") % {'bad_id': id} - LOG.info(msg) - msg = _("Invalid hwm id format") - return exc.HTTPBadRequest(explanation=msg) - - try: - hwm_data = self.db_api.hwm_update(req.context, id, hwm_data) - msg = (_LI("Successfully updated hwm %s") % - hwm_data["id"]) - LOG.info(msg) - if 'hwm' not in hwm_data: - hwm_data = dict(hwm=hwm_data) - return hwm_data - except exception.Duplicate: - msg = _("hwm with identifier %s already exists!") % id - LOG.warn(msg) - return exc.HTTPConflict(msg) - except exception.Invalid as e: - msg = (_("Failed to update hwm metadata.Got error: %s") % - utils.exception_to_str(e)) - LOG.error(msg) - return exc.HTTPBadRequest(msg) - except Exception: - LOG.exception(_LE("Unable to update hwm %s"), id) - raise - - @utils.mutating - def delete_hwm(self, req, id): - """Registers a new hwm with the registry. - - :param req: wsgi Request object - :param body: Dictionary of information about the template - - :retval Returns the newly-created template information as a mapping, - which will include the newly-created template's internal id - in the 'id' field - """ - if id and not utils.is_uuid_like(id): - msg = _LI("Rejecting hwm delete request for invalid hwm " - "id '%(bad_id)s'") % {'bad_id': id} - LOG.info(msg) - msg = _("Invalid hwm id format") - return exc.HTTPBadRequest(explanation=msg) - - try: - hwm_data = self.db_api.hwm_destroy(req.context, id) - msg = (_LI("Successfully deleted hwm %s") % id) - LOG.info(msg) - if 'hwm' not in hwm_data: - hwm_data = dict(hwm=hwm_data) - return hwm_data - except exception.Invalid as e: - msg = (_("Failed to delete hwm metadata. " - "Got error: %s") % utils.exception_to_str(e)) - LOG.error(msg) - return exc.HTTPBadRequest(msg) - except Exception: - LOG.exception(_LE("Unable to delete hwm %s"), id) - raise - - @utils.mutating - def hwm_list(self, req): - params = self._get_query_params(req) - try: - filters = params.pop('filters') - marker = params.get('marker') - limit = params.get('limit') - sort_key = params.get('sort_key') - sort_dir = params.get('sort_dir') - return self.db_api.hwm_get_all( - req.context, filters=filters, marker=marker, limit=limit, - sort_key=sort_key, sort_dir=sort_dir) - except exception.NotFound: - LOG.warn(_LW("Invalid marker. hwm %(id)s could not be " - "found.") % {'id': params.get('marker')}) - msg = _("Invalid marker. hwm could not be found.") - raise exc.HTTPBadRequest(explanation=msg) - except exception.Forbidden: - LOG.warn(_LW("Access denied to hwm %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) - msg = _("Invalid marker. hwm could not be found.") - raise exc.HTTPBadRequest(explanation=msg) - except Exception: - LOG.exception(_LE("Unable to list hwm")) - raise - - @utils.mutating - def detail(self, req, id): - """Registers a new hwm with the registry. - - :param req: wsgi Request object - :param body: Dictionary of information about the template - - :retval Returns the newly-created template information as a mapping, - which will include the newly-created template's internal id - in the 'id' field - """ - if id and not utils.is_uuid_like(id): - msg = _LI("Rejecting hwm delete request for invalid hwm " - "id '%(bad_id)s'") % {'bad_id': id} - LOG.info(msg) - msg = _("Invalid hwm id format") - return exc.HTTPBadRequest(explanation=msg) - - try: - hwm_data = self.db_api.hwm_get(req.context, id) - msg = (_LI("Successfully get hwm information:%s") % id) - LOG.info(msg) - if 'hwm' not in hwm_data: - hwm_data = dict(hwm=hwm_data) - return hwm_data - except exception.Invalid as e: - msg = (_("Failed to get hwm metadata. Got error: %s") % - utils.exception_to_str(e)) - LOG.error(msg) - return exc.HTTPBadRequest(msg) - except Exception: - LOG.exception(_LE("Unable to get hwm %s"), id) - raise - - -def create_resource(): - """Hwms resource factory method.""" - deserializer = wsgi.JSONRequestDeserializer() - serializer = wsgi.JSONResponseSerializer() - return wsgi.Resource(Controller(), deserializer, serializer) +# Copyright 2010-2011 OpenStack Foundation +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" +Reference implementation registry server WSGI controller +""" + +from oslo_config import cfg +from oslo_log import log as logging +from oslo_utils import strutils +from oslo_utils import timeutils +from webob import exc + +from daisy.common import exception +from daisy.common import utils +from daisy.common import wsgi +import daisy.db +from daisy import i18n + + +LOG = logging.getLogger(__name__) +_ = i18n._ +_LE = i18n._LE +_LI = i18n._LI +_LW = i18n._LW +CONF = cfg.CONF +DISPLAY_FIELDS_IN_INDEX = ['id', 'description'] +SUPPORTED_FILTERS = ['name', 'description'] +SUPPORTED_SORT_KEYS = ('name', 'description''id', 'created_at', 'updated_at') +SUPPORTED_SORT_DIRS = ('asc', 'desc') +SUPPORTED_PARAMS = ('limit', 'marker', 'sort_key', 'sort_dir', 'name', + 'description') + + +class Controller(object): + + def __init__(self): + self.db_api = daisy.db.get_api() + + def _get_query_params(self, req): + """Extract necessary query parameters from http request. + + :param req: the Request object coming from the wsgi layer + :retval dictionary of filters to apply to list of templates + """ + params = { + 'filters': self._get_filters(req), + 'limit': self._get_limit(req), + 'sort_key': [self._get_sort_key(req)], + 'sort_dir': [self._get_sort_dir(req)], + 'marker': self._get_marker(req), + } + + for key, value in params.items(): + if value is None: + del params[key] + + return params + + def _get_filters(self, req): + """Return a dictionary of query param filters from the request + + :param req: the Request object coming from the wsgi layer + :retval a dict of key/value filters + """ + filters = {} + properties = {} + + for param in req.params: + if param in SUPPORTED_FILTERS: + filters[param] = req.params.get(param) + if param.startswith('property-'): + _param = param[9:] + properties[_param] = req.params.get(param) + + if 'changes-since' in filters: + isotime = filters['changes-since'] + try: + filters['changes-since'] = timeutils.parse_isotime(isotime) + except ValueError: + raise exc.HTTPBadRequest(_("Unrecognized changes-since value")) + + if 'protected' in filters: + value = self._get_bool(filters['protected']) + if value is None: + raise exc.HTTPBadRequest(_("protected must be True, or " + "False")) + + filters['protected'] = value + + # only allow admins to filter on 'deleted' + if req.context.is_admin: + deleted_filter = self._parse_deleted_filter(req) + if deleted_filter is not None: + filters['deleted'] = deleted_filter + elif 'changes-since' not in filters: + filters['deleted'] = False + elif 'changes-since' not in filters: + filters['deleted'] = False + + if properties: + filters['properties'] = properties + + return filters + + def _get_limit(self, req): + """Parse a limit query param into something usable.""" + try: + limit = int(req.params.get('limit', CONF.limit_param_default)) + except ValueError: + raise exc.HTTPBadRequest(_("limit param must be an integer")) + + if limit < 0: + raise exc.HTTPBadRequest(_("limit param must be positive")) + + return min(CONF.api_limit_max, limit) + + def _get_marker(self, req): + """Parse a marker query param into something usable.""" + marker = req.params.get('marker', None) + + if marker and not utils.is_uuid_like(marker): + msg = _('Invalid marker format') + raise exc.HTTPBadRequest(explanation=msg) + + return marker + + def _get_sort_key(self, req): + """Parse a sort key query param from the request object.""" + sort_key = req.params.get('sort_key', 'created_at') + if sort_key is not None and sort_key not in SUPPORTED_SORT_KEYS: + _keys = ', '.join(SUPPORTED_SORT_KEYS) + msg = _("Unsupported sort_key. Acceptable values: %s") % (_keys,) + raise exc.HTTPBadRequest(explanation=msg) + return sort_key + + def _get_sort_dir(self, req): + """Parse a sort direction query param from the request object.""" + sort_dir = req.params.get('sort_dir', 'desc') + if sort_dir is not None and sort_dir not in SUPPORTED_SORT_DIRS: + _keys = ', '.join(SUPPORTED_SORT_DIRS) + msg = _("Unsupported sort_dir. Acceptable values: %s") % (_keys,) + raise exc.HTTPBadRequest(explanation=msg) + return sort_dir + + def _get_bool(self, value): + value = value.lower() + if value == 'true' or value == '1': + return True + elif value == 'false' or value == '0': + return False + + return None + + def _parse_deleted_filter(self, req): + """Parse deleted into something usable.""" + deleted = req.params.get('deleted') + if deleted is None: + return None + return strutils.bool_from_string(deleted) + + @utils.mutating + def add_hwm(self, req, body): + """Registers a new hwm with the registry. + + :param req: wsgi Request object + :param body: Dictionary of information about the templatae + + :retval Returns the newly-created template information as a mapping, + which will include the newly-created template's internal id + in the 'id' field + """ + hwm_data = body["hwm"] + id = hwm_data.get('id') + + if id and not utils.is_uuid_like(id): + msg = _LI("Rejecting hwm creation request for invalid hwm " + "id '%(bad_id)s'") % {'bad_id': id} + LOG.info(msg) + msg = _("Invalid hwm id format") + return exc.HTTPBadRequest(explanation=msg) + + try: + hwm_data = self.db_api.hwm_add(req.context, hwm_data) + msg = (_LI("Successfully created hwm %s") % + hwm_data["id"]) + LOG.info(msg) + if 'hwm' not in hwm_data: + hwm_data = dict(hwm=hwm_data) + return hwm_data + except exception.Duplicate: + msg = _("hwm with identifier %s already exists!") % id + LOG.warning(msg) + return exc.HTTPConflict(msg) + except exception.Invalid as e: + msg = (_("Failed to add hwm metadata. " + "Got error: %s") % utils.exception_to_str(e)) + LOG.error(msg) + return exc.HTTPBadRequest(msg) + except Exception: + LOG.exception(_LE("Unable to create hwm %s"), id) + raise + + @utils.mutating + def update_hwm(self, req, id, body): + """Registers a new hwm with the registry. + + :param req: wsgi Request object + :param body: Dictionary of information about the template + + :retval Returns the newly-created template information as a mapping, + which will include the newly-created template's internal id + in the 'id' field + """ + hwm_data = body["hwm"] + if id and not utils.is_uuid_like(id): + msg = _LI("Rejecting cluster hwm creation request for invalid " + "hwm id '%(bad_id)s'") % {'bad_id': id} + LOG.info(msg) + msg = _("Invalid hwm id format") + return exc.HTTPBadRequest(explanation=msg) + + try: + hwm_data = self.db_api.hwm_update(req.context, id, hwm_data) + msg = (_LI("Successfully updated hwm %s") % + hwm_data["id"]) + LOG.info(msg) + if 'hwm' not in hwm_data: + hwm_data = dict(hwm=hwm_data) + return hwm_data + except exception.Duplicate: + msg = _("hwm with identifier %s already exists!") % id + LOG.warning(msg) + return exc.HTTPConflict(msg) + except exception.Invalid as e: + msg = (_("Failed to update hwm metadata.Got error: %s") % + utils.exception_to_str(e)) + LOG.error(msg) + return exc.HTTPBadRequest(msg) + except Exception: + LOG.exception(_LE("Unable to update hwm %s"), id) + raise + + @utils.mutating + def delete_hwm(self, req, id): + """Registers a new hwm with the registry. + + :param req: wsgi Request object + :param body: Dictionary of information about the template + + :retval Returns the newly-created template information as a mapping, + which will include the newly-created template's internal id + in the 'id' field + """ + if id and not utils.is_uuid_like(id): + msg = _LI("Rejecting hwm delete request for invalid hwm " + "id '%(bad_id)s'") % {'bad_id': id} + LOG.info(msg) + msg = _("Invalid hwm id format") + return exc.HTTPBadRequest(explanation=msg) + + try: + hwm_data = self.db_api.hwm_destroy(req.context, id) + msg = (_LI("Successfully deleted hwm %s") % id) + LOG.info(msg) + if 'hwm' not in hwm_data: + hwm_data = dict(hwm=hwm_data) + return hwm_data + except exception.Invalid as e: + msg = (_("Failed to delete hwm metadata. " + "Got error: %s") % utils.exception_to_str(e)) + LOG.error(msg) + return exc.HTTPBadRequest(msg) + except Exception: + LOG.exception(_LE("Unable to delete hwm %s"), id) + raise + + @utils.mutating + def hwm_list(self, req): + params = self._get_query_params(req) + try: + filters = params.pop('filters') + marker = params.get('marker') + limit = params.get('limit') + sort_key = params.get('sort_key') + sort_dir = params.get('sort_dir') + return self.db_api.hwm_get_all( + req.context, filters=filters, marker=marker, limit=limit, + sort_key=sort_key, sort_dir=sort_dir) + except exception.NotFound: + LOG.warning(_LW("Invalid marker. hwm %(id)s could not be " + "found.") % {'id': params.get('marker')}) + msg = _("Invalid marker. hwm could not be found.") + raise exc.HTTPBadRequest(explanation=msg) + except exception.Forbidden: + LOG.warning(_LW("Access denied to hwm %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) + msg = _("Invalid marker. hwm could not be found.") + raise exc.HTTPBadRequest(explanation=msg) + except Exception: + LOG.exception(_LE("Unable to list hwm")) + raise + + @utils.mutating + def detail(self, req, id): + """Registers a new hwm with the registry. + + :param req: wsgi Request object + :param body: Dictionary of information about the template + + :retval Returns the newly-created template information as a mapping, + which will include the newly-created template's internal id + in the 'id' field + """ + if id and not utils.is_uuid_like(id): + msg = _LI("Rejecting hwm delete request for invalid hwm " + "id '%(bad_id)s'") % {'bad_id': id} + LOG.info(msg) + msg = _("Invalid hwm id format") + return exc.HTTPBadRequest(explanation=msg) + + try: + hwm_data = self.db_api.hwm_get(req.context, id) + msg = (_LI("Successfully get hwm information:%s") % id) + LOG.info(msg) + if 'hwm' not in hwm_data: + hwm_data = dict(hwm=hwm_data) + return hwm_data + except exception.Invalid as e: + msg = (_("Failed to get hwm metadata. Got error: %s") % + utils.exception_to_str(e)) + LOG.error(msg) + return exc.HTTPBadRequest(msg) + except Exception: + LOG.exception(_LE("Unable to get hwm %s"), id) + raise + + +def create_resource(): + """Hwms resource factory method.""" + deserializer = wsgi.JSONRequestDeserializer() + serializer = wsgi.JSONResponseSerializer() + return wsgi.Resource(Controller(), deserializer, serializer) diff --git a/code/daisy/daisy/registry/api/v1/members.py b/code/daisy/daisy/registry/api/v1/members.py index d70d4495..f27be873 100755 --- a/code/daisy/daisy/registry/api/v1/members.py +++ b/code/daisy/daisy/registry/api/v1/members.py @@ -42,14 +42,14 @@ class Controller(object): self.db_api.cluster_get(req.context, cluster_id) except exception.NotFound: msg = _("Project %(id)s not found") % {'id': cluster_id} - LOG.warn(msg) + LOG.warning(msg) raise webob.exc.HTTPNotFound(msg) except exception.Forbidden: # If it's private and doesn't belong to them, don't let on # that it exists msg = _LW("Access denied to cluster %(id)s but returning" " 'not found'") % {'id': cluster_id} - LOG.warn(msg) + LOG.warning(msg) raise webob.exc.HTTPNotFound() members = self.db_api.cluster_host_member_find( @@ -70,14 +70,14 @@ class Controller(object): self.db_api.cluster_get(req.context, cluster_id) except exception.NotFound: msg = _("Project %(id)s not found") % {'id': cluster_id} - LOG.warn(msg) + LOG.warning(msg) raise webob.exc.HTTPNotFound(msg) except exception.Forbidden: # If it's private and doesn't belong to them, don't let on # that it exists msg = _LW("Access denied to cluster %(id)s but returning" " 'not found'") % {'id': cluster_id} - LOG.warn(msg) + LOG.warning(msg) raise webob.exc.HTTPNotFound() # Make sure the host exists @@ -85,14 +85,14 @@ class Controller(object): self.db_api.host_get(req.context, host_id) except exception.NotFound: msg = _("Host %(id)s not found") % {'id': host_id} - LOG.warn(msg) + LOG.warning(msg) raise webob.exc.HTTPNotFound(msg) except exception.Forbidden: # If it's private and doesn't belong to them, don't let on # that it exists msg = _LW("Access denied to host %(id)s but returning" " 'not found'") % {'id': host_id} - LOG.warn(msg) + LOG.warning(msg) raise webob.exc.HTTPNotFound() # Look up an existing membership... @@ -123,14 +123,14 @@ class Controller(object): self.db_api.cluster_get(req.context, cluster_id) except exception.NotFound: msg = _("Project %(id)s not found") % {'id': cluster_id} - LOG.warn(msg) + LOG.warning(msg) raise webob.exc.HTTPNotFound(msg) except exception.Forbidden: # If it's private and doesn't belong to them, don't let on # that it exists msg = _LW("Access denied to cluster %(id)s but returning" " 'not found'") % {'id': cluster_id} - LOG.warn(msg) + LOG.warning(msg) raise webob.exc.HTTPNotFound() # Make sure the host exists @@ -138,14 +138,14 @@ class Controller(object): self.db_api.host_get(req.context, host_id) except exception.NotFound: msg = _("Host %(id)s not found") % {'id': host_id} - LOG.warn(msg) + LOG.warning(msg) raise webob.exc.HTTPNotFound(msg) except exception.Forbidden: # If it's private and doesn't belong to them, don't let on # that it exists msg = _LW("Access denied to host %(id)s but returning" " 'not found'") % {'id': host_id} - LOG.warn(msg) + LOG.warning(msg) raise webob.exc.HTTPNotFound() # Look up an existing membership @@ -185,7 +185,7 @@ class Controller(object): req.context, host_id=host_id) except exception.NotFound: msg = _LW("Host %(id)s not found") % {'id': host_id} - LOG.warn(msg) + LOG.warning(msg) msg = _("Membership could not be found.") raise webob.exc.HTTPBadRequest(explanation=msg) diff --git a/code/daisy/daisy/registry/api/v1/networks.py b/code/daisy/daisy/registry/api/v1/networks.py index 2aa2f8ea..24eecca0 100755 --- a/code/daisy/daisy/registry/api/v1/networks.py +++ b/code/daisy/daisy/registry/api/v1/networks.py @@ -66,13 +66,13 @@ class Controller(object): filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. Network %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. Network %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Network could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to network %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to network %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. Network could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -274,7 +274,7 @@ class Controller(object): return network_data except exception.Duplicate: msg = _("node with identifier %s already exists!") % network_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add node metadata. " diff --git a/code/daisy/daisy/registry/api/v1/neutron_backend.py b/code/daisy/daisy/registry/api/v1/neutron_backend.py index db8a0607..0f6e5816 100644 --- a/code/daisy/daisy/registry/api/v1/neutron_backend.py +++ b/code/daisy/daisy/registry/api/v1/neutron_backend.py @@ -1,384 +1,384 @@ -# Copyright 2010-2011 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Reference implementation registry server WSGI controller -""" - -from oslo_config import cfg -from oslo_log import log as logging -from oslo_utils import strutils -from oslo_utils import timeutils -from webob import exc - -from daisy.common import exception -from daisy.common import utils -from daisy.common import wsgi -import daisy.db -from daisy import i18n - - -LOG = logging.getLogger(__name__) -_ = i18n._ -_LE = i18n._LE -_LI = i18n._LI -_LW = i18n._LW -CONF = cfg.CONF -DISPLAY_FIELDS_IN_INDEX = ['id', 'role_id', 'user_name', 'user_pwd', - 'controller_ip', 'neutron_backends_type', - 'sdn_type', 'port'] -SUPPORTED_FILTERS = ['role_id', 'user_name', 'user_pwd', - 'controller_ip', 'neutron_backends_type', - 'sdn_type', 'port'] -SUPPORTED_SORT_KEYS = ('id', 'role_id', 'user_name', 'user_pwd', - 'controller_ip', 'neutron_backends_type', - 'sdn_type', 'port', 'created_at', 'updated_at') -SUPPORTED_SORT_DIRS = ('asc', 'desc') -SUPPORTED_PARAMS = ('limit', 'marker', 'sort_key', 'sort_dir', 'name', - 'description') - - -class Controller(object): - - def __init__(self): - self.db_api = daisy.db.get_api() - - def _get_query_params(self, req): - """Extract necessary query parameters from http request. - - :param req: the Request object coming from the wsgi layer - :retval dictionary of filters to apply to list of templates - """ - params = { - 'filters': self._get_filters(req), - 'limit': self._get_limit(req), - 'sort_key': [self._get_sort_key(req)], - 'sort_dir': [self._get_sort_dir(req)], - 'marker': self._get_marker(req), - } - - for key, value in params.items(): - if value is None: - del params[key] - - return params - - def _get_filters(self, req): - """Return a dictionary of query param filters from the request - - :param req: the Request object coming from the wsgi layer - :retval a dict of key/value filters - """ - filters = {} - properties = {} - - for param in req.params: - if param in SUPPORTED_FILTERS: - filters[param] = req.params.get(param) - if param.startswith('property-'): - _param = param[9:] - properties[_param] = req.params.get(param) - - if 'changes-since' in filters: - isotime = filters['changes-since'] - try: - filters['changes-since'] = timeutils.parse_isotime(isotime) - except ValueError: - raise exc.HTTPBadRequest(_("Unrecognized changes-since value")) - - if 'protected' in filters: - value = self._get_bool(filters['protected']) - if value is None: - raise exc.HTTPBadRequest(_("protected must be True, or " - "False")) - - filters['protected'] = value - - # only allow admins to filter on 'deleted' - if req.context.is_admin: - deleted_filter = self._parse_deleted_filter(req) - if deleted_filter is not None: - filters['deleted'] = deleted_filter - elif 'changes-since' not in filters: - filters['deleted'] = False - elif 'changes-since' not in filters: - filters['deleted'] = False - - if properties: - filters['properties'] = properties - - return filters - - def _get_limit(self, req): - """Parse a limit query param into something usable.""" - try: - limit = int(req.params.get('limit', CONF.limit_param_default)) - except ValueError: - raise exc.HTTPBadRequest(_("limit param must be an integer")) - - if limit < 0: - raise exc.HTTPBadRequest(_("limit param must be positive")) - - return min(CONF.api_limit_max, limit) - - def _get_marker(self, req): - """Parse a marker query param into something usable.""" - marker = req.params.get('marker', None) - - if marker and not utils.is_uuid_like(marker): - msg = _('Invalid marker format') - raise exc.HTTPBadRequest(explanation=msg) - - return marker - - def _get_sort_key(self, req): - """Parse a sort key query param from the request object.""" - sort_key = req.params.get('sort_key', 'created_at') - if sort_key is not None and sort_key not in SUPPORTED_SORT_KEYS: - _keys = ', '.join(SUPPORTED_SORT_KEYS) - msg = _("Unsupported sort_key. Acceptable values: %s") % (_keys,) - raise exc.HTTPBadRequest(explanation=msg) - return sort_key - - def _get_sort_dir(self, req): - """Parse a sort direction query param from the request object.""" - sort_dir = req.params.get('sort_dir', 'desc') - if sort_dir is not None and sort_dir not in SUPPORTED_SORT_DIRS: - _keys = ', '.join(SUPPORTED_SORT_DIRS) - msg = _("Unsupported sort_dir. Acceptable values: %s") % (_keys,) - raise exc.HTTPBadRequest(explanation=msg) - return sort_dir - - def _get_bool(self, value): - value = value.lower() - if value == 'true' or value == '1': - return True - elif value == 'false' or value == '0': - return False - - return None - - def _parse_deleted_filter(self, req): - """Parse deleted into something usable.""" - deleted = req.params.get('deleted') - if deleted is None: - return None - return strutils.bool_from_string(deleted) - - @utils.mutating - def neutron_backend_add(self, req, body): - """Registers a new neutron_backend with the registry. - - :param req: wsgi Request object - :param body: Dictionary of information about the templatae - - :retval Returns the newly-created template information as a mapping, - which will include the newly-created template's internal id - in the 'id' field - """ - neutron_backend_data = body["neutron_backend"] - id = neutron_backend_data.get('id') - - if id and not utils.is_uuid_like(id): - msg = _LI("Rejecting neutron_backend creation " - "request for invalid neutron_backend " - "id '%(bad_id)s'") % {'bad_id': id} - LOG.info(msg) - msg = _("Invalid neutron_backend id format") - return exc.HTTPBadRequest(explanation=msg) - - try: - neutron_backend_data = self.db_api.neutron_backend_add( - req.context, neutron_backend_data) - msg = (_LI("Successfully created neutron_backend %s") % - neutron_backend_data["id"]) - LOG.info(msg) - if 'neutron_backend' not in neutron_backend_data: - neutron_backend_data = dict( - neutron_backend=neutron_backend_data) - return neutron_backend_data - except exception.Duplicate: - msg = _("neutron_backend with identifier %s already exists!") % id - LOG.warn(msg) - return exc.HTTPConflict(msg) - except exception.Invalid as e: - msg = (_("Failed to add neutron_backend metadata. " - "Got error: %s") % utils.exception_to_str(e)) - LOG.error(msg) - return exc.HTTPBadRequest(msg) - except Exception: - LOG.exception(_LE("Unable to create neutron_backend %s"), id) - raise - - @utils.mutating - def neutron_backend_update(self, req, id, body): - """Registers a new neutron_backend with the registry. - - :param req: wsgi Request object - :param body: Dictionary of information about the template - - :retval Returns the newly-created template information as a mapping, - which will include the newly-created template's internal id - in the 'id' field - """ - neutron_backend_data = body["neutron_backend"] - if id and not utils.is_uuid_like(id): - msg = _LI("Rejecting cluster neutron_backend " - "creation request for invalid " - "neutron_backend id '%(bad_id)s'") % {'bad_id': id} - LOG.info(msg) - msg = _("Invalid neutron_backend id format") - return exc.HTTPBadRequest(explanation=msg) - - try: - neutron_backend_data = self.db_api.neutron_backend_update( - req.context, id, neutron_backend_data) - msg = (_LI("Successfully updated neutron_backend %s") % - neutron_backend_data["id"]) - LOG.info(msg) - if 'neutron_backend' not in neutron_backend_data: - neutron_backend_data = dict( - neutron_backend=neutron_backend_data) - return neutron_backend_data - except exception.Duplicate: - msg = _("neutron_backend with identifier %s already exists!") % id - LOG.warn(msg) - return exc.HTTPConflict(msg) - except exception.Invalid as e: - msg = (_("Failed to update neutron_backend " - "metadata.Got error: %s") % utils.exception_to_str(e)) - LOG.error(msg) - return exc.HTTPBadRequest(msg) - except Exception: - LOG.exception(_LE("Unable to update neutron_backend %s"), id) - raise - - @utils.mutating - def neutron_backend_delete(self, req, id): - """Registers a new neutron_backend with the registry. - - :param req: wsgi Request object - :param body: Dictionary of information about the template - - :retval Returns the newly-created template information as a mapping, - which will include the newly-created template's internal id - in the 'id' field - """ - if id and not utils.is_uuid_like(id): - msg = _LI("Rejecting neutron_backend delete " - "request for invalid neutron_backend " - "id '%(bad_id)s'") % {'bad_id': id} - LOG.info(msg) - msg = _("Invalid neutron_backend id format") - return exc.HTTPBadRequest(explanation=msg) - - try: - neutron_backend_data = self.db_api.neutron_backend_destroy( - req.context, id) - msg = (_LI("Successfully deleted neutron_backend %s") % id) - LOG.info(msg) - if 'neutron_backend' not in neutron_backend_data: - neutron_backend_data = dict( - neutron_backend=neutron_backend_data) - return neutron_backend_data - except exception.Invalid as e: - msg = (_("Failed to delete neutron_backend metadata. " - "Got error: %s") % utils.exception_to_str(e)) - LOG.error(msg) - return exc.HTTPBadRequest(msg) - except Exception: - LOG.exception(_LE("Unable to delete neutron_backend %s"), id) - raise - - def _list_neutron_backends(self, context, filters, params): - """Get neutron_backends, wrapping in exception if necessary.""" - try: - return self.db_api.neutron_backend_list(context, filters=filters, - **params) - except exception.NotFound: - LOG.warn(_LW("Invalid marker. neutron_backend %(id)s could not be " - "found.") % {'id': params.get('marker')}) - msg = _("Invalid marker. neutron_backend could not be found.") - raise exc.HTTPBadRequest(explanation=msg) - except exception.Forbidden: - LOG.warn(_LW("Access denied to neutron_backend " - "%(id)s but returning " - "'not found'") % {'id': params.get('marker')}) - msg = _("Invalid marker. neutron_backend could not be found.") - raise exc.HTTPBadRequest(explanation=msg) - except Exception: - LOG.exception(_LE("Unable to get neutron_backends")) - raise - - def neutron_backend_list(self, req): - """Return a filtered list of non-deleted neutron_backends in detail - - :param req: the Request object coming from the wsgi layer - :retval a mapping of the following form:: - - dict(neutron_backends=[neutron_backend_list]) - - Where neutron_backend_list is a sequence of mappings containing - all neutron_backend model fields. - """ - params = self._get_query_params(req) - filters = params.pop('filters') - neutron_backends = self._list_neutron_backends( - req.context, filters, params) - return dict(neutron_backends=neutron_backends) - - @utils.mutating - def neutron_backend_detail(self, req, id): - """Registers a new neutron_backend with the registry. - - :param req: wsgi Request object - :param body: Dictionary of information about the template - - :retval Returns the newly-created template information as a mapping, - which will include the newly-created template's internal id - in the 'id' field - """ - if id and not utils.is_uuid_like(id): - msg = _LI("Rejecting neutron_backend delete " - "request for invalid neutron_backend " - "id '%(bad_id)s'") % {'bad_id': id} - LOG.info(msg) - msg = _("Invalid neutron_backend id format") - return exc.HTTPBadRequest(explanation=msg) - - try: - neutron_backend_data = self.db_api.neutron_backend_detail( - req.context, id) - msg = (_LI("Successfully get neutron_backend information:%s") % id) - LOG.info(msg) - if 'neutron_backend' not in neutron_backend_data: - neutron_backend_data = dict( - neutron_backend=neutron_backend_data) - return neutron_backend_data - except exception.Invalid as e: - msg = (_("Failed to get neutron_backend metadata. Got error: %s") % - utils.exception_to_str(e)) - LOG.error(msg) - return exc.HTTPBadRequest(msg) - except Exception: - LOG.exception(_LE("Unable to get neutron_backend %s"), id) - raise - - -def create_resource(): - """neutron_backends resource factory method.""" - deserializer = wsgi.JSONRequestDeserializer() - serializer = wsgi.JSONResponseSerializer() - return wsgi.Resource(Controller(), deserializer, serializer) +# Copyright 2010-2011 OpenStack Foundation +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" +Reference implementation registry server WSGI controller +""" + +from oslo_config import cfg +from oslo_log import log as logging +from oslo_utils import strutils +from oslo_utils import timeutils +from webob import exc + +from daisy.common import exception +from daisy.common import utils +from daisy.common import wsgi +import daisy.db +from daisy import i18n + + +LOG = logging.getLogger(__name__) +_ = i18n._ +_LE = i18n._LE +_LI = i18n._LI +_LW = i18n._LW +CONF = cfg.CONF +DISPLAY_FIELDS_IN_INDEX = ['id', 'role_id', 'user_name', 'user_pwd', + 'controller_ip', 'neutron_backends_type', + 'sdn_type', 'port'] +SUPPORTED_FILTERS = ['role_id', 'user_name', 'user_pwd', + 'controller_ip', 'neutron_backends_type', + 'sdn_type', 'port'] +SUPPORTED_SORT_KEYS = ('id', 'role_id', 'user_name', 'user_pwd', + 'controller_ip', 'neutron_backends_type', + 'sdn_type', 'port', 'created_at', 'updated_at') +SUPPORTED_SORT_DIRS = ('asc', 'desc') +SUPPORTED_PARAMS = ('limit', 'marker', 'sort_key', 'sort_dir', 'name', + 'description') + + +class Controller(object): + + def __init__(self): + self.db_api = daisy.db.get_api() + + def _get_query_params(self, req): + """Extract necessary query parameters from http request. + + :param req: the Request object coming from the wsgi layer + :retval dictionary of filters to apply to list of templates + """ + params = { + 'filters': self._get_filters(req), + 'limit': self._get_limit(req), + 'sort_key': [self._get_sort_key(req)], + 'sort_dir': [self._get_sort_dir(req)], + 'marker': self._get_marker(req), + } + + for key, value in params.items(): + if value is None: + del params[key] + + return params + + def _get_filters(self, req): + """Return a dictionary of query param filters from the request + + :param req: the Request object coming from the wsgi layer + :retval a dict of key/value filters + """ + filters = {} + properties = {} + + for param in req.params: + if param in SUPPORTED_FILTERS: + filters[param] = req.params.get(param) + if param.startswith('property-'): + _param = param[9:] + properties[_param] = req.params.get(param) + + if 'changes-since' in filters: + isotime = filters['changes-since'] + try: + filters['changes-since'] = timeutils.parse_isotime(isotime) + except ValueError: + raise exc.HTTPBadRequest(_("Unrecognized changes-since value")) + + if 'protected' in filters: + value = self._get_bool(filters['protected']) + if value is None: + raise exc.HTTPBadRequest(_("protected must be True, or " + "False")) + + filters['protected'] = value + + # only allow admins to filter on 'deleted' + if req.context.is_admin: + deleted_filter = self._parse_deleted_filter(req) + if deleted_filter is not None: + filters['deleted'] = deleted_filter + elif 'changes-since' not in filters: + filters['deleted'] = False + elif 'changes-since' not in filters: + filters['deleted'] = False + + if properties: + filters['properties'] = properties + + return filters + + def _get_limit(self, req): + """Parse a limit query param into something usable.""" + try: + limit = int(req.params.get('limit', CONF.limit_param_default)) + except ValueError: + raise exc.HTTPBadRequest(_("limit param must be an integer")) + + if limit < 0: + raise exc.HTTPBadRequest(_("limit param must be positive")) + + return min(CONF.api_limit_max, limit) + + def _get_marker(self, req): + """Parse a marker query param into something usable.""" + marker = req.params.get('marker', None) + + if marker and not utils.is_uuid_like(marker): + msg = _('Invalid marker format') + raise exc.HTTPBadRequest(explanation=msg) + + return marker + + def _get_sort_key(self, req): + """Parse a sort key query param from the request object.""" + sort_key = req.params.get('sort_key', 'created_at') + if sort_key is not None and sort_key not in SUPPORTED_SORT_KEYS: + _keys = ', '.join(SUPPORTED_SORT_KEYS) + msg = _("Unsupported sort_key. Acceptable values: %s") % (_keys,) + raise exc.HTTPBadRequest(explanation=msg) + return sort_key + + def _get_sort_dir(self, req): + """Parse a sort direction query param from the request object.""" + sort_dir = req.params.get('sort_dir', 'desc') + if sort_dir is not None and sort_dir not in SUPPORTED_SORT_DIRS: + _keys = ', '.join(SUPPORTED_SORT_DIRS) + msg = _("Unsupported sort_dir. Acceptable values: %s") % (_keys,) + raise exc.HTTPBadRequest(explanation=msg) + return sort_dir + + def _get_bool(self, value): + value = value.lower() + if value == 'true' or value == '1': + return True + elif value == 'false' or value == '0': + return False + + return None + + def _parse_deleted_filter(self, req): + """Parse deleted into something usable.""" + deleted = req.params.get('deleted') + if deleted is None: + return None + return strutils.bool_from_string(deleted) + + @utils.mutating + def neutron_backend_add(self, req, body): + """Registers a new neutron_backend with the registry. + + :param req: wsgi Request object + :param body: Dictionary of information about the templatae + + :retval Returns the newly-created template information as a mapping, + which will include the newly-created template's internal id + in the 'id' field + """ + neutron_backend_data = body["neutron_backend"] + id = neutron_backend_data.get('id') + + if id and not utils.is_uuid_like(id): + msg = _LI("Rejecting neutron_backend creation " + "request for invalid neutron_backend " + "id '%(bad_id)s'") % {'bad_id': id} + LOG.info(msg) + msg = _("Invalid neutron_backend id format") + return exc.HTTPBadRequest(explanation=msg) + + try: + neutron_backend_data = self.db_api.neutron_backend_add( + req.context, neutron_backend_data) + msg = (_LI("Successfully created neutron_backend %s") % + neutron_backend_data["id"]) + LOG.info(msg) + if 'neutron_backend' not in neutron_backend_data: + neutron_backend_data = dict( + neutron_backend=neutron_backend_data) + return neutron_backend_data + except exception.Duplicate: + msg = _("neutron_backend with identifier %s already exists!") % id + LOG.warning(msg) + return exc.HTTPConflict(msg) + except exception.Invalid as e: + msg = (_("Failed to add neutron_backend metadata. " + "Got error: %s") % utils.exception_to_str(e)) + LOG.error(msg) + return exc.HTTPBadRequest(msg) + except Exception: + LOG.exception(_LE("Unable to create neutron_backend %s"), id) + raise + + @utils.mutating + def neutron_backend_update(self, req, id, body): + """Registers a new neutron_backend with the registry. + + :param req: wsgi Request object + :param body: Dictionary of information about the template + + :retval Returns the newly-created template information as a mapping, + which will include the newly-created template's internal id + in the 'id' field + """ + neutron_backend_data = body["neutron_backend"] + if id and not utils.is_uuid_like(id): + msg = _LI("Rejecting cluster neutron_backend " + "creation request for invalid " + "neutron_backend id '%(bad_id)s'") % {'bad_id': id} + LOG.info(msg) + msg = _("Invalid neutron_backend id format") + return exc.HTTPBadRequest(explanation=msg) + + try: + neutron_backend_data = self.db_api.neutron_backend_update( + req.context, id, neutron_backend_data) + msg = (_LI("Successfully updated neutron_backend %s") % + neutron_backend_data["id"]) + LOG.info(msg) + if 'neutron_backend' not in neutron_backend_data: + neutron_backend_data = dict( + neutron_backend=neutron_backend_data) + return neutron_backend_data + except exception.Duplicate: + msg = _("neutron_backend with identifier %s already exists!") % id + LOG.warning(msg) + return exc.HTTPConflict(msg) + except exception.Invalid as e: + msg = (_("Failed to update neutron_backend " + "metadata.Got error: %s") % utils.exception_to_str(e)) + LOG.error(msg) + return exc.HTTPBadRequest(msg) + except Exception: + LOG.exception(_LE("Unable to update neutron_backend %s"), id) + raise + + @utils.mutating + def neutron_backend_delete(self, req, id): + """Registers a new neutron_backend with the registry. + + :param req: wsgi Request object + :param body: Dictionary of information about the template + + :retval Returns the newly-created template information as a mapping, + which will include the newly-created template's internal id + in the 'id' field + """ + if id and not utils.is_uuid_like(id): + msg = _LI("Rejecting neutron_backend delete " + "request for invalid neutron_backend " + "id '%(bad_id)s'") % {'bad_id': id} + LOG.info(msg) + msg = _("Invalid neutron_backend id format") + return exc.HTTPBadRequest(explanation=msg) + + try: + neutron_backend_data = self.db_api.neutron_backend_destroy( + req.context, id) + msg = (_LI("Successfully deleted neutron_backend %s") % id) + LOG.info(msg) + if 'neutron_backend' not in neutron_backend_data: + neutron_backend_data = dict( + neutron_backend=neutron_backend_data) + return neutron_backend_data + except exception.Invalid as e: + msg = (_("Failed to delete neutron_backend metadata. " + "Got error: %s") % utils.exception_to_str(e)) + LOG.error(msg) + return exc.HTTPBadRequest(msg) + except Exception: + LOG.exception(_LE("Unable to delete neutron_backend %s"), id) + raise + + def _list_neutron_backends(self, context, filters, params): + """Get neutron_backends, wrapping in exception if necessary.""" + try: + return self.db_api.neutron_backend_list(context, filters=filters, + **params) + except exception.NotFound: + LOG.warning(_LW("Invalid marker. neutron_backend %(id)s not" + "found.") % {'id': params.get('marker')}) + msg = _("Invalid marker. neutron_backend could not be found.") + raise exc.HTTPBadRequest(explanation=msg) + except exception.Forbidden: + LOG.warning(_LW("Access denied to neutron_backend " + "%(id)s but returning " + "'not found'") % {'id': params.get('marker')}) + msg = _("Invalid marker. neutron_backend could not be found.") + raise exc.HTTPBadRequest(explanation=msg) + except Exception: + LOG.exception(_LE("Unable to get neutron_backends")) + raise + + def neutron_backend_list(self, req): + """Return a filtered list of non-deleted neutron_backends in detail + + :param req: the Request object coming from the wsgi layer + :retval a mapping of the following form:: + + dict(neutron_backends=[neutron_backend_list]) + + Where neutron_backend_list is a sequence of mappings containing + all neutron_backend model fields. + """ + params = self._get_query_params(req) + filters = params.pop('filters') + neutron_backends = self._list_neutron_backends( + req.context, filters, params) + return dict(neutron_backends=neutron_backends) + + @utils.mutating + def neutron_backend_detail(self, req, id): + """Registers a new neutron_backend with the registry. + + :param req: wsgi Request object + :param body: Dictionary of information about the template + + :retval Returns the newly-created template information as a mapping, + which will include the newly-created template's internal id + in the 'id' field + """ + if id and not utils.is_uuid_like(id): + msg = _LI("Rejecting neutron_backend delete " + "request for invalid neutron_backend " + "id '%(bad_id)s'") % {'bad_id': id} + LOG.info(msg) + msg = _("Invalid neutron_backend id format") + return exc.HTTPBadRequest(explanation=msg) + + try: + neutron_backend_data = self.db_api.neutron_backend_detail( + req.context, id) + msg = (_LI("Successfully get neutron_backend information:%s") % id) + LOG.info(msg) + if 'neutron_backend' not in neutron_backend_data: + neutron_backend_data = dict( + neutron_backend=neutron_backend_data) + return neutron_backend_data + except exception.Invalid as e: + msg = (_("Failed to get neutron_backend metadata. Got error: %s") % + utils.exception_to_str(e)) + LOG.error(msg) + return exc.HTTPBadRequest(msg) + except Exception: + LOG.exception(_LE("Unable to get neutron_backend %s"), id) + raise + + +def create_resource(): + """neutron_backends resource factory method.""" + deserializer = wsgi.JSONRequestDeserializer() + serializer = wsgi.JSONResponseSerializer() + return wsgi.Resource(Controller(), deserializer, serializer) diff --git a/code/daisy/daisy/registry/api/v1/template.py b/code/daisy/daisy/registry/api/v1/template.py index 77f954b1..d49f670b 100755 --- a/code/daisy/daisy/registry/api/v1/template.py +++ b/code/daisy/daisy/registry/api/v1/template.py @@ -207,6 +207,7 @@ class Controller(object): if id and not utils.is_uuid_like(id): msg = _LI("Rejecting template creation request for " "invalid template " + "id '%(bad_id)s'") % {'bad_id': id} LOG.info(msg) msg = _("Invalid template id format") @@ -223,7 +224,7 @@ class Controller(object): return template_data except exception.Duplicate: msg = _("template with identifier %s already exists!") % id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add template metadata. " @@ -266,7 +267,7 @@ class Controller(object): except exception.Duplicate: msg = _("template with identifier %s already exists!") % \ template_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to update template metadata. " @@ -327,13 +328,13 @@ class Controller(object): sort_key=sort_key, sort_dir=sort_dir) except exception.NotFound: - LOG.warn(_LW("Invalid marker. template %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. template %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. template could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to template %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to template %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. template could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -421,7 +422,7 @@ class Controller(object): return template_data except exception.Duplicate: msg = _("node with identifier %s already exists!") % id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add node metadata. " @@ -468,7 +469,7 @@ class Controller(object): except exception.Duplicate: msg = _("template with identifier %s already exists!") % \ template_id - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to update template metadata. " @@ -533,13 +534,13 @@ class Controller(object): sort_key=sort_key, sort_dir=sort_dir) except exception.NotFound: - LOG.warn(_LW("Invalid marker. template %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. template %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. template could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to template %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to template %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. template could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: diff --git a/code/daisy/daisy/registry/api/v1/template_configs.py b/code/daisy/daisy/registry/api/v1/template_configs.py index 55c17df6..daab23c3 100644 --- a/code/daisy/daisy/registry/api/v1/template_configs.py +++ b/code/daisy/daisy/registry/api/v1/template_configs.py @@ -63,14 +63,14 @@ class Controller(object): filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. template config %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker.template config %(id)s not" + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. template config could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to template config %(id)s but " - "returning 'not found'") % - {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to template config %(id)s but " + "returning 'not found'") % + {'id': params.get('marker')}) msg = _("Invalid marker. template config could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -253,7 +253,7 @@ class Controller(object): except exception.Duplicate: msg = (_("template function with identifier %s already exists!") % template_config_data) - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add template function metadata. " diff --git a/code/daisy/daisy/registry/api/v1/template_funcs.py b/code/daisy/daisy/registry/api/v1/template_funcs.py index d2002853..f3e2514e 100644 --- a/code/daisy/daisy/registry/api/v1/template_funcs.py +++ b/code/daisy/daisy/registry/api/v1/template_funcs.py @@ -61,14 +61,14 @@ class Controller(object): filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. template function %(id)s could not " - "be found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. template function %(id)s not" + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. template function could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to template function %(id)s but " - "returning 'not found'") % - {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to template function %(id)s but " + "returning 'not found'") % + {'id': params.get('marker')}) msg = _("Invalid marker. template function could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -264,7 +264,7 @@ class Controller(object): except exception.Duplicate: msg = (_("template function with identifier %s already exists!") % template_func_data) - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add template function metadata. " diff --git a/code/daisy/daisy/registry/api/v1/template_services.py b/code/daisy/daisy/registry/api/v1/template_services.py index 24f331fe..ab40dbb0 100644 --- a/code/daisy/daisy/registry/api/v1/template_services.py +++ b/code/daisy/daisy/registry/api/v1/template_services.py @@ -60,14 +60,14 @@ class Controller(object): filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. template function %(id)s could not " - "be found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker.template function %(id)s not " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. template function could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to template func %(id)s but" - "returning 'not found'") % - {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to template func %(id)s but" + "returning 'not found'") % + {'id': params.get('marker')}) msg = _("Invalid marker. template function could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: diff --git a/code/daisy/daisy/registry/api/v1/version_patchs.py b/code/daisy/daisy/registry/api/v1/version_patchs.py index 934427c0..e2b97869 100755 --- a/code/daisy/daisy/registry/api/v1/version_patchs.py +++ b/code/daisy/daisy/registry/api/v1/version_patchs.py @@ -187,13 +187,13 @@ class Controller(object): filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker patch history %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker patch history %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. Host could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to patch history %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied patch history %(id)s but returned " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. Host could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -234,7 +234,7 @@ class Controller(object): except exception.Duplicate: msg = (_("version patch with identifier %s" " already exists!") % version_patch_id) - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add version patch metadata. " @@ -386,7 +386,7 @@ class Controller(object): except exception.Duplicate: msg = (_("patch history with identifier %s already exists!") % patch_history_meta['patch_name']) - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add patch history metadata. " diff --git a/code/daisy/daisy/registry/api/v1/versions.py b/code/daisy/daisy/registry/api/v1/versions.py index a9e9a29b..f7c81de2 100644 --- a/code/daisy/daisy/registry/api/v1/versions.py +++ b/code/daisy/daisy/registry/api/v1/versions.py @@ -64,13 +64,13 @@ class Controller(object): filters=filters, **params) except exception.NotFound: - LOG.warn(_LW("Invalid marker. version %(id)s could not be " - "found.") % {'id': params.get('marker')}) + LOG.warning(_LW("Invalid marker. version %(id)s could not be " + "found.") % {'id': params.get('marker')}) msg = _("Invalid marker. version could not be found.") raise exc.HTTPBadRequest(explanation=msg) except exception.Forbidden: - LOG.warn(_LW("Access denied to version %(id)s but returning " - "'not found'") % {'id': params.get('marker')}) + LOG.warning(_LW("Access denied to version %(id)s but returning " + "'not found'") % {'id': params.get('marker')}) msg = _("Invalid marker. version could not be found.") raise exc.HTTPBadRequest(explanation=msg) except Exception: @@ -246,7 +246,7 @@ class Controller(object): except exception.Duplicate: msg = (_("version with identifier %s already exists!") % version_data['name']) - LOG.warn(msg) + LOG.warning(msg) return exc.HTTPConflict(msg) except exception.Invalid as e: msg = (_("Failed to add version metadata. " diff --git a/code/daisyclient/requirements.txt b/code/daisyclient/requirements.txt index c34e04a5..e51ddf7a 100755 --- a/code/daisyclient/requirements.txt +++ b/code/daisyclient/requirements.txt @@ -1,7 +1,7 @@ # 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 # 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 argparse PrettyTable>=0.7,<0.8 @@ -9,6 +9,6 @@ python-keystoneclient>=1.0.0 pyOpenSSL>=0.11 requests>=2.2.0,!=2.4.0 warlock>=1.0.1,<2 -six>=1.7.0 +#six>=1.7.0 oslo.utils>=1.2.0 # Apache-2.0 oslo.i18n>=1.3.0 # Apache-2.0 diff --git a/code/horizon/openstack_dashboard/openstack/common/policy.py b/code/horizon/openstack_dashboard/openstack/common/policy.py index cecac70b..ca972b82 100644 --- a/code/horizon/openstack_dashboard/openstack/common/policy.py +++ b/code/horizon/openstack_dashboard/openstack/common/policy.py @@ -245,7 +245,7 @@ class Enforcer(object): try: path = self._get_policy_path(path) except cfg.ConfigFilesNotFoundError: - LOG.warn(_LW("Can not find policy directories %s"), path) + LOG.warning(_LW("Can not find policy directories %s"), path) continue self._walk_through_policy_directory(path, self._load_policy_file, diff --git a/code/horizon/openstack_dashboard/policy_backend.py b/code/horizon/openstack_dashboard/policy_backend.py index 430b17af..a81cec74 100644 --- a/code/horizon/openstack_dashboard/policy_backend.py +++ b/code/horizon/openstack_dashboard/policy_backend.py @@ -49,8 +49,8 @@ def _get_enforcer(): LOG.debug("adding enforcer for service: %s" % service) _ENFORCER[service] = enforcer else: - LOG.warn("policy file for service: %s not found at %s" % - (service, enforcer.policy_path)) + LOG.warning("policy file for service: %s not found at %s" % + (service, enforcer.policy_path)) return _ENFORCER diff --git a/rpm/SPECS/openstack-ironic-discoverd.spec b/rpm/SPECS/openstack-ironic-discoverd.spec index e232e2b4..d17e9729 100755 --- a/rpm/SPECS/openstack-ironic-discoverd.spec +++ b/rpm/SPECS/openstack-ironic-discoverd.spec @@ -8,11 +8,10 @@ License: ASL 2.0 Group: System Environment/Base URL: https://pypi.python.org/pypi/ironic-discoverd -Source0: https://pypi.python.org/packages/source/i/ironic-discoverd/ironic-discoverd-%{version}.tar.gz -Source1: openstack-ironic-discoverd.service -Source2: openstack-ironic-discoverd-dnsmasq.service -Source3: dnsmasq.conf -Patch0: 0001-default-database-location.patch +Source0: https://pypi.python.org/packages/source/i/ironic-discoverd/ironic-discoverd-%{version}.tar.gz +Source1: openstack-ironic-discoverd.service +Source2: openstack-ironic-discoverd-dnsmasq.service +Source3: dnsmasq.conf BuildArch: noarch BuildRequires: python-setuptools @@ -75,7 +74,7 @@ This package contains Python modules and documentation. %files -n python-ironic-discoverd %doc README.rst CONTRIBUTING.rst %license LICENSE -%{python_sitelib}/ironic_discoverd* +%{python2_sitelib}/ironic_discoverd* %description @@ -141,6 +140,5 @@ This package contains main executable and service files. * Thu Oct 16 2014 Dmitry Tantsur - 0.2.1-1 - Upstream bugfix release -* Wed Oct 8 2014 Dmitry Tantsur - 0.2.0-1 +* Wed Oct 8 2014 Dmitry Tantsur - 0.2.0-1- Initial package build - Initial package build - diff --git a/test/tempest/tempest/common/fixed_network.py b/test/tempest/tempest/common/fixed_network.py index 15574740..a1e99bdc 100644 --- a/test/tempest/tempest/common/fixed_network.py +++ b/test/tempest/tempest/common/fixed_network.py @@ -51,9 +51,9 @@ def get_network_from_name(name, compute_networks_client): else: msg = "Network with name: %s not found" % name if caller: - LOG.warn('(%s) %s' % (caller, msg)) + LOG.warning('(%s) %s' % (caller, msg)) else: - LOG.warn(msg) + LOG.warning(msg) raise lib_exc.NotFound() # To be consistent with network isolation, add name is only # label is available @@ -125,6 +125,6 @@ def set_networks_kwarg(network, kwargs=None): if 'id' in network.keys(): params.update({"networks": [{'uuid': network['id']}]}) else: - LOG.warn('The provided network dict: %s was invalid and did not ' - ' contain an id' % network) + LOG.warning('provided network dict: %s was invalid, did not ' + ' contain an id' % network) return params diff --git a/test/tempest/tempest/common/isolated_creds.py b/test/tempest/tempest/common/isolated_creds.py index 1f858724..1221901a 100644 --- a/test/tempest/tempest/common/isolated_creds.py +++ b/test/tempest/tempest/common/isolated_creds.py @@ -348,24 +348,24 @@ class IsolatedCreds(cred_provider.CredentialProvider): try: net_client.delete_router(router_id) except lib_exc.NotFound: - LOG.warn('router with name: %s not found for delete' % - router_name) + LOG.warning('router with name: %s not found for delete' % + router_name) def _clear_isolated_subnet(self, subnet_id, subnet_name): net_client = self.network_admin_client try: net_client.delete_subnet(subnet_id) except lib_exc.NotFound: - LOG.warn('subnet with name: %s not found for delete' % - subnet_name) + LOG.warning('subnet with name: %s not found for delete' % + subnet_name) def _clear_isolated_network(self, network_id, network_name): net_client = self.network_admin_client try: net_client.delete_network(network_id) except lib_exc.NotFound: - LOG.warn('network with name: %s not found for delete' % - network_name) + LOG.warning('network with name: %s not found for delete' % + network_name) def _cleanup_default_secgroup(self, tenant): net_client = self.network_admin_client @@ -376,8 +376,8 @@ class IsolatedCreds(cred_provider.CredentialProvider): try: net_client.delete_security_group(secgroup['id']) except lib_exc.NotFound: - LOG.warn('Security group %s, id %s not found for clean-up' % - (secgroup['name'], secgroup['id'])) + LOG.warning('Security group %s, id %s not found for clean-up' % + (secgroup['name'], secgroup['id'])) def _clear_isolated_net_resources(self): net_client = self.network_admin_client @@ -396,8 +396,8 @@ class IsolatedCreds(cred_provider.CredentialProvider): net_client.remove_router_interface_with_subnet_id( creds.router['id'], creds.subnet['id']) except lib_exc.NotFound: - LOG.warn('router with name: %s not found for delete' % - creds.router['name']) + LOG.warning('router with name: %s not found for delete' % + creds.router['name']) self._clear_isolated_router(creds.router['id'], creds.router['name']) if (not self.network_resources or @@ -417,15 +417,15 @@ class IsolatedCreds(cred_provider.CredentialProvider): try: self.creds_client.delete_user(creds.user_id) except lib_exc.NotFound: - LOG.warn("user with name: %s not found for delete" % - creds.username) + LOG.warning("user with name: %s not found for delete" % + creds.username) try: if CONF.service_available.neutron: self._cleanup_default_secgroup(creds.tenant_id) self.creds_client.delete_project(creds.tenant_id) except lib_exc.NotFound: - LOG.warn("tenant with name: %s not found for delete" % - creds.tenant_name) + LOG.warning("tenant with name: %s not found for delete" % + creds.tenant_name) self.isolated_creds = {} def is_multi_user(self):