class Vcloud::Core::Fog::ServiceInterface
Private interface to the fog service layer. You should not use this directly. Expose required functionality in {Vcloud::Core::ApiInterface}
@api private
Public Class Methods
new(fog = FogFacade.new)
click to toggle source
# File lib/vcloud/core/fog/service_interface.rb, line 226 def initialize (fog = FogFacade.new) @fog = fog end
Public Instance Methods
find_networks(network_names, vdc_name)
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
extract_id(link)
click to toggle source
# File lib/vcloud/core/fog/service_interface.rb, line 288 def extract_id(link) link[:href].split('/').last end