AzureTagImport.rb
# Processes TAGs 
# First checks whether category and tag exists, and if it doesn't, category/tag will be created.
# Also, CloudForms tag has limitations of;
#   - Length of 50 chars
#   - only takes lower characters
#   - only underscores allowed
# So tags will be changed to fit into above limitations
# All other chars are converted to an underscore.
#
# The return values will be processed "category" and "tag"
Processes TAGs
First checks whether category and tag exists, and if it doesn't, category/tag will be created.
Also, CloudForms tag has limitations of;
Length of 50 chars
only takes lower characters
only underscores allowed
So tags will be changed to fit into above limitations
All other chars are converted to an underscore.

The return values will be processed "category" and "tag"
Processes TAGs First checks whether category and tag exists and if it doesn ' t category / tag will be created . Also CloudForms tag has limitations of ; Length of 50 chars only takes lower characters only underscores allowed So tags will be changed to fit into above limitations All other chars are converted to an underscore . The return values will be processed " category " and " tag "
def process_tags(category, category_description, single_value, tag, tag_description)
  category_name = category.to_s.downcase.gsub(/\W/, '_')
	category_name = category_name.gsub(/_*_/, '_')
  tag_name = tag.to_s.downcase.gsub(/\W/, '_')
	tag_name = tag_name.gsub(/_*_/, '_')
  unless $evm.execute('category_exists?', category_name)
    log(:info, "Creating Category {#{category_name} => #{category_description}}")
    $evm.execute('category_create', :name => category_name, :single_value => single_value, :description => "#{category_description}")
  end
  unless $evm.execute('tag_exists?', category_name, tag_name)
		log(:info, "Check tag name length")
		tag_name_length = tag_name.length
		if tag_name_length > 47
			log(:info, "Tag : #{tag_name} is too long with #{tag_name_length} chars")
			tag_name = tag_name.slice(0..47)+"__"
			log(:info, "Tag was truncated to #{tag_name}")
		end
    log(:info, "Creating Tag {#{tag_name} => #{tag_description}} in Category #{category_name}")
    $evm.execute('tag_create', category_name, :name => tag_name, :description => "#{tag_description}")
  end
  return category_name, tag_name
end
def process_tags ( category , category_description , single_value , tag , tag_description ) category_name = category . to_s . downcase . gsub ( / \W / , '_' ) category_name = category_name . gsub ( / _*_ / , '_' ) tag_name = tag . to_s . downcase . gsub ( / \W / , '_' ) tag_name = tag_name . gsub ( / _*_ / , '_' ) unless $evm . execute ( 'category_exists?' , category_name ) log ( :info , "Creating Category {#{category_name} => #{category_description}}" ) $evm . execute ( 'category_create' , :name => category_name , :single_value => single_value , :description => "#{category_description}" ) end unless $evm . execute ( 'tag_exists?' , category_name , tag_name ) log ( :info , "Check tag name length" ) tag_name_length = tag_name . length if tag_name_length > 47 log ( :info , "Tag : #{tag_name} is too long with #{tag_name_length} chars" ) tag_name = tag_name . slice ( 0 .. 47 ) + "__" log ( :info , "Tag was truncated to #{tag_name}" ) end log ( :info , "Creating Tag {#{tag_name} => #{tag_description}} in Category #{category_name}" ) $evm . execute ( 'tag_create' , category_name , :name => tag_name , :description => "#{tag_description}" ) end return category_name , tag_name end
Processes TAGs
First checks whether category and tag exists, and if it doesn't, category/tag will be created.
Processes TAGs First checks whether category and tag exists and if it doesn ' t category / tag will be created .
# Convert to lower case and replace all non-word characters with underscores # Then, changes multiple lines underscores to single underscore.
category
<not_specific>
category_description
<not_specific>
single_value
<not_specific>
tag
<not_specific>
tag_description
<not_specific>