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

[vcloud_director] Add #post_answer_vm_pending_question.

This commit is contained in:
Nick Osborn 2013-10-15 23:19:50 +01:00
parent 16db605f9a
commit 6372861cb4
4 changed files with 90 additions and 1 deletions

View file

@ -191,6 +191,7 @@ module Fog
request :get_vms_in_lease_from_query
request :instantiate_vapp_template # to be deprecated
request :post_acquire_ticket
request :post_answer_vm_pending_question
request :post_attach_disk
request :post_cancel_task
request :post_capture_vapp

View file

@ -7,17 +7,26 @@ module Fog
# @param [String] id Object identifier of the VM.
# @return [Excon::Response]
# * body<~Hash>:
# * :href<~String> - The URI of the entity.
# * :type<~String> - The MIME type of the entity.
# * :Question<~String> - Question text.
# * :QuestionId<~String> - Question ID of this question.
# * Choices<~Array<Hash>>:
# * Id<~String> - Choice ID of the answer.
# * Text<~String> - Answer text.
#
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-VmPendingQuestion.html
# @since vCloud API version 0.9
def get_vm_pending_question(id)
request(
response = request(
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => "vApp/#{id}/question"
)
ensure_list! response.body, :Choices
response
end
end
end

View file

@ -0,0 +1,36 @@
module Fog
module Compute
class VcloudDirector
class Real
# Answer a question being asked by a VM.
#
# @param [String] id Object identifier of the VM.
# @param [Integer] choice_id Choice ID of this answer.
# @param [String] question_id Question ID of the question.
# @return [Excon::Response]
#
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/POST-AnswerVmPendingQuestion.html
# @since vCloud API version 0.9
def post_answer_pending_vm_question(id, choice_id, question_id)
body = Nokogiri::XML::Builder.new do
attrs = {
:xmlns => 'http://www.vmware.com/vcloud/v1.5'
}
VmAnswerQuestion(attrs) {
ChoiceId choice_id
QuestionId question_id
}
end.to_xml
request(
:body => body,
:expects => 204, # this might be wrong
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.vmPendingAnswer+xml'},
:method => 'POST',
:path => "vApp/#{id}/quesiton/action/answer"
)
end
end
end
end
end

View file

@ -0,0 +1,43 @@
module Fog
module Compute
class VcloudDirector
class Real
# Update VM's capabilities.
#
# @param [String] id Object identifier of the VM.
# @param [Hash] options
# @option options [Boolean] :MemoryHotAddEnabled True if the virtual
# machine supports addition of memory while powered on.
# @option options [Boolean] :CpuHotAddEnabled True if the virtual
# machine supports addition of virtual CPUs while powered on.
# @return [Excon::Response]
# * body<~Hash>:
#
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/PUT-VmCapabilities.html
def put_vm_capabilities(id, options={})
body = Nokogiri::XML::Builder.new do
attrs = {
:xmlns => 'http://www.vmware.com/vcloud/v1.5'
}
VmCapabilities(attrs) {
if options.key?(:MemoryHotAddEnabled)
MemoryHotAddEnabled options[:MemoryHotAddEnabled]
end
if options.key?(:CpuHotAddEnabled)
MemoryHotAddEnabled options[:CpuHotAddEnabled]
end
}
end.to_xml
request(
:body => body,
:expects => 202,
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.vmCapabilitiesSection+xml'},
:method => 'PUT',
:path => "vApp/#{id}/vmCapabilities"
)
end
end
end
end
end