Get SSH object of VM
(
self, ipaddress=None, reconnect=False, port=None,
keyPairFileLocation=None, retries=20)
| 825 | return apiclient.restoreVirtualMachine(cmd) |
| 826 | |
| 827 | def get_ssh_client( |
| 828 | self, ipaddress=None, reconnect=False, port=None, |
| 829 | keyPairFileLocation=None, retries=20): |
| 830 | """Get SSH object of VM""" |
| 831 | |
| 832 | # If NAT Rules are not created while VM deployment in Advanced mode |
| 833 | # then, IP address must be passed |
| 834 | if ipaddress is not None: |
| 835 | self.ssh_ip = ipaddress |
| 836 | if port: |
| 837 | self.ssh_port = port |
| 838 | |
| 839 | if keyPairFileLocation is not None: |
| 840 | self.password = None |
| 841 | |
| 842 | if reconnect: |
| 843 | self.ssh_client = is_server_ssh_ready( |
| 844 | self.ssh_ip, |
| 845 | self.ssh_port, |
| 846 | self.username, |
| 847 | self.password, |
| 848 | retries=retries, |
| 849 | keyPairFileLocation=keyPairFileLocation |
| 850 | ) |
| 851 | self.ssh_client = self.ssh_client or is_server_ssh_ready( |
| 852 | self.ssh_ip, |
| 853 | self.ssh_port, |
| 854 | self.username, |
| 855 | self.password, |
| 856 | retries=retries, |
| 857 | keyPairFileLocation=keyPairFileLocation |
| 858 | ) |
| 859 | return self.ssh_client |
| 860 | |
| 861 | def getState(self, apiclient, state, timeout=600): |
| 862 | """List VM and check if its state is as expected |