예제 #1
0
# getting parameters
parser = argparse.ArgumentParser(description='Run command on stack')
parser.add_argument('-mc','--machine-cluster', help='Cluster to run the command on', required=False)
parser.add_argument('-c','--command', help='Command to run on cluster', required=False)
parser.add_argument("-f","--filter", action='append',dest='filter', help='Filter a single m/c in the Cluster Ex: nickname REDIS_CHAT')
args = vars(parser.parse_args())

# print args
# Getting filters
args['filter'] = args['filter'][0].split(',') if args['filter'] else None
init(autoreset=True)
sys.path.append('../python')
try:
    from helpers.common_config_reader import ConfigReader
except Exception, e:
    ConfigReader.load_from_file('../app/config/common_config.json')

def shellquote(s):
    return "'" + s.replace("'", "'\\''") + "'"

def convert_to_boolean(parameter):
    if parameter in ["true", "True","false", "False"]:
        return True if parameter in ["true", "True"] else  False
    else:
        return parameter

cluster = raw_input(Fore.CYAN + "Enter cluster name [all] : ") or "all" if not args["machine_cluster"] else args["machine_cluster"]
command = raw_input(Fore.CYAN + "Enter command name to execute [login] : ") or False if not args["command"] else args["command"]

if command and command != "login":
    command = "hostname; " + command