summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/common_config.yaml2
-rw-r--r--osdf/adapters/policy/interface.py9
-rw-r--r--test/test_PolicyCalls.py2
3 files changed, 7 insertions, 6 deletions
diff --git a/config/common_config.yaml b/config/common_config.yaml
index 97bfcca..0f2dc96 100644
--- a/config/common_config.yaml
+++ b/config/common_config.yaml
@@ -38,7 +38,7 @@ osdf_temp: # special configuration required for "workarounds" or testing
placement_policy_files_vfw_td:
- vnfPolicy_vFW_TD.json
- vnfPolicy_vPGN_TD.json
- - affinity_vFW_TD.json
+ - Affinity_vFW_TD.json
- QueryPolicy_vFW_TD.json
slice_selection_policy_dir_urllc_1: "./test/policy-local-files/"
slice_selection_policy_files_urllc_1:
diff --git a/osdf/adapters/policy/interface.py b/osdf/adapters/policy/interface.py
index ccbd3dc..1e7d2cd 100644
--- a/osdf/adapters/policy/interface.py
+++ b/osdf/adapters/policy/interface.py
@@ -76,9 +76,10 @@ def get_by_scope(rest_client, req, config_local, type_service):
keys = scope_fields.keys() & policies[policyName]['properties'].keys()
policy = {}
policy[policyName] = policies[policyName]
- scope_policies.append(policy for k in keys
- if set(policies.get(policyName, {}).get('properties',{}).get(k)) >= set(scope_fields[k])
- and policy not in scope_policies)
+ for k in keys:
+ if set(policies.get(policyName, {}).get('properties',{}).get(k)) >= set(scope_fields[k])\
+ and policy not in scope_policies:
+ scope_policies.append(policy)
return scope_policies
@@ -146,7 +147,7 @@ def remote_api(req_json, osdf_config, service_type="placement"):
policies = get_by_scope(rc, req_json, osdf_config.core, service_type)
formatted_policies = []
- for x in itertools.chain(*policies):
+ for x in policies:
if x[list(x.keys())[0]].get('properties') is None:
raise BusinessException("Properties not found for policy with name %s" % x[list(x.keys()[0])])
else:
diff --git a/test/test_PolicyCalls.py b/test/test_PolicyCalls.py
index d4dc37f..1ca14dc 100644
--- a/test/test_PolicyCalls.py
+++ b/test/test_PolicyCalls.py
@@ -92,7 +92,7 @@ class TestPolicyCalls(unittest.TestCase):
policy_config_file = yaml.load(yaml_file2)
with patch('osdf.utils.interfaces.RestClient.request', return_value=req_json_obj2):
policies_list = interface.get_by_scope(RestClient, req_json_obj, policy_config_file, 'placement')
- self.assertTrue(policies_list, 'is null')
+ self.assertFalse(policies_list)
self.assertRaises(Exception)
def test_gen_demands(self):