Skip to content

Instantly share code, notes, and snippets.

@Cameronwyatt
Created December 11, 2016 18:06
Show Gist options
  • Save Cameronwyatt/16a92c9d3ecbdb92a46697403dc6f866 to your computer and use it in GitHub Desktop.
Save Cameronwyatt/16a92c9d3ecbdb92a46697403dc6f866 to your computer and use it in GitHub Desktop.
CloudForms Automate - check DNS for VM's FQDN name before giving it out to VM being provisioned.
vm_fqdn = "#{vm_name}#{hostname_suffix}"
begin
Resolv::DNS.new.getaddress(vm_fqdn)
rescue Resolv::ResolvError
#If we get a ResolvError, that means that the VM FQDN cannot be found
#That indicates that the VM name that we have calculated does not exist in DNS already
#return VM name here
rescue => err
$evm.log(:warn, "Error querying DNS for VM name:|#{err}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment