Skip to content

Instantly share code, notes, and snippets.

@misterdorm
Created January 14, 2016 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterdorm/c77ee64c9435e232053c to your computer and use it in GitHub Desktop.
Save misterdorm/c77ee64c9435e232053c to your computer and use it in GitHub Desktop.
def self.nova_get_host_by_name_and_type(host_name, service_type)
#find the host by name and service type
nova_hosts.each do |entry|
# (mdorman) Support api!cell_name@host_name -style output of nova host-list under nova cells
if entry["host_name"] =~ /^([a-zA-Z0-1\-_]+![a-zA-Z0-1\-_]+@)?#{Regexp.quote(host_name)}$/
if entry["service"] == service_type
return host_name
end
end
end
#name/service combo not found
return nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment