CLOUDSTACK:8058: Fix test_reset_ssh_keypair.py for EIP setup

Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
Gaurav Aradhye 2014-12-11 10:16:25 +05:30 committed by SrikanteswaraRao Talluri
parent fdb782ffcb
commit 487bf5f57d
1 changed files with 45 additions and 0 deletions

View File

@ -107,6 +107,15 @@ def wait_vm_start(apiclient, vmid, timeout, sleep):
return timeout
def SetPublicIpForVM(apiclient, vm):
""" List VM and set the publicip (if available) of VM
to ssh_ip attribute"""
vms = VirtualMachine.list(apiclient, id=vm.id, listall=True)
virtual_machine = vms[0]
if hasattr(vm, "publicip"):
vm.ssh_ip = virtual_machine.publicip
return vm
class TestResetSSHKeypair(cloudstackTestCase):
@ -353,6 +362,12 @@ class TestResetSSHKeypair(cloudstackTestCase):
% (virtual_machine.name, self.services["timeout"]))
self.debug("SSH key path: %s" % str(keyPairFilePath))
# In case of EIP setup, public IP changes after VM start operation
# Assign the new publicip of the VM to its ssh_ip attribute
# so that correct IP address is used for getting the ssh client of VM
virtual_machine = SetPublicIpForVM(self.apiclient, virtual_machine)
try:
virtual_machine.get_ssh_client(keyPairFileLocation=str(keyPairFilePath))
except Exception as e:
@ -462,6 +477,11 @@ class TestResetSSHKeypair(cloudstackTestCase):
self.fail("The virtual machine %s failed to start even after %s minutes"
% (virtual_machine.name, self.services["timeout"]))
# In case of EIP setup, public IP changes after VM start operation
# Assign the new publicip of the VM to its ssh_ip attribute
# so that correct IP address is used for getting the ssh client of VM
virtual_machine = SetPublicIpForVM(self.apiclient, virtual_machine)
self.debug("SSHing with new keypair")
try:
virtual_machine.get_ssh_client(
@ -572,6 +592,11 @@ class TestResetSSHKeypair(cloudstackTestCase):
self.fail("The virtual machine %s failed to start even after %s minutes"
% (virtual_machine.name, self.services["timeout"]))
# In case of EIP setup, public IP changes after VM start operation
# Assign the new publicip of the VM to its ssh_ip attribute
# so that correct IP address is used for getting the ssh client of VM
virtual_machine = SetPublicIpForVM(self.apiclient, virtual_machine)
self.debug("SSHing with new keypair")
try:
virtual_machine.get_ssh_client(
@ -683,6 +708,11 @@ class TestResetSSHKeypair(cloudstackTestCase):
self.fail("The virtual machine %s failed to start even after %s minutes"
% (virtual_machine.name, self.services["timeout"]))
# In case of EIP setup, public IP changes after VM start operation
# Assign the new publicip of the VM to its ssh_ip attribute
# so that correct IP address is used for getting the ssh client of VM
virtual_machine = SetPublicIpForVM(self.apiclient, virtual_machine)
self.debug("SSHing with new keypair")
try:
virtual_machine.get_ssh_client(
@ -1172,6 +1202,11 @@ class TestResetSSHKeyUserRights(cloudstackTestCase):
self.fail("The virtual machine %s failed to start even after %s minutes"
% (vms[0].name, self.services["timeout"]))
# In case of EIP setup, public IP changes after VM start operation
# Assign the new publicip of the VM to its ssh_ip attribute
# so that correct IP address is used for getting the ssh client of VM
virtual_machine = SetPublicIpForVM(self.apiclient, virtual_machine)
self.debug("SSHing with new keypair")
try:
virtual_machine.get_ssh_client(
@ -1311,6 +1346,11 @@ class TestResetSSHKeyUserRights(cloudstackTestCase):
self.fail("The virtual machine %s failed to start even after %s minutes"
% (virtual_machine.name, self.services["timeout"]))
# In case of EIP setup, public IP changes after VM start operation
# Assign the new publicip of the VM to its ssh_ip attribute
# so that correct IP address is used for getting the ssh client of VM
virtual_machine = SetPublicIpForVM(self.apiclient, virtual_machine)
self.debug("SSHing with new keypair")
try:
virtual_machine.get_ssh_client(
@ -1451,6 +1491,11 @@ class TestResetSSHKeyUserRights(cloudstackTestCase):
self.fail("The virtual machine %s failed to start even after %s minutes"
% (virtual_machine.name, self.services["timeout"]))
# In case of EIP setup, public IP changes after VM start operation
# Assign the new publicip of the VM to its ssh_ip attribute
# so that correct IP address is used for getting the ssh client of VM
virtual_machine = SetPublicIpForVM(self.apiclient, virtual_machine)
self.debug("SSHing with new keypair")
try:
virtual_machine.get_ssh_client(