Skip to content

Instantly share code, notes, and snippets.

@skout23 skout23/get_vm_list
Created Sep 2, 2014

Embed
What would you like to do?
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
You can’t perform that action at this time.