pep8 fixes for contrib (#24344)

This commit is contained in:
Matt Martz 2017-05-09 16:38:08 -05:00 committed by GitHub
commit d3249e7875
37 changed files with 326 additions and 380 deletions

View file

@ -35,7 +35,7 @@ except:
import simplejson as json
# Options
#------------------------------
# ------------------------------
parser = OptionParser(usage="%prog [options] --list | --host <machine>")
parser.add_option('--list', default=False, dest="list", action="store_true",
@ -48,6 +48,7 @@ parser.add_option('--host', default=None, dest="host",
# helper functions
#
def get_ssh_config():
configs = []
for box in list_running_boxes():
@ -55,7 +56,8 @@ def get_ssh_config():
configs.append(config)
return configs
#list all the running instances in the fleet
# list all the running instances in the fleet
def list_running_boxes():
boxes = []
for line in subprocess.check_output(["fleetctl", "list-machines"]).split('\n'):
@ -65,6 +67,7 @@ def list_running_boxes():
return boxes
def get_a_ssh_config(box_name):
config = {}
config['Host'] = box_name
@ -72,11 +75,12 @@ def get_a_ssh_config(box_name):
config['ansible_python_interpreter'] = '/opt/bin/python'
return config
# List out servers that vagrant has running
#------------------------------
# ------------------------------
if options.list:
ssh_config = get_ssh_config()
hosts = { 'coreos': []}
hosts = {'coreos': []}
for data in ssh_config:
hosts['coreos'].append(data['Host'])
@ -85,14 +89,14 @@ if options.list:
sys.exit(1)
# Get out the host details
#------------------------------
# ------------------------------
elif options.host:
result = {}
ssh_config = get_ssh_config()
details = filter(lambda x: (x['Host'] == options.host), ssh_config)
if len(details) > 0:
#pass through the port, in case it's non standard.
# pass through the port, in case it's non standard.
result = details[0]
result
@ -101,7 +105,7 @@ elif options.host:
# Print out help
#------------------------------
# ------------------------------
else:
parser.print_help()
sys.exit(1)