Created
March 17, 2015 23:04
-
-
Save ewannema/70e7be17c17678b69d48 to your computer and use it in GitHub Desktop.
default vmname naming hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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