Class: Octo::OctoMachineList

Inherits:
Chef::Knife
  • Object
show all
Defined in:
lib/chef/knife/octo.rb

Instance Method Summary collapse

Instance Method Details

#runObject



886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
# File 'lib/chef/knife/octo.rb', line 886

def run
  if Chef::Config[:knife][:octo_instance].nil?
    ui.error("Please specify your Octopus Deploy instance in your knife config as -\nknife[:octo_instance] = 'MYOCTO.MYDOMAIN'")
    exit
  end
  if Chef::Config[:knife][:octo_apikey].nil?
    ui.error("Please specify your Octopus API key in your knife config as -\nknife[:octo_apikey]  = 'MYKEY'\nSee Also : https://octopus.com/docs/api-and-integration/api/how-to-create-an-api-key")
    exit
  end
  unless name_args.size == 0
    ui.error('This command does not take any arguments')
    return
  end
  octo_methods = OctoHelperMethods.new(Chef::Config[:knife][:octo_apikey],Chef::Config[:knife][:octo_instance])
  request = octo_methods.generic_call('GET', 'machines/all', false)
  if request['response'] == 'ok'
    if config[:long]
      print octo_methods.parse_machine_list(request['message'],true)
      print "\n"
    else
      print octo_methods.parse_machine_list(request['message'],false)
      print "\n"
    end
  else
    ui.error(response['message'])
    print "\n"
  end
end