1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[vcloud|compute] More work on getting server in a useable shape.

Changing a few bits and bytes here and there. This breaks some apis,
but allows us to get more information about the VM and addresses
also the various parts that didn't work so far.
This commit is contained in:
Peter Meier 2011-09-27 11:38:09 +02:00
parent f2c90dcc7f
commit 4bb95335cf
2 changed files with 24 additions and 36 deletions

View file

@ -11,18 +11,28 @@ module Fog
attribute :name attribute :name
attribute :status attribute :status
attribute :network_connections, :aliases => :NetworkConnectionSection, :squash => :NetworkConnection attribute :network_connections, :aliases => :NetworkConnectionSection, :squash => :NetworkConnection
attribute :os, :aliases => :OperatingSystemSection attribute :virtual_hardware, :aliases => :'ovf:VirtualHardwareSection', :squash => :'ovf:Item'
attribute :virtual_hardware, :aliases => :VirtualHardwareSection
attribute :guest_customization, :aliases => :GuestCustomizationSection
attribute :operating_system, :aliases => :'ovf:OperatingSystemSection'
attribute :description, :aliases => :Description attribute :description, :aliases => :Description
attribute :storage_size, :aliases => :size
attribute :links, :aliases => :Link, :type => :array attribute :links, :aliases => :Link, :type => :array
attribute :tasks, :aliases => :Tasks, :type => :array attribute :tasks, :aliases => :Tasks, :type => :array
attribute :vm_data, :aliases => :Children, :squash => :Vm def computer_name
def ip_address
load_unless_loaded! load_unless_loaded!
vm[0][:NetworkConnectionSection][:NetworkConnection][:IpAddress] self.guest_customization[:ComputerName]
end
def os_desc
load_unless_loaded!
self.operating_system[:'ovf:Description']
end
def ip_addresses
load_unless_loaded!
self.network_connections.collect{|n| n[:IpAddress] }
end end
def friendly_status def friendly_status
@ -83,11 +93,6 @@ module Fog
power_on power_on
end end
def vm
load_unless_loaded!
self.vm_data
end
def name=(new_name) def name=(new_name)
attributes[:name] = new_name attributes[:name] = new_name
@changed = true @changed = true
@ -187,12 +192,12 @@ module Fog
vh[:'rasd:ResourceType'] == '17' && vh[:'rasd:ResourceType'] == '17' &&
vh[:'rasd:AddressOnParent'].to_s == @remove_disk.to_s vh[:'rasd:AddressOnParent'].to_s == @remove_disk.to_s
end end
connection.configure_vm_disks(vm_href, data) connection.configure_vm_disks(self.href, data)
end end
if @disk_change == :added if @disk_change == :added
data = disk_mess data = disk_mess
data << @add_disk data << @add_disk
connection.configure_vm_disks(vm_href, data) connection.configure_vm_disks(self.href, data)
end end
if @name_changed || @description_changed if @name_changed || @description_changed
edit_uri = links.select {|i| i[:rel] == 'edit'} edit_uri = links.select {|i| i[:rel] == 'edit'}
@ -216,14 +221,6 @@ module Fog
end end
alias :delete :destroy alias :delete :destroy
def vm_href
load_unless_loaded!
#require 'pp'
#pp vm_data
#vm_data[0][:Link].select {|v| v[:rel] == 'edit'}[0][:href]
vm_data.kind_of?(Array)? vm_data[0][:href] : vm_data[:href]
end
private private
def reset_tracking def reset_tracking
@ -242,11 +239,6 @@ module Fog
} }
end end
def virtual_hardware_section
load_unless_loaded!
vm[0][:"ovf:VirtualHardwareSection"][:"ovf:Item"]
end
def memory_mess def memory_mess
load_unless_loaded! load_unless_loaded!
if virtual_hardware_section if virtual_hardware_section
@ -284,7 +276,6 @@ module Fog
def reload_status def reload_status
self.status = connection.get_vapp(href).body[:status] self.status = connection.get_vapp(href).body[:status]
end end
end end
end end
end end

View file

@ -10,8 +10,10 @@ module Fog
undef_method :create undef_method :create
attribute :href
def all def all
data = connection.get_organization(organization_uri).body[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.vdc+xml" } data = connection.get_organization(org_uri).body[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.vdc+xml" }
data.each { |link| link.delete_if { |key, value| [:rel].include?(key) } } data.each { |link| link.delete_if { |key, value| [:rel].include?(key) } }
load(data) load(data)
end end
@ -24,16 +26,11 @@ module Fog
nil nil
end end
def organization_uri
@organization_uri ||= connection.default_organization_uri
end
private private
def organization_uri=(new_organization_uri) def org_uri
@organization_uri = new_organization_uri self.href ||= connection.default_organization_uri
end end
end end
end end
end end