re-arrange REMOTE_COPY/EXEC for Shell use

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
Nico Schottelius 2013-08-07 17:52:34 +02:00
parent 2403fc59ee
commit c793825edb
3 changed files with 31 additions and 6 deletions

View File

@ -40,8 +40,11 @@ BANNER = """
"8888P' `"888*"" R888" ` ^"F 'Y"
"P' "" ""
"""
DOT_CDIST = ".cdist"
REMOTE_COPY = "scp -o User=root -q"
REMOTE_EXEC = "ssh -o User=root -q"
class Error(Exception):
"""Base exception class for this project"""

View File

@ -20,9 +20,13 @@
#
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__)
@ -32,9 +36,25 @@ class Shell(object):
pass
@classmethod
def commandline(cls):
def commandline(cls, args):
pass
# 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
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)

View File

@ -75,11 +75,11 @@ def commandline():
parser['configinstall'].add_argument('--remote-copy',
help='Command to use for remote copy (should behave like scp)',
action='store', dest='remote_copy',
default="scp -o User=root -q")
default=cdist.REMOTE_COPY)
parser['configinstall'].add_argument('--remote-exec',
help='Command to use for remote execution (should behave like ssh)',
action='store', dest='remote_exec',
default="ssh -o User=root -q")
default=cdist.REMOTE_EXEC)
# Config
parser['config'] = parser['sub'].add_parser('config',
@ -89,6 +89,8 @@ def commandline():
# Shell
parser['shell'] = parser['sub'].add_parser('shell',
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)