Class: Vcloud::CLI::Utils::GetEntity

Inherits:
Object
  • Object
show all
Includes:
Methadone::CLILogging, Methadone::Main
Defined in:
lib/vcloud/cli/utils/get_entity.rb

Class Method Summary collapse

Class Method Details

.runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vcloud/cli/utils/get_entity.rb', line 13

def self.run

  main do |entity_type, identifier|
    vcloud = ::Fog::Compute::VcloudDirector.new
    case entity_type
    when 'vm'
      pp vcloud.get_vapp(identifier).body
    when 'vApp'
      pp vcloud.get_vapp(identifier).body
    when 'edgeGateway'
      pp vcloud.get_edge_gateway(identifier).body
    when 'orgVdcNetwork'
      pp vcloud.get_network_complete(identifier).body
    when 'orgVdc'
      pp vcloud.get_vdc(identifier).body
    when /^get_/
      pp vcloud.send(entity_type.to_s, identifier).body
    else
      help_now!("Invalid argument #{entity_type}")
    end
  end

  arg :entity_type
  arg :identifier

  description "
vcloud-get-entity retreives the raw Fog body for key entity types in vCD.

It can also call any Fog request method beginning with 'get_', that takes a single
argument -- generally the id of the entity. There are many of these.

Supported entities can usually be retreived by name as well:

   * vm
   * vApp
   * edgeGateway
   * orgVdcNetwork
   * orgVdc

"

  go!

end