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:
parent
f2c90dcc7f
commit
4bb95335cf
2 changed files with 24 additions and 36 deletions
|
@ -11,18 +11,28 @@ module Fog
|
|||
attribute :name
|
||||
attribute :status
|
||||
attribute :network_connections, :aliases => :NetworkConnectionSection, :squash => :NetworkConnection
|
||||
attribute :os, :aliases => :OperatingSystemSection
|
||||
attribute :virtual_hardware, :aliases => :VirtualHardwareSection
|
||||
attribute :virtual_hardware, :aliases => :'ovf:VirtualHardwareSection', :squash => :'ovf:Item'
|
||||
|
||||
attribute :guest_customization, :aliases => :GuestCustomizationSection
|
||||
attribute :operating_system, :aliases => :'ovf:OperatingSystemSection'
|
||||
|
||||
attribute :description, :aliases => :Description
|
||||
attribute :storage_size, :aliases => :size
|
||||
attribute :links, :aliases => :Link, :type => :array
|
||||
attribute :tasks, :aliases => :Tasks, :type => :array
|
||||
|
||||
attribute :vm_data, :aliases => :Children, :squash => :Vm
|
||||
|
||||
def ip_address
|
||||
def computer_name
|
||||
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
|
||||
|
||||
def friendly_status
|
||||
|
@ -83,11 +93,6 @@ module Fog
|
|||
power_on
|
||||
end
|
||||
|
||||
def vm
|
||||
load_unless_loaded!
|
||||
self.vm_data
|
||||
end
|
||||
|
||||
def name=(new_name)
|
||||
attributes[:name] = new_name
|
||||
@changed = true
|
||||
|
@ -187,12 +192,12 @@ module Fog
|
|||
vh[:'rasd:ResourceType'] == '17' &&
|
||||
vh[:'rasd:AddressOnParent'].to_s == @remove_disk.to_s
|
||||
end
|
||||
connection.configure_vm_disks(vm_href, data)
|
||||
connection.configure_vm_disks(self.href, data)
|
||||
end
|
||||
if @disk_change == :added
|
||||
data = disk_mess
|
||||
data << @add_disk
|
||||
connection.configure_vm_disks(vm_href, data)
|
||||
connection.configure_vm_disks(self.href, data)
|
||||
end
|
||||
if @name_changed || @description_changed
|
||||
edit_uri = links.select {|i| i[:rel] == 'edit'}
|
||||
|
@ -216,14 +221,6 @@ module Fog
|
|||
end
|
||||
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
|
||||
|
||||
def reset_tracking
|
||||
|
@ -242,11 +239,6 @@ module Fog
|
|||
}
|
||||
end
|
||||
|
||||
def virtual_hardware_section
|
||||
load_unless_loaded!
|
||||
vm[0][:"ovf:VirtualHardwareSection"][:"ovf:Item"]
|
||||
end
|
||||
|
||||
def memory_mess
|
||||
load_unless_loaded!
|
||||
if virtual_hardware_section
|
||||
|
@ -284,7 +276,6 @@ module Fog
|
|||
def reload_status
|
||||
self.status = connection.get_vapp(href).body[:status]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,8 +10,10 @@ module Fog
|
|||
|
||||
undef_method :create
|
||||
|
||||
attribute :href
|
||||
|
||||
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) } }
|
||||
load(data)
|
||||
end
|
||||
|
@ -24,16 +26,11 @@ module Fog
|
|||
nil
|
||||
end
|
||||
|
||||
def organization_uri
|
||||
@organization_uri ||= connection.default_organization_uri
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def organization_uri=(new_organization_uri)
|
||||
@organization_uri = new_organization_uri
|
||||
def org_uri
|
||||
self.href ||= connection.default_organization_uri
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue