summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/route/optimizers/simple_route_opt.py149
-rw-r--r--config/common_config.yaml4
-rwxr-xr-xconfig/osdf_config.yaml8
-rw-r--r--docs/index.rst1
-rw-r--r--docs/sections/architecture.rst1
-rw-r--r--docs/sections/offeredapis.rst1
-rw-r--r--docs/sections/release-notes.rst1
-rw-r--r--osdf/adapters/aaf/sms.py5
-rw-r--r--osdf/adapters/policy/interface.py9
-rwxr-xr-xosdfapp.py2
-rw-r--r--pom.xml2
-rw-r--r--releases/2.0.3-container.yaml10
-rw-r--r--releases/2.0.3.yaml4
-rwxr-xr-xtest/functest/simulators/simulated-config/osdf_config.yaml3
-rw-r--r--test/simple_route_opt/AAI.json164
-rw-r--r--test/simple_route_opt/routeOpt.json34
-rw-r--r--test/test_simple_route_opt.py57
-rw-r--r--version.properties2
18 files changed, 379 insertions, 78 deletions
diff --git a/apps/route/optimizers/simple_route_opt.py b/apps/route/optimizers/simple_route_opt.py
index 27c1141..9113516 100644
--- a/apps/route/optimizers/simple_route_opt.py
+++ b/apps/route/optimizers/simple_route_opt.py
@@ -17,6 +17,7 @@
#
import requests
+import json
from requests.auth import HTTPBasicAuth
from osdf.utils.mdc_utils import mdc_from_json
@@ -35,18 +36,14 @@ class RouteOpt:
"""
# DNS server and standard port of AAI..
# TODO: read the port from the configuration and add to DNS
- aai_host = "https://aai.api.simpledemo.onap.org:8443"
- audit_log.info("base directory")
- audit_log.info(BASE_DIR)
aai_headers = {
"X-TransactionId": "9999",
"X-FromAppId": "OOF",
"Accept": "application/json",
"Content-Type": "application/json",
- "Real-Time": "true"
}
- def isCrossONAPLink(self, logical_link):
+ def is_cross_onap_link(self, logical_link):
"""
This method checks if cross link is cross onap
:param logical_link:
@@ -57,57 +54,54 @@ class RouteOpt:
return True
return False
- def getLinksName(self, routes,initial_start_edge,initial_end_edge, mappingTable):
+ def get_links_name(self, routes,initial_start_edge,initial_end_edge, mappingTable):
routes=list(routes)
- arr=routes[0]['x']
+ try:
+ arr=routes[0]['x']
+ except Exception as err:
+ audit_log.info("No satisfiable solutions found")
+ raise err
listOfLinks=[]
for i in range(0, len(routes[0]['x'])):
+ individual_link = {}
if arr[i] == 1 :
# listOfLinks.append(self.fetchLogicalLinks(initial_start_edge[i], initial_end_edge[i], mappingTable))
- listOfLinks.append(mappingTable[initial_start_edge[i] + ":" + initial_end_edge[i]])
+ individual_link["link"] = mappingTable[initial_start_edge[i] + ":" + initial_end_edge[i]]
+ individual_link["start_node"] = initial_start_edge[i]
+ individual_link["end_node"] = initial_end_edge[i]
+ listOfLinks.append(individual_link)
return listOfLinks
- # def search(self, ip1, ip2, dic):
- # if ip1 == "" or ip2 == "":
- # return ""
- # else:
- # string = ip1 + ":" + ip2
- # return dic[string]
- #
- # def fetchLogicalLinks(self, initial_start_edge, initial_end_edge, mappingTable):
- # link_name=self.search(initial_start_edge, initial_end_edge, mappingTable)
- # return link_name
-
-
- # def fetchLogicalLinks(self, initial_start_edge, initial_end_edge, mappingTable):
- # return mappingTable[initial_start_edge + ":" + initial_end_edge]
-
def solve(self, mzn_model, dzn_data):
return pymzn.minizinc(mzn=mzn_model, data=dzn_data)
- def getLinks(self, mzn_model, dzn_data, initial_start_edge,initial_end_edge, mappingTable):
+ def get_links(self, mzn_model, dzn_data, initial_start_edge,initial_end_edge, mappingTable):
routes = self.solve(mzn_model, dzn_data)
audit_log.info("mocked minizinc solution====>")
audit_log.info(routes)
- converted_links=self.getLinksName(routes, initial_start_edge,initial_end_edge, mappingTable)
+ converted_links=self.get_links_name(routes, initial_start_edge,initial_end_edge, mappingTable)
audit_log.info("converted links===>")
audit_log.info(converted_links)
return converted_links
def addition(self, data):
- relationship = data["relationship-list"]["relationship"]
res = ""
- for index, eachItem in enumerate(relationship):
- if index == len(relationship) - 1:
- res += eachItem["accessNodeId"]
- else:
- res += eachItem["accessNodeId"] + ":"
-
- return data["link-name"], res
-
- def createMapTable(self, logical_links):
+ if 'relationship-list' in data.keys():
+ relationship = data["relationship-list"]["relationship"]
+ for index, eachItem in enumerate(relationship):
+ temp = eachItem["relationship-data"][0]
+ if index == len(relationship) - 1:
+ res += temp['relationship-value']
+ else:
+ res += temp['relationship-value'] + ":"
+
+ return data["link-name"], res
+ else:
+ return data["link-name"], res
+
+ def create_map_table(self, logical_links):
result = map(self.addition, logical_links)
parseTemplate = {}
@@ -118,30 +112,47 @@ class RouteOpt:
audit_log.info(parseTemplate)
return parseTemplate
- def build_dzn_data(self, src_access_node_id, dst_access_node_id):
+ def build_dzn_data(self, src_access_node_id, dst_access_node_id, osdf_config):
Edge_Start = []
Edge_End = []
- logical_links = self.get_logical_links()
+ logical_links = self.get_logical_links(osdf_config)
+
+
+ logical_links = logical_links['logical-link']
audit_log.info("mocked response of AAI received (logical links) successful===>")
audit_log.info(logical_links)
# prepare map table
- mappingTable = self.createMapTable(logical_links)
+ mappingTable = self.create_map_table(logical_links)
+ audit_log.info("mapping table created successfully====>")
+ audit_log.info(mappingTable)
# take the logical link where both the p-interface in same onap
if logical_links is not None:
+ audit_log.info('logical links not empty=====>')
for logical_link in logical_links:
- if not self.isCrossONAPLink(logical_link):
- # link is in local ONAP
- relationship = logical_link["relationship-list"]["relationship"]
-
- relationshipStartNode = relationship[0]
- relationshipStartNodeID = relationshipStartNode["related-link"].split("/")[-1]
- start_accessNodeId = relationshipStartNodeID.split("-")[-3]
- Edge_Start.append(start_accessNodeId)
-
- relationshipEndtNode = relationship[1]
- relationshipEndNodeID = relationshipEndtNode["related-link"].split("/")[-1]
- end_accessNodeId = relationshipEndNodeID.split("-")[-3]
- Edge_End.append(end_accessNodeId)
+ audit_log.info('logical_link')
+ audit_log.info(logical_link)
+
+ if 'relationship-list' in logical_link.keys():
+ if not self.is_cross_onap_link(logical_link):
+ # link is in local ONAP
+ audit_log.info('link is inside onap===>')
+ relationship = logical_link["relationship-list"]["relationship"]
+
+ relationshipStartNode = relationship[0]
+ audit_log.info('relationshipStartNode')
+ audit_log.info(relationshipStartNode)
+ relationshipStartNodeID = relationshipStartNode["related-link"].split("/")[-4]
+ audit_log.info('relationshipStartNodeID')
+ audit_log.info(relationshipStartNodeID)
+ Edge_Start.append(relationshipStartNodeID)
+
+ relationshipEndtNode = relationship[1]
+ relationshipEndNodeID = relationshipEndtNode["related-link"].split("/")[-4]
+ audit_log.info('relationshipEndNodeID')
+ audit_log.info(relationshipEndNodeID)
+ Edge_End.append(relationshipEndNodeID)
+ else:
+ continue
audit_log.info("edge start and end array of i/p address are===>")
audit_log.info(Edge_Start)
@@ -149,7 +160,6 @@ class RouteOpt:
# labeling ip to number for mapping
le = preprocessing.LabelEncoder()
le.fit(Edge_Start + Edge_End)
- # print(le.classes_)
dzn_start_edge = le.transform(Edge_Start)
final_dzn_start_arr = []
@@ -211,39 +221,46 @@ class RouteOpt:
total_node = len(nodeSet)
return total_node
- def getRoute(self, request):
+ def get_route(self, request, osdf_config):
"""
This method checks
:param logical_link:
:return:
"""
- routeInfo = request["routeInfo"]["routeRequests"]
- routeRequest = routeInfo[0]
- src_access_node_id = routeRequest["srcPort"]["accessNodeId"]
- dst_access_node_id = routeRequest["dstPort"]["accessNodeId"]
+ try:
+ routeInfo = request["routeInfo"]["routeRequests"]
+ routeRequest = routeInfo[0]
+ src_access_node_id = routeRequest["srcPort"]["accessNodeId"]
+ dst_access_node_id = routeRequest["dstPort"]["accessNodeId"]
- dzn_data, initial_start_edge, initial_end_edge, mappingTable = self.build_dzn_data(src_access_node_id, dst_access_node_id )
- #mzn_model = "/home/root1/Videos/projects/osdf/test/functest/simulators/osdf/optimizers/routeopt/route_opt.mzn"
- mzn_model = os.path.join(BASE_DIR, 'route_opt.mzn')
+ dzn_data, initial_start_edge, initial_end_edge, mappingTable = self.build_dzn_data(src_access_node_id, dst_access_node_id, osdf_config)
+ #mzn_model = "/home/root1/Videos/projects/osdf/test/functest/simulators/osdf/optimizers/routeopt/route_opt.mzn"
+ mzn_model = os.path.join(BASE_DIR, 'route_opt.mzn')
- routeSolutions = self.getLinks(mzn_model, dzn_data, initial_start_edge,initial_end_edge, mappingTable)
+ routeSolutions = self.get_links(mzn_model, dzn_data, initial_start_edge,initial_end_edge, mappingTable)
- return {
+ return {
"requestId": request["requestInfo"]["requestId"],
"transactionId": request["requestInfo"]["transactionId"],
"statusMessage": " ",
"requestStatus": "accepted",
"solutions": routeSolutions
- }
+ }
+ except Exception as err:
+ audit_log.info(err)
+ raise err
- def get_logical_links(self):
+ def get_logical_links(self, osdf_config):
"""
This method returns list of all cross ONAP links
from /aai/v14/network/logical-links?operation-status="Up"
:return: logical-links[]
"""
- logical_link_url = "/aai/v13/network/logical-links?operational-status=up"
- aai_req_url = self.aai_host + logical_link_url
+
+ config = osdf_config.deployment
+ aai_url = config["aaiUrl"]
+ aai_req_url = aai_url + config["aaiGetLinksUrl"]
+
response = requests.get(aai_req_url,headers=self.aai_headers,auth=HTTPBasicAuth("AAI", "AAI"),verify=False)
if response.status_code == 200:
return response.json() \ No newline at end of file
diff --git a/config/common_config.yaml b/config/common_config.yaml
index 9a6d7e7..97bfcca 100644
--- a/config/common_config.yaml
+++ b/config/common_config.yaml
@@ -83,7 +83,7 @@ policy_info:
-
scope:
- OSDF_FRANKFURT
- service:
+ services:
- get_param: service_name
placement:
@@ -94,7 +94,7 @@ policy_info:
- OSDF_FRANKFURT
geography:
- US
- service:
+ services:
- get_param: service_name
resources:
- get_param: resource
diff --git a/config/osdf_config.yaml b/config/osdf_config.yaml
index eba89e0..4802a67 100755
--- a/config/osdf_config.yaml
+++ b/config/osdf_config.yaml
@@ -18,7 +18,7 @@ conductorMaxRetries: 30 # if we don't get something in 30 minutes, give up
conductorMinorVersion: 0
# Policy Platform -- requires Authorization
-policyPlatformUrl: https://policy-xacml-pdp:6969/policy/pdpx/decision/v1 # Policy Dev platform URL
+policyPlatformUrl: https://policy-xacml-pdp:6969/policy/pdpx/v1/decision # Policy Dev platform URL
# URL for policy model uploading
policyPlatformUrlModelUpload: https://policy.api.simpledemo.onap.org:8081/policy/api/v1/policytypes
pathPolicyModelUpload: ../../models/policy/placement/tosca_upload/
@@ -50,8 +50,12 @@ configDbUrl: http://config.db.url:8080
configDbGetCellListUrl: 'SDNCConfigDBAPI/getCellList'
configDbGetNbrListUrl: 'SDNCConfigDBAPI/getNbrList'
+#aai api
+aaiUrl: "https://aai.url:30233"
+aaiGetLinksUrl: "/aai/v16/network/logical-links"
+
pciHMSUsername: test
pciHMSPassword: passwd
#key
-appkey: os35@rrtky400fdntc#001t5 \ No newline at end of file
+#appkey: os35@rrtky400fdntc#001t5
diff --git a/docs/index.rst b/docs/index.rst
index c3ea9da..231a4bc 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,4 +1,5 @@
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. _master_index:
Optimization Framework: Optimization Service Design Framework (OSDF)
diff --git a/docs/sections/architecture.rst b/docs/sections/architecture.rst
index 64bc43c..b11eec2 100644
--- a/docs/sections/architecture.rst
+++ b/docs/sections/architecture.rst
@@ -1,4 +1,5 @@
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. _architecture:
Architecture
=============================================
diff --git a/docs/sections/offeredapis.rst b/docs/sections/offeredapis.rst
index 5151431..f50831f 100644
--- a/docs/sections/offeredapis.rst
+++ b/docs/sections/offeredapis.rst
@@ -1,5 +1,6 @@
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
+.. _offeredapis:
Offered APIs
=============================================
diff --git a/docs/sections/release-notes.rst b/docs/sections/release-notes.rst
index 27b4f4b..1cfb099 100644
--- a/docs/sections/release-notes.rst
+++ b/docs/sections/release-notes.rst
@@ -1,6 +1,7 @@
..
This work is licensed under a Creative Commons Attribution 4.0
International License.
+.. _release_notes:
=============
Release Notes
diff --git a/osdf/adapters/aaf/sms.py b/osdf/adapters/aaf/sms.py
index 0168ba0..bcc449c 100644
--- a/osdf/adapters/aaf/sms.py
+++ b/osdf/adapters/aaf/sms.py
@@ -21,6 +21,7 @@
'''Secret Management Service Integration'''
from onapsmsclient import Client
+
import osdf.config.base as cfg_base
import osdf.config.credentials as creds
import osdf.config.loader as config_loader
@@ -71,6 +72,7 @@ def retrieve_secrets():
debug_log.debug("Secret Dictionary Retrieval Success")
return secret_dict
+
def load_secrets():
config = osdf_config.deployment
secret_dict = retrieve_secrets()
@@ -107,7 +109,8 @@ def load_secrets():
def decrypt_pass(passwd):
- if passwd == '' or passwd == 'NA':
+ config = osdf_config.deployment
+ if not config.get('appkey') or passwd == '' or passwd == 'NA':
return passwd
else:
return cipherUtils.AESCipher.get_instance().decrypt(passwd)
diff --git a/osdf/adapters/policy/interface.py b/osdf/adapters/policy/interface.py
index 9ace75e..ccbd3dc 100644
--- a/osdf/adapters/policy/interface.py
+++ b/osdf/adapters/policy/interface.py
@@ -64,8 +64,8 @@ def get_by_scope(rest_client, req, config_local, type_service):
for scopes in pscope:
for key in scopes.keys():
for field in scopes[key]:
- scope_fields[key] = set(list_flatten([get_scope_fields(field, references, req, policies)
- if 'get_param' in field else field]))
+ scope_fields[key] = list_flatten([get_scope_fields(field, references, req, policies)
+ if 'get_param' in field else field])
if scope_fields.get('resources') and len(scope_fields['resources']) > 1:
for s in scope_fields['resources']:
scope_fields['resources'] = [s]
@@ -122,7 +122,7 @@ def policy_api_call(rest_client, scope_fields):
"ONAPComponent": "OOF_Component",
"ONAPInstance": "OOF_Component_Instance",
"action": "optimize",
- "resources": "{}".format(scope_fields)}
+ "resource": scope_fields}
return rest_client.request(json=api_call_body)
def remote_api(req_json, osdf_config, service_type="placement"):
@@ -133,9 +133,10 @@ def remote_api(req_json, osdf_config, service_type="placement"):
:return: all related policies and provStatus retrieved from Subscriber policy
"""
config = osdf_config.deployment
+ headers = {"Content-type": "application/json"}
uid, passwd = config['policyPlatformUsername'], config['policyPlatformPassword']
url = config['policyPlatformUrl']
- rc = RestClient(userid=uid, passwd=passwd, url=url, log_func=debug_log.debug)
+ rc = RestClient(userid=uid, passwd=passwd, headers=headers, url=url, log_func=debug_log.debug)
if osdf_config.core['policy_info'][service_type]['policy_fetch'] == "by_name":
policies = get_by_name(rc, req_json[service_type + "Info"]['policyId'], wildcards=True)
diff --git a/osdfapp.py b/osdfapp.py
index fdc2c1d..1099e55 100755
--- a/osdfapp.py
+++ b/osdfapp.py
@@ -101,7 +101,7 @@ def do_route_calc():
"""
request_json = request.get_json()
audit_log.info("Calculate Route request received!")
- response = RouteOpt().getRoute(request_json)
+ response = RouteOpt().get_route(request_json, osdf_config)
return response
@app.route("/api/oof/v1/selection/nst", methods=["POST"])
diff --git a/pom.xml b/pom.xml
index cb9baad..a07617f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@ http://maven.apache.org/POM/4.0.0 ">
<groupId>org.onap.optf.osdf</groupId>
<artifactId>optf-osdf</artifactId>
<name>optf-osdf</name>
- <version>2.0.2-SNAPSHOT</version>
+ <version>2.0.3-SNAPSHOT</version>
<description>Optimization Service Design Framework</description>
<properties>
diff --git a/releases/2.0.3-container.yaml b/releases/2.0.3-container.yaml
new file mode 100644
index 0000000..30d8603
--- /dev/null
+++ b/releases/2.0.3-container.yaml
@@ -0,0 +1,10 @@
+distribution_type: 'container'
+container_release_tag: '2.0.3'
+project: 'optf-osdf'
+log_dir: 'optf-osdf-maven-docker-stage-master/185/'
+ref: d79e6bda8b636d77d51ddb63dcd3d91ddda34d83
+containers:
+ - name: 'optf-osdf'
+ version: '2.0.3-STAGING-20200415T161453Z'
+ - name: 'optf-opteng'
+ version: '2.0.3-STAGING-20200415T161453Z' \ No newline at end of file
diff --git a/releases/2.0.3.yaml b/releases/2.0.3.yaml
new file mode 100644
index 0000000..5a2d322
--- /dev/null
+++ b/releases/2.0.3.yaml
@@ -0,0 +1,4 @@
+distribution_type: 'maven'
+version: '2.0.3'
+project: 'optf-osdf'
+log_dir: 'optf-osdf-maven-stage-master/365/' \ No newline at end of file
diff --git a/test/functest/simulators/simulated-config/osdf_config.yaml b/test/functest/simulators/simulated-config/osdf_config.yaml
index eccad14..414d7c7 100755
--- a/test/functest/simulators/simulated-config/osdf_config.yaml
+++ b/test/functest/simulators/simulated-config/osdf_config.yaml
@@ -71,3 +71,6 @@ configDbGetNbrListUrl: 'getNbrList'
pciHMSUsername: "" # pcihandler username for call back.
pciHMSPassword: "" # pcihandler password for call back.
+aaiUrl: "https://api.url:30233"
+aaiGetLinksUrl: "/aai/v16/network/logical-links"
+
diff --git a/test/simple_route_opt/AAI.json b/test/simple_route_opt/AAI.json
new file mode 100644
index 0000000..6ef264b
--- /dev/null
+++ b/test/simple_route_opt/AAI.json
@@ -0,0 +1,164 @@
+{
+ "logical-link": [
+ {
+ "link-name": "link-id-1",
+ "in-maint": true,
+ "link-type": "example-link-type-val-16287",
+ "resource-version": "1585009311719",
+ "operational-status": "UP",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/20.20.20.20/p-interfaces/p-interface/p-interface-3",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "20.20.20.20"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-3"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ },
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/10.10.10.10/p-interfaces/p-interface/p-interface-2",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "10.10.10.10"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-2"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "link-name": "link-id-2",
+ "in-maint": true,
+ "link-type": "example-link-type-val-16287",
+ "resource-version": "1584943281792",
+ "operational-status": "UP",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/22.22.22.22/p-interfaces/p-interface/p-interface-7",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "22.22.22.22"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-7"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ },
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/11.11.11.11/p-interfaces/p-interface/p-interface-6",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "11.11.11.11"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-6"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "link-name": "link-id-3",
+ "in-maint": true,
+ "link-type": "example-link-type-val-16287",
+ "resource-version": "1584943345290",
+ "operational-status": "UP",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/11.11.11.11/p-interfaces/p-interface/p-interface-5",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "11.11.11.11"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-5"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ },
+ {
+ "related-to": "p-interface",
+ "relationship-label": "tosca.relationships.network.LinksTo",
+ "related-link": "/aai/v16/network/pnfs/pnf/20.20.20.20/p-interfaces/p-interface/p-interface-4",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "20.20.20.20"
+ },
+ {
+ "relationship-key": "p-interface.interface-name",
+ "relationship-value": "p-interface-4"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "p-interface.prov-status"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "link-name": "rahul",
+ "in-maint": true,
+ "link-type": "example-link-type-val-rahul",
+ "resource-version": "1585023629505",
+ "operational-status": "UP"
+ }
+ ]
+} \ No newline at end of file
diff --git a/test/simple_route_opt/routeOpt.json b/test/simple_route_opt/routeOpt.json
new file mode 100644
index 0000000..887b85b
--- /dev/null
+++ b/test/simple_route_opt/routeOpt.json
@@ -0,0 +1,34 @@
+{
+ "requestInfo": {
+ "transactionId": "xxx-xxx-xxxx",
+ "requestId": "yyy-yyy-yyyy",
+ "callbackUrl": "https://wiki.onap.org:5000/callbackUrl",
+ "sourceId": "",
+ "requestType": "create",
+ "numSolutions": 1,
+ "optimizers": [
+ "route"
+ ],
+ "timeout": 600
+ },
+ "routeInfo": {
+ "routeRequests": [
+ {
+ "srcPort": {
+ "accessTopologyId": "Topo113",
+ "accessClientId": "clientU12",
+ "accessProviderId": "VDF1234",
+ "accessNodeId": "22.22.22.22",
+ "accessLtpId": "1345"
+ },
+ "dstPort": {
+ "accessTopologyId": "Topo3421",
+ "accessClientId": "clientD123",
+ "accessProviderId": "VDF3214",
+ "accessNodeId": "10.10.10.10",
+ "accessLtpId": "3452"
+ }
+ }
+ ]
+ }
+}
diff --git a/test/test_simple_route_opt.py b/test/test_simple_route_opt.py
new file mode 100644
index 0000000..3b4facc
--- /dev/null
+++ b/test/test_simple_route_opt.py
@@ -0,0 +1,57 @@
+from apps.route.optimizers.simple_route_opt import RouteOpt
+from osdf.utils.interfaces import json_from_file
+from unittest.mock import patch
+import osdf.config.loader as config_loader
+from osdf.utils.programming_utils import DotDict
+import unittest
+
+
+class TestSimpleRouteOptimization(unittest.TestCase):
+ @patch('apps.route.optimizers.simple_route_opt.requests.get')
+ @patch('apps.route.optimizers.simple_route_opt.pymzn.minizinc')
+ def test_process_nst_selection_solutions( self, mock_solve, mock_get):
+
+ main_dir = ""
+ response_data_file = main_dir + "test/simple_route_opt/AAI.json"
+ mock_get.return_value.json.return_value = json_from_file(response_data_file)
+ mock_get.return_value.status_code = 200
+ mock_solve.return_value = [{'x': [1, 1, 1]}]
+ self.config_spec = {
+ "deployment": "test/functest/simulators/simulated-config/osdf_config.yaml",
+ "core": "test/functest/simulators/simulated-config/common_config.yaml"
+ }
+ self.osdf_config = DotDict(config_loader.all_configs(**self.config_spec))
+ parameter_data_file = main_dir + "test/simple_route_opt/routeOpt.json"
+ request_json = json_from_file(parameter_data_file)
+ mock_response = {
+ "requestId": "yyy-yyy-yyyy",
+ "requestStatus": "accepted",
+ "solutions": [
+ {
+ "end_node": "10.10.10.10",
+ "link": "link-id-1",
+ "start_node": "20.20.20.20"
+ },
+ {
+ "end_node": "11.11.11.11",
+ "link": "link-id-2",
+ "start_node": "22.22.22.22"
+ },
+ {
+ "end_node": "20.20.20.20",
+ "link": "link-id-3",
+ "start_node": "11.11.11.11"
+ }
+ ],
+ "statusMessage": " ",
+ "transactionId": "xxx-xxx-xxxx"
+ }
+ routopt = RouteOpt()
+ actual_response = routopt.get_route(request_json,self.osdf_config)
+ self.assertEqual(mock_response, actual_response)
+
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/version.properties b/version.properties
index 487c94e..7026b76 100644
--- a/version.properties
+++ b/version.properties
@@ -19,7 +19,7 @@
major=2
minor=0
-patch=2
+patch=3
base_version=${major}.${minor}.${patch}