Skip to content

Commit

Permalink
support label tag mapping for Azure
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Zagaynov committed Apr 20, 2018
1 parent 1987641 commit 3a1d2a0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/controllers/ops_controller/settings/label_tag_mapping.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module OpsController::Settings::LabelTagMapping
extend ActiveSupport::Concern

Expand All @@ -13,6 +15,7 @@ module OpsController::Settings::LabelTagMapping
MAPPABLE_ENTITIES = {
nil => nil, # map all entities
"Vm" => "Amazon",
"VmAzure" => "Azure",
"Image" => "Amazon",
"ContainerProject" => "Kubernetes",
"ContainerRoute" => "Kubernetes",
Expand Down Expand Up @@ -79,7 +82,7 @@ def entity_ui_name_or_all(entity)
if entity
provider = MAPPABLE_ENTITIES[entity]
model = case entity
when 'Vm'
when 'Vm', 'VmAzure'
"ManageIQ::Providers::#{provider}::CloudManager::Vm"
when 'Image'
"ManageIQ::Providers::#{provider}::CloudManager::Template"
Expand Down Expand Up @@ -172,8 +175,8 @@ def label_tag_mapping_add(entity, label_name, cat_description)
provider = ALL_PREFIX
entity_str = ''
else
provider = MAPPABLE_ENTITIES[entity].downcase
entity_str = entity.underscore
provider = MAPPABLE_ENTITIES[entity].downcase.inquiry
entity_str = (provider.azure? && entity.sub(/Azure$/, '') || entity).underscore
end

cat_name = "#{provider}:#{entity_str}:" + Classification.sanitize_name(label_name.tr("/", ":"))
Expand All @@ -192,8 +195,9 @@ def label_tag_mapping_add(entity, label_name, cat_description)
:description => cat_description,
:single_value => true,
:read_only => true)
ContainerLabelTagMapping.create!(:labeled_resource_type => entity, :label_name => label_name,
:tag => category.tag)
ContainerLabelTagMapping.create!(:labeled_resource_type => entity,
:label_name => label_name,
:tag => category.tag)
end
rescue StandardError => bang
add_flash(_("Error during 'add': %{message}") % {:message => bang.message}, :error)
Expand Down

0 comments on commit 3a1d2a0

Please sign in to comment.