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

make vm_customization to work

This commit is contained in:
Rodrigo Estebanez 2013-07-01 17:27:12 +02:00
parent e0e7ba9ed7
commit 74c9f0800e
4 changed files with 43 additions and 22 deletions

View file

@ -57,16 +57,24 @@ module Fog
end end
def header def header
'<GuestCustomizationSection '<GuestCustomizationSection xmlns="http://www.vmware.com/vcloud/v1.5"
xmlns="http://www.vmware.com/vcloud/v1.5"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
ovf:required="false"> type="application/vnd.vmware.vcloud.guestCustomizationSection+xml"
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info> ovf:required="false"
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.dmtf.org/ovf/envelope/1
http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd
http://www.vmware.com/vcloud/v1.5
http://zone01.bluelock.com/api/v1.5/schema/master.xsd">'
end end
# the order maters http://communities.vmware.com/thread/448760?start=0&tstart=0
def body(opts={}) def body(opts={})
"<Enabled>#{opts[:enabled]}</Enabled> body = <<EOF
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
<Enabled>#{opts[:enabled]}</Enabled>
<ChangeSid>#{opts[:change_sid]}</ChangeSid> <ChangeSid>#{opts[:change_sid]}</ChangeSid>
<VirtualMachineId>#{opts[:virtual_machine_id]}</VirtualMachineId> <VirtualMachineId>#{opts[:virtual_machine_id]}</VirtualMachineId>
<JoinDomainEnabled>#{opts[:join_domain_enabled]}</JoinDomainEnabled> <JoinDomainEnabled>#{opts[:join_domain_enabled]}</JoinDomainEnabled>
@ -74,8 +82,9 @@ module Fog
<AdminPasswordEnabled>#{opts[:admin_password_enabled]}</AdminPasswordEnabled> <AdminPasswordEnabled>#{opts[:admin_password_enabled]}</AdminPasswordEnabled>
<AdminPasswordAuto>#{opts[:admin_password_auto]}</AdminPasswordAuto> <AdminPasswordAuto>#{opts[:admin_password_auto]}</AdminPasswordAuto>
<ResetPasswordRequired>#{opts[:reset_password_required]}</ResetPasswordRequired> <ResetPasswordRequired>#{opts[:reset_password_required]}</ResetPasswordRequired>
<CustomizationScript>#{CGI.escapeHTML(opts[:customization_script])}</CustomizationScript>
<ComputerName>#{opts[:computer_name]}</ComputerName> <ComputerName>#{opts[:computer_name]}</ComputerName>
<CustomizationScript>#{CGI.escapeHTML(opts[:customization_script])}</CustomizationScript>" EOF
end end
def tail def tail

View file

@ -6,6 +6,7 @@ module Fog
class VmCustomization < Fog::Model class VmCustomization < Fog::Model
identity :id identity :id
attribute :type attribute :type
@ -29,10 +30,21 @@ module Fog
end end
def save def save
show_exception_body_error {
response = service.put_vm_customization(id, attributes) response = service.put_vm_customization(id, attributes)
task = response.body task = response.body
task[:id] = task[:href].split('/').last task[:id] = task[:href].split('/').last
attributes[:customization_task] = service.tasks.new(task) 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

View file

@ -43,8 +43,8 @@ module Fog
when 'ComputerName' when 'ComputerName'
@response[:computer_name] = value @response[:computer_name] = value
when 'CustomizationScript' when 'CustomizationScript'
@response[:customization_script] = value
@response[:has_customization_script] = !value.empty? @response[:has_customization_script] = !value.empty?
@response[:customization_script] = CGI::unescapeHTML(value) if @response[:has_customization_script]
end end
end end