Hey everyone,
So i’ve been struggeling the whole day with a very weird issue.
I made a simple script that asks a external CMDB which vlan’s a certain customer has.
The intention of this script is to list all the vLAN’s of a specific customer. So he can choose in which vlan he want to provision his vm.
This is the script (the customer_id is a constant atm to make everything simple):
require 'httparty'
$i = 0
vlan = Array.new
auth = {:username => $evm.object['user'], :password => $evm.object.decrypt('password')}
$evm.log(:info, "Device42 Entering getSubnets")
subnets = Array.new
response = HTTParty.get("#{$evm.object['url']}subnets/?mask_bits_gt=24&customer_id=3",
{
:headers => {'Content-Type' => 'application/x-www-form-urlencoded'},
:basic_auth => auth,
:verify => false,
})
response.parsed_response["subnets"].each do |a|
subnets.push(a["subnet_id"])
end
$evm.log(:info, "Device42 subnets are #{subnets}")
subnets.each do |subnet|
response = HTTParty.get("#{$evm.object['url']}subnets/?mask_bits_gt=24&customer_id=3&subnet_id=#{subnet}",
{
:headers => {'Content-Type' => 'application/x-www-form-urlencoded'},
:basic_auth => auth,
:verify => false,
})
unless response.parsed_response["subnets"].nil?
vlan[$i] = response.parsed_response["subnets"][0]["parent_vlan_name"]
$i = $i + 1
end
end
$evm.log(:info, "Device42 vlans are #{vlan}")
dialog_field = $evm.object
dialog_field["sort_by"] = "value"
dialog_field["sort_order"] = "ascending"
dialog_field["data_type"] = "string"
dialog_field["required"] = "true"
dialog_field["values"] = vlan
This is what i can see in the logs, everything seems normal
And i can also see that the values get inserted into dialog_field[“values”]
Now here comes the weird thing, the service dialog looks like this:
So instead of the names of my vLAN’s it just says “L” for every vlan the customer has.
Does anyone know why this is happening?
Thanks in advance.