Class: VagrantPlugins::ArubaCloud::Action::ListTemplates
- Inherits:
-
Object
- Object
- VagrantPlugins::ArubaCloud::Action::ListTemplates
- Defined in:
- lib/vagrant-arubacloud/action/list_templates.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #enum_hypervisor_id(id) ⇒ Object
-
#initialize(app, env) ⇒ ListTemplates
constructor
A new instance of ListTemplates.
Constructor Details
#initialize(app, env) ⇒ ListTemplates
Returns a new instance of ListTemplates.
5 6 7 |
# File 'lib/vagrant-arubacloud/action/list_templates.rb', line 5 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/vagrant-arubacloud/action/list_templates.rb', line 9 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 |
#enum_hypervisor_id(id) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-arubacloud/action/list_templates.rb', line 23 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 |