update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b second try
[osm/SO.git] / rwlaunchpad / test / launchpad.py
1 #!/usr/bin/env python3
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 resource
23 import socket
24 import sys
25 import subprocess
26 import shlex
27 import shutil
28 import netifaces
29
30 from rift.rwlib.util import certs
31 import rift.rwcal.cloudsim
32 import rift.rwcal.cloudsim.net
33 import rift.vcs
34 import rift.vcs.core as core
35 import rift.vcs.demo
36 import rift.vcs.vms
37
38 import rift.rwcal.cloudsim
39 import rift.rwcal.cloudsim.net
40
41 from rift.vcs.ext import ClassProperty
42
43
44 logger = logging.getLogger(__name__)
45
46 IDP_PORT_NUMBER = "8009"
47
48 def get_launchpad_address():
49 # Search for externally accessible IP address with netifaces
50 gateways = netifaces.gateways()
51 # Check for default route facing interface and then get its ip address
52 if 'default' in gateways:
53 interface = gateways['default'][netifaces.AF_INET][1]
54 launchpad_ip_address = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['addr']
55 else:
56 # no default gateway. Revert to 127.0.0.1
57 launchpad_ip_address = "127.0.0.1"
58
59 return launchpad_ip_address
60
61 class NsmTasklet(rift.vcs.core.Tasklet):
62 """
63 This class represents a network services manager tasklet.
64 """
65
66 def __init__(self, name='network-services-manager', uid=None,
67 config_ready=True,
68 recovery_action=core.RecoveryType.FAILCRITICAL.value,
69 data_storetype=core.DataStore.NOSTORE.value,
70 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
71 ):
72 """
73 Creates a NsmTasklet object.
74
75 Arguments:
76 name - the name of the tasklet
77 uid - a unique identifier
78 """
79 super(NsmTasklet, self).__init__(name=name, uid=uid,
80 config_ready=config_ready,
81 recovery_action=recovery_action,
82 data_storetype=data_storetype,
83 ha_startup_mode=ha_startup_mode,
84 )
85
86 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwnsmtasklet')
87 plugin_name = ClassProperty('rwnsmtasklet')
88
89
90 class VnsTasklet(rift.vcs.core.Tasklet):
91 """
92 This class represents a network services manager tasklet.
93 """
94
95 def __init__(self, name='virtual-network-service', uid=None,
96 config_ready=True,
97 recovery_action=core.RecoveryType.FAILCRITICAL.value,
98 data_storetype=core.DataStore.NOSTORE.value,
99 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
100 ):
101 """
102 Creates a VnsTasklet object.
103
104 Arguments:
105 name - the name of the tasklet
106 uid - a unique identifier
107 """
108 super(VnsTasklet, self).__init__(name=name, uid=uid,
109 config_ready=config_ready,
110 recovery_action=recovery_action,
111 data_storetype=data_storetype,
112 ha_startup_mode=ha_startup_mode,
113 )
114
115 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwvnstasklet')
116 plugin_name = ClassProperty('rwvnstasklet')
117
118
119 class VnfmTasklet(rift.vcs.core.Tasklet):
120 """
121 This class represents a virtual network function manager tasklet.
122 """
123
124 def __init__(self, name='virtual-network-function-manager', uid=None,
125 config_ready=True,
126 recovery_action=core.RecoveryType.FAILCRITICAL.value,
127 data_storetype=core.DataStore.NOSTORE.value,
128 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
129 ):
130 """
131 Creates a VnfmTasklet object.
132
133 Arguments:
134 name - the name of the tasklet
135 uid - a unique identifier
136 """
137 super(VnfmTasklet, self).__init__(name=name, uid=uid,
138 config_ready=config_ready,
139 recovery_action=recovery_action,
140 data_storetype=data_storetype,
141 ha_startup_mode=ha_startup_mode,
142 )
143
144 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwvnfmtasklet')
145 plugin_name = ClassProperty('rwvnfmtasklet')
146
147
148 class ResMgrTasklet(rift.vcs.core.Tasklet):
149 """
150 This class represents a Resource Manager tasklet.
151 """
152
153 def __init__(self, name='Resource-Manager', uid=None,
154 config_ready=True,
155 recovery_action=core.RecoveryType.FAILCRITICAL.value,
156 data_storetype=core.DataStore.NOSTORE.value,
157 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
158 ):
159 """
160 Creates a ResMgrTasklet object.
161
162 Arguments:
163 name - the name of the tasklet
164 uid - a unique identifier
165 """
166 super(ResMgrTasklet, self).__init__(name=name, uid=uid,
167 config_ready=config_ready,
168 recovery_action=recovery_action,
169 data_storetype=data_storetype,
170 ha_startup_mode=ha_startup_mode,
171 )
172
173 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwresmgrtasklet')
174 plugin_name = ClassProperty('rwresmgrtasklet')
175
176
177 class ImageMgrTasklet(rift.vcs.core.Tasklet):
178 """
179 This class represents a Image Manager tasklet.
180 """
181
182 def __init__(self, name='Image-Manager', uid=None,
183 config_ready=True,
184 recovery_action=core.RecoveryType.FAILCRITICAL.value,
185 data_storetype=core.DataStore.NOSTORE.value,
186 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
187 ):
188 """
189 Creates a Image Manager Tasklet object.
190
191 Arguments:
192 name - the name of the tasklet
193 uid - a unique identifier
194 """
195 super(ImageMgrTasklet, self).__init__(
196 name=name, uid=uid,
197 config_ready=config_ready,
198 recovery_action=recovery_action,
199 data_storetype=data_storetype,
200 ha_startup_mode=ha_startup_mode,
201 )
202
203 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwimagemgrtasklet')
204 plugin_name = ClassProperty('rwimagemgrtasklet')
205
206
207 class MonitorTasklet(rift.vcs.core.Tasklet):
208 """
209 This class represents a tasklet that is used to monitor NFVI metrics.
210 """
211
212 def __init__(self, name='nfvi-metrics-monitor', uid=None,
213 config_ready=True,
214 recovery_action=core.RecoveryType.FAILCRITICAL.value,
215 data_storetype=core.DataStore.NOSTORE.value,
216 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
217 ):
218 """
219 Creates a MonitorTasklet object.
220
221 Arguments:
222 name - the name of the tasklet
223 uid - a unique identifier
224
225 """
226 super(MonitorTasklet, self).__init__(name=name, uid=uid,
227 config_ready=config_ready,
228 recovery_action=recovery_action,
229 data_storetype=data_storetype,
230 ha_startup_mode=ha_startup_mode,
231 )
232
233 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwmonitor')
234 plugin_name = ClassProperty('rwmonitor')
235
236 class RedisServer(rift.vcs.NativeProcess):
237 def __init__(self, name="RW.Redis.Server",
238 config_ready=True,
239 recovery_action=core.RecoveryType.FAILCRITICAL.value,
240 data_storetype=core.DataStore.NOSTORE.value,
241 ha_startup_mode=core.HaStartup.ANY_VM.value,
242 ):
243 super(RedisServer, self).__init__(
244 name=name,
245 exe="/usr/bin/redis-server",
246 config_ready=config_ready,
247 recovery_action=recovery_action,
248 data_storetype=data_storetype,
249 ha_startup_mode=ha_startup_mode,
250 )
251
252 @property
253 def args(self):
254 return "./usr/bin/active_redis.conf --port 9999"
255
256
257 class MonitoringParameterTasklet(rift.vcs.core.Tasklet):
258 """
259 This class represents a tasklet that is used to generate monitoring
260 parameters.
261 """
262
263 def __init__(self, name='Monitoring-Parameter', uid=None,
264 config_ready=True,
265 recovery_action=core.RecoveryType.FAILCRITICAL.value,
266 data_storetype=core.DataStore.NOSTORE.value,
267 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
268 ):
269 """
270 Creates a MonitoringParameterTasklet object.
271
272 Arguments:
273 name - the name of the tasklet
274 uid - a unique identifier
275
276 """
277 super(MonitoringParameterTasklet, self).__init__(name=name, uid=uid,
278 config_ready=config_ready,
279 recovery_action=recovery_action,
280 data_storetype=data_storetype,
281 ha_startup_mode=ha_startup_mode,
282 )
283
284 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwmonparam')
285 plugin_name = ClassProperty('rwmonparam')
286
287
288 class AutoscalerTasklet(rift.vcs.core.Tasklet):
289 """
290 This class represents a tasklet that is used to generate monitoring
291 parameters.
292 """
293
294 def __init__(self, name='Autoscaler', uid=None,
295 config_ready=True,
296 recovery_action=core.RecoveryType.FAILCRITICAL.value,
297 data_storetype=core.DataStore.NOSTORE.value,
298 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
299 ):
300 """
301 Creates a MonitoringParameterTasklet object.
302
303 Arguments:
304 name - the name of the tasklet
305 uid - a unique identifier
306
307 """
308 super(AutoscalerTasklet, self).__init__(name=name, uid=uid,
309 config_ready=config_ready,
310 recovery_action=recovery_action,
311 data_storetype=data_storetype,
312 ha_startup_mode=ha_startup_mode,
313 )
314
315 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwautoscaler')
316 plugin_name = ClassProperty('rwautoscaler')
317
318 class StagingManagerTasklet(rift.vcs.core.Tasklet):
319 """
320 A class that provide a simple staging area for all tasklets
321 """
322
323 def __init__(self, name='StagingManager', uid=None,
324 config_ready=True,
325 recovery_action=core.RecoveryType.FAILCRITICAL.value,
326 data_storetype=core.DataStore.NOSTORE.value,
327 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
328 ):
329 """
330 Creates a StagingMangerTasklet object.
331
332 Arguments:
333 name - the name of the tasklet
334 uid - a unique identifier
335
336 """
337 super(StagingManagerTasklet, self).__init__(name=name, uid=uid,
338 config_ready=config_ready,
339 recovery_action=recovery_action,
340 data_storetype=data_storetype,
341 ha_startup_mode=ha_startup_mode,
342 )
343
344 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwstagingmgr')
345 plugin_name = ClassProperty('rwstagingmgr')
346
347
348 class UIServer(rift.vcs.NativeProcess):
349 def __init__(self, name="RW.MC.UI",
350 config_ready=True,
351 recovery_action=core.RecoveryType.FAILCRITICAL.value,
352 data_storetype=core.DataStore.NOSTORE.value,
353 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
354 external_address=None,
355 ):
356 super(UIServer, self).__init__(
357 name=name,
358 exe="./usr/share/rw.ui/skyquake/scripts/launch_ui.sh",
359 config_ready=config_ready,
360 recovery_action=recovery_action,
361 data_storetype=data_storetype,
362 ha_startup_mode=ha_startup_mode,
363 )
364 self._external_address = external_address
365
366 @property
367 def args(self):
368 return self._get_ui_args()
369
370 def _get_ui_args(self):
371 """Returns the SSL parameter string for launchpad UI processes"""
372
373 try:
374 use_ssl, certfile_path, keyfile_path = certs.get_bootstrap_cert_and_key()
375 except certs.BootstrapSslMissingException:
376 logger.error('No bootstrap certificates found. Disabling UI SSL')
377 use_ssl = False
378
379 # If we're not using SSL, no SSL arguments are necessary
380 if not use_ssl:
381 return ""
382
383 # If an external address is set, take that value for launchpad IP
384 # address, else use the internal IP address used for default route
385 launchpad_ip_address = self._external_address
386 if not launchpad_ip_address:
387 launchpad_ip_address = get_launchpad_address()
388
389 return "--enable-https" +\
390 " --keyfile-path={}".format(keyfile_path) +\
391 " --certfile-path={}".format(certfile_path) +\
392 " --launchpad-address={}".format(launchpad_ip_address) +\
393 " --idp-port-number={}".format(IDP_PORT_NUMBER) +\
394 " --callback-address={}".format(launchpad_ip_address)
395
396
397 class ConfigManagerTasklet(rift.vcs.core.Tasklet):
398 """
399 This class represents a Resource Manager tasklet.
400 """
401
402 def __init__(self, name='Configuration-Manager', uid=None,
403 config_ready=True,
404 recovery_action=core.RecoveryType.FAILCRITICAL.value,
405 data_storetype=core.DataStore.NOSTORE.value,
406 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
407 ):
408 """
409 Creates a ConfigManagerTasklet object.
410
411 Arguments:
412 name - the name of the tasklet
413 uid - a unique identifier
414 """
415 super(ConfigManagerTasklet, self).__init__(name=name, uid=uid,
416 config_ready=config_ready,
417 recovery_action=recovery_action,
418 data_storetype=data_storetype,
419 ha_startup_mode=ha_startup_mode,
420 )
421
422 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwconmantasklet')
423 plugin_name = ClassProperty('rwconmantasklet')
424
425
426 class ProjectMgrManoTasklet(rift.vcs.core.Tasklet):
427 """
428 This class represents a Resource Manager tasklet.
429 """
430
431 def __init__(self, name='Project-Manager-Mano', uid=None,
432 config_ready=True,
433 recovery_action=core.RecoveryType.FAILCRITICAL.value,
434 data_storetype=core.DataStore.NOSTORE.value,
435 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
436 ):
437 """
438 Creates a ProjectMgrManoTasklet object.
439
440 Arguments:
441 name - the name of the tasklet
442 uid - a unique identifier
443 """
444 super(ProjectMgrManoTasklet, self).__init__(name=name, uid=uid,
445 config_ready=config_ready,
446 recovery_action=recovery_action,
447 data_storetype=data_storetype,
448 ha_startup_mode=ha_startup_mode,
449 )
450
451 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwprojectmano')
452 plugin_name = ClassProperty('rwprojectmano')
453
454
455 class PackageManagerTasklet(rift.vcs.core.Tasklet):
456 """
457 This class represents a Resource Manager tasklet.
458 """
459
460 def __init__(self, name='Package-Manager', uid=None,
461 config_ready=True,
462 recovery_action=core.RecoveryType.FAILCRITICAL.value,
463 data_storetype=core.DataStore.NOSTORE.value,
464 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
465 ):
466 """
467 Creates a PackageManager object.
468
469 Arguments:
470 name - the name of the tasklet
471 uid - a unique identifier
472 """
473 super(PackageManagerTasklet, self).__init__(name=name, uid=uid,
474 config_ready=config_ready,
475 recovery_action=recovery_action,
476 data_storetype=data_storetype,
477 ha_startup_mode=ha_startup_mode,
478 )
479
480 plugin_directory = ClassProperty('./usr/lib/rift/plugins/rwpkgmgr')
481 plugin_name = ClassProperty('rwpkgmgr')
482
483 class GlanceServer(rift.vcs.NativeProcess):
484 def __init__(self, name="glance-image-catalog",
485 config_ready=True,
486 recovery_action=core.RecoveryType.FAILCRITICAL.value,
487 data_storetype=core.DataStore.NOSTORE.value,
488 ha_startup_mode=core.HaStartup.ONLY_ACTIVE.value,
489 ):
490 super(GlanceServer, self).__init__(
491 name=name,
492 exe="./usr/bin/glance_start_wrapper",
493 config_ready=config_ready,
494 recovery_action=recovery_action,
495 data_storetype=data_storetype,
496 ha_startup_mode=ha_startup_mode,
497 )
498
499 @property
500 def args(self):
501 return "./etc/glance"
502
503
504 class Demo(rift.vcs.demo.Demo):
505 def __init__(self, no_ui=False,
506 data_store=None,
507 mgmt_ip_list=[],
508 test_name=None,
509 start_auth_svc=None,
510 start_pam_svc=None,
511 external_address=None):
512
513 datastore = core.DataStore.BDB.value
514 if data_store == "Redis":
515 datastore = core.DataStore.REDIS.value
516 elif data_store == "None":
517 datastore = core.DataStore.NOSTORE.value
518
519 restart_db_active = {"recovery_action" : core.RecoveryType.RESTART.value, \
520 "data_storetype" : datastore, \
521 "ha_startup_mode" : core.HaStartup.ONLY_ACTIVE.value}
522
523 failcrit_db_active = {"recovery_action" : core.RecoveryType.FAILCRITICAL.value, \
524 "data_storetype" : datastore, \
525 "ha_startup_mode" : core.HaStartup.ONLY_ACTIVE.value}
526
527 failcrit_db_any = {"recovery_action" : core.RecoveryType.FAILCRITICAL.value, \
528 "data_storetype" : datastore, \
529 "ha_startup_mode" : core.HaStartup.ANY_VM.value}
530
531 procs = [
532 ConfigManagerTasklet(**failcrit_db_active),
533 GlanceServer(**failcrit_db_active),
534 rift.vcs.DtsRouterTasklet(**failcrit_db_any),
535 rift.vcs.MsgBrokerTasklet(**failcrit_db_any),
536 rift.vcs.RestconfTasklet(**failcrit_db_active),
537 rift.vcs.RiftCli(**failcrit_db_active, as_console=True),
538 rift.vcs.uAgentTasklet(**failcrit_db_any),
539 rift.vcs.Launchpad(**failcrit_db_active),
540 rift.vcs.IdentityManagerTasklet(**failcrit_db_active),
541 rift.vcs.ProjectManagerTasklet(**failcrit_db_active),
542 rift.vcs.HAManager(**failcrit_db_any),
543 rift.vcs.OpenIDCProviderTasklet(**failcrit_db_active),
544 rift.vcs.AuthExtUserTasklet(**failcrit_db_active),
545 rift.vcs.OTTAuthTasklet(**failcrit_db_active),
546 NsmTasklet(**failcrit_db_active),
547 VnfmTasklet(**failcrit_db_active),
548 VnsTasklet(**failcrit_db_active),
549 ResMgrTasklet(**failcrit_db_active),
550 ImageMgrTasklet(**failcrit_db_active),
551 AutoscalerTasklet(**failcrit_db_active),
552 StagingManagerTasklet(**failcrit_db_active),
553 PackageManagerTasklet(**failcrit_db_active),
554 MonitoringParameterTasklet(**failcrit_db_active),
555 ProjectMgrManoTasklet(**failcrit_db_active)
556 ]
557
558 if datastore == core.DataStore.REDIS.value:
559 procs.append(RedisServer(**failcrit_db_any))
560
561 if not no_ui:
562 procs.append(UIServer(external_address=external_address))
563
564 if start_auth_svc:
565 procs.append(rift.vcs.WebAuthSvcTasklet(**failcrit_db_active))
566
567 if start_pam_svc:
568 procs.append(rift.vcs.PAMAuthTasklet())
569
570 restart_procs = []
571
572 if not mgmt_ip_list or len(mgmt_ip_list) == 0:
573 mgmt_ip_list.append(get_launchpad_address())
574
575 colony = rift.vcs.core.Colony(name='top', uid=1)
576 leader = 0
577 for mgmt_ip in mgmt_ip_list:
578 vm = rift.vcs.VirtualMachine(name='mgmt-vm-lp',
579 ip=mgmt_ip,
580 procs=procs,
581 restart_procs=restart_procs,start=False,)
582 if (leader == 0):
583 vm.leader = True
584 leader = 1
585 colony.append(vm)
586
587 sysinfo = rift.vcs.SystemInfo(
588 mode='ethsim',
589 zookeeper=rift.vcs.manifest.RaZookeeper(master_ip=mgmt_ip_list[0]),
590 colonies=[colony],
591 multi_broker=True,
592 multi_dtsrouter=True,
593 mgmt_ip_list=mgmt_ip_list,
594 test_name=test_name,
595 )
596
597 super(Demo, self).__init__(
598 # Construct the system. This system consists of 1 cluster in 1
599 # colony. The master cluster houses CLI and management VMs
600 sysinfo = sysinfo,
601
602 # Define the generic portmap.
603 port_map = {},
604
605 # Define a mapping from the placeholder logical names to the real
606 # port names for each of the different modes supported by this demo.
607 port_names = {
608 'ethsim': {
609 },
610 'pci': {
611 }
612 },
613
614 # Define the connectivity between logical port names.
615 port_groups = {},
616 )
617
618
619 def main(argv=sys.argv[1:]):
620 logging.basicConfig(format='%(asctime)-15s %(levelname)s %(message)s')
621
622 # Create a parser which includes all generic demo arguments
623 parser = rift.vcs.demo.DemoArgParser()
624 parser.add_argument("--no-ui", action='store_true')
625 parser.add_argument("--start-auth-svc",
626 action='store_true',
627 help="Start the Web Based Authentication service simualtor.")
628 parser.add_argument("--start-pam-svc",
629 action='store_true',
630 help="Start the PAM Authentication service.")
631 parser.add_argument("--external-address",
632 type=str,
633 help="External IP address or hostname using which the host can "+
634 "be reached.")
635 if rift.vcs.mgmt.default_agent_mode() == 'CONFD':
636 parser.add_argument("--use-osm-model",
637 action='store_true',
638 help="Load only OSM specific models and hide the Rift Specific Augments")
639
640 args = parser.parse_args(argv)
641
642 # Disable loading any kernel modules for the launchpad VM
643 # since it doesn't need it and it will fail within containers
644 os.environ["NO_KERNEL_MODS"] = "1"
645
646 # Get external_address from env if args not set
647 if args.external_address is None:
648 args.external_address = os.getenv("RIFT_EXTERNAL_ADDRESS")
649
650 os.environ["RIFT_EXTERNAL_ADDRESS"] = \
651 args.external_address if args.external_address else get_launchpad_address()
652
653 cleanup_dir_name = None
654 if os.environ["INSTALLDIR"] in ["/usr/rift",
655 "/usr/rift/build/ub16_debug/install/usr/rift",
656 "/usr/rift/build/fc20_debug/install/usr/rift"]:
657 cleanup_dir_name = os.environ["INSTALLDIR"] + "/var/rift/"
658
659 if args.test_name and not cleanup_dir_name:
660 cleanup_dir_name = "find {rift_install}/var/rift -name '*{pattern}*' -type d".format( \
661 rift_install=os.environ['RIFT_INSTALL'],
662 pattern = args.test_name)
663 try:
664 cleanup_dir_name = subprocess.check_output(cleanup_dir_name, shell=True)
665 cleanup_dir_name = cleanup_dir_name[:-1].decode("utf-8") + "/"
666 except Exception as e:
667 print ("Directory not found exception occurred. Probably running for first time")
668 print ("Zookeper cleanup cmd = {}".format(cleanup_dir_name))
669 else:
670 if not cleanup_dir_name:
671 cleanup_dir_name = os.environ["INSTALLDIR"] + "/"
672
673 # Remove the persistent Redis data
674 try:
675 for f in os.listdir(cleanup_dir_name):
676 if f.endswith(".aof") or f.endswith(".rdb"):
677 os.remove(os.path.join(cleanup_dir_name, f))
678
679 # Remove the persistant DTS recovery files
680 for f in os.listdir(cleanup_dir_name):
681 if f.endswith(".db"):
682 os.remove(os.path.join(cleanup_dir_name, f))
683
684 shutil.rmtree(os.path.join(cleanup_dir_name, "zk/server-1"))
685 shutil.rmtree(os.path.join(os.environ["INSTALLDIR"], "var/rift/tmp*"))
686 except FileNotFoundError as e:
687 pass
688 except Exception as e:
689 print ("Error while cleanup: {}".format(str(e)))
690
691 datastore = args.datastore
692 mgmt_ip_list = [] if not args.mgmt_ip_list else args.mgmt_ip_list
693
694 #load demo info and create Demo object
695 demo = Demo(args.no_ui,
696 datastore,
697 mgmt_ip_list,
698 args.test_name,
699 args.start_auth_svc,
700 args.start_pam_svc,
701 args.external_address)
702
703 if 'use_osm_model' in args and args.use_osm_model:
704 northbound_listing = ["platform_schema_listing.txt",
705 "platform_mgmt_schema_listing.txt",
706 "cli_launchpad_schema_listing.txt"]
707 args.use_xml_mode = True
708
709 else:
710 northbound_listing = ["platform_schema_listing.txt",
711 "platform_mgmt_schema_listing.txt",
712 "cli_launchpad_schema_listing.txt",
713 "cli_launchpad_rift_specific_schema_listing.txt"]
714
715 # Create the prepared system from the demo
716 system = rift.vcs.demo.prepared_system_from_demo_and_args(
717 demo, args,
718 northbound_listing=northbound_listing,
719 netconf_trace_override=True)
720
721 confd_ip = get_launchpad_address()
722 # TODO: This need to be changed when launchpad starts running on multiple VMs
723 rift.vcs.logger.configure_sink(config_file=None, confd_ip=confd_ip)
724
725 # Start the prepared system
726 system.start()
727
728 if __name__ == "__main__":
729 resource.setrlimit(resource.RLIMIT_CORE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY) )
730 os.system('/usr/rift/bin/UpdateHostsFile')
731 try:
732 main()
733 except rift.vcs.demo.ReservationError:
734 print("ERROR: unable to retrieve a list of IP addresses from the reservation system")
735 sys.exit(1)
736 except rift.vcs.demo.MissingModeError:
737 print("ERROR: you need to provide a mode to run the script")
738 sys.exit(1)
739 finally:
740 os.system("stty sane")