mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #1551 from chirag-jog/vcloud_enhancements
vCloud Director 1.5 enhancements
This commit is contained in:
commit
83e8d790f4
5 changed files with 73 additions and 7 deletions
|
@ -117,6 +117,7 @@ module Fog
|
|||
request :configure_vm_name_description
|
||||
request :configure_vm_disks
|
||||
request :configure_vm_password
|
||||
request :configure_vm_network
|
||||
request :delete_vapp
|
||||
request :get_catalog_item
|
||||
request :get_customization_options
|
||||
|
|
|
@ -18,7 +18,7 @@ module Fog
|
|||
|
||||
attribute :vapp_scoped_local_id, :aliases => :VAppScopedLocalId
|
||||
|
||||
attribute :network_connections, :aliases => :NetworkConnectionSection, :squash => :NetworkConnection
|
||||
attribute :network_connections, :aliases => :NetworkConnectionSection#, :squash => :NetworkConnection
|
||||
attribute :virtual_hardware, :aliases => :'ovf:VirtualHardwareSection', :squash => :'ovf:Item'
|
||||
|
||||
attribute :guest_customization, :aliases => :GuestCustomizationSection
|
||||
|
@ -123,7 +123,14 @@ module Fog
|
|||
@update_memory_value = amount
|
||||
amount
|
||||
end
|
||||
|
||||
def network
|
||||
network_connections[:NetworkConnection] if network_connections
|
||||
end
|
||||
def network=(network_info)
|
||||
@changed = true
|
||||
@update_network = network_info
|
||||
network_info
|
||||
end
|
||||
def disks
|
||||
disk_mess.map do |dm|
|
||||
{ :number => dm[:"rasd:AddressOnParent"].to_i, :size => dm[:"rasd:HostResource"][:vcloud_capacity].to_i, :resource => dm[:"rasd:HostResource"], :disk_data => dm }
|
||||
|
@ -203,6 +210,12 @@ module Fog
|
|||
wait_for { ready? }
|
||||
end
|
||||
|
||||
if @update_network
|
||||
network_connections[:NetworkConnection][:network] = @update_network[:network_name]
|
||||
network_connections[:NetworkConnection][:IpAddressAllocationMode] = @update_network[:network_mode]
|
||||
service.configure_vm_network(network_connections)
|
||||
wait_for { ready? }
|
||||
end
|
||||
if @disk_change == :deleted
|
||||
data = disk_mess.delete_if do |vh|
|
||||
vh[:'rasd:ResourceType'] == '17' &&
|
||||
|
|
|
@ -37,6 +37,17 @@ module Fog
|
|||
:href => href
|
||||
)
|
||||
end
|
||||
|
||||
def ready?
|
||||
reload_status # always ensure we have the correct status
|
||||
status != '0'
|
||||
end
|
||||
|
||||
private
|
||||
def reload_status
|
||||
vapp = service.get_vapp(href)
|
||||
self.status = vapp.status
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
37
lib/fog/vcloud/requests/compute/configure_vm_network.rb
Normal file
37
lib/fog/vcloud/requests/compute/configure_vm_network.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
module Fog
|
||||
module Vcloud
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def configure_vm_network(network_info)
|
||||
edit_uri = network_info.select {|k,v| k == :Link && v[:rel] == 'edit'}
|
||||
edit_uri = edit_uri.kind_of?(Array) ? edit_uri.flatten[1][:href] : edit_uri[:Link][:href]
|
||||
|
||||
body = <<EOF
|
||||
<NetworkConnectionSection xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="#{edit_uri}">
|
||||
<ovf:Info>Specifies the available VM network connections</ovf:Info>
|
||||
<PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
|
||||
<NetworkConnection network="#{network_info[:NetworkConnection][:network]}" needsCustomization="true">
|
||||
<NetworkConnectionIndex>0</NetworkConnectionIndex>
|
||||
<IsConnected>true</IsConnected>
|
||||
<IpAddressAllocationMode>#{network_info[:NetworkConnection][:IpAddressAllocationMode]}</IpAddressAllocationMode>
|
||||
</NetworkConnection>
|
||||
</NetworkConnectionSection>
|
||||
EOF
|
||||
print "Request: #{body}"
|
||||
request(
|
||||
:body => body,
|
||||
:expects => 202,
|
||||
:headers => {'Content-Type' => network_info[:"vcloud_type"] },
|
||||
:method => 'PUT',
|
||||
:uri => "#{edit_uri}",
|
||||
:parse => true
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
unless valid_opts.all? { |opt| options.has_key?(opt) }
|
||||
raise ArgumentError.new("Required data missing: #{(valid_opts - options.keys).map(&:inspect).join(", ")}")
|
||||
end
|
||||
|
||||
|
||||
catalog_item_uri = options[:catalog_item_uri]
|
||||
|
||||
# Figure out the template_uri
|
||||
|
@ -49,8 +49,13 @@ module Fog
|
|||
if options[:network_uri]
|
||||
# TODO - implement properly
|
||||
xml.NetworkConfigSection {
|
||||
xml.NetworkConfig {
|
||||
xml.NetworkAssociation( :href => options[:network_uri] )
|
||||
xml.tag!("ovf:Info"){ "Configuration parameters for logical networks" }
|
||||
xml.NetworkConfig("networkName" => options[:network_name]) {
|
||||
# xml.NetworkAssociation( :href => options[:network_uri] )
|
||||
xml.Configuration {
|
||||
xml.ParentNetwork("name" => options[:network_name], "href" => options[:network_uri])
|
||||
xml.FenceMode("bridged")
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -66,8 +71,7 @@ module Fog
|
|||
include Shared
|
||||
|
||||
def instantiate_vapp_template options = {}
|
||||
validate_instantiate_vapp_template_options options
|
||||
|
||||
validate_instantiate_vapp_template_options optionsgi
|
||||
request(
|
||||
:body => generate_instantiate_vapp_template_request(options),
|
||||
:expects => 201,
|
||||
|
|
Loading…
Reference in a new issue