re-arrange REMOTE_COPY/EXEC for Shell use
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
2403fc59ee
commit
c793825edb
3 changed files with 31 additions and 6 deletions
|
@ -40,8 +40,11 @@ BANNER = """
|
||||||
"8888P' `"888*"" R888" ` ^"F 'Y"
|
"8888P' `"888*"" R888" ` ^"F 'Y"
|
||||||
"P' "" ""
|
"P' "" ""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DOT_CDIST = ".cdist"
|
DOT_CDIST = ".cdist"
|
||||||
|
|
||||||
|
REMOTE_COPY = "scp -o User=root -q"
|
||||||
|
REMOTE_EXEC = "ssh -o User=root -q"
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
"""Base exception class for this project"""
|
"""Base exception class for this project"""
|
||||||
|
|
|
@ -20,9 +20,13 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import cdist
|
# FIXME: only considering config here - enable
|
||||||
|
# command line switch for using install object
|
||||||
|
# when it is available
|
||||||
|
import cdist.config
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -32,9 +36,25 @@ class Shell(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def commandline(cls):
|
def commandline(cls, args):
|
||||||
pass
|
pass
|
||||||
# initialise cdist
|
# initialise cdist
|
||||||
|
import cdist.context
|
||||||
|
|
||||||
|
context = cdist.context.Context(
|
||||||
|
target_host="cdist-shell-no-target-host",
|
||||||
|
remote_copy=cdist.REMOTE_COPY,
|
||||||
|
remote_exec=cdist.REMOTE_EXEC)
|
||||||
|
|
||||||
|
config = cdist.config.Config(context)
|
||||||
|
|
||||||
# Startup Shell
|
# Startup Shell
|
||||||
|
if args.shell:
|
||||||
|
shell = [args.shell]
|
||||||
|
elif 'SHELL' in os.environ:
|
||||||
|
shell = [os.environ['SHELL']]
|
||||||
|
else:
|
||||||
|
shell = ["/bin/sh"]
|
||||||
|
|
||||||
|
log.info("Starting shell...")
|
||||||
|
subprocess.call(shell)
|
||||||
|
|
|
@ -75,11 +75,11 @@ def commandline():
|
||||||
parser['configinstall'].add_argument('--remote-copy',
|
parser['configinstall'].add_argument('--remote-copy',
|
||||||
help='Command to use for remote copy (should behave like scp)',
|
help='Command to use for remote copy (should behave like scp)',
|
||||||
action='store', dest='remote_copy',
|
action='store', dest='remote_copy',
|
||||||
default="scp -o User=root -q")
|
default=cdist.REMOTE_COPY)
|
||||||
parser['configinstall'].add_argument('--remote-exec',
|
parser['configinstall'].add_argument('--remote-exec',
|
||||||
help='Command to use for remote execution (should behave like ssh)',
|
help='Command to use for remote execution (should behave like ssh)',
|
||||||
action='store', dest='remote_exec',
|
action='store', dest='remote_exec',
|
||||||
default="ssh -o User=root -q")
|
default=cdist.REMOTE_EXEC)
|
||||||
|
|
||||||
# Config
|
# Config
|
||||||
parser['config'] = parser['sub'].add_parser('config',
|
parser['config'] = parser['sub'].add_parser('config',
|
||||||
|
@ -89,6 +89,8 @@ def commandline():
|
||||||
# Shell
|
# Shell
|
||||||
parser['shell'] = parser['sub'].add_parser('shell',
|
parser['shell'] = parser['sub'].add_parser('shell',
|
||||||
parents=[parser['loglevel']])
|
parents=[parser['loglevel']])
|
||||||
|
parser['shell'].add_argument('-s', '--shell',
|
||||||
|
help='Select shell to use, defaults to current shell')
|
||||||
parser['shell'].set_defaults(func=cdist.shell.Shell.commandline)
|
parser['shell'].set_defaults(func=cdist.shell.Shell.commandline)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue