execute code remote machine feature added

This commit is contained in:
volkansahin 2017-07-06 11:41:36 +03:00
parent 6496b0e35e
commit 4301037dd2

View file

@ -132,10 +132,13 @@ class Util:
raise raise
@staticmethod @staticmethod
def execute(command, stdin=None, env=None, cwd=None, shell=True, result=True, as_user=None): def execute(command, stdin=None, env=None, cwd=None, shell=True, result=True, as_user=None, ip=None):
try: try:
if as_user is not None: if ip:
command = 'ssh root@{0} "{1}"'.format(ip, command)
elif as_user:
command = 'su - {0} -c "{1}"'.format(as_user, command) command = 'su - {0} -c "{1}"'.format(as_user, command)
process = subprocess.Popen(command, stdin=stdin, env=env, cwd=cwd, stderr=subprocess.PIPE, process = subprocess.Popen(command, stdin=stdin, env=env, cwd=cwd, stderr=subprocess.PIPE,
stdout=subprocess.PIPE, shell=shell) stdout=subprocess.PIPE, shell=shell)