Merge branch 'pm_phase2' into v2.0. Amend change for NSD based on package_type rpc...
[osm/SO.git] / rwcm / test / start_cm_system.py
1 #!/usr/bin/env python
2
3 #
4 # Copyright 2016 RIFT.IO Inc
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18
19
20 import logging
21 import os
22 import sys
23
24 import rift.vcs
25 import rift.vcs.demo
26 import rift.vcs.vms
27
28 from rift.vcs.ext import ClassProperty
29
30 logger = logging.getLogger(__name__)
31
32
33 class ConfigManagerTasklet(rift.vcs.core.Tasklet):
34 """
35 This class represents SO tasklet.
36 """
37
38 def __init__(self, name='rwcmtasklet', uid=None):
39 """
40 Creates a PingTasklet object.
41
42 Arguments:
43 name - the name of the tasklet
44 uid - a unique identifier
45 """
46 super(ConfigManagerTasklet, self).__init__(name=name, uid=uid)
47
48 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwconmantasklet')
49 plugin_name = ClassProperty('rwconmantasklet')
50
51
52 # Construct the system. This system consists of 1 cluster in 1
53 # colony. The master cluster houses CLI and management VMs
54 sysinfo = rift.vcs.SystemInfo(
55 colonies=[
56 rift.vcs.Colony(
57 clusters=[
58 rift.vcs.Cluster(
59 name='master',
60 virtual_machines=[
61 rift.vcs.VirtualMachine(
62 name='vm-so',
63 ip='127.0.0.1',
64 tasklets=[
65 rift.vcs.uAgentTasklet(),
66 ],
67 procs=[
68 rift.vcs.CliTasklet(),
69 rift.vcs.DtsRouterTasklet(),
70 rift.vcs.MsgBrokerTasklet(),
71 rift.vcs.RestconfTasklet(),
72 ConfigManagerTasklet()
73 ],
74 ),
75 ]
76 )
77 ]
78 )
79 ]
80 )
81
82
83 # Define the generic portmap.
84 port_map = {}
85
86
87 # Define a mapping from the placeholder logical names to the real
88 # port names for each of the different modes supported by this demo.
89 port_names = {
90 'ethsim': {
91 },
92 'pci': {
93 }
94 }
95
96
97 # Define the connectivity between logical port names.
98 port_groups = {}
99
100 def main(argv=sys.argv[1:]):
101 logging.basicConfig(format='%(asctime)-15s %(levelname)s %(message)s')
102
103 # Create a parser which includes all generic demo arguments
104 parser = rift.vcs.demo.DemoArgParser()
105
106 args = parser.parse_args(argv)
107
108 #load demo info and create Demo object
109 demo = rift.vcs.demo.Demo(sysinfo=sysinfo,
110 port_map=port_map,
111 port_names=port_names,
112 port_groups=port_groups)
113
114 # Create the prepared system from the demo
115 system = rift.vcs.demo.prepared_system_from_demo_and_args(demo, args, netconf_trace_override=True)
116
117 # Start the prepared system
118 system.start()
119
120
121 if __name__ == "__main__":
122 try:
123 main()
124 except rift.vcs.demo.ReservationError:
125 print("ERROR: unable to retrieve a list of IP addresses from the reservation system")
126 sys.exit(1)
127 except rift.vcs.demo.MissingModeError:
128 print("ERROR: you need to provide a mode to run the script")
129 sys.exit(1)
130 finally:
131 os.system("stty sane")