<commit_before>#
# Description: This method is used to Customize the Openstack Provisioning Request
#

require 'socket'

# Get provisioning object
prov = $evm.root["miq_provision"]

#$evm.root.attributes.sort.each { |k, v| $evm.log("info", "Root:<$evm.root> Attribute - #{k}: #{v}")}
#prov.attributes.sort.each { |k, v| $evm.log("info", "Root:<$evm.root> Attribute - #{k}: #{v}")}

source_ems_id=prov.get_option(:src_ems_id)
$evm.log("info", "EVM Source ID: #{source_ems_id}")

ems=$evm.vmdb("ext_management_system").find_by_id(source_ems_id)

size=prov.get_option(:flavor)

size="#{size}".downcase.gsub('_','.')

$evm.log("info", "flavors: #{ems.flavors.inspect}")

id=0
name=""

ems.flavors.each do |flavor|
  name=flavor["name"]
  $evm.log("info", "Comparing #{name} with #{size}")
  if name == "#{size}" then
    id=flavor["id"]
    break
  end
end

$evm.log("info", "Setting flavor ID: #{id} and name: #{name}")

hostname = Socket.gethostname
domainname=hostname.split('.')[1,hostname.length].join('.')
$evm.log("info", "Storing Domain Name #{domainname} for use in cloud-init")  
prov.set_option(:domainname,domainname)<commit_msg>tag VM as managed or unmanaged depending on service request<commit_after>#
# Description: This method is used to Customize the Openstack Provisioning Request
#

require 'socket'

# Get provisioning object
prov = $evm.root["miq_provision"]

$evm.root.attributes.sort.each { |k, v| $evm.log("info", "Root:<$evm.root> Attribute - #{k}: #{v}")}
prov.attributes.sort.each { |k, v| $evm.log("info", "Root:<$evm.root> Attribute - #{k}: #{v}")}

source_ems_id=prov.get_option(:src_ems_id)
$evm.log("info", "EVM Source ID: #{source_ems_id}")

ems=$evm.vmdb("ext_management_system").find_by_id(source_ems_id)

size=prov.get_option(:flavor)

size="#{size}".downcase.gsub('_','.')

$evm.log("info", "flavors: #{ems.flavors.inspect}")

id=0
name=""

ems.flavors.each do |flavor|
  name=flavor["name"]
  $evm.log("info", "Comparing #{name} with #{size}")
  if name == "#{size}" then
    id=flavor["id"]
    break
  end
end

$evm.log("info", "Setting flavor ID: #{id} and name: #{name}")

hostname = Socket.gethostname
domainname=hostname.split('.')[1,hostname.length].join('.')
$evm.log("info", "Storing Domain Name #{domainname} for use in cloud-init")  
prov.set_option(:domainname,domainname)

@servicename=prov.get_option(:name)
$evm.log("info","Looking for Unmanaged as part of the service name: #{@servicename}")
if "#{@servicename}".match("UnManaged")
  $evm.log("info","Setting management_status tag to unmanaged")
  prov.add_tag("management_status","unmanaged")
else
  $evm.log("info","Setting management_status tag to managed")
  prov.add_tag("management_status","managed")
end
{'fraction_non_alphanumeric': 0.1996309963099631, 'fraction_numerical': 0.0014760147601476014, 'mean_word_length': 6.115485564304462, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '686477', 'n_tokens_mistral': 1022, 'n_tokens_neox': 1040, 'n_words': 209}