From 5e2ec5797f278976ddda6e08c34d045224184210 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Tue, 8 Mar 2016 09:57:37 +0000 Subject: [PATCH] Added ORCHESTRA_SSH_DEFAULT_USER setting --- TODO.md | 3 +++ orchestra/contrib/issues/serializers.py | 2 +- orchestra/contrib/orchestration/methods.py | 3 ++- orchestra/settings.py | 5 +++++ orchestra/utils/sys.py | 5 +++-- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index 77c7988e..db6e1a4b 100644 --- a/TODO.md +++ b/TODO.md @@ -431,3 +431,6 @@ mkhomedir_helper or create ssh homes with bash.rc and such # Automatically re-run backends until success? only timedout executions? # TODO save serialized versions ob backendoperation.instance in order to allow backend reexecution of deleted objects + +# Rename Backend -> COntroller + diff --git a/orchestra/contrib/issues/serializers.py b/orchestra/contrib/issues/serializers.py index 37d53cce..c8855600 100644 --- a/orchestra/contrib/issues/serializers.py +++ b/orchestra/contrib/issues/serializers.py @@ -13,7 +13,7 @@ class QueueSerializer(serializers.HyperlinkedModelSerializer): class MessageSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Message - fields = ('url', 'id', 'author', 'author_name', 'content', 'created_on') + fields = ('id', 'author', 'author_name', 'content', 'created_on') read_only_fields = ('author', 'author_name', 'created_on') def get_identity(self, data): diff --git a/orchestra/contrib/orchestration/methods.py b/orchestra/contrib/orchestration/methods.py index fde43b4b..db665a0d 100644 --- a/orchestra/contrib/orchestration/methods.py +++ b/orchestra/contrib/orchestration/methods.py @@ -7,6 +7,7 @@ import textwrap from celery.datastructures import ExceptionInfo +from orchestra.settings import ORCHESTRA_SSH_DEFAULT_USER from orchestra.utils.sys import sshrun from orchestra.utils.python import CaptureStdout, import_class @@ -39,7 +40,7 @@ def Paramiko(backend, log, server, cmds, async=False, paramiko_connections={}): ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) key = settings.ORCHESTRATION_SSH_KEY_PATH try: - ssh.connect(addr, username='root', key_filename=key) + ssh.connect(addr, username=ORCHESTRA_SSH_DEFAULT_USER, key_filename=key) except socket.error as e: logger.error('%s timed out on %s' % (backend, addr)) log.state = log.TIMEOUT diff --git a/orchestra/settings.py b/orchestra/settings.py index 9aa2d436..9dd45566 100644 --- a/orchestra/settings.py +++ b/orchestra/settings.py @@ -69,6 +69,11 @@ ORCHESTRA_API_ROOT_VIEW = Setting('ORCHESTRA_API_ROOT_VIEW', ) +ORCHESTRA_SSH_DEFAULT_USER = Setting('ORCHESTRA_SSH_DEFAULT_USER', + 'root' +) + + ORCHESTRA_DEFAULT_SUPPORT_FROM_EMAIL = Setting('ORCHESTRA_DEFAULT_SUPPORT_FROM_EMAIL', 'support@{}'.format(ORCHESTRA_BASE_DOMAIN), validators=[validate_email], diff --git a/orchestra/utils/sys.py b/orchestra/utils/sys.py index e39bcd91..84ab5b1e 100644 --- a/orchestra/utils/sys.py +++ b/orchestra/utils/sys.py @@ -175,8 +175,9 @@ def sshrun(addr, command, *args, executable='bash', persist=False, options=None, base_options.update(options or {}) options = ['%s=%s' % (k, v) for k, v in base_options.items()] options = ' -o '.join(options) - cmd = 'ssh -o {options} -C root@{addr} {executable}'.format( - options=options, addr=addr, executable=executable) + user = kwargs.get('user', settings.ORCHESTRA_SSH_DEFAULT_USER) + cmd = 'ssh -o {options} -C {user}@{addr} {executable}'.format( + options=options, addr=addr, user=user, executable=executable) return run(cmd, *args, stdin=command.encode('utf8'), **kwargs)