def test_startup(self): path = os.path.abspath(__file__) dir_path = os.path.dirname(path) lm = LogManager('./test-logs') ptm = PhysicalTopologyManager(root_dir=dir_path + '/../..', log_manager=lm) ptm.configure(dir_path + '/test-config.json') ptm.startup() self.assertTrue(LinuxCLI().grep_cmd('ip netns', 'zoo1')) self.assertTrue(LinuxCLI().grep_cmd('ip netns', 'test-host1')) root_host = ptm.hosts_by_name['root'] test_host1 = ptm.hosts_by_name['test-host1'] self.assertTrue(root_host.cli.grep_cmd('ip l', 'th1eth1')) self.assertTrue(test_host1.cli.grep_cmd('ip l', 'eth1')) ptm.shutdown() self.assertFalse(LinuxCLI().grep_cmd('ip netns', 'zoo1')) self.assertFalse(LinuxCLI().grep_cmd('ip netns', 'test-host1'))
if command == '': usage(ArgMismatchException('Must specify at least one command option')) root_dir = LinuxCLI().cmd('pwd').strip() log_manager = LogManager(root_dir=log_dir) if command == 'startup': log_manager.rollover_logs_fresh(file_filter='ptm*.log') ptm = PhysicalTopologyManager(root_dir=root_dir, log_manager=log_manager) ptm.configure_logging(debug=debug) ptm.configure(ptm_config_file) if command == 'startup': ptm.startup() elif command == 'shutdown': ptm.shutdown() elif command == 'print': ptm.print_config() else: usage(ArgMismatchException('Command option not recognized: ' + command)) except ExitCleanException: exit(1) except ArgMismatchException as a: print 'Argument mismatch: ' + str(a) traceback.print_tb(sys.exc_traceback) exit(2) except ObjectNotFoundException as e: print 'Object not found: ' + str(e)