def __init__(self, cli_send_command): """Initialize libvirt class. """ super().__init__() self.cli_send_command = cli_send_command self.service_manager = service_lib.SpecificServiceManager( self.SERVICE, self.cli_send_command)
def __init__(self, cli_send_command, switch_map, name_to_switchid_map): """Initialize openvswitch class. """ super(OpenvSwitch, self).__init__() self.cli_send_command = cli_send_command self.switch_map = switch_map self.name_to_switchid_map = name_to_switchid_map self.service_manager = service_lib.SpecificServiceManager( self.SERVICE, self.cli_send_command)
def __init__(self, cli_send_command): """Initialize Collectd class. """ super(Collectd, self).__init__() self.send_command = cli_send_command self.collectd_conf = None self.service_manager = service_lib.SpecificServiceManager( self.SERVICE, self.send_command) # Data structure presenting content of collectd.conf self.plugins_config = None
def __init__(self, run_command, switch): """Initialize Dcrpd class. Args: run_command(function): function that runs the actual commands """ super(Dcrpd, self).__init__() self.run_command = run_command self.switch = switch self.switch_driver = SwitchDriver(self, switch) self.service_manager = service_lib.SpecificServiceManager( self.SERVICE, self.run_command)
def __init__(self, run_command, mgmt_ports): """Initialize NetworkD class. Args: run_command(function): function that runs the actual commands mgmt_ports(iter): list of mgmt ports to treat specially """ super(NetworkD, self).__init__() self.run_command = run_command self.mgmt_ports = mgmt_ports self.service_manager = service_lib.SpecificServiceManager( self.SERVICE, self.run_command)
def start(self, command, prefix=None, timeout=None, tool_name=None, tool_instance_id=None, pid=None, service_name=None, **kwargs): """Generate command for tool execution. Args: command(str): tool command prefix(str): command prefix timeout(int): time of tool execution Returns: int: tool instance ID """ if not tool_name: tool_name = self.tool if not tool_instance_id: tool_instance_id = self.next_id() if not pid: pid = os.getpid() if not service_name: service_name = "{}_{}_{}".format(tool_name, tool_instance_id, pid) # use --scope for synchronous execution in the current enviroment, # and maybe --pty and no -q systemd_cmd_str = "systemd-run --unit={0} -q -- {1}".format( service_name, command) cmd_str = (prefix if prefix else '') + systemd_cmd_str self.run_command(cmd_str, **kwargs) self.instances[tool_instance_id] = { 'command': cmd_str, 'instance_id': tool_instance_id, 'service_name': service_name, 'service_manager': service_lib.SpecificServiceManager(service_name, self.run_command), } # Wait for tool instance to start self.is_active(tool_instance_id) return tool_instance_id
def setUp(self): self.run_mock = MagicMock() self.service_manager = service_lib.SpecificServiceManager( "lldpad", self.run_mock)