Implement sending commands to all severs
This commit is contained in:
parent
b53442c482
commit
81df9ef443
1 changed files with 17 additions and 6 deletions
|
@ -41,9 +41,9 @@ def list_servers(mode=int(1)):
|
|||
def create_server(isfirstrun=False):
|
||||
global servers
|
||||
if(isfirstrun):
|
||||
print('!! Looks like you do not have any servers yet - Let\'s add one.\n')
|
||||
print('\n!! Looks like you do not have any servers yet - Let\'s add one.\n')
|
||||
|
||||
print('=== Add Server ===')
|
||||
print('\n=== Add Server ===')
|
||||
srv_name = input('Name: ')
|
||||
srv_addr = input('Address: ')
|
||||
srv_port = input('Port: ')
|
||||
|
@ -62,7 +62,7 @@ def create_server(isfirstrun=False):
|
|||
|
||||
def pop_server():
|
||||
global servers
|
||||
print('=== Remove Server ===\nPick a server to delete')
|
||||
print('\n=== Remove Server ===\nPick a server to delete')
|
||||
list_servers(2)
|
||||
delete = int(input('?: '))
|
||||
|
||||
|
@ -74,13 +74,13 @@ def pop_server():
|
|||
|
||||
def send_commands():
|
||||
proceed=True
|
||||
print('=== Send commands ===')
|
||||
print('\n=== Send commands ===')
|
||||
choice = int(input('Single Server (1) or All (2)?: '))
|
||||
if(choice==1):
|
||||
list_servers(2)
|
||||
server = int(input('Server?: '))
|
||||
while(proceed):
|
||||
command = input('Input command: ')
|
||||
command = input('Input command (None to exit): ')
|
||||
if(command!=""):
|
||||
with Client(servers[server]['address'], int(servers[server]['port']), passwd=servers[server]['password']) as client:
|
||||
response = client.run(command)
|
||||
|
@ -91,7 +91,18 @@ def send_commands():
|
|||
print('No command was entered. Exiting.\n')
|
||||
initial_choice()
|
||||
elif(choice==2):
|
||||
print('Would do every server')
|
||||
while(proceed):
|
||||
command = input('Input command (None to exit): ')
|
||||
for x in servers:
|
||||
if(command!=""):
|
||||
with Client(x['address'], int(x['port']), passwd=x['password']) as client:
|
||||
response = client.run(command)
|
||||
|
||||
print(x['name']+': '+response)
|
||||
else:
|
||||
proceed = False
|
||||
print('No command was entered. Exiting.\n')
|
||||
initial_choice()
|
||||
|
||||
def initial_choice():
|
||||
choose_func = input('=== Choose Function ===\n1. Add servers\n2. Remove servers\n3. List servers\n4. Send commands\n5. Exit\n?: ')
|
||||
|
|
Loading…
Reference in a new issue