Added method to access the console of a running VM.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/da6fac86 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/da6fac86 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/da6fac86 Branch: refs/heads/trunk Commit: da6fac863c1d53fc61b11b0ad8f1019600a319af Parents: 90b263c Author: Juan Font Alonso <juanfontalo...@gmail.com> Authored: Sun Feb 7 00:08:40 2016 +0100 Committer: anthony-shaw <anthony.p.s...@gmail.com> Committed: Tue Feb 16 13:21:35 2016 +1100 ---------------------------------------------------------------------- libcloud/compute/drivers/vcloud.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/da6fac86/libcloud/compute/drivers/vcloud.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/vcloud.py b/libcloud/compute/drivers/vcloud.py index 3f7fc1a..e02a5ab 100644 --- a/libcloud/compute/drivers/vcloud.py +++ b/libcloud/compute/drivers/vcloud.py @@ -2186,3 +2186,34 @@ class VCloud_5_5_NodeDriver(VCloud_5_1_NodeDriver): self._wait_for_task_completion(res.object.get('href')) res = self.connection.request(get_url_path(node.id)) return self._to_node(res.object) + + def ex_acquire_mks_ticket(self, vapp_or_vm_id, vm_num=0): + """ + Retrieve a mks ticket that you can use to gain access to the console + of a running VM. + :param vapp_or_vm_id: vApp or VM ID you want to connect to. + :param vm_num: If a vApp ID is provided, vm_num is position in the vApp + VM list of the VM you want to get a screen ticket. + Default is 0. + :return: If successful, a dict with the following keys: + - host: host (or proxy) through which the console connection + is made + - vmx: a reference to the VMX file of the VM for which this + ticket was issued + - ticket: screen ticket to use to authenticate the client + - port: host port to be used for console access + """ + vm = self._get_vm_elements(vapp_or_vm_id)[vm_num] + try: + res = self.connection.request('%s/screen/action/acquireMksTicket' % + (get_url_path(vm.get('href'))), + method='POST') + output = { + "host": res.object.find(fixxpath(res.object, 'Host')).text, + "vmx": res.object.find(fixxpath(res.object, 'Vmx')).text, + "ticket": res.object.find(fixxpath(res.object, 'Ticket')).text, + "port": res.object.find(fixxpath(res.object, 'Port')).text, + } + return output + except: + return None