Skip to content

Instantly share code, notes, and snippets.

@skout23
Created September 2, 2014 21:13
Show Gist options
  • Save skout23/5b5505023c69787a8c76 to your computer and use it in GitHub Desktop.
Save skout23/5b5505023c69787a8c76 to your computer and use it in GitHub Desktop.
silly wrapper for azure vm list to a hash.
~$ azure vm list
info: Executing command vm list
data: DNS Name VM Name Status
data: -------------------------------- ----------- ---------
data: my-vm-name.cloudapp-preview.net my-vm0 ReadyRole
data: my-vm-name.cloudapp-preview.net my-vm1 ReadyRole
data: my-vm-name.cloudapp-preview.net my-vm2 ReadyRole
data: my-vm-name.cloudapp-preview.net my-vm3 NotReady
data: my-vm-name.cloudapp-preview.net my-vm4 ReadyRole
data: my-vm-name.cloudapp-preview.net my-vm5 ReadyRole
#!/usr/bin/env ruby
def get_vm_list()
vms = []
dork = %x[azure vm list| grep ReadyRole]
dork.eachline do |line|
vms = {:vm_name => line.split[2], :vm_state => line.split[3]}
end
return vms
end
vms.each do |vm|
puts vm.vm_name
puts vm.vm_state
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment