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

[vcloud_director] Add ability to undeploy vApp

This commit is contained in:
Philip Potter 2013-09-16 15:38:38 +01:00
parent e2c22289ed
commit 31954efdaa
3 changed files with 33 additions and 7 deletions

View file

@ -109,6 +109,7 @@ module Fog
request :get_vms_by_metadata
request :get_vm
request :post_task_cancel
request :undeploy
class Model < Fog::Model
def initialize(attrs={})

View file

@ -5,10 +5,10 @@ module Fog
class VcloudDirector
class Vapp < Model
identity :id
attribute :name
attribute :type
attribute :href
@ -20,7 +20,7 @@ module Fog
attribute :network_config, :aliases => :NetworkConfigSection, :squash => :NetworkConfig
attribute :owner, :aliases => :Owner, :squash => :User
attribute :InMaintenanceMode, :type => :boolean
def vms
requires :id
service.vms(:vapp => self)
@ -30,9 +30,12 @@ module Fog
requires :id
service.tags(:vm => self)
end
def undeploy
service.undeploy(id)
end
end
end
end
end
end

View file

@ -0,0 +1,22 @@
module Fog
module Compute
class VcloudDirector
class Real
def undeploy(vapp_id)
body = <<EOF
<UndeployVAppParams xmlns="http://www.vmware.com/vcloud/v1.5">
<UndeployPowerAction>shutdown</UndeployPowerAction>
</UndeployVAppParams>
EOF
request(
:body => body,
:expects => 202,
:method => 'POST',
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.undeployVAppParams+xml' },
:path => "vApp/#{vapp_id}/action/undeploy"
)
end
end
end
end
end