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,25 +57,34 @@ module Fog
|
|||
end
|
||||
|
||||
def header
|
||||
'<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>
|
||||
'
|
||||
'<GuestCustomizationSection xmlns="http://www.vmware.com/vcloud/v1.5"
|
||||
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
|
||||
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>
|
||||
<ChangeSid>#{opts[:change_sid]}</ChangeSid>
|
||||
<VirtualMachineId>#{opts[:virtual_machine_id]}</VirtualMachineId>
|
||||
<JoinDomainEnabled>#{opts[:join_domain_enabled]}</JoinDomainEnabled>
|
||||
<UseOrgSettings>#{opts[:use_org_settings]}</UseOrgSettings>
|
||||
<AdminPasswordEnabled>#{opts[:admin_password_enabled]}</AdminPasswordEnabled>
|
||||
<AdminPasswordAuto>#{opts[:admin_password_auto]}</AdminPasswordAuto>
|
||||
<ResetPasswordRequired>#{opts[:reset_password_required]}</ResetPasswordRequired>
|
||||
<ComputerName>#{opts[:computer_name]}</ComputerName>
|
||||
<CustomizationScript>#{CGI.escapeHTML(opts[:customization_script])}</CustomizationScript>"
|
||||
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>
|
||||
<UseOrgSettings>#{opts[:use_org_settings]}</UseOrgSettings>
|
||||
<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>
|
||||
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
|
||||
response = service.put_vm_customization(id, attributes)
|
||||
task = response.body
|
||||
task[:id] = task[:href].split('/').last
|
||||
attributes[:customization_task] = service.tasks.new(task)
|
||||
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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Fog
|
||||
module Compute
|
||||
module Helper
|
||||
|
||||
|
||||
def catalog_item_end_point(catalog_item_id = nil)
|
||||
end_point + ( catalog_item_id ? "catalogItem/#{catalog_item_id}" : "catalogItem" )
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue