Skip to content

Commit

Permalink
Merge pull request #3697 from AlexanderZagaynov/BZ-1493041
Browse files Browse the repository at this point in the history
Azure labeling and tagging support
  • Loading branch information
martinpovolny authored Apr 18, 2018
2 parents 8699e42 + d4f0437 commit 9945ede
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 9945ede

Please sign in to comment.