from ONAPLibrary.RequestsHelper import RequestsHelper
from ONAPLibrary.HTTPKeywords import HTTPKeywords
+from ONAPLibrary.VariableKeywords import VariableKeywords
class BaseAAIKeywords(object):
self.reqs = RequestsHelper()
self.builtin = BuiltIn()
self.http = HTTPKeywords()
+ self.vars = VariableKeywords()
+ aai_ip_addr = self.vars.get_globally_injected_parameters()['GLOBAL_INJECTED_AAI_IP_ADDR']
+ aai_server_protocol = self.vars.get_global_parameters()['GLOBAL_AAI_SERVER_PROTOCOL']
+ aai_server_port = self.vars.get_global_parameters()['GLOBAL_AAI_SERVER_PORT']
+ self.aai_endpoint = aai_server_protocol + '://' + aai_ip_addr + ':' + aai_server_port
@keyword
def run_get_request(self, endpoint, data_path, accept="application/json", auth=None):
def run_delete_request(self, endpoint, data_path, resource_version, accept="application/json", auth=None):
"""Runs an AAI delete request"""
self.http.disable_warnings()
- return self.reqs.delete_request("aai", endpoint, data_path + '?resource-version=' + resource_version, data=None,
- sdc_user=None, accept=accept, auth=auth)
+ return self.reqs.delete_request("aai", endpoint, data_path + '?resource-version=' + resource_version,
+ data=None, sdc_user=None, accept=accept, auth=auth)
@keyword
- def wait_for_node_to_exist(self, endpoint, search_node_type, key, uuid, auth=None):
+ def wait_for_node_to_exist(self, search_node_type, key, uuid, auth=None):
logger.info('Waiting for AAI traversal to complete...')
for i in range(30):
time.sleep(1)
- result = self.find_node(endpoint, search_node_type, key, uuid, auth=auth)
+ result = self.find_node(search_node_type, key, uuid, auth=auth)
if result:
return result
self.builtin.fail(error_message)
@keyword
- def find_node(self, endpoint, search_node_type, key, node_uuid, auth=None):
+ def find_node(self, search_node_type, key, node_uuid, auth=None):
data_path = '/aai/v11/search/nodes-query?search-node-type={0}&filter={1}:EQUALS:{2}'.format(
search_node_type, key, node_uuid)
self.http.disable_warnings()
- resp = self.reqs.get_request("aai", endpoint, data_path, accept="application/json", auth=auth)
+ resp = self.reqs.get_request("aai", self.aai_endpoint, data_path, accept="application/json", auth=auth)
response = resp.json()
return 'result-data' in response
# limitations under the License.
from robot.libraries.BuiltIn import BuiltIn
+from robot.api.deco import keyword
-class VariableHelper(object):
- """ Non keyword class for useful for working with varaibles """
+class VariableKeywords(object):
+ """ keyword class for useful keywords for working with varaibles """
def __init__(self):
- super(VariableHelper, self).__init__()
+ super(VariableKeywords, self).__init__()
self.builtin = BuiltIn()
+ @keyword
def get_globally_injected_parameters(self):
dictionary = self.builtin.get_variables(no_decoration=True)
- return self.filter_variables_by_key_prefix(dictionary, "GLOBAL_INJECTED_")
+ return self._filter_variables_by_key_prefix(dictionary, "GLOBAL_INJECTED_")
+ @keyword
def get_global_parameters(self):
dictionary = self.builtin.get_variables(no_decoration=True)
- global_variables = self.filter_variables_by_key_prefix(dictionary, "GLOBAL_")
+ global_variables = self._filter_variables_by_key_prefix(dictionary, "GLOBAL_")
# strip out global injected (get those above)
for key in self.get_globally_injected_parameters():
del global_variables[key]
return global_variables
@staticmethod
- def filter_variables_by_key_prefix(dictionary, partial):
+ def _filter_variables_by_key_prefix(dictionary, partial):
matches = dict()
for key, val in dictionary.items():
if key.startswith(partial):
self.so_userpass = 'InfraPortalClient', 'password1$'
self.so_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
- # aai urls
- self.aai_userpass = 'AAI', 'AAI'
- self.aai_query_port = '8443'
- self.aai_host = 'aai.onap'
-
# mr utls
self.mr_ip_addr = 'mr.onap'
self.mr_ip_port = '3904'
return None
# wait for AAI to complete traversal
- endpoint = "https://{0}:{1}".format(self.aai_host, self.aai_query_port)
- self.aai.wait_for_node_to_exist(endpoint, 'service-instance', 'service-instance-id', svc_instance_id)
+ self.aai.wait_for_node_to_exist('service-instance', 'service-instance-id', svc_instance_id)
# create networks
for model in parser.net_models:
if not vnf_instance_id:
logger.error('No VNF instance ID returned!')
sys.exit()
- endpoint = "https://{0}:{1}".format(self.aai_host, self.aai_query_port)
- self.aai.wait_for_node_to_exist(endpoint, 'generic-vnf', 'vnf-id', vnf_instance_id)
+ self.aai.wait_for_node_to_exist('generic-vnf', 'vnf-id', vnf_instance_id)
# SDNC Preload
preloader = PreloadSDNCKeywords()