Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Adding functionality to retrieve and answer vm pending questions #712

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyvcloud/vcd/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ class EntityType(Enum):
VM_CAPABILITIES_SECTION = \
'application/vnd.vmware.vcloud.vmCapabilitiesSection+xml'
VMS = 'application/vnd.vmware.vcloud.vms+xml'
VM_PENDING_ANSWER = 'application/vnd.vmware.vcloud.vmPendingAnswer+xml'
VM_PENDING_QUESTION = 'application/vnd.vmware.vcloud.vmPendingQuestion+xml'
VM_SCREEN_ACQUIRE_TICKET = \
'application/vnd.vmware.vcloud.screenTicket+xml'
VM_SCREEN_ACQUIRE_MKSTICKET = \
Expand Down
24 changes: 24 additions & 0 deletions pyvcloud/vcd/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1984,3 +1984,27 @@ def enable_nested_hypervisor(self):
uri = self.href + '/action/enableNestedHypervisor'
return self.client. \
post_resource(uri=uri, contents=None, media_type=None)

def get_pending_user_input_question(self):
"""Retrieves pending user input question of the VM.

:return: an object containing EntityType.VM_PENDING_QUESTION data which
represents the question pending the user's input
:rtype: lxml.objectify.ObjectifiedElement
"""
uri = self.href + '/question'
return self.client.get_resource(uri=uri)

def post_answer_to_pending_user_input_question(self, choice_id,
question_id):
"""POST an answer choice id for a pending question id.

:param int choice_id
:param int question_id
"""
uri = self.href + '/question/action/answer'
vm_question_answer = E.VmQuestionAnswer()
vm_question_answer.append(E.ChoiceId(choice_id))
vm_question_answer.append(E.QuestionId(question_id))
return self.client.post_resource(uri, vm_question_answer,
EntityType.VM_PENDING_ANSWER.value)