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
|
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"
|
type="application/vnd.vmware.vcloud.guestCustomizationSection+xml"
|
||||||
ovf:required="false">
|
ovf:required="false"
|
||||||
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
|
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
|
||||||
<ChangeSid>#{opts[:change_sid]}</ChangeSid>
|
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
|
||||||
<VirtualMachineId>#{opts[:virtual_machine_id]}</VirtualMachineId>
|
<Enabled>#{opts[:enabled]}</Enabled>
|
||||||
<JoinDomainEnabled>#{opts[:join_domain_enabled]}</JoinDomainEnabled>
|
<ChangeSid>#{opts[:change_sid]}</ChangeSid>
|
||||||
<UseOrgSettings>#{opts[:use_org_settings]}</UseOrgSettings>
|
<VirtualMachineId>#{opts[:virtual_machine_id]}</VirtualMachineId>
|
||||||
<AdminPasswordEnabled>#{opts[:admin_password_enabled]}</AdminPasswordEnabled>
|
<JoinDomainEnabled>#{opts[:join_domain_enabled]}</JoinDomainEnabled>
|
||||||
<AdminPasswordAuto>#{opts[:admin_password_auto]}</AdminPasswordAuto>
|
<UseOrgSettings>#{opts[:use_org_settings]}</UseOrgSettings>
|
||||||
<ResetPasswordRequired>#{opts[:reset_password_required]}</ResetPasswordRequired>
|
<AdminPasswordEnabled>#{opts[:admin_password_enabled]}</AdminPasswordEnabled>
|
||||||
<ComputerName>#{opts[:computer_name]}</ComputerName>
|
<AdminPasswordAuto>#{opts[:admin_password_auto]}</AdminPasswordAuto>
|
||||||
<CustomizationScript>#{CGI.escapeHTML(opts[:customization_script])}</CustomizationScript>"
|
<ResetPasswordRequired>#{opts[:reset_password_required]}</ResetPasswordRequired>
|
||||||
|
<CustomizationScript>#{CGI.escapeHTML(opts[:customization_script])}</CustomizationScript>
|
||||||
|
<ComputerName>#{opts[:computer_name]}</ComputerName>
|
||||||
|
EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
def tail
|
def tail
|
||||||
|
|
|
@ -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
|
||||||
response = service.put_vm_customization(id, attributes)
|
show_exception_body_error {
|
||||||
task = response.body
|
response = service.put_vm_customization(id, attributes)
|
||||||
task[:id] = task[:href].split('/').last
|
task = response.body
|
||||||
attributes[:customization_task] = service.tasks.new(task)
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
module Helper
|
module Helper
|
||||||
|
|
||||||
def catalog_item_end_point(catalog_item_id = nil)
|
def catalog_item_end_point(catalog_item_id = nil)
|
||||||
end_point + ( catalog_item_id ? "catalogItem/#{catalog_item_id}" : "catalogItem" )
|
end_point + ( catalog_item_id ? "catalogItem/#{catalog_item_id}" : "catalogItem" )
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue