Simplified sensor plugins

pull/3/head
Thorsten Sick 4 years ago
parent 27c204c0c9
commit 6db4718afc

@ -72,13 +72,9 @@ class BasePlugin():
self.machine_plugin.put(filename, self.machine_plugin.get_playground()) self.machine_plugin.put(filename, self.machine_plugin.get_playground())
# plugin_folder = os.path.dirname(os.path.realpath(self.plugin_path)) def get_from_machine(self, src, dst):
# src = os.path.join(plugin_folder, filename) """ Get a file from the machine """
self.machine_plugin.get(src, dst) # nosec
# if os.path.commonprefix((os.path.realpath(src), plugin_folder)) != plugin_folder:
# raise PluginError
# copy(src, self.sysconf["abs_machinepath_external"])
def run_cmd(self, command, warn=True, disown=False): def run_cmd(self, command, warn=True, disown=False):
""" Execute a command on the vm using the connection """ Execute a command on the vm using the connection

@ -19,7 +19,6 @@ class SensorPlugin(BasePlugin):
def __init__(self): def __init__(self):
super().__init__() # pylint:disable=useless-super-delegation super().__init__() # pylint:disable=useless-super-delegation
self.debugit = False self.debugit = False
# self.machine = None
def set_sysconf(self, config): def set_sysconf(self, config):
""" Set system config """ Set system config
@ -36,21 +35,10 @@ class SensorPlugin(BasePlugin):
return False return False
def install_command(self):
""" Generate the install command. Put everything you need that does not require a reboot in here. If you want to hard core alter the OS of the target, use the prime method """
raise NotImplementedError
def install(self): def install(self):
""" Install the sensor. Executed on the target. Take the sensor from the share and (maybe) copy it to its destination. Do some setup """ Install the sensor. Executed on the target. Take the sensor from the share and (maybe) copy it to its destination. Do some setup
""" """
cmd = self.install_command()
if cmd:
self.machine_plugin.__call_remote_run__(cmd)
def start_command(self):
""" Generate the start command """
raise NotImplementedError raise NotImplementedError
def start(self, disown=None): def start(self, disown=None):
@ -59,23 +47,12 @@ class SensorPlugin(BasePlugin):
@param disown: Send async into background @param disown: Send async into background
""" """
if disown is None:
disown = not self.debugit
cmd = self.start_command()
if cmd:
# self.run_cmd(cmd, disown=not self.debugit)
self.machine_plugin.__call_remote_run__(cmd, disown=disown)
def stop_command(self):
""" Generate the stop command """
raise NotImplementedError raise NotImplementedError
def stop(self): def stop(self):
""" Stop the sensor """ """ Stop the sensor """
cmd = self.stop_command()
if cmd: raise NotImplementedError
# self.run_cmd(cmd)
self.machine_plugin.__call_remote_run__(cmd)
def __call_collect__(self, machine_path): def __call_collect__(self, machine_path):
""" Generate the data collect command """ Generate the data collect command
@ -87,12 +64,6 @@ class SensorPlugin(BasePlugin):
os.makedirs(path) os.makedirs(path)
self.collect(path) self.collect(path)
def collect_command(self, path):
""" Generate the data collect command
@param path: Path to put the data into
"""
def collect(self, path): def collect(self, path):
""" Collect data from sensor. Copy it from sensor collection dir on target OS to the share """ Collect data from sensor. Copy it from sensor collection dir on target OS to the share

Loading…
Cancel
Save