summaryrefslogtreecommitdiffstats
path: root/robotframework-onap/ONAPLibrary/ServiceMappingKeywords.py
diff options
context:
space:
mode:
authorDR695H <dr695h@att.com>2019-05-22 15:36:04 -0400
committerDR695H <dr695h@att.com>2019-05-22 15:42:54 -0400
commit43f18d19dc859f4bf59b1f21aa921d8674d5e977 (patch)
treea998222f0e80980ca05f96f272a428ba58d23028 /robotframework-onap/ONAPLibrary/ServiceMappingKeywords.py
parent26ef55453fd4950cd5841c098b5b1473b09d7be5 (diff)
adding in new onap lib and servicemapping
this remvoes the need for servicemapping.json Change-Id: I4a151293c19a386b79135816e86f7402ba29ad8d Issue-ID: TEST-157 Signed-off-by: DR695H <dr695h@att.com>
Diffstat (limited to 'robotframework-onap/ONAPLibrary/ServiceMappingKeywords.py')
-rw-r--r--robotframework-onap/ONAPLibrary/ServiceMappingKeywords.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/robotframework-onap/ONAPLibrary/ServiceMappingKeywords.py b/robotframework-onap/ONAPLibrary/ServiceMappingKeywords.py
new file mode 100644
index 0000000..610ee57
--- /dev/null
+++ b/robotframework-onap/ONAPLibrary/ServiceMappingKeywords.py
@@ -0,0 +1,67 @@
+# Copyright 2019 AT&T Intellectual Property. 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.
+
+from robot import utils
+from robot.api.deco import keyword
+import os.path
+import json
+
+
+class ServiceMappingKeywords(object):
+ """ServiceMapping is used for loading data for services into the robot framework in a structured decentralized way
+ that lets vnfs be added without code change to testuite"""
+
+ def __init__(self):
+ super(ServiceMappingKeywords, self).__init__()
+ self._cache = utils.ConnectionCache('No Service Mappings directories loaded')
+
+ @keyword
+ def set_directory(self, alias, service_mappings_directory):
+ self._cache.register(service_mappings_directory, alias=alias)
+
+ @keyword
+ def get_service_folder_mapping(self, alias, service):
+ """returns an array of strings with the folder where the vnf's heat files are stored """
+ return self._service_mapping(alias, service)['GLOBAL_SERVICE_FOLDER_MAPPING'][service]
+
+ @keyword
+ def get_service_vnf_mapping(self, alias, service):
+ """returns an array of strings that is the vnfs in this service """
+ return self._service_mapping(alias, service)['GLOBAL_SERVICE_VNF_MAPPING'][service]
+
+ @keyword
+ def get_service_neutron_mapping(self, alias, service):
+ """returns an array of strings that lists the neutron networks needed in this service """
+ return self._service_mapping(alias, service)['GLOBAL_SERVICE_GEN_NEUTRON_NETWORK_MAPPING'][service]
+
+ @keyword
+ def get_service_deployment_artifact_mapping(self, alias, service):
+ """returns an array of strings that is the extra deployment artifacts needed with this service """
+ return self._service_mapping(alias, service)['GLOBAL_SERVICE_DEPLOYMENT_ARTIFACT_MAPPING'][service]
+
+ @keyword
+ def get_service_template_mapping(self, alias, service, vnf):
+ """returns an array of strings that are the heat templates for this vnf """
+ return self._service_mapping(alias, service)['GLOBAL_SERVICE_TEMPLATE_MAPPING'][vnf]
+
+ """@PendingDeprecationWarning"""
+ @keyword
+ def get_validate_name_mapping(self, alias, service, vnf):
+ """returns an array of strings that are the names to validate in heatbridge for the vnf """
+ return self._service_mapping(alias, service)['GLOBAL_VALIDATE_NAME_MAPPING'][vnf]
+
+ def _service_mapping(self, alias, service):
+ filepath = os.path.join(self._cache.switch(alias), service, 'service_mapping.json')
+ with open(filepath, 'r') as f:
+ return json.load(f)