mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
VM@customization_script=
This commit is contained in:
parent
8a1637f8f5
commit
d809e146a9
3 changed files with 46 additions and 0 deletions
|
@ -140,6 +140,7 @@ module Fog
|
|||
request :get_metadata
|
||||
request :delete_metadata
|
||||
request :configure_metadata
|
||||
request :configure_vm_customization_script
|
||||
|
||||
class Mock
|
||||
|
||||
|
|
|
@ -37,6 +37,11 @@ module Fog
|
|||
self.guest_customization[:CustomizationScript]
|
||||
end
|
||||
|
||||
def customization_script=(custom_script)
|
||||
@changed = true
|
||||
@update_custom_script = custom_script
|
||||
end
|
||||
|
||||
def computer_name
|
||||
load_unless_loaded!
|
||||
self.guest_customization[:ComputerName]
|
||||
|
@ -201,6 +206,12 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
if @update_custom_script
|
||||
guest_customization[:CustomizationScript] = @update_custom_script.to_s
|
||||
service.configure_vm_customization_script(guest_customization)
|
||||
wait_for { ready? }
|
||||
end
|
||||
|
||||
if @update_password
|
||||
guest_customization[:AdminPassword] = @update_password.to_s
|
||||
service.configure_vm_password(guest_customization)
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
module Fog
|
||||
module Vcloud
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def configure_vm_customization_script(vmdata)
|
||||
# The customization script cannot exceed 1500 characters.
|
||||
edit_uri = vmdata[:href]
|
||||
body = <<EOF
|
||||
<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" href="https://zone01.bluelock.com/api/vApp/vm-cc8e27be-f18c-4263-87c5-58a9297bac5b/guestCustomizationSection/" 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">
|
||||
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
|
||||
<Enabled>true</Enabled>
|
||||
<CustomizationScript>#{vmdata[:CustomizationScript]}</CustomizationScript>
|
||||
<ComputerName>#{vmdata[:ComputerName]}</ComputerName>
|
||||
|
||||
<Link rel="edit" type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" href="#{edit_uri}"/>
|
||||
</GuestCustomizationSection>
|
||||
EOF
|
||||
request(
|
||||
:body => body,
|
||||
:expects => 202,
|
||||
:headers => {'Content-Type' => vmdata[:type] },
|
||||
:method => 'PUT',
|
||||
:uri => "#{edit_uri}",
|
||||
:parse => true
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue