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():
24   argv = sys.argv[1:]
25   try:
26     #tosca = ToscaTemplate(argv[0])
27     tpl = yaml.load(file(argv[0],'r'))
28     # Extract Labels
29     node_labels = label.extract_labels( tpl )
30     print node_labels
31     site_id = 0
32     subscribed_labels = {}
33     for key in node_labels:
34       subscribed_labels[site_id] = node_labels[key]
35       site_id = site_id + 1
36
37     # Map nodes in the template to resource domains
38     site_map = label.map_nodes( subscribed_labels , node_labels )
39     print site_map 
40
41     # Select a site for each VNF
42     node_site = label.select_site( site_map )
43     print node_site
44
45     tpl_site = {}
46     file_paths = partitioner.partition_tosca("./tests/tmp/tosca",node_site,tpl,tpl_site)
47     print file_paths
48
49     boundary_VLs, VL_sites = partitioner.return_boundarylinks(tpl_site)
50     print boundary_VLs
51     print VL_sites
52
53   except:
54     print('Unexpected error: %s', sys.exc_info()[0])
55     raise
56
57 if __name__ == "__main__":
58   sys.exit(main())