Class: VCloudSdk::Xml::Vdc

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb

Instance Method Summary collapse

Methods inherited from Wrapper

#==, #[], #[]=, #add_child, #attribute, #content, #content=, #create_child, #create_qualified_name, #create_xpath_query, #doc_namespaces, #edit_link, #get_nodes, #href, #href=, #href_id, #initialize, #name, #name=, #power_off_link, #power_on_link, #remove_link, #running_tasks, #to_s, #type, #type=, #undeploy_link, #urn, #xpath

Constructor Details

This class inherits a constructor from VCloudSdk::Xml::Wrapper

Instance Method Details



4
5
6
7
8
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 4

def add_disk_link
  get_nodes(XML_TYPE[:LINK],
            type: MEDIA_TYPE[:DISK_CREATE_PARAMS])
            .first
end

#available_cpu_coresObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 76

def available_cpu_cores
  cpu_resource = get_nodes("ComputeCapacity")
                   .first.get_nodes("Cpu").first
  available_cpu_clock_speed = get_available_resource(cpu_resource)

  # clock units can only be MHz or GHz
  units = cpu_resource.get_nodes("Units").first.content
  if units == "MHz"
    available_cpu_clock_speed = available_cpu_clock_speed / 1000
  end

  # We assume 1 GHz is converted to 1 vCpu core
  available_cpu_clock_speed
end

#available_memory_mbObject



91
92
93
94
95
96
97
98
99
100
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 91

def available_memory_mb
  memory_resource = get_nodes("ComputeCapacity")
                      .first.get_nodes("Memory").first
  available_memory = get_available_resource(memory_resource)

  # clock units can only be MB or GB
  units = memory_resource.get_nodes("Units").first.content
  available_memory = available_memory * 1024 if units == "GB"
  available_memory
end

#available_network(name) ⇒ Object



60
61
62
63
64
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 60

def available_network(name)
  get_nodes("Network",
            type: MEDIA_TYPE[:NETWORK], name: name)
            .first
end

#available_networksObject



55
56
57
58
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 55

def available_networks
  get_nodes("Network",
            type: MEDIA_TYPE[:NETWORK])
end

#disks(name = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 10

def disks(name = nil)
  if name.nil?
    get_nodes("ResourceEntity",
              type: MEDIA_TYPE[:DISK])
  else
    get_nodes("ResourceEntity",
              type: MEDIA_TYPE[:DISK], name: name)
              .first
  end
end


43
44
45
46
47
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 43

def edge_gateways_link
  get_nodes(XML_TYPE[:LINK],
            rel: "edgeGateways")
            .first
end

#get_vapp_templates(name) ⇒ Object

vApp Template names are not unique so multiple ones can be returned.



50
51
52
53
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 50

def get_vapp_templates(name)
  get_nodes("ResourceEntity",
            type: MEDIA_TYPE[:VAPP_TEMPLATE], name: name)
end


21
22
23
24
25
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 21

def instantiate_vapp_template_link
  get_nodes(XML_TYPE[:LINK],
            type: MEDIA_TYPE[:INSTANTIATE_VAPP_TEMPLATE_PARAMS])
            .first
end

#storage_profile(name) ⇒ Object



70
71
72
73
74
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 70

def storage_profile(name)
  get_nodes(:VdcStorageProfile,
            type: MEDIA_TYPE[:VDC_STORAGE_PROFILE], name: name)
            .first
end

#storage_profilesObject



66
67
68
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 66

def storage_profiles
  get_nodes(:VdcStorageProfile, type: MEDIA_TYPE[:VDC_STORAGE_PROFILE])
end


27
28
29
30
31
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 27

def upload_link
  get_nodes(XML_TYPE[:LINK],
            type: MEDIA_TYPE[:UPLOAD_VAPP_TEMPLATE_PARAMS])
            .first
end


33
34
35
36
37
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 33

def upload_media_link
  get_nodes(XML_TYPE[:LINK],
            type: MEDIA_TYPE[:MEDIA])
            .first
end

#vappsObject



39
40
41
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb', line 39

def vapps
  get_nodes(:ResourceEntity, type: MEDIA_TYPE[:VAPP])
end