summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2017-09-14 17:39:35 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2017-09-14 17:41:47 +0200
commite9f6917f3229f67958c503943cd4d934d4a514fc (patch)
tree00e15df35b2d9d7e8b7dfd940c1cc29a748da88e
parente5faa3bf2046efcfc7412299887f802c15a413b8 (diff)
resource: find: replicate_times() is not needed anymore
Resources are expanded before this point, so we don't need to expand them here. Change-Id: I12a5349f9377dc8a24cb2afbe33c2401eeed0660
-rwxr-xr-xselftest/resource_test.py2
-rw-r--r--src/osmo_gsm_tester/resource.py12
2 files changed, 9 insertions, 5 deletions
diff --git a/selftest/resource_test.py b/selftest/resource_test.py
index 664f076..52d8e47 100755
--- a/selftest/resource_test.py
+++ b/selftest/resource_test.py
@@ -80,7 +80,7 @@ want = {
origin = log.Origin(None, 'testowner')
-resources = pool.reserve(origin, want)
+resources = pool.reserve(origin, config.replicate_times(want))
print('~~~ currently reserved:')
with open(rrfile, 'r') as f:
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index 80328d4..a4643ac 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -139,7 +139,7 @@ class ResourcesPool(log.Origin):
'''
schema.validate(want, WANT_SCHEMA)
- want = config.replicate_times(want)
+ want = copy.deepcopy(want)
origin_id = origin.origin_id()
@@ -275,10 +275,10 @@ class Resources(dict):
Pass a dict of resource requirements, e.g.:
want = {
'bts': [ {'type': 'osmo-bts-sysmo',}, {} ],
- 'modem': [ {'times': 3} ]
+ 'modem': [ {}, {}, {} ]
}
This function tries to find a combination from the available resources that
- matches these requiremens. The returnvalue is a dict (wrapped in a Resources class)
+ matches these requirements. The return value is a dict (wrapped in a Resources class)
that contains the matching resources in the order of 'want' dict: in above
example, the returned dict would have a 'bts' list with the first item being
a sysmoBTS, the second item being any other available BTS.
@@ -294,6 +294,10 @@ class Resources(dict):
If raise_if_missing is False, this will return an empty item for any
resource that had no match, instead of immediately raising an exception.
+
+ This function expects input dictionaries whose contents have already
+ been replicated based on its the 'times' attributes. See
+ config.replicate_times() for more details.
'''
matches = {}
for key, want_list in sorted(want.items()): # sorted for deterministic test results
@@ -318,7 +322,7 @@ class Resources(dict):
my_item = my_list[i]
if skip_if_marked and my_item.get(skip_if_marked):
continue
- if item_matches(my_item, want_item, ignore_keys=('times',)):
+ if item_matches(my_item, want_item):
item_match_list.append(i)
if not item_match_list:
if raise_if_missing: