예제 #1
0
 def test_action_manager_calls_create_machines_with_create_action_and_machines_and_nohosts(
         self):
     manager = ActionManager(config_path="blaap", no_hosts=True)
     manager.machines = ["machine"]
     manager.execute("create")
     self.create_machines.assert_called_once_with(
         self.validator.updated_config, machines=["machine"])
예제 #2
0
 def test_action_manager_calls_change_machine_status_with_stop_action_and_machines(
         self):
     manager = ActionManager(config_path="blaap")
     manager.machines = ["machine"]
     manager.execute("stop")
     self.change_machine_status.assert_called_once_with(
         self.validator.updated_config, machines=["machine"], status="stop")
예제 #3
0
 def test_action_manager_calls_destroy_machines_with_destroy_action_and_machines(
         self):
     manager = ActionManager(config_path="blaap")
     manager.machines = ["machine"]
     manager.execute("destroy")
     self.destroy_machines.assert_called_once_with(
         self.validator.updated_config, machines=["machine"])
     self.assertFalse(self.destroy_lxc_image.called)
예제 #4
0
def main(args=None):
    """
    Program entry point
    :param list args: The pre-cooked arguments to pass to the ArgParser
    :return int: exit_code
    """
    args = parse_args(args)
    # Set the VNET_FORCE variable, if --yes is given this will answer yes to all questions
    environ[settings.VNET_FORCE_ENV_VAR] = "true" if args.yes else "false"
    # Setup logging
    setup_console_logging(verbosity=DEBUG if args.verbose else INFO)
    # Most VNet operation require root. So, do a root check
    if not check_for_root_user():
        logger.critical("This program should only be run as root")
        return EX_NOPERM
    # Let the action manager handle the rest
    manager = ActionManager(config_path=args.config,
                            sniffer=args.sniffer,
                            base_image=args.base_image,
                            no_hosts=args.no_hosts)
    if args.machines:
        manager.machines = args.machines
    return manager.execute(args.action)
예제 #5
0
 def test_action_manager_has_machine_property(self):
     manager = ActionManager()
     manager.machines = ["1", "2", "3"]
     self.assertEqual(manager.machines, ["1", "2", "3"])
     self.assertIsInstance(ActionManager.machines, property)
예제 #6
0
 def test_action_manager_does_not_call_delete_vnet_interfaces_with_destroy_action_and_machines(
         self):
     manager = ActionManager(config_path="blaap")
     manager.machines = ["machine"]
     manager.execute("destroy")
     self.assertFalse(self.delete_vnet_interfaces.called)
예제 #7
0
 def test_action_manager_does_not_call_bring_down_vnet_interfaces_with_stop_action_and_machines(
         self):
     manager = ActionManager(config_path="blaap")
     manager.machines = ["machine"]
     manager.execute("stop")
     self.assertFalse(self.bring_down_vnet_interfaces.called)