Sha256: c550597e82a8ec0fe975c37b2b70cf02e29dd66d72f8638998fca215e541e1b1

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

module VagrantPlugins
  module ArubaCloud
    module Action
      class ListTemplates
        def initialize(app, env)
          @app = app
        end

        def call(env)
          config = env[:machine].provider_config
          arubacloud_dc = config.endpoint
          compute_service = env[:arubacloud_compute]
          env[:ui].info ('%-5s %-40s %-60s %-20s %s' % ['DC', 'Template Name', 'Description', 'ID', 'Hypervisor ID'])
          compute_service.templates.sort_by(&:hypervisor).each do |template|
          env[:ui].info ('%-5s %-40s %-60s %-20s %s' % [arubacloud_dc, template.name,
                                                     template.description,
                                                     template.id,
                                                     enum_hypervisor_id(template.hypervisor)])
          end
          @app.call(env)
        end

        def enum_hypervisor_id(id)
          case id
            when 1 then return 'Pro Hyper-V'
            when 2 then return 'Pro VmWare'
            when 3 then return 'Pro Hyper-V LowCost'
            when 4 then return 'Pro Smart'
            else
              return 'Not Found'
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-arubacloud-0.0.7 lib/vagrant-arubacloud/action/list_templates.rb
vagrant-arubacloud-0.0.6 lib/vagrant-arubacloud/action/list_templates.rb
vagrant-arubacloud-0.0.5 lib/vagrant-arubacloud/action/list_templates.rb