diff options
-rwxr-xr-x | DominoClient.py | 2 | ||||
-rwxr-xr-x | DominoServer.py | 16 | ||||
-rw-r--r-- | lib/partitioner/partitioner.py | 20 | ||||
-rw-r--r-- | tests/logdata/client1.log | 66 | ||||
-rw-r--r-- | tests/logdata/server.log | 82 | ||||
-rwxr-xr-x | tests/test_partitioner.py | 10 |
6 files changed, 115 insertions, 81 deletions
diff --git a/DominoClient.py b/DominoClient.py index d02027b..3d29665 100755 --- a/DominoClient.py +++ b/DominoClient.py @@ -17,8 +17,6 @@ import getopt, socket import logging, errno import uuid -#sys.path.append('gen-py') -#sys.path.insert(0, glob.glob('./lib/py/build/lib.*')[0]) sys.path.insert(0, glob.glob('./lib')[0]) from dominoRPC import Communication diff --git a/DominoServer.py b/DominoServer.py index d92b72c..679ca42 100755 --- a/DominoServer.py +++ b/DominoServer.py @@ -16,8 +16,7 @@ import getopt, socket import logging, json import sqlite3, yaml import uuid -#sys.path.append('gen-py') -#sys.path.insert(0, glob.glob('./lib/py/build/lib.*')[0]) + sys.path.insert(0, glob.glob('./lib')[0]) @@ -287,10 +286,17 @@ class CommunicationHandler: node_site = label.select_site( site_map ) logging.debug('Selected Sites: %s', node_site) - # Create per-domain Tosca files - file_paths = partitioner.partition_tosca('./toscafiles/template',node_site,tpl) + # Create per-site Tosca files + tpl_site = {} + file_paths = partitioner.partition_tosca('./toscafiles/template',node_site,tpl,tpl_site) logging.debug('Per domain file paths: %s', file_paths) - + logging.debug('Per domain topologies: %s', tpl_site) + + # Detect boundary links + boundary_VLs, VL_sites = partitioner.return_boundarylinks(tpl_site) + logging.debug('Boundary VLs: %s', boundary_VLs) + logging.debug('VL sites: %s', VL_sites) + # Create work-flow # Assign template UUID if no UUID specified diff --git a/lib/partitioner/partitioner.py b/lib/partitioner/partitioner.py index 75adc63..5188193 100644 --- a/lib/partitioner/partitioner.py +++ b/lib/partitioner/partitioner.py @@ -7,7 +7,7 @@ import constants import copy -def partition_tosca(filepath, nodesite, tpl): +def partition_tosca(filepath, nodesite, tpl, tpl_local={}): file_paths = {} #holds the list of partitioned files sitenodes = {} #holds nodes in each site @@ -20,7 +20,7 @@ def partition_tosca(filepath, nodesite, tpl): sitenodes[nodesite[node]] = [node] #prepare the nodes - tpl_local = {} + #tpl_local = {} for site in sitenodes: tpl_local[site] = copy.deepcopy(tpl) #remove the nodes not assigned to a site @@ -137,3 +137,19 @@ def rm_orphans(tpl): for node in list(nodes): if (nodes[node]['type'] == 'tosca.nodes.nfv.VL') and (node not in keep_list): del nodes[node] + +def return_boundarylinks(tpl_site): + VL = {} + sites_of_VL = {} + # First find all the VLs copied to each site + for site in tpl_site.keys(): + nodes = tpl_site[site]['topology_template']['node_templates'] + for node in nodes: + if (nodes[node]['type'] == 'tosca.nodes.nfv.VL'): + if sites_of_VL.has_key(node): #if true, then this VL maps to more than 1 site + sites_of_VL[node].add(site) + VL[node] = nodes[node] + else: + sites_of_VL[node] = set([site]) + + return VL, sites_of_VL diff --git a/tests/logdata/client1.log b/tests/logdata/client1.log index c589f6d..f7544df 100644 --- a/tests/logdata/client1.log +++ b/tests/logdata/client1.log @@ -1,33 +1,33 @@ -12/15/2016 04:19:39 PM Domino Client Starting... -12/15/2016 04:19:39 PM 1 Sending Registration -12/15/2016 04:19:39 PM Registration Response: Response Code: 1 -12/15/2016 04:19:39 PM CLI Service is starting -12/15/2016 04:19:39 PM RPC service for CLI is starting... -12/15/2016 04:19:41 PM Received CLI ['heartbeat'] -12/15/2016 04:19:41 PM 12345678123456781234567812345678 Sending heartbeat -12/15/2016 04:19:41 PM heart beat received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 2 -12/15/2016 04:19:42 PM Received CLI ['subscribe', '-t', 'hot', '-l', 'tosca.policies.Placement:properties:region:nova-1'] -12/15/2016 04:19:42 PM subscribing labels ['tosca.policies.Placement:properties:region:nova-1'] and templates ['hot'] -12/15/2016 04:19:42 PM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 3 -12/15/2016 04:19:43 PM Received CLI ['subscribe', '-t', 'dummy1,dummy2', '--top', 'OVERWRITE'] -12/15/2016 04:19:43 PM subscribing labels [] and templates ['dummy1', 'dummy2'] -12/15/2016 04:19:43 PM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 4 -12/15/2016 04:19:44 PM Received CLI ['subscribe', '-t', 'dummy1,dummy2', '--top', 'DELETE'] -12/15/2016 04:19:44 PM subscribing labels [] and templates ['dummy1', 'dummy2'] -12/15/2016 04:19:44 PM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 5 -12/15/2016 04:19:45 PM Received CLI ['subscribe', '-l', 'tosca.policies.Placement:properties:region:nova-2'] -12/15/2016 04:19:45 PM subscribing labels ['tosca.policies.Placement:properties:region:nova-2'] and templates [] -12/15/2016 04:19:45 PM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 6 -12/15/2016 04:19:46 PM Received CLI ['subscribe', '-l', 'tosca.policies.Placement:properties:region:nova-3', '--lop', 'OVERWRITE'] -12/15/2016 04:19:46 PM subscribing labels ['tosca.policies.Placement:properties:region:nova-3'] and templates [] -12/15/2016 04:19:46 PM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 7 -12/15/2016 04:19:47 PM Received CLI ['subscribe', '-l', 'tosca.policies.Placement:properties:region:nova-3', '--lop', 'DELETE'] -12/15/2016 04:19:47 PM subscribing labels ['tosca.policies.Placement:properties:region:nova-3'] and templates [] -12/15/2016 04:19:47 PM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 8 -12/15/2016 04:19:48 PM Received CLI ['publish', '-t', './tosca-templates/tosca_helloworld_nfv.yaml'] -12/15/2016 04:19:48 PM Publishing the template file: ./tosca-templates/tosca_helloworld_nfv.yaml -12/15/2016 04:19:48 PM Publish Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 9 Status: 2 -12/15/2016 04:19:49 PM Received CLI ['subscribe', '-l', 'tosca.policies.Placement.Geolocation:properties:region:us-west-1'] -12/15/2016 04:19:49 PM subscribing labels ['tosca.policies.Placement.Geolocation:properties:region:us-west-1'] and templates [] -12/15/2016 04:19:49 PM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 10 -12/15/2016 04:19:50 PM 12345678123456781234567812345678 Received Template File +02/06/2017 06:36:52 AM Domino Client Starting... +02/06/2017 06:36:52 AM 1 Sending Registration +02/06/2017 06:36:52 AM Registration Response: Response Code: 1 +02/06/2017 06:36:52 AM CLI Service is starting +02/06/2017 06:36:52 AM RPC service for CLI is starting... +02/06/2017 06:36:54 AM Received CLI ['heartbeat'] +02/06/2017 06:36:54 AM 12345678123456781234567812345678 Sending heartbeat +02/06/2017 06:36:54 AM heart beat received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 2 +02/06/2017 06:36:55 AM Received CLI ['subscribe', '-t', 'hot', '-l', 'tosca.policies.Placement:properties:region:nova-1'] +02/06/2017 06:36:55 AM subscribing labels ['tosca.policies.Placement:properties:region:nova-1'] and templates ['hot'] +02/06/2017 06:36:55 AM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 3 +02/06/2017 06:36:56 AM Received CLI ['subscribe', '-t', 'dummy1,dummy2', '--top', 'OVERWRITE'] +02/06/2017 06:36:56 AM subscribing labels [] and templates ['dummy1', 'dummy2'] +02/06/2017 06:36:56 AM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 4 +02/06/2017 06:36:57 AM Received CLI ['subscribe', '-t', 'dummy1,dummy2', '--top', 'DELETE'] +02/06/2017 06:36:57 AM subscribing labels [] and templates ['dummy1', 'dummy2'] +02/06/2017 06:36:57 AM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 5 +02/06/2017 06:36:58 AM Received CLI ['subscribe', '-l', 'tosca.policies.Placement:properties:region:nova-2'] +02/06/2017 06:36:58 AM subscribing labels ['tosca.policies.Placement:properties:region:nova-2'] and templates [] +02/06/2017 06:36:58 AM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 6 +02/06/2017 06:36:59 AM Received CLI ['subscribe', '-l', 'tosca.policies.Placement:properties:region:nova-3', '--lop', 'OVERWRITE'] +02/06/2017 06:36:59 AM subscribing labels ['tosca.policies.Placement:properties:region:nova-3'] and templates [] +02/06/2017 06:36:59 AM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 7 +02/06/2017 06:37:01 AM Received CLI ['subscribe', '-l', 'tosca.policies.Placement:properties:region:nova-3', '--lop', 'DELETE'] +02/06/2017 06:37:01 AM subscribing labels ['tosca.policies.Placement:properties:region:nova-3'] and templates [] +02/06/2017 06:37:01 AM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 8 +02/06/2017 06:37:02 AM Received CLI ['publish', '-t', './tosca-templates/tosca_helloworld_nfv.yaml'] +02/06/2017 06:37:02 AM Publishing the template file: ./tosca-templates/tosca_helloworld_nfv.yaml +02/06/2017 06:37:02 AM Publish Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 9 Status: 2 +02/06/2017 06:37:03 AM Received CLI ['subscribe', '-l', 'tosca.policies.Placement.Geolocation:properties:region:us-west-1'] +02/06/2017 06:37:03 AM subscribing labels ['tosca.policies.Placement.Geolocation:properties:region:us-west-1'] and templates [] +02/06/2017 06:37:03 AM Subscribe Response is received from: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ,sequence number: 10 +02/06/2017 06:37:04 AM 12345678123456781234567812345678 Received Template File diff --git a/tests/logdata/server.log b/tests/logdata/server.log index bdd4c20..c017d54 100644 --- a/tests/logdata/server.log +++ b/tests/logdata/server.log @@ -1,37 +1,45 @@ -12/15/2016 04:19:38 PM Domino Server Starting... -12/15/2016 04:19:39 PM Registration Request received for UUID 12345678123456781234567812345678 from IP: 192.168.253.148 port: 9091 -12/15/2016 04:19:40 PM Registration Request received for UUID 12345678123456781234567812345678 from IP: 192.168.253.148 port: 9092 -12/15/2016 04:19:41 PM heartbeat received from 12345678123456781234567812345678 -12/15/2016 04:19:42 PM Subscribe Request received from 12345678123456781234567812345678 -12/15/2016 04:19:42 PM APPENDING Labels... -12/15/2016 04:19:42 PM Supported Template: set(['hot']) Supported Labels: set(['tosca.policies.Placement:properties:region:nova-1']) -12/15/2016 04:19:43 PM Subscribe Request received from 12345678123456781234567812345678 -12/15/2016 04:19:43 PM APPENDING Labels... -12/15/2016 04:19:43 PM Supported Template: set(['dummy2', 'dummy1']) Supported Labels: set(['tosca.policies.Placement:properties:region:nova-1']) -12/15/2016 04:19:44 PM Subscribe Request received from 12345678123456781234567812345678 -12/15/2016 04:19:44 PM APPENDING Labels... -12/15/2016 04:19:44 PM Supported Template: set([]) Supported Labels: set(['tosca.policies.Placement:properties:region:nova-1']) -12/15/2016 04:19:45 PM Subscribe Request received from 12345678123456781234567812345678 -12/15/2016 04:19:45 PM APPENDING Labels... -12/15/2016 04:19:45 PM Supported Template: set([]) Supported Labels: set(['tosca.policies.Placement:properties:region:nova-2', 'tosca.policies.Placement:properties:region:nova-1']) -12/15/2016 04:19:46 PM Subscribe Request received from 12345678123456781234567812345678 -12/15/2016 04:19:46 PM OVERWRITING Labels... -12/15/2016 04:19:46 PM Supported Template: set([]) Supported Labels: set(['tosca.policies.Placement:properties:region:nova-3']) -12/15/2016 04:19:47 PM Subscribe Request received from 12345678123456781234567812345678 -12/15/2016 04:19:47 PM DELETING Labels... -12/15/2016 04:19:47 PM Supported Template: set([]) Supported Labels: set([]) -12/15/2016 04:19:48 PM Publish Request received from 12345678123456781234567812345678 -12/15/2016 04:19:48 PM Node Labels: {'VNF2': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1', 'tosca.policies.Placement.Geolocation:properties:region:us-west-2']), 'VNF3': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1', 'tosca.policies.Placement.Geolocation:properties:region:us-west-2']), 'VNF1': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1'])} -12/15/2016 04:19:48 PM Site Maps: {'VNF2': set([]), 'VNF3': set([]), 'VNF1': set([])} -12/15/2016 04:19:48 PM Selected Sites: {'VNF2': [], 'VNF3': [], 'VNF1': []} -12/15/2016 04:19:48 PM Per domain file paths: {} -12/15/2016 04:19:49 PM Subscribe Request received from 12345678123456781234567812345678 -12/15/2016 04:19:49 PM APPENDING Labels... -12/15/2016 04:19:49 PM Supported Template: set([]) Supported Labels: set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1']) -12/15/2016 04:19:50 PM Publish Request received from 8339120b7e2e4e87a0164c806bea4e06 -12/15/2016 04:19:50 PM ERRNO 17; ./toscafiles/ exists. Creating: ./toscafiles/template1.yaml -12/15/2016 04:19:50 PM Node Labels: {'VNF2': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1', 'tosca.policies.Placement.Geolocation:properties:region:us-west-2']), 'VNF3': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1', 'tosca.policies.Placement.Geolocation:properties:region:us-west-2']), 'VNF1': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1'])} -12/15/2016 04:19:50 PM Site Maps: {'VNF2': set([]), 'VNF3': set([]), 'VNF1': set(['12345678123456781234567812345678'])} -12/15/2016 04:19:50 PM Selected Sites: {'VNF2': [], 'VNF3': [], 'VNF1': '12345678123456781234567812345678'} -12/15/2016 04:19:50 PM Per domain file paths: {'12345678123456781234567812345678': './toscafiles/template_part12345678123456781234567812345678.yaml'} -12/15/2016 04:19:50 PM Push Response received from 12345678123456781234567812345678 +02/06/2017 06:36:52 AM Domino Server Starting... +02/06/2017 06:36:52 AM Registration Request received for UUID 12345678123456781234567812345678 from IP: 172.16.42.2 port: 9091 +02/06/2017 06:36:53 AM Registration Request received for UUID 12345678123456781234567812345678 from IP: 172.16.42.2 port: 9092 +02/06/2017 06:36:54 AM heartbeat received from 12345678123456781234567812345678 +02/06/2017 06:36:55 AM Subscribe Request received from 12345678123456781234567812345678 +02/06/2017 06:36:55 AM APPENDING Labels... +02/06/2017 06:36:55 AM Supported Template: set(['hot']) Supported Labels: set(['tosca.policies.Placement:properties:region:nova-1']) +02/06/2017 06:36:56 AM Subscribe Request received from 12345678123456781234567812345678 +02/06/2017 06:36:56 AM APPENDING Labels... +02/06/2017 06:36:56 AM Supported Template: set(['dummy2', 'dummy1']) Supported Labels: set(['tosca.policies.Placement:properties:region:nova-1']) +02/06/2017 06:36:57 AM Subscribe Request received from 12345678123456781234567812345678 +02/06/2017 06:36:57 AM APPENDING Labels... +02/06/2017 06:36:57 AM Supported Template: set([]) Supported Labels: set(['tosca.policies.Placement:properties:region:nova-1']) +02/06/2017 06:36:58 AM Subscribe Request received from 12345678123456781234567812345678 +02/06/2017 06:36:58 AM APPENDING Labels... +02/06/2017 06:36:58 AM Supported Template: set([]) Supported Labels: set(['tosca.policies.Placement:properties:region:nova-2', 'tosca.policies.Placement:properties:region:nova-1']) +02/06/2017 06:36:59 AM Subscribe Request received from 12345678123456781234567812345678 +02/06/2017 06:36:59 AM OVERWRITING Labels... +02/06/2017 06:36:59 AM Supported Template: set([]) Supported Labels: set(['tosca.policies.Placement:properties:region:nova-3']) +02/06/2017 06:37:01 AM Subscribe Request received from 12345678123456781234567812345678 +02/06/2017 06:37:01 AM DELETING Labels... +02/06/2017 06:37:01 AM Supported Template: set([]) Supported Labels: set([]) +02/06/2017 06:37:02 AM Publish Request received from 12345678123456781234567812345678 +02/06/2017 06:37:02 AM Node Labels: {'VNF2': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1', 'tosca.policies.Placement.Geolocation:properties:region:us-west-2']), 'VNF3': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1', 'tosca.policies.Placement.Geolocation:properties:region:us-west-2']), 'VNF1': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1'])} +02/06/2017 06:37:02 AM Site Maps: {'VNF2': set([]), 'VNF3': set([]), 'VNF1': set([])} +02/06/2017 06:37:02 AM Selected Sites: {'VNF2': [], 'VNF3': [], 'VNF1': []} +02/06/2017 06:37:02 AM Per domain file paths: {} +02/06/2017 06:37:02 AM Per domain topologies: {} +02/06/2017 06:37:02 AM Boundary VLs: {} +02/06/2017 06:37:02 AM VL sites: {} +02/06/2017 06:37:02 AM Subscribers: [] for TUID: 5105955fa64f44db96b5e3ac57d224e6 +02/06/2017 06:37:03 AM Subscribe Request received from 12345678123456781234567812345678 +02/06/2017 06:37:03 AM APPENDING Labels... +02/06/2017 06:37:03 AM Supported Template: set([]) Supported Labels: set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1']) +02/06/2017 06:37:04 AM Publish Request received from 3b49733eca51447c8e4bd6028f6f45b6 +02/06/2017 06:37:04 AM ERRNO 17; ./toscafiles/ exists. Creating: ./toscafiles/template1.yaml +02/06/2017 06:37:04 AM Node Labels: {'VNF2': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1', 'tosca.policies.Placement.Geolocation:properties:region:us-west-2']), 'VNF3': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1', 'tosca.policies.Placement.Geolocation:properties:region:us-west-2']), 'VNF1': set(['tosca.policies.Placement.Geolocation:properties:region:us-west-1'])} +02/06/2017 06:37:04 AM Site Maps: {'VNF2': set([]), 'VNF3': set([]), 'VNF1': set(['12345678123456781234567812345678'])} +02/06/2017 06:37:04 AM Selected Sites: {'VNF2': [], 'VNF3': [], 'VNF1': '12345678123456781234567812345678'} +02/06/2017 06:37:04 AM Per domain file paths: {'12345678123456781234567812345678': './toscafiles/template_part12345678123456781234567812345678.yaml'} +02/06/2017 06:37:04 AM Per domain topologies: {'12345678123456781234567812345678': {'policy_types': {'tosca.policies.Placement.Geolocation': {'description': 'Geolocation policy', 'derived_from': 'tosca.policies.Placement'}}, 'tosca_definitions_version': 'tosca_simple_profile_for_nfv_1_0_0', 'description': 'Template for deploying a single server with predefined properties.', 'topology_template': {'node_templates': {'VNF1': {'type': 'tosca.nodes.nfv.VNF', 'properties': {'version': 1.0, 'vendor': 'acmetelco', 'id': 'vnf1'}}}, 'policies': [{'rule1': {'type': 'tosca.policies.Placement.Geolocation', 'targets': ['VNF1'], 'properties': {'region': ['us-west-1']}}}]}, 'metadata': {'template_name': 'TOSCA NFV Sample Template'}}} +02/06/2017 06:37:04 AM Boundary VLs: {} +02/06/2017 06:37:04 AM VL sites: {} +02/06/2017 06:37:04 AM Push Response received from 12345678123456781234567812345678 +02/06/2017 06:37:04 AM Subscribers: ['12345678123456781234567812345678'] for TUID: c520de762fb44803b99170e34c3dc21a diff --git a/tests/test_partitioner.py b/tests/test_partitioner.py index 75ec817..5634c01 100755 --- a/tests/test_partitioner.py +++ b/tests/test_partitioner.py @@ -41,11 +41,17 @@ def main(argv): node_site = label.select_site( site_map ) print node_site - file_paths = partitioner.partition_tosca("./tests/tmp/tosca",node_site,tpl) + tpl_site = {} + file_paths = partitioner.partition_tosca("./tests/tmp/tosca",node_site,tpl,tpl_site) print file_paths + + boundary_VLs, VL_sites = partitioner.return_boundarylinks(tpl_site) + print boundary_VLs + print VL_sites + except: print('Unexpected error: %s', sys.exc_info()[0]) - + raise if __name__ == "__main__": main(sys.argv[1:]) |