Commit 788063f7 authored by Christian Jung's avatar Christian Jung

splitting methods

parent 3ffe500e
Pipeline #57270958 passed with stage
in 4 seconds
begin
clusters = {}
# get currently selected tags
current_tag = $evm.root["dialog_security_zone"]
if current_tag == [] then
clusters['!'] = '-- select tag first --'
else
$evm.log("info", "Current Tag is: #{current_tag}")
tag_name = current_tag[0].name
$evm.vmdb(:ems_cluster).all.each do |cluster|
tags = cluster.tags
$evm.log("info", "Current cluster #{cluster.name} tags: #{tags}")
$evm.log("info", "Checking if current tag matches department/#{tag_name}")
cluster.tags.each do |tag|
if tag == "department/#{tag_name}" then
$evm.log("info", "Tag matches")
clusters[cluster.name] = "#{cluster.name}"
end
else
$evm.log("info", "Tag does not match")
end
end
end
end
if clusters == {} then
clusters['!'] = '-- select tag first --'
end
list_values = {
'sort_by' => :value,
'data_type' => :string,
'required' => true,
'values' => clusters
}
list_values.each { |key, value| $evm.object[key] = value }
rescue => err
$evm.log(:error, "[#{err}]\n#{err.backtrace.join("\n")}")
exit MIQ_STOP
end
---
object_type: method
version: 1.0
object:
attributes:
name: list_clusters
display_name:
description:
scope: instance
language: ruby
location: inline
options: {}
inputs: []
---
object_type: instance
version: 1.0
object:
attributes:
display_name:
name: list_clusters
inherits:
description:
fields:
- execute:
value: list_clusters
# README
This code was used to retrieve the list of VLANs for a selected cluster. The Clusters are configured with different security tags and only clusters with a matching tag should be shown in the resulting list.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment