summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSun Austin <austin.sun@intel.com>2019-01-02 11:34:16 +0800
committerAustin Sun <austin.sun@intel.com>2019-01-15 00:33:38 +0000
commit5e9dc4838422af9daa688f2b44a7db5eb091c4c5 (patch)
tree7f607ce98709da51f66a5bea7fe3873413642ff7
parentbb65ec36e69d1a32b037017b8d5a27320a4911c1 (diff)
FIX: "dict" issue for Python 2/3 compatible code
Replace dict.iteritems() with dict.items() Change dict.keys() to list(dict.keys()) Story: 2004585 Task: 28449 Change-Id: I674c499fd575800fa307a835d8f7f272f2b2cd03 Signed-off-by: Sun Austin <austin.sun@intel.com>
Notes
Notes (review): Code-Review+2: Bart Wensley <barton.wensley@windriver.com> Code-Review+2: John Kung <john.kung@windriver.com> Workflow+1: John Kung <john.kung@windriver.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 18 Jan 2019 14:53:39 +0000 Reviewed-on: https://review.openstack.org/629405 Project: openstack/stx-distcloud Branch: refs/heads/master
-rw-r--r--dcmanager/manager/sw_update_manager.py4
-rw-r--r--dcorch/api/proxy/apps/acceptor.py16
-rw-r--r--dcorch/api/proxy/apps/controller.py4
-rw-r--r--dcorch/api/proxy/apps/patch.py2
-rw-r--r--dcorch/api/proxy/common/utils.py2
-rw-r--r--dcorch/common/endpoint_cache.py2
-rw-r--r--dcorch/drivers/openstack/sysinv_v1.py8
-rw-r--r--dcorch/engine/quota_manager.py4
-rw-r--r--dcorch/engine/sync_services/compute.py12
-rw-r--r--dcorch/snmp/controller.py2
10 files changed, 28 insertions, 28 deletions
diff --git a/dcmanager/manager/sw_update_manager.py b/dcmanager/manager/sw_update_manager.py
index bd3c77a..9ddc0c3 100644
--- a/dcmanager/manager/sw_update_manager.py
+++ b/dcmanager/manager/sw_update_manager.py
@@ -707,7 +707,7 @@ class PatchOrchThread(threading.Thread):
707 # removed to match the applied patches in RegionOne. Check the 707 # removed to match the applied patches in RegionOne. Check the
708 # repostate, which indicates whether it is applied or removed in 708 # repostate, which indicates whether it is applied or removed in
709 # the repo. 709 # the repo.
710 subcloud_patch_ids = subcloud_patches.keys() 710 subcloud_patch_ids = list(subcloud_patches.keys())
711 for patch_id in subcloud_patch_ids: 711 for patch_id in subcloud_patch_ids:
712 if subcloud_patches[patch_id]['repostate'] == \ 712 if subcloud_patches[patch_id]['repostate'] == \
713 patching_v1.PATCH_STATE_APPLIED: 713 patching_v1.PATCH_STATE_APPLIED:
@@ -1386,7 +1386,7 @@ class PatchOrchThread(threading.Thread):
1386 # which should be deleted. We check the patchstate here because 1386 # which should be deleted. We check the patchstate here because
1387 # patches cannot be deleted or committed if they are in a partial 1387 # patches cannot be deleted or committed if they are in a partial
1388 # state (e.g. Partial-Apply or Partial-Remove). 1388 # state (e.g. Partial-Apply or Partial-Remove).
1389 subcloud_patch_ids = subcloud_patches.keys() 1389 subcloud_patch_ids = list(subcloud_patches.keys())
1390 for patch_id in subcloud_patch_ids: 1390 for patch_id in subcloud_patch_ids:
1391 if subcloud_patches[patch_id]['patchstate'] == \ 1391 if subcloud_patches[patch_id]['patchstate'] == \
1392 patching_v1.PATCH_STATE_AVAILABLE: 1392 patching_v1.PATCH_STATE_AVAILABLE:
diff --git a/dcorch/api/proxy/apps/acceptor.py b/dcorch/api/proxy/apps/acceptor.py
index 63b571b..b9dbcf0 100644
--- a/dcorch/api/proxy/apps/acceptor.py
+++ b/dcorch/api/proxy/apps/acceptor.py
@@ -74,8 +74,8 @@ class Acceptor(Router):
74 api_controller = ComputeAPIController(app, conf) 74 api_controller = ComputeAPIController(app, conf)
75 orch_controller = OrchAPIController(app, conf) 75 orch_controller = OrchAPIController(app, conf)
76 76
77 for key, value in proxy_consts.COMPUTE_PATH_MAP.iteritems(): 77 for key, value in proxy_consts.COMPUTE_PATH_MAP.items():
78 for k, v in value.iteritems(): 78 for k, v in value.items():
79 self._add_resource(mapper, api_controller, v, k, 79 self._add_resource(mapper, api_controller, v, k,
80 CONF.type, key) 80 CONF.type, key)
81 81
@@ -87,14 +87,14 @@ class Acceptor(Router):
87 def add_platform_routes(self, app, conf, mapper): 87 def add_platform_routes(self, app, conf, mapper):
88 api_controller = SysinvAPIController(app, conf) 88 api_controller = SysinvAPIController(app, conf)
89 89
90 for key, value in proxy_consts.SYSINV_PATH_MAP.iteritems(): 90 for key, value in proxy_consts.SYSINV_PATH_MAP.items():
91 self._add_resource(mapper, api_controller, value, key, CONF.type) 91 self._add_resource(mapper, api_controller, value, key, CONF.type)
92 92
93 def add_volume_routes(self, app, conf, mapper): 93 def add_volume_routes(self, app, conf, mapper):
94 api_controller = CinderAPIController(app, conf) 94 api_controller = CinderAPIController(app, conf)
95 95
96 for key, value in proxy_consts.CINDER_PATH_MAP.iteritems(): 96 for key, value in proxy_consts.CINDER_PATH_MAP.items():
97 for k, v in value.iteritems(): 97 for k, v in value.items():
98 self._add_resource(mapper, api_controller, v, k, 98 self._add_resource(mapper, api_controller, v, k,
99 CONF.type, key) 99 CONF.type, key)
100 100
@@ -102,7 +102,7 @@ class Acceptor(Router):
102 api_controller = NeutronAPIController(app, conf) 102 api_controller = NeutronAPIController(app, conf)
103 orch_controller = OrchAPIController(app, conf) 103 orch_controller = OrchAPIController(app, conf)
104 104
105 for key, value in proxy_consts.NEUTRON_PATH_MAP.iteritems(): 105 for key, value in proxy_consts.NEUTRON_PATH_MAP.items():
106 self._add_resource(mapper, api_controller, value, key, CONF.type) 106 self._add_resource(mapper, api_controller, value, key, CONF.type)
107 107
108 self._add_resource(mapper, orch_controller, 108 self._add_resource(mapper, orch_controller,
@@ -113,11 +113,11 @@ class Acceptor(Router):
113 def add_patch_routes(self, app, conf, mapper): 113 def add_patch_routes(self, app, conf, mapper):
114 api_controller = PatchAPIController(app, conf) 114 api_controller = PatchAPIController(app, conf)
115 115
116 for key, value in proxy_consts.PATCH_PATH_MAP.iteritems(): 116 for key, value in proxy_consts.PATCH_PATH_MAP.items():
117 self._add_resource(mapper, api_controller, value, key, CONF.type) 117 self._add_resource(mapper, api_controller, value, key, CONF.type)
118 118
119 def add_identity_routes(self, app, conf, mapper): 119 def add_identity_routes(self, app, conf, mapper):
120 api_controller = IdentityAPIController(app, conf) 120 api_controller = IdentityAPIController(app, conf)
121 121
122 for key, value in proxy_consts.IDENTITY_PATH_MAP.iteritems(): 122 for key, value in proxy_consts.IDENTITY_PATH_MAP.items():
123 self._add_resource(mapper, api_controller, value, key, CONF.type) 123 self._add_resource(mapper, api_controller, value, key, CONF.type)
diff --git a/dcorch/api/proxy/apps/controller.py b/dcorch/api/proxy/apps/controller.py
index 1485972..673a178 100644
--- a/dcorch/api/proxy/apps/controller.py
+++ b/dcorch/api/proxy/apps/controller.py
@@ -157,7 +157,7 @@ class APIController(Middleware):
157 environ['REQUEST_METHOD'], length) 157 environ['REQUEST_METHOD'], length)
158 LOG.info("Request URL: (%s)\n", self.get_request_header(environ)) 158 LOG.info("Request URL: (%s)\n", self.get_request_header(environ))
159 LOG.info("Request header: \n") 159 LOG.info("Request header: \n")
160 for k, v in req.headers.iteritems(): 160 for k, v in req.headers.items():
161 LOG.info(" %s: %s\n", k, v) 161 LOG.info(" %s: %s\n", k, v)
162 self.print_environ(environ) 162 self.print_environ(environ)
163 self.print_request_body(req.body) 163 self.print_request_body(req.body)
@@ -485,7 +485,7 @@ class IdentityAPIController(APIController):
485 else: 485 else:
486 if operation_type == consts.OPERATION_TYPE_POST: 486 if operation_type == consts.OPERATION_TYPE_POST:
487 # Retrieve the ID from the response 487 # Retrieve the ID from the response
488 resource = json.loads(response.body).items()[0][1] 488 resource = list(json.loads(response.body).items())[0][1]
489 resource_id = resource['id'] 489 resource_id = resource['id']
490 else: 490 else:
491 resource_id = self.get_resource_id_from_link(request_header) 491 resource_id = self.get_resource_id_from_link(request_header)
diff --git a/dcorch/api/proxy/apps/patch.py b/dcorch/api/proxy/apps/patch.py
index 82b6c54..504fb7f 100644
--- a/dcorch/api/proxy/apps/patch.py
+++ b/dcorch/api/proxy/apps/patch.py
@@ -176,7 +176,7 @@ class PatchAPIController(Middleware):
176 176
177 def patch_upload_dir_req(self, request, response): 177 def patch_upload_dir_req(self, request, response):
178 files = [] 178 files = []
179 for key, path in request.GET.iteritems(): 179 for key, path in request.GET.items():
180 LOG.info("upload-dir: Retrieving patches from %s" % path) 180 LOG.info("upload-dir: Retrieving patches from %s" % path)
181 for f in glob.glob(path + '/*.patch'): 181 for f in glob.glob(path + '/*.patch'):
182 if os.path.isfile(f): 182 if os.path.isfile(f):
diff --git a/dcorch/api/proxy/common/utils.py b/dcorch/api/proxy/common/utils.py
index 6f13a5c..a457cd1 100644
--- a/dcorch/api/proxy/common/utils.py
+++ b/dcorch/api/proxy/common/utils.py
@@ -71,7 +71,7 @@ def get_routing_match_value(environ, key):
71 return match[key] 71 return match[key]
72 else: 72 else:
73 LOG.info("(%s) is not available in routing match arguments.", key) 73 LOG.info("(%s) is not available in routing match arguments.", key)
74 for k, v in match.iteritems(): 74 for k, v in match.items():
75 LOG.info("Match key:(%s), value:(%s)", k, v) 75 LOG.info("Match key:(%s), value:(%s)", k, v)
76 return None 76 return None
77 77
diff --git a/dcorch/common/endpoint_cache.py b/dcorch/common/endpoint_cache.py
index 5387d94..b9fc264 100644
--- a/dcorch/common/endpoint_cache.py
+++ b/dcorch/common/endpoint_cache.py
@@ -161,7 +161,7 @@ class EndpointCache(object):
161 161
162 return: List of regions 162 return: List of regions
163 """ 163 """
164 return self.endpoint_map.keys() 164 return list(self.endpoint_map.keys())
165 165
166 def get_session_from_token(self, token, project_id): 166 def get_session_from_token(self, token, project_id):
167 """Get session based on token to communicate with openstack services. 167 """Get session based on token to communicate with openstack services.
diff --git a/dcorch/drivers/openstack/sysinv_v1.py b/dcorch/drivers/openstack/sysinv_v1.py
index da71c69..2251019 100644
--- a/dcorch/drivers/openstack/sysinv_v1.py
+++ b/dcorch/drivers/openstack/sysinv_v1.py
@@ -36,7 +36,7 @@ API_VERSION = '1'
36 36
37def make_sysinv_patch(update_dict): 37def make_sysinv_patch(update_dict):
38 patch = [] 38 patch = []
39 for k, v in update_dict.iteritems(): 39 for k, v in update_dict.items():
40 key = k 40 key = k
41 if not k.startswith('/'): 41 if not k.startswith('/'):
42 key = '/' + key 42 key = '/' + key
@@ -265,7 +265,7 @@ class SysinvClient(base.DriverBase):
265 # {"ip_address": "10.10.10.12", "community": "cgcs"} 265 # {"ip_address": "10.10.10.12", "community": "cgcs"}
266 itrapdest = None 266 itrapdest = None
267 trapdest_create_dict = {} 267 trapdest_create_dict = {}
268 for k, v in trapdest_dict.iteritems(): 268 for k, v in trapdest_dict.items():
269 if k in SNMP_TRAPDEST_CREATION_ATTRIBUTES: 269 if k in SNMP_TRAPDEST_CREATION_ATTRIBUTES:
270 trapdest_create_dict[str(k)] = v 270 trapdest_create_dict[str(k)] = v
271 271
@@ -329,7 +329,7 @@ class SysinvClient(base.DriverBase):
329 # Example community_dict: {"community": "cgcs"} 329 # Example community_dict: {"community": "cgcs"}
330 icommunity = None 330 icommunity = None
331 community_create_dict = {} 331 community_create_dict = {}
332 for k, v in community_dict.iteritems(): 332 for k, v in community_dict.items():
333 if k in SNMP_COMMUNITY_CREATION_ATTRIBUTES: 333 if k in SNMP_COMMUNITY_CREATION_ATTRIBUTES:
334 community_create_dict[str(k)] = v 334 community_create_dict[str(k)] = v
335 335
@@ -399,7 +399,7 @@ class SysinvClient(base.DriverBase):
399 def create_remote_logging_patch_from_dict(self, values): 399 def create_remote_logging_patch_from_dict(self, values):
400 patch = {} 400 patch = {}
401 action_found = False 401 action_found = False
402 for k, v in values.iteritems(): 402 for k, v in values.items():
403 if k in self.REMOTELOGGING_PATCH_ATTRS: 403 if k in self.REMOTELOGGING_PATCH_ATTRS:
404 if k == 'action': 404 if k == 'action':
405 action_found = True 405 action_found = True
diff --git a/dcorch/engine/quota_manager.py b/dcorch/engine/quota_manager.py
index f3939de..25f40f7 100644
--- a/dcorch/engine/quota_manager.py
+++ b/dcorch/engine/quota_manager.py
@@ -251,7 +251,7 @@ class QuotaManager(manager.Manager):
251 project_id) 251 project_id)
252 except exceptions.ProjectQuotaNotFound: 252 except exceptions.ProjectQuotaNotFound:
253 limits_from_db = {} 253 limits_from_db = {}
254 for current_resource in CONF.dc_orch_global_limit.iteritems(): 254 for current_resource in CONF.dc_orch_global_limit.items():
255 resource = re.sub('quota_', '', current_resource[0]) 255 resource = re.sub('quota_', '', current_resource[0])
256 # If resource limit in DB, then use it or else use limit 256 # If resource limit in DB, then use it or else use limit
257 # from conf file 257 # from conf file
@@ -481,7 +481,7 @@ class QuotaManager(manager.Manager):
481 # endpoint types, so we need to figure out which ones we want. 481 # endpoint types, so we need to figure out which ones we want.
482 desired_fields = consts.ENDPOINT_QUOTA_MAPPING[endpoint_type] 482 desired_fields = consts.ENDPOINT_QUOTA_MAPPING[endpoint_type]
483 usage_dict = {} 483 usage_dict = {}
484 for k, v in total_project_usages.iteritems(): 484 for k, v in total_project_usages.items():
485 if k in desired_fields: 485 if k in desired_fields:
486 usage_dict[k] = v 486 usage_dict[k] = v
487 return usage_dict 487 return usage_dict
diff --git a/dcorch/engine/sync_services/compute.py b/dcorch/engine/sync_services/compute.py
index 7ddce9e..dc537e6 100644
--- a/dcorch/engine/sync_services/compute.py
+++ b/dcorch/engine/sync_services/compute.py
@@ -292,7 +292,7 @@ class ComputeSyncThread(SyncThread):
292 consts.ACTION_EXTRASPECS_POST: self.set_extra_specs, 292 consts.ACTION_EXTRASPECS_POST: self.set_extra_specs,
293 consts.ACTION_EXTRASPECS_DELETE: self.unset_extra_specs, 293 consts.ACTION_EXTRASPECS_DELETE: self.unset_extra_specs,
294 } 294 }
295 action = action_dict.keys()[0] 295 action = list(action_dict.keys())[0]
296 if action not in switcher.keys(): 296 if action not in switcher.keys():
297 LOG.error("Unsupported flavor action {}".format(action), 297 LOG.error("Unsupported flavor action {}".format(action),
298 extra=self.log_extra) 298 extra=self.log_extra)
@@ -343,10 +343,10 @@ class ComputeSyncThread(SyncThread):
343 metadata[metadatum] = None 343 metadata[metadatum] = None
344 344
345 try: 345 try:
346 flavor.unset_keys(metadata.keys()) 346 flavor.unset_keys(list(metadata.keys()))
347 except novaclient_exceptions.NotFound: 347 except novaclient_exceptions.NotFound:
348 LOG.info("Extra-spec {} not found {}:{}" 348 LOG.info("Extra-spec {} not found {}:{}"
349 .format(metadata.keys(), rsrc, action_dict), 349 .format(list(metadata.keys()), rsrc, action_dict),
350 extra=self.log_extra) 350 extra=self.log_extra)
351 351
352 def get_flavor_resources(self, nc): 352 def get_flavor_resources(self, nc):
@@ -449,9 +449,9 @@ class ComputeSyncThread(SyncThread):
449 # Extra-spec needs to be audited. Extra-spec details are 449 # Extra-spec needs to be audited. Extra-spec details are
450 # filled in m_resources and sc_resources during query. 450 # filled in m_resources and sc_resources during query.
451 metadata = {} 451 metadata = {}
452 for m_key, m_value in m_flavor.attach_es.iteritems(): 452 for m_key, m_value in m_flavor.attach_es.items():
453 found = False 453 found = False
454 for sc_key, sc_value in sc_es_attachment.iteritems(): 454 for sc_key, sc_value in sc_es_attachment.items():
455 if m_key == sc_key and m_value == sc_value: 455 if m_key == sc_key and m_value == sc_value:
456 found = True 456 found = True
457 sc_es_attachment.pop(sc_key) 457 sc_es_attachment.pop(sc_key)
@@ -466,7 +466,7 @@ class ComputeSyncThread(SyncThread):
466 num_of_audit_jobs += 1 466 num_of_audit_jobs += 1
467 467
468 keys_to_delete = "" 468 keys_to_delete = ""
469 for sc_key, sc_value in sc_es_attachment.iteritems(): 469 for sc_key, sc_value in sc_es_attachment.items():
470 keys_to_delete += sc_key + ";" 470 keys_to_delete += sc_key + ";"
471 if keys_to_delete: 471 if keys_to_delete:
472 action_dict = {consts.ACTION_EXTRASPECS_DELETE: keys_to_delete} 472 action_dict = {consts.ACTION_EXTRASPECS_DELETE: keys_to_delete}
diff --git a/dcorch/snmp/controller.py b/dcorch/snmp/controller.py
index 0a28c01..6e3df3d 100644
--- a/dcorch/snmp/controller.py
+++ b/dcorch/snmp/controller.py
@@ -97,7 +97,7 @@ class Controller(object):
97 97
98 def handle_delayed_notifications(self): 98 def handle_delayed_notifications(self):
99 curr_time = datetime.datetime.utcnow() 99 curr_time = datetime.datetime.utcnow()
100 for system, notify_time in self.system_throttle_timers.iteritems(): 100 for system, notify_time in self.system_throttle_timers.items():
101 if notify_time is not None: 101 if notify_time is not None:
102 if curr_time > notify_time: 102 if curr_time > notify_time:
103 self.send_notification(system) 103 self.send_notification(system)