Exemplo n.º 1
0
def setAllEnvironments(clients, password):

  print(f'Calling \'environment.py\' for all clients ({clients.hosts})... ', flush=True)
  RemoteCommand(clients, f'echo {password} | sudo -S -- sh -c ". {VENV_PATH} && {ENV_EXEC_PATH}"', 10, False).remoteCommandHandler()
  print('OK!', flush=True)

#=============================
#	Main code
#=============================
if __name__ == '__main__':
  user, password = helper.recoverCredentials()
  
  hosts = helper.recoverHosts(PROGRAM_PATH +"/../../data/environment.json", FileType.JSON)
  
  # Definind Connection with Virtual Machines
  clients = helper.defineConnection(user, password, hosts)
  
  # Setting client's shell as non-interactive.
  helper.settingNonItectivity(clients, password)

  # Run script 'environment.py' for all 'clients'
  setAllEnvironments(clients, password)
  
  # Creating Temporary folder.
  helper.createFolder(f'{PROGRAM_PATH}/keys')
  
  # Sending keys and authorized_keys to the clients
  helper.sendFiles(clients, f'{PROGRAM_PATH}/keys/', "./.ssh")
  
  # Changing permission of keys and authorized_keys in clients.
  helper.changeKeyPermissions(clients)
Exemplo n.º 2
0
def crossConnectAll(user, password, vm_file_path):

  vm_hosts = helper.recoverHosts(f'{vm_file_path}', FileType.TEXT)
  vm_clients = helper.defineConnection(user, password, vm_hosts)
  
  helper.crossConnect(vm_hosts, vm_clients)