fixing, improve sersors installation code
diff --git a/wally/sensors/deploy_sensors.py b/wally/sensors/deploy_sensors.py
index 249adfb..73e7902 100644
--- a/wally/sensors/deploy_sensors.py
+++ b/wally/sensors/deploy_sensors.py
@@ -7,14 +7,14 @@
from wally.ssh_utils import copy_paths, run_over_ssh
-logger = logging.getLogger('wally')
+logger = logging.getLogger('wally.sensors')
def wait_all_ok(futures):
return all(future.result() for future in futures)
-def deploy_and_start_sensors(monitor_uri, sensor_configs,
+def deploy_and_start_sensors(sensor_configs,
remote_path='/tmp/sensors/sensors'):
paths = {os.path.dirname(__file__): remote_path}
@@ -25,29 +25,29 @@
futures.append(executor.submit(deploy_and_start_sensor,
paths,
node_sensor_config,
- monitor_uri,
remote_path))
if not wait_all_ok(futures):
raise RuntimeError("Sensor deployment fails on some nodes")
-def deploy_and_start_sensor(paths, node_sensor_config,
- monitor_uri, remote_path):
+def deploy_and_start_sensor(paths, node_sensor_config, remote_path):
try:
copy_paths(node_sensor_config.conn, paths)
sftp = node_sensor_config.conn.open_sftp()
config_remote_path = os.path.join(remote_path, "conf.json")
+ sensors_config = node_sensor_config.sensors.copy()
+ sensors_config['source_id'] = node_sensor_config.source_id
with sftp.open(config_remote_path, "w") as fd:
- fd.write(json.dumps(node_sensor_config.sensors))
+ fd.write(json.dumps(sensors_config))
cmd_templ = 'env PYTHONPATH="{0}" python -m ' + \
"sensors.main -d start -u {1} {2}"
cmd = cmd_templ.format(os.path.dirname(remote_path),
- monitor_uri,
+ node_sensor_config.monitor_url,
config_remote_path)
run_over_ssh(node_sensor_config.conn, cmd,
@@ -55,7 +55,7 @@
sftp.close()
except:
- msg = "During deploing sensors in {0}".format(node_sensor_config.url)
+ msg = "During deploing sensors on {0}".format(node_sensor_config.url)
logger.exception(msg)
return False
return True
@@ -69,9 +69,8 @@
# some magic
time.sleep(0.3)
- conn.exec_command("rm -rf {0}".format(remote_path))
-
- logger.debug("Sensors stopped and removed")
+ # logger.warning("Sensors don't removed")
+ run_over_ssh(conn, "rm -rf {0}".format(remote_path), node=url)
def stop_and_remove_sensors(configs, remote_path='/tmp/sensors'):
@@ -85,3 +84,4 @@
remote_path))
wait(futures)
+ logger.debug("Sensors stopped and removed")