| Total Complexity | 2 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| 1 | # Licensed to the StackStorm, Inc ('StackStorm') under one or more |
||
| 19 | class GetVMConsoleUrls(BaseAction): |
||
| 20 | |||
| 21 | def run(self, vms): |
||
| 22 | meta_url_template = 'https://{host}:{port}/vsphere-client/vmrc/vmrc.jsp?' \ |
||
| 23 | 'vm=urn:vmomi:VirtualMachine:{{vm}}:{si_uuid}' |
||
| 24 | |||
| 25 | si_content = self.si.RetrieveContent() |
||
| 26 | si_uuid = si_content.about.instanceUuid |
||
| 27 | |||
| 28 | host = self.config['host'] |
||
| 29 | port = self.config['port'] |
||
| 30 | |||
| 31 | vm_url_template = meta_url_template.format(host=host, port=port, si_uuid=si_uuid) |
||
| 32 | |||
| 33 | vm_moids = vms |
||
| 34 | vms_console_urls = [ |
||
| 35 | {moid: {'url': vm_url_template.format(vm=moid)}} for moid in vm_moids |
||
| 36 | ] |
||
| 37 | |||
| 38 | return vms_console_urls |
||
| 39 |