Class: Vcloud::Fog::ServiceInterface::FogFacade

Inherits:
Object
  • Object
show all
Defined in:
lib/vcloud/fog/service_interface.rb

Overview

FogFacade Inner class to represent a logic free facade over our interactions with Fog

Instance Method Summary collapse

Constructor Details

#initializeFogFacade

Returns a new instance of FogFacade.



18
19
20
# File 'lib/vcloud/fog/service_interface.rb', line 18

def initialize
  @vcloud = ::Fog::Compute::VcloudDirector.new
end

Instance Method Details

#delete_network(id) ⇒ Object



115
116
117
118
# File 'lib/vcloud/fog/service_interface.rb', line 115

def delete_network(id)
  task = @vcloud.delete_network(id).body
  @vcloud.process_task(task)
end

#delete_vapp(vapp_id) ⇒ Object



106
107
108
109
# File 'lib/vcloud/fog/service_interface.rb', line 106

def delete_vapp(vapp_id)
  task = @vcloud.delete_vapp(vapp_id).body
  @vcloud.process_task(task)
end

#end_pointObject



80
81
82
# File 'lib/vcloud/fog/service_interface.rb', line 80

def end_point
  @vcloud.end_point
end

#get_catalog(id) ⇒ Object



154
155
156
# File 'lib/vcloud/fog/service_interface.rb', line 154

def get_catalog(id)
  @vcloud.get_catalog(id).body
end

#get_catalog_item(id) ⇒ Object



38
39
40
# File 'lib/vcloud/fog/service_interface.rb', line 38

def get_catalog_item(id)
  @vcloud.get_catalog_item(id).body
end

#get_edge_gateway(id) ⇒ Object



165
166
167
# File 'lib/vcloud/fog/service_interface.rb', line 165

def get_edge_gateway(id)
  @vcloud.get_edge_gateway(id).body
end

#get_execute_query(type = nil, options = {}) ⇒ Object



89
90
91
# File 'lib/vcloud/fog/service_interface.rb', line 89

def get_execute_query(type=nil, options={})
  @vcloud.get_execute_query(type, options).body
end

#get_network_complete(id) ⇒ Object



111
112
113
# File 'lib/vcloud/fog/service_interface.rb', line 111

def get_network_complete(id)
  @vcloud.get_network_complete(id).body
end

#get_organization(name) ⇒ Object



26
27
28
# File 'lib/vcloud/fog/service_interface.rb', line 26

def get_organization (name)
  @vcloud.get_organization(name).body
end

#get_vapp(id) ⇒ Object



55
56
57
# File 'lib/vcloud/fog/service_interface.rb', line 55

def get_vapp(id)
  @vcloud.get_vapp(id).body
end

#get_vapp_metadata(id) ⇒ Object



93
94
95
# File 'lib/vcloud/fog/service_interface.rb', line 93

def (id)
  @vcloud.(id).body
end

#get_vapps_in_lease_from_query(options) ⇒ Object



34
35
36
# File 'lib/vcloud/fog/service_interface.rb', line 34

def get_vapps_in_lease_from_query(options)
  @vcloud.get_vapps_in_lease_from_query(options).body
end

#get_vdc(name) ⇒ Object



22
23
24
# File 'lib/vcloud/fog/service_interface.rb', line 22

def get_vdc(name)
  @vcloud.get_vdc(name).body
end

#org_nameObject



102
103
104
# File 'lib/vcloud/fog/service_interface.rb', line 102

def org_name
  @vcloud.org_name
end

#organizationsObject



98
99
100
# File 'lib/vcloud/fog/service_interface.rb', line 98

def organizations
  @vcloud.organizations
end

#post_configure_edge_gateway_services(edgegw_id, config) ⇒ Object



127
128
129
130
131
132
133
134
135
136
# File 'lib/vcloud/fog/service_interface.rb', line 127

def post_configure_edge_gateway_services(edgegw_id, config)
  Vcloud::Core.logger.info("Updating EdgeGateway #{edgegw_id}")
  begin
    task = @vcloud.post_configure_edge_gateway_services(edgegw_id, config).body
    @vcloud.process_task(task)
  rescue => ex
    Vcloud::Core.logger.error("Could not update EdgeGateway #{edgegw_id} : #{ex}")
    raise
  end
end

#post_create_org_vdc_network(vdc_id, name, options) ⇒ Object



120
121
122
123
124
125
# File 'lib/vcloud/fog/service_interface.rb', line 120

def post_create_org_vdc_network(vdc_id, name, options)
  Vcloud::Core.logger.debug("creating #{options[:fence_mode]} OrgVdcNetwork #{name} in vDC #{vdc_id}")
  attrs = @vcloud.post_create_org_vdc_network(vdc_id, name, options).body
  @vcloud.process_task(attrs[:Tasks][:Task])
  get_network_complete(extract_id(attrs))
end

#post_instantiate_vapp_template(vdc, template, name, params) ⇒ Object



42
43
44
45
46
47
# File 'lib/vcloud/fog/service_interface.rb', line 42

def post_instantiate_vapp_template(vdc, template, name, params)
  Vcloud::Core.logger.debug("instantiating #{name} vapp in #{vdc[:name]}")
  vapp = @vcloud.post_instantiate_vapp_template(extract_id(vdc), template, name, params).body
  @vcloud.process_task(vapp[:Tasks][:Task])
  @vcloud.get_vapp(extract_id(vapp)).body
end

#power_off_vapp(vapp_id) ⇒ Object



138
139
140
141
# File 'lib/vcloud/fog/service_interface.rb', line 138

def power_off_vapp(vapp_id)
  task = @vcloud.post_power_off_vapp(vapp_id).body
  @vcloud.process_task(task)
end

#power_on_vapp(vapp_id) ⇒ Object



143
144
145
146
147
# File 'lib/vcloud/fog/service_interface.rb', line 143

def power_on_vapp(vapp_id)
  Vcloud::Core.logger.debug("Powering on vApp #{vapp_id}")
  task = @vcloud.post_power_on_vapp(vapp_id).body
  @vcloud.process_task(task)
end

#put_cpu(vm_id, cpu) ⇒ Object



64
65
66
67
68
# File 'lib/vcloud/fog/service_interface.rb', line 64

def put_cpu(vm_id, cpu)
  Vcloud::Core.logger.debug("putting #{cpu} CPU(s) into VM #{vm_id}")
  task = @vcloud.put_cpu(vm_id, cpu).body
  @vcloud.process_task(task)
end

#put_guest_customization_section_vapp(vm_id, customization_req) ⇒ Object



84
85
86
87
# File 'lib/vcloud/fog/service_interface.rb', line 84

def put_guest_customization_section_vapp(vm_id, customization_req)
  task = @vcloud.put_guest_customization_section_vapp(vm_id, customization_req).body
  @vcloud.process_task(task)
end

#put_memory(vm_id, memory) ⇒ Object



49
50
51
52
53
# File 'lib/vcloud/fog/service_interface.rb', line 49

def put_memory(vm_id, memory)
  Vcloud::Core.logger.debug("putting #{memory}MB memory into VM #{vm_id}")
  task = @vcloud.put_memory(vm_id, memory).body
  @vcloud.process_task(task)
end

#put_network_connection_system_section_vapp(vm_id, section) ⇒ Object



59
60
61
62
# File 'lib/vcloud/fog/service_interface.rb', line 59

def put_network_connection_system_section_vapp(vm_id, section)
  task = @vcloud.put_network_connection_system_section_vapp(vm_id, section).body
  @vcloud.process_task(task)
end

#put_vapp_metadata_value(id, k, v) ⇒ Object



158
159
160
161
162
163
# File 'lib/vcloud/fog/service_interface.rb', line 158

def (id, k, v)
  Vcloud::Core.logger.debug("putting metadata pair '#{k}'=>'#{v}' to #{id}")
  # need to convert key to_s since Fog 0.17 borks on symbol key
  task = @vcloud.(id, k.to_s, v).body
  @vcloud.process_task(task)
end

#put_vm(id, name, options = {}) ⇒ Object



70
71
72
73
74
# File 'lib/vcloud/fog/service_interface.rb', line 70

def put_vm(id, name, options={})
  Vcloud::Core.logger.debug("updating name : #{name}, :options => #{options} in vm : #{id}")
  task = @vcloud.put_vm(id, name, options).body
  @vcloud.process_task(task)
end

#sessionObject



30
31
32
# File 'lib/vcloud/fog/service_interface.rb', line 30

def session
  @vcloud.get_current_session.body
end

#shutdown_vapp(vapp_id) ⇒ Object



149
150
151
152
# File 'lib/vcloud/fog/service_interface.rb', line 149

def shutdown_vapp(vapp_id)
  task = @vcloud.post_shutdown_vapp(vapp_id).body
  @vcloud.process_task(task)
end

#vcloud_tokenObject



76
77
78
# File 'lib/vcloud/fog/service_interface.rb', line 76

def vcloud_token
  @vcloud.vcloud_token
end