summaryrefslogtreecommitdiff
path: root/host-control
diff options
context:
space:
mode:
Diffstat (limited to 'host-control')
-rwxr-xr-xhost-control24
1 files changed, 23 insertions, 1 deletions
diff --git a/host-control b/host-control
index 1b60b2f..efeea96 100755
--- a/host-control
+++ b/host-control
@@ -39,7 +39,8 @@ class host_control():
" unit-stop [unit] stop unit\n" \
" unit-restart [unit] restart unit\n" \
" unit-log [unit] show unit log\n" \
- " unit-update [unit] update unit"
+ " unit-update [unit] update unit\n" \
+ " unit-docker-shell [unit] access unit docker shell"
# trace
@@ -214,6 +215,12 @@ class host_control():
return None
+ def unit_docker_container(self, unit):
+ if "docker-container" in unit:
+ return unit["docker-container"]
+ else:
+ return unit["name"]
+
def unit_systemctl(self, host, name, option):
address = self.ssh_address(host)
@@ -299,6 +306,19 @@ class host_control():
return 0
+ def unit_docker_shell(self, host, name):
+ unit = self.unit_lookup(host, name)
+ if unit is None:
+ self.print_message("No " + name + " unit in host: " + self.host)
+ return 1
+
+ container = self.unit_docker_container(unit)
+ address = self.ssh_address(host)
+ command = self.ssh_command(address, [ "-t", "docker", "exec", "-ti", container, "sh" ])
+
+ self.print_command(command)
+ subprocess.call(command)
+
def unit_list(self, host):
if not "units" in host:
self.print_message("No units in host: " + self.host)
@@ -486,6 +506,8 @@ class host_control():
return self.unit_log(host, arguments[1])
elif action == "unit-update":
return self.unit_update(host, arguments[1])
+ elif action == "unit-docker-shell":
+ return self.unit_docker_shell(host, arguments[1])
else:
self.print_message("Unknown action: " + action)
return 1