rm dependents, update tests
[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
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     # Extract Labels
27     node_labels = label.extract_labels( tosca )
28     print node_labels
29     site_id = 0
30     subscribed_labels = {}
31     for key in node_labels:
32       subscribed_labels[site_id] = node_labels[key]
33       site_id = site_id + 1
34
35     # Map nodes in the template to resource domains
36     site_map = label.map_nodes( subscribed_labels , node_labels )
37     print site_map 
38
39     # Select a site for each VNF
40     node_site = label.select_site( site_map )
41     print node_site
42
43     file_paths = partitioner.partition_tosca("./tests/tmp/tosca",node_site,tosca.tpl)
44     print file_paths
45   except:
46     print('Unexpected error: %s', sys.exc_info()[0])
47
48 if __name__ == "__main__":
49    main(sys.argv[1:])