Added ORCHESTRA_SSH_DEFAULT_USER setting
This commit is contained in:
parent
d3caeeea2a
commit
5e2ec5797f
3
TODO.md
3
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?
|
# 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
|
# TODO save serialized versions ob backendoperation.instance in order to allow backend reexecution of deleted objects
|
||||||
|
|
||||||
|
|
||||||
|
# Rename Backend -> COntroller
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class QueueSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
class MessageSerializer(serializers.HyperlinkedModelSerializer):
|
class MessageSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Message
|
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')
|
read_only_fields = ('author', 'author_name', 'created_on')
|
||||||
|
|
||||||
def get_identity(self, data):
|
def get_identity(self, data):
|
||||||
|
|
|
@ -7,6 +7,7 @@ import textwrap
|
||||||
|
|
||||||
from celery.datastructures import ExceptionInfo
|
from celery.datastructures import ExceptionInfo
|
||||||
|
|
||||||
|
from orchestra.settings import ORCHESTRA_SSH_DEFAULT_USER
|
||||||
from orchestra.utils.sys import sshrun
|
from orchestra.utils.sys import sshrun
|
||||||
from orchestra.utils.python import CaptureStdout, import_class
|
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())
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
key = settings.ORCHESTRATION_SSH_KEY_PATH
|
key = settings.ORCHESTRATION_SSH_KEY_PATH
|
||||||
try:
|
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:
|
except socket.error as e:
|
||||||
logger.error('%s timed out on %s' % (backend, addr))
|
logger.error('%s timed out on %s' % (backend, addr))
|
||||||
log.state = log.TIMEOUT
|
log.state = log.TIMEOUT
|
||||||
|
|
|
@ -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',
|
ORCHESTRA_DEFAULT_SUPPORT_FROM_EMAIL = Setting('ORCHESTRA_DEFAULT_SUPPORT_FROM_EMAIL',
|
||||||
'support@{}'.format(ORCHESTRA_BASE_DOMAIN),
|
'support@{}'.format(ORCHESTRA_BASE_DOMAIN),
|
||||||
validators=[validate_email],
|
validators=[validate_email],
|
||||||
|
|
|
@ -175,8 +175,9 @@ def sshrun(addr, command, *args, executable='bash', persist=False, options=None,
|
||||||
base_options.update(options or {})
|
base_options.update(options or {})
|
||||||
options = ['%s=%s' % (k, v) for k, v in base_options.items()]
|
options = ['%s=%s' % (k, v) for k, v in base_options.items()]
|
||||||
options = ' -o '.join(options)
|
options = ' -o '.join(options)
|
||||||
cmd = 'ssh -o {options} -C root@{addr} {executable}'.format(
|
user = kwargs.get('user', settings.ORCHESTRA_SSH_DEFAULT_USER)
|
||||||
options=options, addr=addr, executable=executable)
|
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)
|
return run(cmd, *args, stdin=command.encode('utf8'), **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue