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:
parent
e0e7ba9ed7
commit
74c9f0800e
4 changed files with 43 additions and 22 deletions
|
@ -57,16 +57,24 @@ module Fog
|
|||
end
|
||||
|
||||
def header
|
||||
'<GuestCustomizationSection
|
||||
xmlns="http://www.vmware.com/vcloud/v1.5"
|
||||
'<GuestCustomizationSection xmlns="http://www.vmware.com/vcloud/v1.5"
|
||||
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
|
||||
ovf:required="false">
|
||||
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
|
||||
'
|
||||
type="application/vnd.vmware.vcloud.guestCustomizationSection+xml"
|
||||
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
|
||||
|
||||
# the order maters http://communities.vmware.com/thread/448760?start=0&tstart=0
|
||||
|
||||
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>
|
||||
<VirtualMachineId>#{opts[:virtual_machine_id]}</VirtualMachineId>
|
||||
<JoinDomainEnabled>#{opts[:join_domain_enabled]}</JoinDomainEnabled>
|
||||
|
@ -74,8 +82,9 @@ module Fog
|
|||
<AdminPasswordEnabled>#{opts[:admin_password_enabled]}</AdminPasswordEnabled>
|
||||
<AdminPasswordAuto>#{opts[:admin_password_auto]}</AdminPasswordAuto>
|
||||
<ResetPasswordRequired>#{opts[:reset_password_required]}</ResetPasswordRequired>
|
||||
<CustomizationScript>#{CGI.escapeHTML(opts[:customization_script])}</CustomizationScript>
|
||||
<ComputerName>#{opts[:computer_name]}</ComputerName>
|
||||
<CustomizationScript>#{CGI.escapeHTML(opts[:customization_script])}</CustomizationScript>"
|
||||
EOF
|
||||
end
|
||||
|
||||
def tail
|
||||
|
|
|
@ -6,6 +6,7 @@ module Fog
|
|||
|
||||
class VmCustomization < Fog::Model
|
||||
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :type
|
||||
|
@ -29,10 +30,21 @@ 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)
|
||||
}
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ module Fog
|
|||
when 'ComputerName'
|
||||
@response[:computer_name] = value
|
||||
when 'CustomizationScript'
|
||||
@response[:customization_script] = value
|
||||
@response[:has_customization_script] = !value.empty?
|
||||
@response[:customization_script] = CGI::unescapeHTML(value) if @response[:has_customization_script]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue