def test_compress(self):
     result = hostlists.compress(['foo1', 'foo3', 'foo4'])
     expected_result = ['foo1', 'foo[3-4]']
     self.assertListEqual(result, expected_result)
Beispiel #2
0
  if options.match:
    callback.append(callback_filter_match)
  if options.output_base64:
    callback.append(callback_filter_base64)
  if options.output_json:
    callback.append(callback_filter_json)
  if options.callback_script:
    callback.append(callback_exec_command)
  else:
    callback.append(callback_output_prefix_host)
  if options.show_status:
    callback.append(callback_status_count)

  # Get the password if the options passed indicate it might be needed
  if options.sudo:
    # Prompt for password
    options.password=getpass.getpass('Enter sudo password for user '+getpass.getuser()+': ')
  elif options.password:
    # Prompt for password
    options.password=getpass.getpass('Enter password for user '+getpass.getuser()+': ')


  command=' '.join(args[1:])
  range=args[0]

  results=run(args[0],command,username=options.username,password=options.password,sudo=options.sudo,timeout=options.timeout,script=options.runscript,jobs=options.jobs,sort=options.sort,shuffle=options.shuffle,output_callback=callback,parms=vars(options))

  # Print the failure summary if it was requested and there are failures
  if options.summarize_failed and 'failures' in results.parm.keys() and len(results.parm['failures']):
    print 'SSH Failed to: %s' % hostlists.compress(results.parm['failures'])
Beispiel #3
0
 def test_compress(self):
     result = hostlists.compress(['foo1', 'foo3', 'foo4'])
     expected_result = ['foo1', 'foo[3-4]']
     self.assertListEqual(result, expected_result)