summaryrefslogtreecommitdiffstats
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/src/tools/crim.py18
-rw-r--r--engine/src/tools/lib/common.py10
-rw-r--r--engine/src/tools/lib/song.py6
-rw-r--r--engine/src/tools/lib/tables.py12
-rw-r--r--engine/src/tools/lock.py2
-rw-r--r--engine/src/tools/ppdb.py8
-rw-r--r--engine/src/valet/engine/app_manager/app.py26
-rw-r--r--engine/src/valet/engine/app_manager/app_handler.py6
-rw-r--r--engine/src/valet/engine/app_manager/app_parser.py18
-rw-r--r--engine/src/valet/engine/app_manager/group.py8
-rw-r--r--engine/src/valet/engine/app_manager/server.py4
-rw-r--r--engine/src/valet/engine/db_connect/db_apis/mem_db.py8
-rw-r--r--engine/src/valet/engine/db_connect/db_apis/music.py6
-rw-r--r--engine/src/valet/engine/db_connect/db_handler.py24
-rw-r--r--engine/src/valet/engine/resource_manager/compute_manager.py6
-rw-r--r--engine/src/valet/engine/resource_manager/metadata_manager.py12
-rw-r--r--engine/src/valet/engine/resource_manager/naming.py6
-rw-r--r--engine/src/valet/engine/resource_manager/nova_compute.py40
-rw-r--r--engine/src/valet/engine/resource_manager/resource.py72
-rw-r--r--engine/src/valet/engine/resource_manager/resource_handler.py8
-rw-r--r--engine/src/valet/engine/resource_manager/resources/datacenter.py2
-rw-r--r--engine/src/valet/engine/resource_manager/resources/flavor.py2
-rw-r--r--engine/src/valet/engine/resource_manager/resources/group_rule.py2
-rw-r--r--engine/src/valet/engine/resource_manager/resources/host.py4
-rw-r--r--engine/src/valet/engine/resource_manager/topology_manager.py2
-rw-r--r--engine/src/valet/engine/search/avail_resources.py8
-rw-r--r--engine/src/valet/engine/search/constraint_solver.py2
-rw-r--r--engine/src/valet/engine/search/filters/affinity_filter.py2
-rw-r--r--engine/src/valet/engine/search/filters/aggregate_instance_filter.py4
-rw-r--r--engine/src/valet/engine/search/filters/diversity_filter.py4
-rw-r--r--engine/src/valet/engine/search/filters/dynamic_aggregate_filter.py4
-rw-r--r--engine/src/valet/engine/search/filters/exclusivity_filter.py4
-rw-r--r--engine/src/valet/engine/search/filters/filter_utils.py4
-rw-r--r--engine/src/valet/engine/search/filters/no_exclusivity_filter.py2
-rw-r--r--engine/src/valet/engine/search/filters/quorum_diversity_filter.py6
-rw-r--r--engine/src/valet/engine/search/optimizer.py22
-rw-r--r--engine/src/valet/engine/search/resource.py10
-rw-r--r--engine/src/valet/engine/search/search.py46
-rw-r--r--engine/src/valet/engine/search/search_helper.py4
-rw-r--r--engine/src/valet/solver/ostro.py4
-rw-r--r--engine/src/valet/valet_main.py2
41 files changed, 220 insertions, 220 deletions
diff --git a/engine/src/tools/crim.py b/engine/src/tools/crim.py
index a92ac6c..b0a5596 100644
--- a/engine/src/tools/crim.py
+++ b/engine/src/tools/crim.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/usr/bin/env python2.7
+#!/usr/bin/env python3
"""
Commandline Rest Interface Music (CRIM)
@@ -105,13 +105,13 @@ if __name__ == "__main__":
if opts.viewTables:
for table in Tables.__subclasses__():
- print (re.sub("[[\]',]", '', str(table.table_alias()))).split(" ")[0]
+ print((re.sub("[[\]',]", '', str(table.table_alias()))).split(" ")[0])
sys.exit(0)
if opts.viewSchema:
for table in Tables.__subclasses__():
sys.stdout.write(re.sub("[[\]',]", '', str(table.table_alias())) + ' ')
- print json.dumps(table.schema, sort_keys=True, indent=2), "\n"
+ print(json.dumps(table.schema, sort_keys=True, indent=2), "\n")
sys.exit(0)
""" Keyspace Create """ # <<<1
@@ -137,7 +137,7 @@ if __name__ == "__main__":
opts.names = True
for keyspace in Song.Keyspaces.keys():
music.keyspace = Song.Keyspaces[keyspace]
- print "\n----------------- %s : %s -----------------" % (keyspace, music.keyspace)
+ print("\n----------------- %s : %s -----------------" % (keyspace, music.keyspace))
# noinspection PyBroadException
try:
for tName in opts.read:
@@ -155,13 +155,13 @@ if __name__ == "__main__":
# show all db stuff <<<1
if opts.show or opts.ShowConfig:
if opts.show:
- print "music"
+ print("music")
pprint(music.__dict__, indent=2)
- print "\nrest"
+ print("\nrest")
pprint(music.rest.__dict__, indent=2)
if table is not None:
- print "\n", table.table()
+ print("\n", table.table())
pprint(table.__dict__, indent=2)
if opts.ShowConfig:
@@ -193,7 +193,7 @@ if __name__ == "__main__":
""" UPDATE use json file to update db record """ # <<<1
if opts.action == 'u':
if not opts.file or not os.path.exists(opts.file):
- print "--file filename (filename exists) is required for update"
+ print("--file filename (filename exists) is required for update")
sys.exit(1)
table.update(opts.file)
@@ -202,7 +202,7 @@ if __name__ == "__main__":
""" DELETE use id to delete record from db -- requres ID """ # <<<1
if opts.action == 'd':
if not opts.id:
- print "--id ID is required for delete"
+ print("--id ID is required for delete")
sys.exit(1)
if opts.id:
diff --git a/engine/src/tools/lib/common.py b/engine/src/tools/lib/common.py
index 4973f4e..643e988 100644
--- a/engine/src/tools/lib/common.py
+++ b/engine/src/tools/lib/common.py
@@ -37,7 +37,7 @@ def set_argument(arg=None, prompt=None, multiline=False):
if sys.stdin in select.select([sys.stdin], [], [], .5)[0]:
message = sys.stdin.readlines()
else:
- print prompt,
+ print(prompt)
if multiline:
sentinel = ''
message = list(iter(raw_input, sentinel))
@@ -64,10 +64,10 @@ if __name__ == "__main__":
msg = set_argument(sys.argv[0])
for row in msg:
- print row,
- print "\n", list2string(msg)
+ print(row)
+ print("\n", list2string(msg))
msg = set_argument(prompt="Message? ")
for row in msg:
- print row,
- print "\n", list2string(msg)
+ print(row)
+ print("\n", list2string(msg))
diff --git a/engine/src/tools/lib/song.py b/engine/src/tools/lib/song.py
index fdbba99..8383ffe 100644
--- a/engine/src/tools/lib/song.py
+++ b/engine/src/tools/lib/song.py
@@ -44,7 +44,7 @@ def hosts(opts, config):
config["music"]["hosts"] = _hosts["music"][opts.env or "dev"]["hosts"]["a"]
if opts.verbose:
- print "hosts: " + str(config["music"]["hosts"])
+ print("hosts: " + str(config["music"]["hosts"]))
# noinspection PyBroadException
@@ -61,7 +61,7 @@ class Song(Music):
"ist": "valet_IST",
"gj": "valet_TestDB2"
}
- Keyspaces.update(dict((v, v) for k, v in Keyspaces.iteritems())) # full name is valid too
+ Keyspaces.update(dict((v, v) for k, v in Keyspaces.items())) # full name is valid too
def __init__(self, opts, config, logger):
if opts.env:
@@ -143,7 +143,7 @@ def main():
config = json.loads(open(opts.config).read())
music = Song(opts, config, logger)
- print json.dumps(config.get("music"))
+ print (json.dumps(config.get("music")))
print (music.keyspace)
diff --git a/engine/src/tools/lib/tables.py b/engine/src/tools/lib/tables.py
index 7ad4836..b0957a4 100644
--- a/engine/src/tools/lib/tables.py
+++ b/engine/src/tools/lib/tables.py
@@ -94,7 +94,7 @@ class Tables(object):
result = self.music.read_row(self.keyspace, self.table(), key, row_id)["result"]
# strip "Row n"
- for _, data in sorted(result.iteritems()):
+ for _, data in sorted(result.items()):
rows.append(data)
if raw:
@@ -113,9 +113,9 @@ class Tables(object):
if raw:
if names:
- print "\n" + self.table()
+ print("\n" + self.table())
for row in rows:
- print row
+ print(row)
return
if isinstance(rows, list):
@@ -142,8 +142,8 @@ class Tables(object):
if json_file is None:
if names:
- print "\n" + self.table()
- print json.dumps(rows, sort_keys=True, indent=4)
+ print("\n" + self.table())
+ print (json.dumps(rows, sort_keys=True, indent=4))
return
fh = open(json_file, "w")
@@ -305,4 +305,4 @@ class Groups(Tables):
if __name__ == "__main__":
- print Tables.option_choices()
+ print(Tables.option_choices())
diff --git a/engine/src/tools/lock.py b/engine/src/tools/lock.py
index a77eb8a..c9e0cc9 100644
--- a/engine/src/tools/lock.py
+++ b/engine/src/tools/lock.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/usr/bin/env python2.7
+#!/usr/bin/env python3
import argparse
diff --git a/engine/src/tools/ppdb.py b/engine/src/tools/ppdb.py
index c89f0f2..93f3b9d 100644
--- a/engine/src/tools/ppdb.py
+++ b/engine/src/tools/ppdb.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/usr/bin/env python2.7
+#!/usr/bin/env python3
import sys
@@ -39,7 +39,7 @@ if __name__ == "__main__":
results = json.loads(inf.read())
if opts.verbose:
print (json.dumps(results, sort_keys=True, indent=4))
- print "---------------------------------------------"
+ print ("---------------------------------------------")
if "request" in results.keys():
key = "request"
@@ -57,7 +57,7 @@ if __name__ == "__main__":
print (json.dumps(result, sort_keys=True, indent=4))
sys.exit(0)
- for _, row in result.iteritems():
+ for _, row in result.items():
rr = json.loads(row["result"])
# for k, d in row.iteritems():
@@ -65,7 +65,7 @@ if __name__ == "__main__":
sys.stdout.write("result ")
sys.stdout.flush()
- print json.dumps(rr, indent=4)
+ print (json.dumps(rr, indent=4))
# for f in rr:
# for line in (json.dumps(f, sort_keys=True, indent=4)).splitlines():
# print "\t%s"%line
diff --git a/engine/src/valet/engine/app_manager/app.py b/engine/src/valet/engine/app_manager/app.py
index de6fb8f..4804cd0 100644
--- a/engine/src/valet/engine/app_manager/app.py
+++ b/engine/src/valet/engine/app_manager/app.py
@@ -326,7 +326,7 @@ class App(object):
stack = {}
- for rk, r in _stack["resources"].iteritems():
+ for rk, r in _stack["resources"].items():
if "type" not in r.keys():
self.status = "type key is missing in stack"
return None
@@ -359,7 +359,7 @@ class App(object):
self.logger.warning("non-applicable to valet: no server resource in stack")
return {}
- first_resource = stack[stack.keys()[0]]
+ first_resource = stack[list(stack)[0]]
apply_valet = False
# To apply Valet decision, availability_zone must exist.
@@ -369,7 +369,7 @@ class App(object):
if isinstance(az_value, list):
apply_valet = True
- for rk, r in stack.iteritems():
+ for rk, r in stack.items():
if apply_valet:
if "availability_zone" not in r["properties"].keys():
self.status = "az is missing in stack for valet"
@@ -400,7 +400,7 @@ class App(object):
def init_valet_groups(self):
"""Create Valet groups from input request."""
- for rk, r in self.stack.iteritems():
+ for rk, r in self.stack.items():
properties = r.get("properties", {})
metadata = properties.get("metadata", {})
@@ -490,7 +490,7 @@ class App(object):
if isinstance(_group_hint, dict):
# _group_hint is a single key/value pair
- g = _group_hint[_group_hint.keys()[0]]
+ g = _group_hint[list(_group_hint)[0]]
r_type = g.get("type", "none")
if r_type != "OS::Nova::ServerGroup":
@@ -570,23 +570,23 @@ class App(object):
def set_weight(self):
"""Set relative weight of each servers and groups."""
- for _, s in self.servers.iteritems():
+ for _, s in self.servers.items():
self._set_server_weight(s)
- for _, g in self.groups.iteritems():
+ for _, g in self.groups.items():
self._set_server_weight(g)
- for _, g in self.groups.iteritems():
+ for _, g in self.groups.items():
self._set_group_resource(g)
- for _, g in self.groups.iteritems():
+ for _, g in self.groups.items():
self._set_group_weight(g)
def _set_server_weight(self, _v):
"""Set relative weight of each server against available resource amount."""
if isinstance(_v, Group):
- for _, sg in _v.subgroups.iteritems():
+ for _, sg in _v.subgroups.items():
self._set_server_weight(sg)
else:
if self.resource.CPU_avail > 0:
@@ -616,7 +616,7 @@ class App(object):
if isinstance(_g, Server):
return
- for _, sg in _g.subgroups.iteritems():
+ for _, sg in _g.subgroups.items():
self._set_group_resource(sg)
_g.vCPUs += sg.vCPUs
_g.mem += sg.mem
@@ -649,7 +649,7 @@ class App(object):
else:
_group.local_volume_weight = 0.0
- for _, sg in _group.subgroups.iteritems():
+ for _, sg in _group.subgroups.items():
if isinstance(sg, Group):
self._set_group_weight(sg)
@@ -693,7 +693,7 @@ class App(object):
"""Get servers back from containers (i.e., affinity groups)"""
servers = []
- for _, g in self.groups.iteritems():
+ for _, g in self.groups.items():
g.get_servers(servers)
for s in servers:
diff --git a/engine/src/valet/engine/app_manager/app_handler.py b/engine/src/valet/engine/app_manager/app_handler.py
index 14ef35c..60370b3 100644
--- a/engine/src/valet/engine/app_manager/app_handler.py
+++ b/engine/src/valet/engine/app_manager/app_handler.py
@@ -175,7 +175,7 @@ class AppHandler(object):
return
# Set flavor properties for each server.
- for rk, r in _app.stack.iteritems():
+ for rk, r in _app.stack.items():
if "vcpus" not in r["properties"].keys():
flavor = _app.resource.get_flavor(r["properties"]["flavor"])
@@ -194,7 +194,7 @@ class AppHandler(object):
if len(flavor.extra_specs) > 0:
extra_specs = {}
- for mk, mv in flavor.extra_specs.iteritems():
+ for mk, mv in flavor.extra_specs.items():
extra_specs[mk] = mv
r["properties"]["extra_specs"] = extra_specs
@@ -268,7 +268,7 @@ class AppHandler(object):
"vnf_instance_name": _app.vnf_instance_name}
servers = {}
- for sk, s in _app.servers.iteritems():
+ for sk, s in _app.servers.items():
servers[sk] = s.get_json_info()
if not self.dbh.create_stack(_app.app_name,
diff --git a/engine/src/valet/engine/app_manager/app_parser.py b/engine/src/valet/engine/app_manager/app_parser.py
index 9e6336b..fcab60f 100644
--- a/engine/src/valet/engine/app_manager/app_parser.py
+++ b/engine/src/valet/engine/app_manager/app_parser.py
@@ -34,7 +34,7 @@ class Parser(object):
servers = {}
- for rk, r in _stack.iteritems():
+ for rk, r in _stack.items():
properties = r.get("properties")
server_name = properties["name"].strip()
@@ -65,7 +65,7 @@ class Parser(object):
ess = properties.get("extra_specs", {})
if len(ess) > 0:
extra_specs = {}
- for mk, mv in ess.iteritems():
+ for mk, mv in ess.items():
extra_specs[mk] = mv
server.extra_specs_list.append(extra_specs)
@@ -92,7 +92,7 @@ class Parser(object):
return {}, {}
# To delete all exclusivity and diversity groups after merging
- groups = {gk: g for gk, g in _groups.iteritems() if g.group_type == "affinity"}
+ groups = {gk: g for gk, g in _groups.items() if g.group_type == "affinity"}
return servers, groups
@@ -100,7 +100,7 @@ class Parser(object):
"""Merge diversity sub groups."""
for level in LEVEL:
- for gk, group in _groups.iteritems():
+ for gk, group in _groups.items():
if group.level == level and group.group_type == "diversity":
for sk in group.server_list:
if sk in _servers.keys():
@@ -116,7 +116,7 @@ class Parser(object):
"""Merge quorum-diversity sub groups."""
for level in LEVEL:
- for gk, group in _groups.iteritems():
+ for gk, group in _groups.items():
if group.level == level and group.group_type == "quorum-diversity":
for sk in group.server_list:
if sk in _servers.keys():
@@ -132,7 +132,7 @@ class Parser(object):
"""Merge exclusivity sub groups."""
for level in LEVEL:
- for gk, group in _groups.iteritems():
+ for gk, group in _groups.items():
if group.level == level and group.group_type == "exclusivity":
for sk in group.server_list:
if sk in _servers.keys():
@@ -199,21 +199,21 @@ class Parser(object):
def _add_implicit_diversity_groups(self, _group, _diversity_groups):
"""Add subgroup's diversity groups."""
- for dk, div_group in _diversity_groups.iteritems():
+ for dk, div_group in _diversity_groups.items():
if LEVEL.index(div_group.level) >= LEVEL.index(_group.level):
_group.diversity_groups[dk] = div_group
def _add_implicit_quorum_diversity_groups(self, _group, _quorum_diversity_groups):
"""Add subgroup's quorum diversity groups."""
- for dk, div_group in _quorum_diversity_groups.iteritems():
+ for dk, div_group in _quorum_diversity_groups.items():
if LEVEL.index(div_group.level) >= LEVEL.index(_group.level):
_group.quorum_diversity_groups[dk] = div_group
def _add_implicit_exclusivity_groups(self, _group, _exclusivity_groups):
"""Add subgroup's exclusivity groups."""
- for ek, ex_group in _exclusivity_groups.iteritems():
+ for ek, ex_group in _exclusivity_groups.items():
if LEVEL.index(ex_group.level) >= LEVEL.index(_group.level):
_group.exclusivity_groups[ek] = ex_group
diff --git a/engine/src/valet/engine/app_manager/group.py b/engine/src/valet/engine/app_manager/group.py
index 69c9339..0c0258c 100644
--- a/engine/src/valet/engine/app_manager/group.py
+++ b/engine/src/valet/engine/app_manager/group.py
@@ -80,7 +80,7 @@ class Group(object):
exclusivities = {}
- for exk, group in self.exclusivity_groups.iteritems():
+ for exk, group in self.exclusivity_groups.items():
if group.level == _level:
exclusivities[exk] = group
@@ -102,7 +102,7 @@ class Group(object):
exist = False
- for sgk, sg in self.subgroups.iteritems():
+ for sgk, sg in self.subgroups.items():
if sgk == _vk:
exist = True
break
@@ -117,7 +117,7 @@ class Group(object):
def get_servers(self, _servers):
"""Get all child servers."""
- for _, sg in self.subgroups.iteritems():
+ for _, sg in self.subgroups.items():
if isinstance(sg, Group):
sg.get_servers(_servers)
else:
@@ -128,7 +128,7 @@ class Group(object):
flavor_type_list = []
for extra_specs in self.extra_specs_list:
- for k, v in extra_specs.iteritems():
+ for k, v in extra_specs.items():
k_elements = k.split(':')
if len(k_elements) > 1:
if k_elements[0] == "aggregate_instance_extra_specs":
diff --git a/engine/src/valet/engine/app_manager/server.py b/engine/src/valet/engine/app_manager/server.py
index 9052285..9f0598e 100644
--- a/engine/src/valet/engine/app_manager/server.py
+++ b/engine/src/valet/engine/app_manager/server.py
@@ -85,7 +85,7 @@ class Server(object):
exclusivities = {}
- for exk, group in self.exclusivity_groups.iteritems():
+ for exk, group in self.exclusivity_groups.items():
if group.level == _level:
exclusivities[exk] = group
@@ -106,7 +106,7 @@ class Server(object):
flavor_type_list = []
for extra_specs in self.extra_specs_list:
- for k, v in extra_specs.iteritems():
+ for k, v in extra_specs.items():
k_elements = k.split(':')
if len(k_elements) > 1:
if k_elements[0] == "aggregate_instance_extra_specs":
diff --git a/engine/src/valet/engine/db_connect/db_apis/mem_db.py b/engine/src/valet/engine/db_connect/db_apis/mem_db.py
index b706c63..c6fc329 100644
--- a/engine/src/valet/engine/db_connect/db_apis/mem_db.py
+++ b/engine/src/valet/engine/db_connect/db_apis/mem_db.py
@@ -45,16 +45,16 @@ class MemDB(object):
rows = {"result": {}}
if table == self.requests_table:
- for k, v in self.requests.iteritems():
+ for k, v in self.requests.items():
rows["result"][k] = copy.deepcopy(v)
elif table == self.results_table:
- for k, v in self.results.iteritems():
+ for k, v in self.results.items():
rows["result"][k] = copy.deepcopy(v)
elif table == self.group_rules_table:
- for k, v in self.group_rules.iteritems():
+ for k, v in self.group_rules.items():
rows["result"][k] = copy.deepcopy(v)
elif table == self.groups_table:
- for k, v in self.groups.iteritems():
+ for k, v in self.groups.items():
rows["result"][k] = copy.deepcopy(v)
return rows
diff --git a/engine/src/valet/engine/db_connect/db_apis/music.py b/engine/src/valet/engine/db_connect/db_apis/music.py
index 85e2d31..655c317 100644
--- a/engine/src/valet/engine/db_connect/db_apis/music.py
+++ b/engine/src/valet/engine/db_connect/db_apis/music.py
@@ -57,7 +57,7 @@ class REST(object):
'ns': self.ns,
'accept': content_type,
'content-type': content_type,
- 'authorization': 'Basic %s' % base64.b64encode(self.userid + ':' + self.password)
+ 'authorization': 'Basic %s' % base64.b64encode((self.userid + ':' + self.password).encode()).decode()
}
return headers
@@ -99,7 +99,7 @@ class REST(object):
return response
except requests.exceptions.Timeout as err:
- err_message = err.message
+ err_message = str(err) #err.message
response = requests.Response()
response.url = full_url
if not timeout:
@@ -107,7 +107,7 @@ class REST(object):
timeout = True
except requests.exceptions.RequestException as err:
- err_message = err.message
+ err_message = str(err) #err.message
self.logger.debug("Music: %s Request Exception" % url)
self.logger.debug(" method = %s" % method)
self.logger.debug(" timeout = %s" % self.timeout)
diff --git a/engine/src/valet/engine/db_connect/db_handler.py b/engine/src/valet/engine/db_connect/db_handler.py
index 2165b8a..d3ad7ad 100644
--- a/engine/src/valet/engine/db_connect/db_handler.py
+++ b/engine/src/valet/engine/db_connect/db_handler.py
@@ -51,7 +51,7 @@ class DBHandler(object):
return []
if rows is not None and len(rows) > 0:
- for key, row in rows.iteritems():
+ for key, row in rows.items():
if key == "status":
if row == "FAILURE":
self.logger.error("DB: Failure in " + self.requests_table)
@@ -60,7 +60,7 @@ class DBHandler(object):
elif key == "error":
continue
elif key == "result":
- for _, dbrow in row.iteritems():
+ for _, dbrow in row.items():
request_list.append(dbrow)
if len(request_list) > 0:
@@ -105,13 +105,13 @@ class DBHandler(object):
return None
if rows is not None and len(rows) > 0:
- for key, row in rows.iteritems():
+ for key, row in rows.items():
if key == "status":
continue
elif key == "error":
continue
elif key == "result":
- for _, dbrow in row.iteritems():
+ for _, dbrow in row.items():
result_list.append(dbrow)
return result_list
@@ -158,7 +158,7 @@ class DBHandler(object):
self.logger.error("DB: while reading locked regions: " + str(e))
return None
- for _, data in sorted(result.iteritems()):
+ for _, data in sorted(result.items()):
if int(data["expire_time"]) < now():
self.logger.warning("lock on %s has timed out and is revoked" % data["region_id"])
@@ -234,7 +234,7 @@ class DBHandler(object):
if len(row) > 0:
if "result" in row.keys():
if len(row["result"]) > 0:
- return row["result"][row["result"].keys()[0]]
+ return row["result"][list(row["result"])[0]]
else:
return {}
else:
@@ -266,9 +266,9 @@ class DBHandler(object):
return None
if len(rows) > 0:
- for key, row in rows.iteritems():
+ for key, row in rows.items():
if key == "result":
- for _, dbrow in row.iteritems():
+ for _, dbrow in row.items():
rule_list.append(dbrow)
return rule_list
@@ -285,7 +285,7 @@ class DBHandler(object):
if len(row) > 0:
if "result" in row.keys():
if len(row["result"]) > 0:
- return row["result"][row["result"].keys()[0]]
+ return row["result"][list(row["result"])[0]]
else:
return {}
else:
@@ -326,9 +326,9 @@ class DBHandler(object):
return None
if len(rows) > 0:
- for key, row in rows.iteritems():
+ for key, row in rows.items():
if key == "result":
- for _, dbrow in row.iteritems():
+ for _, dbrow in row.items():
group_list.append(dbrow)
return group_list
@@ -403,7 +403,7 @@ class DBHandler(object):
if len(row) > 0:
if "result" in row.keys():
if len(row["result"]) > 0:
- return row["result"][row["result"].keys()[0]]
+ return row["result"][list(row["result"])[0]]
else:
return {}
else:
diff --git a/engine/src/valet/engine/resource_manager/compute_manager.py b/engine/src/valet/engine/resource_manager/compute_manager.py
index 81a95ee..3ee5154 100644
--- a/engine/src/valet/engine/resource_manager/compute_manager.py
+++ b/engine/src/valet/engine/resource_manager/compute_manager.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/bin/python
+#!/usr/bin/env python3
from valet.engine.resource_manager.resources.host import Host
@@ -151,7 +151,7 @@ class ComputeManager(object):
# the server is placed as planned.
change_of_placements = {}
- for hk, host in self.hosts.iteritems():
+ for hk, host in self.hosts.items():
rhost = _resource.hosts[hk]
for s_info in host.server_list:
@@ -170,7 +170,7 @@ class ComputeManager(object):
else:
change_of_placements[sid]["host"] = hk
- for rhk, rhost in _resource.hosts.iteritems():
+ for rhk, rhost in _resource.hosts.items():
if not rhost.is_available():
continue
diff --git a/engine/src/valet/engine/resource_manager/metadata_manager.py b/engine/src/valet/engine/resource_manager/metadata_manager.py
index f34e3f0..2625eb6 100644
--- a/engine/src/valet/engine/resource_manager/metadata_manager.py
+++ b/engine/src/valet/engine/resource_manager/metadata_manager.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/bin/python
+#!/usr/bin/env python3
import json
@@ -178,7 +178,7 @@ class MetadataManager(object):
def _check_host_memberships_updated(self, _resource):
"""Check host memberships consistency."""
- for gk, g in _resource.groups.iteritems():
+ for gk, g in _resource.groups.items():
# Other group types will be handled later
if g.factory != "valet" and g.status == "enabled":
for hk in g.member_hosts.keys():
@@ -189,7 +189,7 @@ class MetadataManager(object):
self.logger.info("host (" + hk + ") updated (update membership - " + gk + ")")
- for hk, host in _resource.hosts.iteritems():
+ for hk, host in _resource.hosts.items():
if host.is_available():
for gk in host.memberships.keys():
if gk in _resource.groups.keys():
@@ -240,7 +240,7 @@ class MetadataManager(object):
if len(_group.metadata) > 0:
metadata = {}
- for mk, mv in _group.metadata.iteritems():
+ for mk, mv in _group.metadata.items():
if mk == "prior_metadata":
metadata[mk] = json.dumps(mv)
else:
@@ -280,7 +280,7 @@ class MetadataManager(object):
if len(_metadata) > 0:
metadata = {}
- for mk, mv in _metadata.iteritems():
+ for mk, mv in _metadata.items():
if mk == "prior_metadata":
metadata[mk] = json.dumps(mv)
else:
@@ -312,7 +312,7 @@ class MetadataManager(object):
if len(_metadata) > 0:
metadata = {}
- for mk, mv in _metadata.iteritems():
+ for mk, mv in _metadata.items():
if mk == "prior_metadata":
metadata[mk] = json.dumps(mv)
else:
diff --git a/engine/src/valet/engine/resource_manager/naming.py b/engine/src/valet/engine/resource_manager/naming.py
index 69a404d..158d978 100644
--- a/engine/src/valet/engine/resource_manager/naming.py
+++ b/engine/src/valet/engine/resource_manager/naming.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/bin/python
+#!/usr/bin/env python3
import copy
@@ -42,7 +42,7 @@ class Naming(object):
status = "ok"
- for rhk, rhost in _rhosts.iteritems():
+ for rhk, rhost in _rhosts.items():
h = copy.deepcopy(rhost)
(rack_name, parsing_status) = self._set_layout_by_name(rhk)
@@ -65,7 +65,7 @@ class Naming(object):
_hosts[h.name] = h
- for hgk, hg in _host_groups.iteritems():
+ for hgk, hg in _host_groups.items():
hg.parent_resource = _datacenter
_datacenter.resources[hgk] = hg
diff --git a/engine/src/valet/engine/resource_manager/nova_compute.py b/engine/src/valet/engine/resource_manager/nova_compute.py
index 6887eb8..50de589 100644
--- a/engine/src/valet/engine/resource_manager/nova_compute.py
+++ b/engine/src/valet/engine/resource_manager/nova_compute.py
@@ -1,21 +1,21 @@
-#
-# -------------------------------------------------------------------------
-# Copyright (c) 2019 AT&T Intellectual Property
-#
-# 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.
-#
-# -------------------------------------------------------------------------
-#
+#
+# -------------------------------------------------------------------------
+# Copyright (c) 2019 AT&T Intellectual Property
+#
+# 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.
+#
+# -------------------------------------------------------------------------
+#
import json
import time
import traceback
@@ -141,7 +141,7 @@ class NovaCompute(object):
# TODO: Get AZ first with init Compute Hosts?
- for hk, h_info in a.hosts.iteritems():
+ for hk, h_info in a.hosts.items():
if "nova-compute" in h_info.keys():
if h_info["nova-compute"]["active"] and \
h_info["nova-compute"]["available"]:
@@ -538,7 +538,7 @@ class NovaCompute(object):
flavor.disk_cap = root_gb + ephemeral_gb + swap_mb / float(1024)
extra_specs = _f.get_keys()
- for sk, sv in extra_specs.iteritems():
+ for sk, sv in extra_specs.items():
flavor.extra_specs[sk] = sv
return flavor
diff --git a/engine/src/valet/engine/resource_manager/resource.py b/engine/src/valet/engine/resource_manager/resource.py
index 0f2b550..90fba0d 100644
--- a/engine/src/valet/engine/resource_manager/resource.py
+++ b/engine/src/valet/engine/resource_manager/resource.py
@@ -158,7 +158,7 @@ class Resource(object):
hgs = resource.get("host_groups")
if hgs:
- for hgk, hg in hgs.iteritems():
+ for hgk, hg in hgs.items():
host_group = self.host_groups[hgk]
pk = hg.get("parent")
@@ -175,7 +175,7 @@ class Resource(object):
hs = resource.get("hosts")
if hs:
- for hk, h in hs.iteritems():
+ for hk, h in hs.items():
host = self.hosts[hk]
pk = h.get("parent")
@@ -184,7 +184,7 @@ class Resource(object):
elif pk in self.host_groups.keys():
host.host_group = self.host_groups[pk]
- for _, g in self.groups.iteritems():
+ for _, g in self.groups.items():
for hk in g.member_hosts.keys():
if hk not in self.hosts.keys() and \
hk not in self.host_groups.keys():
@@ -199,7 +199,7 @@ class Resource(object):
create Group instance.
"""
- for gk, g in _groups.iteritems():
+ for gk, g in _groups.items():
group = Group(gk)
group.status = g.get("status")
@@ -214,13 +214,13 @@ class Resource(object):
if rule_id != "none" and rule_id in self.group_rules.keys():
group.rule = self.group_rules[rule_id]
- for mk, mv in g["metadata"].iteritems():
+ for mk, mv in g["metadata"].items():
group.metadata[mk] = mv
for s_info in g["server_list"]:
group.server_list.append(s_info)
- for hk, server_list in g["member_hosts"].iteritems():
+ for hk, server_list in g["member_hosts"].items():
group.member_hosts[hk] = []
for s_info in server_list:
group.member_hosts[hk].append(s_info)
@@ -232,7 +232,7 @@ class Resource(object):
create Flavor instance.
"""
- for fk, f in _flavors.iteritems():
+ for fk, f in _flavors.items():
flavor = Flavor(fk)
flavor.status = f.get("status")
@@ -241,7 +241,7 @@ class Resource(object):
flavor.vCPUs = f.get("vCPUs")
flavor.mem_cap = f.get("mem")
flavor.disk_cap = f.get("disk")
- for k, v in f["extra_specs"].iteritems():
+ for k, v in f["extra_specs"].items():
flavor.extra_specs[k] = v
self.flavors[fk] = flavor
@@ -251,7 +251,7 @@ class Resource(object):
create Host instance.
"""
- for hk, h in _hosts.iteritems():
+ for hk, h in _hosts.items():
host = Host(hk)
host.status = h.get("status")
@@ -286,7 +286,7 @@ class Resource(object):
# Not used by Valet currently, only capacity planning module
if "candidate_host_types" in h.keys():
- for htk, ht in h["candidate_host_types"].iteritems():
+ for htk, ht in h["candidate_host_types"].items():
host.candidate_host_types[htk] = ht
else:
host.candidate_host_types = {}
@@ -294,7 +294,7 @@ class Resource(object):
self.hosts[hk] = host
def _load_host_groups(self, _host_groups):
- for hgk, hg in _host_groups.iteritems():
+ for hgk, hg in _host_groups.items():
host_group = HostGroup(hgk)
host_group.status = hg.get("status")
@@ -351,7 +351,7 @@ class Resource(object):
"""Update resource status triggered by placements, events, and batch."""
for level in LEVEL:
- for _, host_group in self.host_groups.iteritems():
+ for _, host_group in self.host_groups.items():
if host_group.host_type == level:
if host_group.is_available() and host_group.updated:
self._update_host_group(host_group)
@@ -368,7 +368,7 @@ class Resource(object):
del _host_group.server_list[:]
_host_group.init_memberships()
- for _, host in _host_group.child_resources.iteritems():
+ for _, host in _host_group.child_resources.items():
if host.is_available():
_host_group.vCPUs += host.vCPUs
_host_group.avail_vCPUs += host.avail_vCPUs
@@ -390,7 +390,7 @@ class Resource(object):
del self.datacenter.server_list[:]
self.datacenter.memberships.clear()
- for _, resource in self.datacenter.resources.iteritems():
+ for _, resource in self.datacenter.resources.items():
if resource.is_available():
self.datacenter.vCPUs += resource.vCPUs
self.datacenter.avail_vCPUs += resource.avail_vCPUs
@@ -412,7 +412,7 @@ class Resource(object):
cpu_allocation_ratio_list = []
disk_allocation_ratio_list = []
- for _, g in host.memberships.iteritems():
+ for _, g in host.memberships.items():
if g.group_type == "aggr":
if g.name.startswith("valet:"):
metadata = g.metadata["prior_metadata"]
@@ -531,7 +531,7 @@ class Resource(object):
if host_name is not None:
host = self.hosts[host_name]
else:
- for _, h in self.hosts.iteritems():
+ for _, h in self.hosts.items():
if h.has_server(_s_info):
host = h
break
@@ -547,7 +547,7 @@ class Resource(object):
if change_of_placements is None:
change_of_placements = self.change_of_placements
- for _, change in change_of_placements.iteritems():
+ for _, change in change_of_placements.items():
if "new_host" in change and "old_host" in change:
# Migration case
@@ -707,7 +707,7 @@ class Resource(object):
if new_groups is None:
new_groups = self._get_new_grouping()
- for _, placement in change_of_placements.iteritems():
+ for _, placement in change_of_placements.items():
if "new_host" in placement.keys() and "old_host" in placement.keys():
# Migrated server. This server can be unknown one previously.
@@ -777,13 +777,13 @@ class Resource(object):
# Add host's memberships for server-group.
# Do not need to verify.
- for _, placement in change_of_placements.iteritems():
+ for _, placement in change_of_placements.items():
if "new_host" in placement.keys():
host = self.hosts[placement.get("new_host")]
s_info = placement.get("info")
new_info = host.get_server_info(s_info)
- for gk, g in self.groups.iteritems():
+ for gk, g in self.groups.items():
if g.factory == "server-group" and g.status == "enabled":
if g.has_server_uuid(new_info.get("uuid")):
if gk not in host.memberships.keys():
@@ -806,7 +806,7 @@ class Resource(object):
_uuid = _s_info.get("uuid")
_name = _s_info.get("name")
- for gk, server_list in new_groups.iteritems():
+ for gk, server_list in new_groups.items():
for s_info in server_list:
if s_info["uuid"] != "none":
if s_info["uuid"] == _uuid:
@@ -1048,7 +1048,7 @@ class Resource(object):
def get_group_by_uuid(self, _uuid):
"""Check and get the group with its uuid."""
- for _, g in self.groups.iteritems():
+ for _, g in self.groups.items():
if g.uuid == _uuid:
return g
@@ -1151,7 +1151,7 @@ class Resource(object):
if a.name.startswith("valet:"):
continue
- for mk, mv in a.metadata.iteritems():
+ for mk, mv in a.metadata.items():
if mk not in ex_metadata.keys():
ex_metadata[mk] = mv
else:
@@ -1222,7 +1222,7 @@ class Resource(object):
if a.name.startswith("valet:"):
continue
- for mk, mv in a.metadata.iteritems():
+ for mk, mv in a.metadata.items():
if mk not in ex_metadata.keys():
ex_metadata[mk] = mv
else:
@@ -1400,7 +1400,7 @@ class Resource(object):
# Update total capacities of each host.
# Triggered by overcommit ratio update or newly added.
- for _, host in self.hosts.iteritems():
+ for _, host in self.hosts.items():
if host.is_available() and host.updated:
self.compute_resources(host)
@@ -1411,7 +1411,7 @@ class Resource(object):
# Update the available capacities of each NUMA and host.
# Triggered by unknown server additions and deletions.
- for _, host in self.hosts.iteritems():
+ for _, host in self.hosts.items():
if host.is_available() and host.updated:
self.compute_avail_resources(host)
@@ -1443,7 +1443,7 @@ class Resource(object):
if flavor_id in self.flavors.keys():
flavor = self.flavors[flavor_id]
else:
- for _, f in self.flavors.iteritems():
+ for _, f in self.flavors.items():
if f.flavor_id == flavor_id:
flavor = f
break
@@ -1488,20 +1488,20 @@ class Resource(object):
# Do not store disbaled resources.
- for fk, flavor in self.flavors.iteritems():
+ for fk, flavor in self.flavors.items():
# TODO(Gueyoung): store disabled flavor?
flavor_updates[fk] = flavor.get_json_info()
- for gk, group in self.groups.iteritems():
+ for gk, group in self.groups.items():
if group.status == "enabled":
if group.factory != "valet":
group_updates[gk] = group.get_json_info()
- for hk, host in self.hosts.iteritems():
+ for hk, host in self.hosts.items():
if host.is_available():
host_updates[hk] = host.get_json_info()
- for hgk, host_group in self.host_groups.iteritems():
+ for hgk, host_group in self.host_groups.items():
if host_group.is_available():
host_group_updates[hgk] = host_group.get_json_info()
@@ -1547,14 +1547,14 @@ class Resource(object):
self.logger.debug("hosts = " + json.dumps(json_update['hosts'], indent=4))
self.logger.debug("groups = " + json.dumps(json_update['groups'], indent=4))
self.logger.debug("flavors = ")
- for fk, f_info in json_update['flavors'].iteritems():
+ for fk, f_info in json_update['flavors'].items():
if f_info["vCPUs"] > 0:
self.logger.debug(json.dumps(f_info, indent=4))
updated_valet_groups = {}
new_valet_groups = {}
deleted_valet_groups = {}
- for gk, group in self.groups.iteritems():
+ for gk, group in self.groups.items():
if group.status == "enabled":
if group.factory == "valet":
if group.new:
@@ -1565,21 +1565,21 @@ class Resource(object):
if group.factory == "valet":
deleted_valet_groups[gk] = group.get_json_info()
- for gk, g_info in new_valet_groups.iteritems():
+ for gk, g_info in new_valet_groups.items():
if not self.dbh.create_valet_group(gk, g_info):
return False
self.logger.debug("new valet group = " + gk)
self.logger.debug("info = " + json.dumps(g_info, indent=4))
- for gk, g_info in updated_valet_groups.iteritems():
+ for gk, g_info in updated_valet_groups.items():
if not self.dbh.update_valet_group(gk, g_info):
return False
self.logger.debug("updated valet group = " + gk)
self.logger.debug("info = " + json.dumps(g_info, indent=4))
- for gk, g_info in deleted_valet_groups.iteritems():
+ for gk, g_info in deleted_valet_groups.items():
if not self.dbh.delete_valet_group(gk):
return False
diff --git a/engine/src/valet/engine/resource_manager/resource_handler.py b/engine/src/valet/engine/resource_manager/resource_handler.py
index 38868c7..179ac5a 100644
--- a/engine/src/valet/engine/resource_manager/resource_handler.py
+++ b/engine/src/valet/engine/resource_manager/resource_handler.py
@@ -124,7 +124,7 @@ class ResourceHandler:
if valet_group_list is None:
return None
- for rk, rule in self.group_rules.iteritems():
+ for rk, rule in self.group_rules.items():
rule_info = self._get_rule(rule)
for vg in valet_group_list:
@@ -163,7 +163,7 @@ class ResourceHandler:
rule = self.group_rules[_rule_name]
- for gk, g in _resource.groups.iteritems():
+ for gk, g in _resource.groups.items():
if g.factory == "valet":
if g.rule.rule_id == _rule_name:
placements[gk] = self._get_placements(g, _resource)
@@ -185,7 +185,7 @@ class ResourceHandler:
placements = {}
- for hk, server_list in _g.member_hosts.iteritems():
+ for hk, server_list in _g.member_hosts.items():
for s_info in server_list:
sid = s_info.get("stack_name") + ":" + s_info.get("name")
placements[sid] = {}
@@ -216,7 +216,7 @@ class ResourceHandler:
if hg.host_type == "rack":
placements[sid]["rack"] = hg.name
- for hhk, host in hg.child_resources.iteritems():
+ for hhk, host in hg.child_resources.items():
if host.has_server(s_info):
placements[sid]["host"] = host.name
diff --git a/engine/src/valet/engine/resource_manager/resources/datacenter.py b/engine/src/valet/engine/resource_manager/resources/datacenter.py
index 6f03bae..bdf6554 100644
--- a/engine/src/valet/engine/resource_manager/resources/datacenter.py
+++ b/engine/src/valet/engine/resource_manager/resources/datacenter.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/bin/python
+#!/usr/bin/env python3
class Datacenter(object):
diff --git a/engine/src/valet/engine/resource_manager/resources/flavor.py b/engine/src/valet/engine/resource_manager/resources/flavor.py
index ef8b13e..65f4150 100644
--- a/engine/src/valet/engine/resource_manager/resources/flavor.py
+++ b/engine/src/valet/engine/resource_manager/resources/flavor.py
@@ -46,7 +46,7 @@ class Flavor(object):
self.mem_cap = _f.mem_cap
self.disk_cap = _f.disk_cap
- for ek, ev in _f.extra_specs.iteritems():
+ for ek, ev in _f.extra_specs.items():
self.extra_specs[ek] = ev
def need_numa_alignment(self):
diff --git a/engine/src/valet/engine/resource_manager/resources/group_rule.py b/engine/src/valet/engine/resource_manager/resources/group_rule.py
index d43dc12..6909f37 100644
--- a/engine/src/valet/engine/resource_manager/resources/group_rule.py
+++ b/engine/src/valet/engine/resource_manager/resources/group_rule.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/bin/python
+#!/usr/bin/env/ python3
class GroupRule(object):
diff --git a/engine/src/valet/engine/resource_manager/resources/host.py b/engine/src/valet/engine/resource_manager/resources/host.py
index a4d92ba..18b6840 100644
--- a/engine/src/valet/engine/resource_manager/resources/host.py
+++ b/engine/src/valet/engine/resource_manager/resources/host.py
@@ -382,7 +382,7 @@ class Host(object):
def get_availability_zone(self):
"""Get the availability-zone of this host."""
- for gk, g in self.memberships.iteritems():
+ for gk, g in self.memberships.items():
if g.group_type == "az":
return g
@@ -393,7 +393,7 @@ class Host(object):
aggregates = []
- for gk, g in self.memberships.iteritems():
+ for gk, g in self.memberships.items():
if g.group_type == "aggr":
aggregates.append(g)
diff --git a/engine/src/valet/engine/resource_manager/topology_manager.py b/engine/src/valet/engine/resource_manager/topology_manager.py
index f8422d3..f5fa421 100644
--- a/engine/src/valet/engine/resource_manager/topology_manager.py
+++ b/engine/src/valet/engine/resource_manager/topology_manager.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/bin/python
+#!/usr/bin/env python3
from valet.engine.resource_manager.resources.datacenter import Datacenter
diff --git a/engine/src/valet/engine/search/avail_resources.py b/engine/src/valet/engine/search/avail_resources.py
index c4484b8..70e611e 100644
--- a/engine/src/valet/engine/search/avail_resources.py
+++ b/engine/src/valet/engine/search/avail_resources.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/bin/python
+#!/usr/bin/env python3
from valet.engine.app_manager.group import LEVEL
@@ -47,7 +47,7 @@ class AvailResources(object):
def set_next_avail_hosts(self, _avail_hosts, _resource_of_level):
"""Set the next level of available hosting resources."""
- for hk, h in _avail_hosts.iteritems():
+ for hk, h in _avail_hosts.items():
if self.level == "rack":
if h.rack_name == _resource_of_level:
self.avail_hosts[hk] = h
@@ -57,7 +57,7 @@ class AvailResources(object):
def set_candidates(self):
if self.level == "rack":
- for _, h in self.avail_hosts.iteritems():
+ for _, h in self.avail_hosts.items():
self.candidates[h.rack_name] = h
elif self.level == "host":
self.candidates = self.avail_hosts
@@ -66,7 +66,7 @@ class AvailResources(object):
candidate = None
if self.level == "rack":
- for _, h in self.avail_hosts.iteritems():
+ for _, h in self.avail_hosts.items():
if h.rack_name == _resource.rack_name:
candidate = h
elif self.level == "host":
diff --git a/engine/src/valet/engine/search/constraint_solver.py b/engine/src/valet/engine/search/constraint_solver.py
index 2593db8..27e940d 100644
--- a/engine/src/valet/engine/search/constraint_solver.py
+++ b/engine/src/valet/engine/search/constraint_solver.py
@@ -75,7 +75,7 @@ class ConstraintSolver(object):
# This is the resource which name is 'any'
ghost_candidate = None
- for _, r in _avail_resources.candidates.iteritems():
+ for _, r in _avail_resources.candidates.items():
candidate_list.append(r)
if r.get_resource_name(level) == "any":
diff --git a/engine/src/valet/engine/search/filters/affinity_filter.py b/engine/src/valet/engine/search/filters/affinity_filter.py
index fb9aadc..6fc1427 100644
--- a/engine/src/valet/engine/search/filters/affinity_filter.py
+++ b/engine/src/valet/engine/search/filters/affinity_filter.py
@@ -62,7 +62,7 @@ class AffinityFilter(object):
"""Filter based on named affinity group."""
memberships = _candidate.get_all_memberships(_level)
- for gk, gr in memberships.iteritems():
+ for gk, gr in memberships.items():
if gr.group_type == "affinity" and gk == self.affinity_id:
return True
diff --git a/engine/src/valet/engine/search/filters/aggregate_instance_filter.py b/engine/src/valet/engine/search/filters/aggregate_instance_filter.py
index 753d16f..6911b24 100644
--- a/engine/src/valet/engine/search/filters/aggregate_instance_filter.py
+++ b/engine/src/valet/engine/search/filters/aggregate_instance_filter.py
@@ -61,7 +61,7 @@ class AggregateInstanceExtraSpecsFilter(object):
else:
# In rack level, if any host's host_type in the rack is not determined,
# skip the filter
- for _, rh in self.avail_hosts.iteritems():
+ for _, rh in self.avail_hosts.items():
if rh.rack_name == _candidate.rack_name:
if len(rh.candidate_host_types) > 0:
return True
@@ -69,7 +69,7 @@ class AggregateInstanceExtraSpecsFilter(object):
metadatas = filter_utils.aggregate_metadata_get_by_host(_level, _candidate)
for extra_specs in _v.extra_specs_list:
- for gk, metadata in metadatas.iteritems():
+ for gk, metadata in metadatas.items():
if self._match_metadata(gk, extra_specs, metadata):
break
else:
diff --git a/engine/src/valet/engine/search/filters/diversity_filter.py b/engine/src/valet/engine/search/filters/diversity_filter.py
index 882e11a..47ce33a 100644
--- a/engine/src/valet/engine/search/filters/diversity_filter.py
+++ b/engine/src/valet/engine/search/filters/diversity_filter.py
@@ -31,7 +31,7 @@ class DiversityFilter(object):
def check_pre_condition(self, _level, _v, _avail_hosts, _avail_groups):
if len(_v.diversity_groups) > 0:
- for _, div_group in _v.diversity_groups.iteritems():
+ for _, div_group in _v.diversity_groups.items():
if div_group.level == _level:
self.diversity_list.append(div_group.vid)
@@ -55,7 +55,7 @@ class DiversityFilter(object):
memberships = _candidate.get_memberships(_level)
for diversity_id in self.diversity_list:
- for gk, gr in memberships.iteritems():
+ for gk, gr in memberships.items():
if gr.group_type == "diversity" and gk == diversity_id:
return False
diff --git a/engine/src/valet/engine/search/filters/dynamic_aggregate_filter.py b/engine/src/valet/engine/search/filters/dynamic_aggregate_filter.py
index 709a9b9..4811378 100644
--- a/engine/src/valet/engine/search/filters/dynamic_aggregate_filter.py
+++ b/engine/src/valet/engine/search/filters/dynamic_aggregate_filter.py
@@ -85,7 +85,7 @@ class DynamicAggregateFilter(object):
candidate.adjust_avail_resources(ha)
# Change all others in the same rack.
- for hrk, hr in self.avail_hosts.iteritems():
+ for hrk, hr in self.avail_hosts.items():
if hrk != candidate.host_name:
if hr.rack_name == candidate.rack_name:
hr.adjust_avail_rack_resources(ha,
@@ -130,7 +130,7 @@ class DynamicAggregateFilter(object):
candidate.candidate_host_types = copy.deepcopy(candidate.old_candidate_host_types)
candidate.old_candidate_host_types.clear()
- for hrk, hr in self.avail_hosts.iteritems():
+ for hrk, hr in self.avail_hosts.items():
if hrk != candidate.host_name:
if hr.rack_name == candidate.rack_name:
hr.rollback_avail_rack_resources(ha,
diff --git a/engine/src/valet/engine/search/filters/exclusivity_filter.py b/engine/src/valet/engine/search/filters/exclusivity_filter.py
index 77efd97..6328c03 100644
--- a/engine/src/valet/engine/search/filters/exclusivity_filter.py
+++ b/engine/src/valet/engine/search/filters/exclusivity_filter.py
@@ -37,7 +37,7 @@ class ExclusivityFilter(object):
return False
if len(exclusivities) == 1:
- ex_group = exclusivities[exclusivities.keys()[0]]
+ ex_group = exclusivities[list(exclusivities)[0]]
if ex_group.level == _level:
self.exclusivity_id = ex_group.vid
@@ -66,7 +66,7 @@ class ExclusivityFilter(object):
def _check_exclusive_candidate(self, _level, _candidate):
memberships = _candidate.get_memberships(_level)
- for gk, gr in memberships.iteritems():
+ for gk, gr in memberships.items():
if gr.group_type == "exclusivity" and gk == self.exclusivity_id:
return True
diff --git a/engine/src/valet/engine/search/filters/filter_utils.py b/engine/src/valet/engine/search/filters/filter_utils.py
index 1005263..2a10980 100644
--- a/engine/src/valet/engine/search/filters/filter_utils.py
+++ b/engine/src/valet/engine/search/filters/filter_utils.py
@@ -82,7 +82,7 @@ def aggregate_metadata_get_by_host(_level, _host, _key=None):
groups = _host.get_memberships(_level)
- for gk, g in groups.iteritems():
+ for gk, g in groups.items():
if g.group_type == "aggr":
if _key is None or _key in g.metadata:
metadata = collections.defaultdict(set)
@@ -104,7 +104,7 @@ def availability_zone_get_by_host(_level, _host):
groups = _host.get_memberships(_level)
- for gk, g in groups.iteritems():
+ for gk, g in groups.items():
if g.group_type == "az":
g_name_elements = gk.split(':', 1)
if len(g_name_elements) > 1:
diff --git a/engine/src/valet/engine/search/filters/no_exclusivity_filter.py b/engine/src/valet/engine/search/filters/no_exclusivity_filter.py
index 43516fe..3920653 100644
--- a/engine/src/valet/engine/search/filters/no_exclusivity_filter.py
+++ b/engine/src/valet/engine/search/filters/no_exclusivity_filter.py
@@ -46,7 +46,7 @@ class NoExclusivityFilter(object):
def _check_candidate(self, _level, _candidate):
memberships = _candidate.get_memberships(_level)
- for _, g in memberships.iteritems():
+ for _, g in memberships.items():
if g.group_type == "exclusivity" and g.level == _level:
return False
diff --git a/engine/src/valet/engine/search/filters/quorum_diversity_filter.py b/engine/src/valet/engine/search/filters/quorum_diversity_filter.py
index 6388ebc..ba6fad8 100644
--- a/engine/src/valet/engine/search/filters/quorum_diversity_filter.py
+++ b/engine/src/valet/engine/search/filters/quorum_diversity_filter.py
@@ -34,7 +34,7 @@ class QuorumDiversityFilter(object):
def check_pre_condition(self, _level, _v, _avail_hosts, _avail_groups):
if len(_v.quorum_diversity_groups) > 0:
- for _, qdiv_group in _v.quorum_diversity_groups.iteritems():
+ for _, qdiv_group in _v.quorum_diversity_groups.items():
if qdiv_group.level == _level:
self.quorum_diversity_group_list.append(qdiv_group)
@@ -69,7 +69,7 @@ class QuorumDiversityFilter(object):
memberships = _candidate.get_memberships(_level)
for qdiv in self.quorum_diversity_group_list:
- for gk, gr in memberships.iteritems():
+ for gk, gr in memberships.items():
if gr.group_type == "quorum-diversity" and gk == qdiv.vid:
return False
@@ -87,7 +87,7 @@ class QuorumDiversityFilter(object):
num_of_placed_servers_in_candidate = -1
- for gk, gr in memberships.iteritems():
+ for gk, gr in memberships.items():
if gr.group_type == "quorum-diversity" and gk == qdiv.vid:
# Total num of servers under this rule
total_num_of_servers += gr.original_num_of_placed_servers
diff --git a/engine/src/valet/engine/search/optimizer.py b/engine/src/valet/engine/search/optimizer.py
index de45cee..b745a2b 100644
--- a/engine/src/valet/engine/search/optimizer.py
+++ b/engine/src/valet/engine/search/optimizer.py
@@ -100,7 +100,7 @@ class Optimizer(object):
def _set_app(self, _app, _state):
"""Update with assigned hosts."""
- for v, p in self.search.node_placements.iteritems():
+ for v, p in self.search.node_placements.items():
if isinstance(v, Server):
v.host = p.host_name
if p.rack_name != "any":
@@ -127,7 +127,7 @@ class Optimizer(object):
def _update_app(self, _app):
"""Update state of servers."""
- for sk, s in _app.servers.iteritems():
+ for sk, s in _app.servers.items():
if s["host"] == "none":
continue
@@ -161,7 +161,7 @@ class Optimizer(object):
And update placements if they have been changed.
"""
- for sk, s in _app.servers.iteritems():
+ for sk, s in _app.servers.items():
if s["host"] == "none":
continue
@@ -201,7 +201,7 @@ class Optimizer(object):
# If host's type (i.e., host-aggregate) is not determined before,
# Convert/set host's type to one as specified in VM.
- for v, p in self.search.node_placements.iteritems():
+ for v, p in self.search.node_placements.items():
if isinstance(v, Server):
# The host object p was deep copied, so use original object.
rh = self.search.avail_hosts[p.host_name]
@@ -217,7 +217,7 @@ class Optimizer(object):
placements = {}
- for v, p in self.search.node_placements.iteritems():
+ for v, p in self.search.node_placements.items():
if isinstance(v, Server):
s_info = {}
@@ -254,11 +254,11 @@ class Optimizer(object):
groups = {}
- for v, p in self.search.node_placements.iteritems():
+ for v, p in self.search.node_placements.items():
if isinstance(v, Server):
rh = self.search.avail_hosts[p.host_name]
- for gk, g in rh.host_memberships.iteritems():
+ for gk, g in rh.host_memberships.items():
if g.factory in ("valet", "server-group"):
if g.level == "host":
_app.resource.add_group(gk,
@@ -268,7 +268,7 @@ class Optimizer(object):
rh.host_name)
if rh.rack_name != "any":
- for gk, g in rh.rack_memberships.iteritems():
+ for gk, g in rh.rack_memberships.items():
if g.factory in ("valet", "server-group"):
if g.level == "rack":
_app.resource.add_group(gk,
@@ -329,7 +329,7 @@ class Optimizer(object):
Remove placements from NUMA cells of resource object.
"""
- for v, p in self.search.node_placements.iteritems():
+ for v, p in self.search.node_placements.items():
if isinstance(v, Server):
s_info = {}
@@ -396,7 +396,7 @@ class Optimizer(object):
placements = {}
- for sk, s in _app.servers.iteritems():
+ for sk, s in _app.servers.items():
if s["host"] == "none":
continue
@@ -449,7 +449,7 @@ class Optimizer(object):
placements = {}
- for sk, s in _app.servers.iteritems():
+ for sk, s in _app.servers.items():
if s["host"] == "none":
continue
diff --git a/engine/src/valet/engine/search/resource.py b/engine/src/valet/engine/search/resource.py
index 18c8ca7..12b96bd 100644
--- a/engine/src/valet/engine/search/resource.py
+++ b/engine/src/valet/engine/search/resource.py
@@ -125,7 +125,7 @@ class HostResource(object):
self.NUMA = NUMA(numa=host_type["NUMA"])
if self.candidate_host_types is not None:
- for htk, htl in self.candidate_host_types.iteritems():
+ for htk, htl in self.candidate_host_types.items():
if htk == "mockup":
self.rack_avail_vCPUs -= htl[0]["avail_vCPUs"]
self.rack_avail_mem -= htl[0]["avail_mem"]
@@ -162,7 +162,7 @@ class HostResource(object):
host_type = self.get_host_type(_ha, self.old_candidate_host_types)
if self.old_candidate_host_types is not None:
- for htk, htl in self.old_candidate_host_types.iteritems():
+ for htk, htl in self.old_candidate_host_types.items():
if htk == "mockup":
self.host_avail_vCPUs = htl[0]["avail_vCPUs"]
self.host_avail_mem = htl[0]["avail_mem"]
@@ -243,12 +243,12 @@ class HostResource(object):
memberships = {}
if _level == "rack":
- for mk, m in self.rack_memberships.iteritems():
+ for mk, m in self.rack_memberships.items():
memberships[mk] = m
- for mk, m in self.host_memberships.iteritems():
+ for mk, m in self.host_memberships.items():
memberships[mk] = m
elif _level == "host":
- for mk, m in self.host_memberships.iteritems():
+ for mk, m in self.host_memberships.items():
memberships[mk] = m
return memberships
diff --git a/engine/src/valet/engine/search/search.py b/engine/src/valet/engine/search/search.py
index 40added..aa4e11d 100644
--- a/engine/src/valet/engine/search/search.py
+++ b/engine/src/valet/engine/search/search.py
@@ -88,7 +88,7 @@ class Search(object):
availability-zone, host-aggregate, server-group.
"""
- for gk, g in self.resource.groups.iteritems():
+ for gk, g in self.resource.groups.items():
if g.status != "enabled":
self.logger.debug("group (" + g.name + ") disabled")
continue
@@ -104,7 +104,7 @@ class Search(object):
else:
gr.level = "host"
- for mk, mv in g.metadata.iteritems():
+ for mk, mv in g.metadata.items():
gr.metadata[mk] = mv
gr.original_num_of_placed_servers = len(g.server_list)
@@ -118,7 +118,7 @@ class Search(object):
def _create_avail_hosts(self):
"""Create all available hosts."""
- for hk, host in self.resource.hosts.iteritems():
+ for hk, host in self.resource.hosts.items():
if not host.is_available():
self.logger.warning("host (" + host.name + ") not available at this time")
continue
@@ -132,7 +132,7 @@ class Search(object):
# Not used by Valet, only capacity planning
try:
- for htk, ht in host.candidate_host_types.iteritems():
+ for htk, ht in host.candidate_host_types.items():
hr.candidate_host_types[htk] = copy.deepcopy(ht)
except AttributeError:
hr.candidate_host_types = {}
@@ -214,11 +214,11 @@ class Search(object):
open_node_list = []
- for _, s in _servers.iteritems():
+ for _, s in _servers.items():
self._set_node_weight(s)
open_node_list.append(s)
- for _, g in _groups.iteritems():
+ for _, g in _groups.items():
self._set_node_weight(g)
open_node_list.append(g)
@@ -403,11 +403,11 @@ class Search(object):
self._add_group(_level, _best, _n)
if len(_n.diversity_groups) > 0:
- for _, div_group in _n.diversity_groups.iteritems():
+ for _, div_group in _n.diversity_groups.items():
self._add_group(_level, _best, div_group)
if len(_n.quorum_diversity_groups) > 0:
- for _, div_group in _n.quorum_diversity_groups.iteritems():
+ for _, div_group in _n.quorum_diversity_groups.items():
self._add_group(_level, _best, div_group)
# Apply this placement to hosting resources.
@@ -440,12 +440,12 @@ class Search(object):
if _group.level == "host":
if _group.vid not in chosen_host.host_memberships.keys():
chosen_host.host_memberships[_group.vid] = gr
- for _, np in self.avail_hosts.iteritems():
+ for _, np in self.avail_hosts.items():
if chosen_host.rack_name != "any" and np.rack_name == chosen_host.rack_name:
if _group.vid not in np.rack_memberships.keys():
np.rack_memberships[_group.vid] = gr
else: # Rack level
- for _, np in self.avail_hosts.iteritems():
+ for _, np in self.avail_hosts.items():
if chosen_host.rack_name != "any" and np.rack_name == chosen_host.rack_name:
if _group.vid not in np.rack_memberships.keys():
np.rack_memberships[_group.vid] = gr
@@ -477,12 +477,12 @@ class Search(object):
if _level == "host":
if _group.vid not in chosen_host.host_memberships.keys():
chosen_host.host_memberships[_group.vid] = gr
- for _, np in self.avail_hosts.iteritems():
+ for _, np in self.avail_hosts.items():
if chosen_host.rack_name != "any" and np.rack_name == chosen_host.rack_name:
if _group.vid not in np.rack_memberships.keys():
np.rack_memberships[_group.vid] = gr
else: # Rack level
- for _, np in self.avail_hosts.iteritems():
+ for _, np in self.avail_hosts.items():
if chosen_host.rack_name != "any" and np.rack_name == chosen_host.rack_name:
if _group.vid not in np.rack_memberships.keys():
np.rack_memberships[_group.vid] = gr
@@ -521,7 +521,7 @@ class Search(object):
chosen_host.host_num_of_placed_servers += 1
- for _, np in self.avail_hosts.iteritems():
+ for _, np in self.avail_hosts.items():
if chosen_host.rack_name != "any" and np.rack_name == chosen_host.rack_name:
np.rack_avail_vCPUs -= _n.vCPUs
np.rack_avail_mem -= _n.mem
@@ -549,7 +549,7 @@ class Search(object):
if isinstance(_v, Server):
self._rollback_server_resources(_v)
elif isinstance(_v, Group):
- for _, v in _v.subgroups.iteritems():
+ for _, v in _v.subgroups.items():
self._rollback_resources(v)
if _v in self.node_placements.keys():
@@ -565,11 +565,11 @@ class Search(object):
self._remove_exclusivity(chosen_host, ex_group)
if len(_v.diversity_groups) > 0:
- for _, div_group in _v.diversity_groups.iteritems():
+ for _, div_group in _v.diversity_groups.items():
self._remove_group(chosen_host, div_group, level)
if len(_v.quorum_diversity_groups) > 0:
- for _, div_group in _v.quorum_diversity_groups.iteritems():
+ for _, div_group in _v.quorum_diversity_groups.items():
self._remove_group(chosen_host, div_group, level)
def _remove_exclusivity(self, _chosen_host, _group):
@@ -593,13 +593,13 @@ class Search(object):
_group.vid in _chosen_host.host_memberships.keys():
del _chosen_host.host_memberships[_group.vid]
- for _, np in self.avail_hosts.iteritems():
+ for _, np in self.avail_hosts.items():
if _chosen_host.rack_name != "any" and np.rack_name == _chosen_host.rack_name:
if _group.vid in np.rack_memberships.keys():
del np.rack_memberships[_group.vid]
else: # Rack level
if _chosen_host.rack_num_of_placed_servers == 0:
- for _, np in self.avail_hosts.iteritems():
+ for _, np in self.avail_hosts.items():
if _chosen_host.rack_name != "any" and np.rack_name == _chosen_host.rack_name:
if _group.vid in np.rack_memberships.keys():
del np.rack_memberships[_group.vid]
@@ -632,13 +632,13 @@ class Search(object):
if not exist_group and _group.vid in _chosen_host.host_memberships.keys():
del _chosen_host.host_memberships[_group.vid]
- for _, np in self.avail_hosts.iteritems():
+ for _, np in self.avail_hosts.items():
if _chosen_host.rack_name != "any" and np.rack_name == _chosen_host.rack_name:
if _group.vid in np.rack_memberships.keys():
del np.rack_memberships[_group.vid]
else: # Rack level
if not exist_group:
- for _, np in self.avail_hosts.iteritems():
+ for _, np in self.avail_hosts.items():
if _chosen_host.rack_name != "any" and np.rack_name == _chosen_host.rack_name:
if _group.vid in np.rack_memberships.keys():
del np.rack_memberships[_group.vid]
@@ -670,7 +670,7 @@ class Search(object):
if chosen_host.host_num_of_placed_servers == 0:
self.num_of_hosts -= 1
- for _, np in self.avail_hosts.iteritems():
+ for _, np in self.avail_hosts.items():
if chosen_host.rack_name != "any" and np.rack_name == chosen_host.rack_name:
np.rack_avail_vCPUs += _v.vCPUs
np.rack_avail_mem += _v.mem
@@ -689,7 +689,7 @@ class Search(object):
chosen_host.candidate_host_types = copy.deepcopy(chosen_host.old_candidate_host_types)
chosen_host.old_candidate_host_types.clear()
- for hrk, hr in self.avail_hosts.iteritems():
+ for hrk, hr in self.avail_hosts.items():
if hrk != chosen_host.host_name:
if hr.rack_name == chosen_host.rack_name:
hr.rollback_avail_rack_resources(ha,
@@ -704,5 +704,5 @@ class Search(object):
del self.node_placements[_v]
if isinstance(_v, Group):
- for _, sg in _v.subgroups.iteritems():
+ for _, sg in _v.subgroups.items():
self._rollback_node_placement(sg)
diff --git a/engine/src/valet/engine/search/search_helper.py b/engine/src/valet/engine/search/search_helper.py
index 0e64ef7..0309f46 100644
--- a/engine/src/valet/engine/search/search_helper.py
+++ b/engine/src/valet/engine/search/search_helper.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/bin/python
+#!/usr/bin/env python3
from valet.engine.app_manager.group import Group, LEVEL
@@ -32,7 +32,7 @@ def get_next_placements(_n, _level):
if LEVEL.index(_n.level) < LEVEL.index(_level):
groups[_n.vid] = _n
else:
- for _, sg in _n.subgroups.iteritems():
+ for _, sg in _n.subgroups.items():
if isinstance(sg, Group):
groups[sg.vid] = sg
else:
diff --git a/engine/src/valet/solver/ostro.py b/engine/src/valet/solver/ostro.py
index 67ba5df..166c833 100644
--- a/engine/src/valet/solver/ostro.py
+++ b/engine/src/valet/solver/ostro.py
@@ -506,7 +506,7 @@ class Ostro(object):
return status, {}
if _app.state == "create":
- for sk, s in _app.servers.iteritems():
+ for sk, s in _app.servers.items():
if s.host_assignment_inx == -1:
result[s.host_assignment_variable] = '::' + s.host
else:
@@ -516,7 +516,7 @@ class Ostro(object):
result[s.host_assignment_variable] = []
result[s.host_assignment_variable].insert(s.host_assignment_inx, p)
elif _app.state == "update":
- for sk, s in _app.servers.iteritems():
+ for sk, s in _app.servers.items():
if s.host_assignment_inx == -1:
result[s.host_assignment_variable] = ""
else:
diff --git a/engine/src/valet/valet_main.py b/engine/src/valet/valet_main.py
index ba91f97..312eccb 100644
--- a/engine/src/valet/valet_main.py
+++ b/engine/src/valet/valet_main.py
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------------
#
-#!/usr/bin/env python2.7
+#!/usr/bin/env python3
import argparse