Sha256: d88945e80053a269632289f497a9d9f7a019422e79c267c8c2ed6a1f46a60c25

Contents?: true

Size: 994 Bytes

Versions: 2

Compression:

Stored size: 994 Bytes

Contents

module Rundock
  module Builder
    class TargetBuilder < Base
      DEFAULT_TARGET_TYPE = 'host'

      def build(target_name, target_info)
        target_type = DEFAULT_TARGET_TYPE

        if target_info.nil? ||
           !target_info.key?(target_name.to_sym)
          target_info = { target_name.to_sym => {} }
          target_type = DEFAULT_TARGET_TYPE
        else
          target_type = if target_info[target_name.to_sym].key?(:target_type)
                          target_info[target_name.to_sym][:target_type]
                        else
                          DEFAULT_TARGET_TYPE
                        end
        end

        begin
          target = Rundock::TargetFactory.instance(target_type).create(target_name, target_info[target_name.to_sym])
        rescue Rundock::TargetFactory::TargetNotSupportedError
          Logger.error("target type not supported: #{target_type}")
        end

        target.create_nodes(target_info, @options)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rundock-1.2.1 lib/rundock/builder/target_builder.rb
rundock-1.2.0 lib/rundock/builder/target_builder.rb