Class: Vcloud::Core::Fog::ServiceInterface Private
- Inherits:
-
Object
- Object
- Vcloud::Core::Fog::ServiceInterface
- Extended by:
- Forwardable
- Defined in:
- lib/vcloud/core/fog/service_interface.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Private interface to the fog service layer. You should not use this directly. Expose required functionality in ApiInterface
Defined Under Namespace
Classes: FogFacade
Instance Method Summary collapse
- #find_networks(network_names, vdc_name) ⇒ Object private
- #get_vapp_by_name_and_vdc_name(name, vdc_name) ⇒ Object private
-
#initialize(fog = FogFacade.new) ⇒ ServiceInterface
constructor
private
A new instance of ServiceInterface.
- #org ⇒ Object private
- #put_guest_customization_section(vm_id, vm_name, script) ⇒ Object private
- #put_network_connection_system_section_vapp(vm_id, section) ⇒ Object private
- #vdc(name) ⇒ Object private
Constructor Details
#initialize(fog = FogFacade.new) ⇒ ServiceInterface
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ServiceInterface.
226 227 228 |
# File 'lib/vcloud/core/fog/service_interface.rb', line 226 def initialize (fog = FogFacade.new) @fog = fog end |
Instance Method Details
#find_networks(network_names, vdc_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
262 263 264 265 266 267 268 |
# File 'lib/vcloud/core/fog/service_interface.rb', line 262 def find_networks(network_names, vdc_name) network_names.collect do |network| vdc(vdc_name)[:AvailableNetworks][:Network].detect do |l| l[:type] == ContentTypes::NETWORK && l[:name] == network end end end |
#get_vapp_by_name_and_vdc_name(name, vdc_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
237 238 239 240 |
# File 'lib/vcloud/core/fog/service_interface.rb', line 237 def get_vapp_by_name_and_vdc_name name, vdc_name response_body = @fog.get_vapps_in_lease_from_query({:filter => "name==#{name}"}) response_body[:VAppRecord].detect { |record| record[:vdcName] == vdc_name } end |
#org ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
230 231 232 233 234 235 |
# File 'lib/vcloud/core/fog/service_interface.rb', line 230 def org link = session[:Link].select { |l| l[:rel] == RELATION::CHILD }.detect do |l| l[:type] == ContentTypes::ORG end @fog.get_organization(link[:href].split('/').last) end |
#put_guest_customization_section(vm_id, vm_name, script) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/vcloud/core/fog/service_interface.rb', line 270 def put_guest_customization_section(vm_id, vm_name, script) begin Vcloud::Core.logger.debug("configuring guest customization section for vm : #{vm_id}") customization_req = { :Enabled => true, :CustomizationScript => script, :ComputerName => vm_name } @fog.put_guest_customization_section_vapp(vm_id, customization_req) rescue => ex Vcloud::Core.logger.error("Failed to update guest customization section: #{ex}") Vcloud::Core.logger.debug("=== interpolated preamble:") Vcloud::Core.logger.debug(script) raise end end |
#put_network_connection_system_section_vapp(vm_id, section) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
251 252 253 254 255 256 257 258 259 260 |
# File 'lib/vcloud/core/fog/service_interface.rb', line 251 def put_network_connection_system_section_vapp(vm_id, section) begin Vcloud::Core.logger.debug("adding NIC into VM #{vm_id}") @fog.put_network_connection_system_section_vapp(vm_id, section) rescue => ex Vcloud::Core.logger.error("failed to put_network_connection_system_section_vapp for vm #{vm_id}: #{ex}") Vcloud::Core.logger.debug("requested network section : #{section.inspect}") raise end end |
#vdc(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
242 243 244 245 246 247 248 249 |
# File 'lib/vcloud/core/fog/service_interface.rb', line 242 def vdc(name) link = org[:Link].select { |l| l[:rel] == RELATION::CHILD }.detect do |l| l[:type] == ContentTypes::VDC && l[:name] == name end raise "vdc #{name} cannot be found" unless link @fog.get_vdc(link[:href].split('/').last) end |