Auto Generated INFO.yaml file
[domino.git] / tests / test_partitioner.py
1 #!/usr/bin/env python
2
3 #Copyright 2016 Open Platform for NFV Project, Inc. and its contributors
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #   Unless required by applicable law or agreed to in writing, software
9 #   distributed under the License is distributed on an "AS IS" BASIS,
10 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 #   See the License for the specific language governing permissions and
12 #   limitations under the License.
13
14 import sys, os, glob, yaml
15
16 sys.path.insert(0, glob.glob('./lib')[0])
17
18 #from toscaparser.tosca_template import ToscaTemplate
19
20 from mapper import *
21 from partitioner import *
22
23 def main(argv):
24   try:
25     #tosca = ToscaTemplate(argv[0])
26     tpl = yaml.load(file(argv[0],'r'))
27     # Extract Labels
28     node_labels = label.extract_labels( tpl )
29     print node_labels
30     site_id = 0
31     subscribed_labels = {}
32     for key in node_labels:
33       subscribed_labels[site_id] = node_labels[key]
34       site_id = site_id + 1
35
36     # Map nodes in the template to resource domains
37     site_map = label.map_nodes( subscribed_labels , node_labels )
38     print site_map 
39
40     # Select a site for each VNF
41     node_site = label.select_site( site_map )
42     print node_site
43
44     tpl_site = {}
45     file_paths = partitioner.partition_tosca("./tests/tmp/tosca",node_site,tpl,tpl_site)
46     print file_paths
47
48     boundary_VLs, VL_sites = partitioner.return_boundarylinks(tpl_site)
49     print boundary_VLs
50     print VL_sites
51
52   except:
53     print('Unexpected error: %s', sys.exc_info()[0])
54     raise
55 if __name__ == "__main__":
56    main(sys.argv[1:])
57