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

lot of small improvments

This commit is contained in:
Rodrigo Estebanez 2013-07-04 13:24:25 +02:00
parent 1371c15daf
commit c6a6786de8
9 changed files with 45 additions and 53 deletions

View file

@ -23,7 +23,6 @@ class VcloudngParser < Fog::Parsers::Base
def extract_link(attributes_xml)
response = {}
link_attrs = extract_attributes(attributes_xml)
puts link_attrs["type"]
response[:type] = link_attrs["type"]
response[:rel] = link_attrs["rel"]
response[:href] = link_attrs["href"]
@ -183,6 +182,11 @@ module Fog
:parser => params[:parser],
:path => path
})
rescue => @e
raise @e unless @e.class.to_s =~ /^Excon::Errors/
puts @e.response.status
puts CGI::unescapeHTML(@e.response.body)
raise @e
end

View file

@ -27,7 +27,7 @@ module Fog
if capacity_changed?
puts "Debug: change the cpu from #{attributes[:old_capacity]} to #{attributes[:capacity]}"
set_capacity(capacity)
attributes[:capacity_task].wait_for { :ready? }
attributes[:capacity_task]
end
end

View file

@ -20,11 +20,6 @@ module Fog
attribute :result, :aliases => :Result
attribute :progress, :aliases => :Progress
def reload
data = service.get_task(id).body
data[:id] = data[:href].split('/').last
service.tasks.new(data)
end
def ready?
status == 'success'

View file

@ -15,6 +15,13 @@ module Fog
end
def get(id)
data = service.get_task(id).body
return nil unless data
data[:id] = data[:href].split('/').last
new(data)
end
end
end
end

View file

@ -64,14 +64,20 @@ module Fog
if cpu_changed?
puts "Debug: change the cpu from #{attributes[:old_cpu]} to #{attributes[:cpu]}"
set_cpu(cpu)
attributes[:cpu_task].wait_for { :ready? }
attributes[:cpu_task].wait_for { non_running? }
if attributes[:cpu_task].status != 'success'
raise "Error will setting cpu: #{attributes[:cpu_task].inspect}"
end
end
if memory_changed?
puts "Debug: change the memory from #{attributes[:old_memory]} to #{attributes[:memory]}"
set_memory(memory)
attributes[:memory_task].wait_for { :ready? }
attributes[:memory_task].wait_for { non_running? }
if attributes[:memory_task].status != 'success'
raise "Error will setting memory: #{attributes[:memory_task].inspect}"
end
end
true
end
def memory=(new_memory)

View file

@ -30,24 +30,12 @@ module Fog
end
def save
show_exception_body_error {
response = service.put_vm_customization(id, attributes)
task = response.body
task[:id] = task[:href].split('/').last
attributes[:customization_task] = service.tasks.new(task)
}
response = service.put_vm_customization(id, attributes)
task = response.body
task[:id] = task[:href].split('/').last
attributes[:customization_task] = service.tasks.new(task)
end
def show_exception_body_error
yield
rescue => @e
raise @e unless @e.class.to_s =~ /^Excon::Errors/
puts @e.response.status
puts CGI::unescapeHTML(@e.response.body)
raise @e
end
end
end
end

View file

@ -21,24 +21,12 @@ module Fog
attribute :ip_address_allocation_mode
def save
show_exception_body_error {
response = service.put_vm_network(id, attributes)
task = response.body
task[:id] = task[:href].split('/').last
attributes[:network_task] = service.tasks.new(task)
}
response = service.put_vm_network(id, attributes)
task = response.body
task[:id] = task[:href].split('/').last
attributes[:network_task] = service.tasks.new(task)
end
def show_exception_body_error
yield
rescue => @e
raise @e unless @e.class.to_s =~ /^Excon::Errors/
puts @e.response.status
puts CGI::unescapeHTML(@e.response.body)
raise @e
end
end
end
end

View file

@ -10,6 +10,10 @@ module Fog
attribute :vm
def get(id)
data = service.get_vm_network(id).body
new(data)
end
end
end

View file

@ -53,17 +53,17 @@ module Fog
xml.Description(options[:description])
xml.InstantiationParams {
# This options are fully ignored
#if options[:network_uri]
# xml.NetworkConfigSection {
# xml.tag!("ovf:Info"){ "Configuration parameters for logical networks" }
# xml.NetworkConfig("networkName" => options[:network_name]) {
# xml.Configuration {
# xml.ParentNetwork(:href => options[:network_uri])
# xml.FenceMode("bridged")
# }
# }
# }
#end
if options[:network_uri]
xml.NetworkConfigSection {
xml.tag!("ovf:Info"){ "Configuration parameters for logical networks" }
xml.NetworkConfig("networkName" => options[:network_name]) {
xml.Configuration {
xml.ParentNetwork(:href => options[:network_uri])
xml.FenceMode("bridged")
}
}
}
end
}
# The template
xml.Source(:href => options[:template_uri])