Skip to content

Instantly share code, notes, and snippets.

@ewannema
Created March 17, 2015 23:04
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 ewannema/70e7be17c17678b69d48 to your computer and use it in GitHub Desktop.
Save ewannema/70e7be17c17678b69d48 to your computer and use it in GitHub Desktop.
default vmname naming hack
prov = $evm.root["miq_provision"]
vm_target_name = prov.get_option(:vm_target_name).to_s.strip
if vm_target_name.blank? || vm_target_name =~ /^default\d*/
# We need the function for our naming method to work. If is is not present we will set a default
# because services and CatalogItemInitialization runs after the naming methods are called the
# first time.
function = tags[:function]
if function.nil?
$evm.log(:info, "The naming method could not name the VM appropriately. Setting a default.")
derived_name = "default$n{4}"
else
vm_name = "it-dev-#{function}".upcase
derived_name = "#{vm_name}$n{2}"
end
$evm.object['vmname'] = derived_name
else
$evm.object['vmname'] = vm_target_name
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment