|
@ -10,7 +10,7 @@ import module |
|
|
|
|
|
|
|
|
INPUT_FILE = "/home/jeff/scripts/servers.txt" |
|
|
INPUT_FILE = "/home/jeff/scripts/servers.txt" |
|
|
Computer = collections.namedtuple("Computer", ('host', 'menue_id')) |
|
|
Computer = collections.namedtuple("Computer", ('host', 'menue_id')) |
|
|
WELCOME_MESSAGE = "*************Jeff-Laptop***************" |
|
|
|
|
|
|
|
|
WELCOME_MESSAGE = "*************Jeff-Tower***************" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_welcome_message(): |
|
|
def print_welcome_message(): |
|
@ -46,23 +46,76 @@ def main(): |
|
|
cmp.append(Computer(line, count)) |
|
|
cmp.append(Computer(line, count)) |
|
|
count += 1 |
|
|
count += 1 |
|
|
|
|
|
|
|
|
print("* SSH manager V 0.1 *") |
|
|
|
|
|
|
|
|
print("* SSH manager V 0.2 *") |
|
|
for c in cmp: |
|
|
for c in cmp: |
|
|
print_menu_option(str(c.menue_id) + ") " + c.host) |
|
|
print_menu_option(str(c.menue_id) + ") " + c.host) |
|
|
|
|
|
|
|
|
|
|
|
print_menu_option("A/' ') Exit") |
|
|
|
|
|
print_menu_option("B/' ') Manager tools") |
|
|
|
|
|
|
|
|
print("*" * len(WELCOME_MESSAGE)) |
|
|
print("*" * len(WELCOME_MESSAGE)) |
|
|
i = input("Enter number of computer to connect to or enter to exit:") |
|
|
i = input("Enter number of computer to connect to or enter to exit:") |
|
|
|
|
|
|
|
|
if i == '': |
|
|
|
|
|
|
|
|
if i == '' or i == 'A' or i == 'a': |
|
|
subprocess.call(["clear"]) |
|
|
subprocess.call(["clear"]) |
|
|
|
|
|
elif i == 'b' or i == 'B': |
|
|
|
|
|
subMenu() |
|
|
else: |
|
|
else: |
|
|
for c in cmp: |
|
|
for c in cmp: |
|
|
if int(i) == c.menue_id: |
|
|
if int(i) == c.menue_id: |
|
|
subprocess.call(["ssh", c.host]) |
|
|
subprocess.call(["ssh", c.host]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def printSubMenu(): |
|
|
|
|
|
""" |
|
|
|
|
|
prints out a sub help menu for other options |
|
|
|
|
|
:return: None |
|
|
|
|
|
""" |
|
|
|
|
|
print("**************************************") |
|
|
|
|
|
print("* SSH manager V 0.2 Options *") |
|
|
|
|
|
print_menu_option("1) Add Host") |
|
|
|
|
|
print_menu_option("2) Copy SSH key to server") |
|
|
|
|
|
print_menu_option("3) Remove host name") |
|
|
|
|
|
print_menu_option("4) Return to ssh manager") |
|
|
|
|
|
print_menu_option("5) Exit") |
|
|
|
|
|
print("*" * len(WELCOME_MESSAGE)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def subMenu(): |
|
|
|
|
|
""" |
|
|
|
|
|
calls printSubMenu and then gets input from user to make appropriate function calls |
|
|
|
|
|
:return: None |
|
|
|
|
|
""" |
|
|
|
|
|
printSubMenu() |
|
|
|
|
|
input = input("Enter selection:") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def addHost(): |
|
|
|
|
|
""" |
|
|
|
|
|
appends an inputted host name to servers.txt |
|
|
|
|
|
:return: None |
|
|
|
|
|
""" |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def copySSHKey(): |
|
|
|
|
|
""" |
|
|
|
|
|
calls systems ssh-copy-id with host name |
|
|
|
|
|
:return: None |
|
|
|
|
|
""" |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def removeHost(): |
|
|
|
|
|
""" |
|
|
|
|
|
Removes a host name from servers.txt |
|
|
|
|
|
:return: None |
|
|
|
|
|
""" |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
""" |
|
|
Makes sure that other programs don't execute the main |
|
|
Makes sure that other programs don't execute the main |
|
|
""" |
|
|
""" |
|
|
if __name__ == '__main__': |
|
|
if __name__ == '__main__': |
|
|
main() |
|
|
|
|
|
|
|
|
main() |