Fixing the remoteSSHClient imports, migrate VM, SSVM and router tests

This commit is contained in:
Prasanna Santhanam 2012-06-06 12:29:55 +05:30
parent ecfa3e7cf8
commit cddcc097b9
23 changed files with 113 additions and 89 deletions

View File

@ -22,7 +22,7 @@ from marvin.cloudstackAPI import *
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
import datetime

View File

@ -24,7 +24,7 @@ from integration.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
class Services:
"""Test Services

View File

@ -21,7 +21,7 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *

View File

@ -24,7 +24,7 @@ from marvin.cloudstackAPI import *
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
import datetime
@ -171,7 +171,7 @@ class TestHighAvailability(cloudstackTestCase):
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@unittest.skip("skipped")
def test_01_host_maintenance_mode(self):
"""Test host maintenance mode
"""

View File

@ -24,7 +24,7 @@ from marvin.cloudstackAPI import *
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
import datetime
@ -1579,7 +1579,7 @@ class TestNetworkUpgrade(cloudstackTestCase):
vpns = Vpn.list(
self.apiclient,
publicipid=src_nat.id,
listall=True,
listall=True,
)
self.assertEqual(

View File

@ -23,7 +23,7 @@ from marvin.cloudstackAPI import *
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
import datetime

View File

@ -23,7 +23,7 @@ from marvin.cloudstackAPI import *
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
import datetime
class Services:

View File

@ -23,7 +23,7 @@ from marvin.cloudstackAPI import *
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
import datetime

View File

@ -20,10 +20,10 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin import remoteSSHClient
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin.remoteSSHClient import remoteSSHClient
#Import System modules
import time
@ -80,6 +80,7 @@ class Services:
# Algorithm used for load balancing
"privateport": 22,
"publicport": 2222,
"protocol": 'TCP',
},
"fw_rule":{
"startport": 1,

View File

@ -21,10 +21,10 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin import remoteSSHClient
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin.remoteSSHClient import remoteSSHClient
#Import System modules
import time

View File

@ -23,7 +23,7 @@ from marvin.cloudstackAPI import *
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
class Services:
"""Test Snapshots Services

View File

@ -23,7 +23,7 @@ from marvin.cloudstackAPI import *
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
import datetime
class Services:

View File

@ -23,7 +23,7 @@ from marvin.cloudstackAPI import *
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
#Import System modules
import os
import urllib

View File

@ -601,7 +601,9 @@ class Template:
time.sleep(interval)
elif 'Installing' not in template.status:
raise Exception("ErrorInDownload")
raise Exception(
"Error in downloading template: status - %s" %
template.status)
elif timeout == 0:
break
@ -693,10 +695,12 @@ class Iso:
return
elif 'Downloaded' not in response.status and \
'Installing' not in response.status:
raise Exception("ErrorInDownload")
raise Exception(
"Error In Downloading ISO: ISO Status - %s" %
response.status)
elif timeout == 0:
raise Exception("TimeoutException")
raise Exception("ISO download Timeout Exception")
else:
timeout = timeout - 1
return
@ -728,12 +732,12 @@ class PublicIPAddress:
if zoneid:
cmd.zoneid = zoneid
elif "zoneid" in services:
services["zoneid"]
cmd.zoneid = services["zoneid"]
if domainid:
cmd.domainid = domainid
elif "domainid" in services:
services["domainid"]
cmd.domainid = services["domainid"]
if networkid:
cmd.networkid = networkid
@ -1143,7 +1147,7 @@ class LoadBalancerRule:
apiclient.removeFromLoadBalancerRule(cmd)
return
def update(self, apiclient, algorithm=None, description=None, name=None):
def update(self, apiclient, algorithm=None, description=None, name=None, **kwargs):
"""Updates the load balancing rule"""
cmd = updateLoadBalancerRule.updateLoadBalancerRuleCmd()
cmd.id = self.id
@ -1154,8 +1158,40 @@ class LoadBalancerRule:
if name:
cmd.name = name
[setattr(cmd, k, v) for k, v in kwargs.items()]
return apiclient.updateLoadBalancerRule(cmd)
def createSticky(self, apiclient, methodname, name, description=None, param=None):
"""Creates a sticky policy for the LB rule"""
cmd = createLBStickinessPolicy.createLBStickinessPolicyCmd()
cmd.lbruleid = self.id
cmd.methodname = methodname
cmd.name = name
if description:
cmd.description = description
if param:
cmd.param = []
for name, value in param.items():
cmd.param.append({'name': name, 'value': value})
return apiclient.createLBStickinessPolicy(cmd)
def deleteSticky(self, apiclient, id):
"""Deletes stickyness policy"""
cmd = deleteLBStickinessPolicy.deleteLBStickinessPolicyCmd()
cmd.id = id
return apiclient.deleteLBStickinessPolicy(cmd)
@classmethod
def listStickyPolicies(cls, apiclient, lbruleid, **kwargs):
"""Lists stickiness policies for load balancing rule"""
cmd= listLBStickinessPolicies.listLBStickinessPoliciesCmd()
cmd.lbruleid = lbruleid
[setattr(cmd, k, v) for k, v in kwargs.items()]
return apiclient.listLBStickinessPolicies(cmd)
@classmethod
def list(cls, apiclient, **kwargs):
"""List all Load balancing rules matching criteria"""
@ -1404,6 +1440,15 @@ class Network:
[setattr(cmd, k, v) for k, v in kwargs.items()]
return(apiclient.updateNetwork(cmd))
def restart(self, apiclient, cleanup=None):
"""Restarts the network"""
cmd = restartNetwork.restartNetworkCmd()
cmd.id = self.id
if cleanup:
cmd.cleanup = cleanup
return(apiclient.restartNetwork(cmd))
@classmethod
def list(cls, apiclient, **kwargs):
"""List all Networks matching criteria"""

View File

@ -106,12 +106,12 @@ def download_systemplates_sec_storage(server, services):
try:
# Login to management server
ssh = remoteSSHClient.remoteSSHClient(
ssh = remoteSSHClient(
server["ipaddress"],
server["port"],
server["username"],
server["password"]
)
)
except Exception:
raise Exception("SSH access failted for server with IP address: %s" %
server["ipaddess"])

View File

@ -114,12 +114,7 @@ def is_server_ssh_ready(ipaddress, port, username, password, retries=50):
loop_cnt = retries
while True:
try:
ssh = remoteSSHClient.remoteSSHClient(
ipaddress,
port,
username,
password
)
ssh = remoteSSHClient(ipaddress, port, username, password)
except Exception as e:
if loop_cnt == 0:
raise e
@ -161,12 +156,7 @@ def get_process_status(hostip, port, username, password, linklocalip, process):
"""Double hop and returns a process status"""
#SSH to the machine
ssh = remoteSSHClient.remoteSSHClient(
hostip,
port,
username,
password
)
ssh = remoteSSHClient(hostip, port, username, password)
ssh_command = "ssh -i ~/.ssh/id_rsa.cloud -ostricthostkeychecking=no "
ssh_command = ssh_command + \
"-oUserKnownHostsFile=/dev/null -p 3922 %s %s" % (

View File

@ -34,7 +34,7 @@ class Services:
def __init__(self):
self.services = {
"ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9',
"ostypeid": '1a568aed-db2d-41ca-b644-416b0bdc067e',
# Cent OS 5.3 (64 bit)
"mode": 'advanced',
# Networking mode: Basic or advanced
@ -460,7 +460,7 @@ class TestPortForwarding(cloudstackTestCase):
"SSHing into VM with IP address %s after NAT rule deletion" %
self.virtual_machine.ipaddress)
remoteSSHClient.remoteSSHClient(
remoteSSHClient(
src_nat_ip_addr.ipaddress,
self.virtual_machine.ssh_port,
self.virtual_machine.username,
@ -576,7 +576,7 @@ class TestPortForwarding(cloudstackTestCase):
"SSHing into VM with IP address %s after NAT rule deletion" %
self.virtual_machine.ipaddress)
remoteSSHClient.remoteSSHClient(
remoteSSHClient(
ip_address.ipaddress.ipaddress,
self.virtual_machine.ssh_port,
self.virtual_machine.username,
@ -781,7 +781,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
(self.vm_1.ipaddress, src_nat_ip_addr.ipaddress)
)
ssh_1 = remoteSSHClient.remoteSSHClient(
ssh_1 = remoteSSHClient(
src_nat_ip_addr.ipaddress,
self.services['lbrule']["publicport"],
self.vm_1.username,
@ -806,7 +806,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
self.vm_2.id
))
ssh_2 = remoteSSHClient.remoteSSHClient(
ssh_2 = remoteSSHClient(
src_nat_ip_addr.ipaddress,
self.services['lbrule']["publicport"],
self.vm_1.username,
@ -839,7 +839,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
self.vm_2.id
))
ssh_1 = remoteSSHClient.remoteSSHClient(
ssh_1 = remoteSSHClient(
src_nat_ip_addr.ipaddress,
self.services['lbrule']["publicport"],
self.vm_1.username,
@ -862,7 +862,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
with self.assertRaises(Exception):
self.debug("Removed all VMs, trying to SSH")
ssh_1 = remoteSSHClient.remoteSSHClient(
ssh_1 = remoteSSHClient(
src_nat_ip_addr.ipaddress,
self.services['lbrule']["publicport"],
self.vm_1.username,
@ -972,7 +972,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
self.vm_1.id,
self.vm_2.id
))
ssh_1 = remoteSSHClient.remoteSSHClient(
ssh_1 = remoteSSHClient(
self.non_src_nat_ip.ipaddress.ipaddress,
self.services['lbrule']["publicport"],
self.vm_1.username,
@ -991,7 +991,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
self.vm_1.id,
self.vm_2.id
))
ssh_2 = remoteSSHClient.remoteSSHClient(
ssh_2 = remoteSSHClient(
self.non_src_nat_ip.ipaddress.ipaddress,
self.services['lbrule']["publicport"],
self.vm_1.username,
@ -1019,7 +1019,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
self.non_src_nat_ip.ipaddress.ipaddress,
self.vm_2.id
))
ssh_1 = remoteSSHClient.remoteSSHClient(
ssh_1 = remoteSSHClient(
self.non_src_nat_ip.ipaddress.ipaddress,
self.services['lbrule']["publicport"],
self.vm_1.username,
@ -1045,7 +1045,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
self.non_src_nat_ip.ipaddress.ipaddress,
self.vm_1.id
))
ssh_1 = remoteSSHClient.remoteSSHClient(
ssh_1 = remoteSSHClient(
self.non_src_nat_ip.ipaddress.ipaddress,
self.services['lbrule']["publicport"],
self.vm_1.username,
@ -1198,7 +1198,7 @@ class TestRebootRouter(cloudstackTestCase):
try:
self.debug("SSH into VM (ID : %s ) after reboot" % self.vm_1.id)
remoteSSHClient.remoteSSHClient(
remoteSSHClient(
self.nat_rule.ipaddress,
self.services["natrule"]["publicport"],
self.vm_1.username,
@ -1276,7 +1276,7 @@ class TestAssignRemoveLB(cloudstackTestCase):
]
return
def test_assign_and_removal_elb(self):
def test_assign_and_removal_lb(self):
"""Test for assign & removing load balancing rule"""
# Validate:
@ -1350,7 +1350,7 @@ class TestAssignRemoveLB(cloudstackTestCase):
self.vm_2.id
))
#Create SSH client for each VM
ssh_1 = remoteSSHClient.remoteSSHClient(
ssh_1 = remoteSSHClient(
self.non_src_nat_ip.ipaddress,
self.services["lbrule"]["publicport"],
self.vm_1.username,
@ -1367,7 +1367,7 @@ class TestAssignRemoveLB(cloudstackTestCase):
self.vm_1.id,
self.vm_2.id
))
ssh_2 = remoteSSHClient.remoteSSHClient(
ssh_2 = remoteSSHClient(
self.non_src_nat_ip.ipaddress,
self.services["lbrule"]["publicport"],
self.vm_2.username,
@ -1409,7 +1409,7 @@ class TestAssignRemoveLB(cloudstackTestCase):
self.vm_1.id,
))
# Again make a SSH connection, as previous is not used after LB remove
ssh_1 = remoteSSHClient.remoteSSHClient(
ssh_1 = remoteSSHClient(
self.non_src_nat_ip.ipaddress,
self.services["lbrule"]["publicport"],
self.vm_1.username,
@ -1431,13 +1431,13 @@ class TestAssignRemoveLB(cloudstackTestCase):
lb_rule.assign(self.apiclient, [self.vm_3])
try:
ssh_1 = remoteSSHClient.remoteSSHClient(
ssh_1 = remoteSSHClient(
self.non_src_nat_ip.ipaddress,
self.services["lbrule"]["publicport"],
self.vm_1.username,
self.vm_1.password
)
ssh_3 = remoteSSHClient.remoteSSHClient(
ssh_3 = remoteSSHClient(
self.non_src_nat_ip.ipaddress,
self.services["lbrule"]["publicport"],
self.vm_3.username,
@ -1602,7 +1602,7 @@ class TestReleaseIP(cloudstackTestCase):
# SSH Attempt though public IP should fail
with self.assertRaises(Exception):
ssh_2 = remoteSSHClient.remoteSSHClient(
ssh_2 = remoteSSHClient(
self.ip_addr.ipaddress,
self.services["natrule"]["publicport"],
self.virtual_machine.username,

View File

@ -45,7 +45,7 @@ class Services:
{
"displayname": "Test VM",
"username": "root",
"password": "fr3sca",
"password": "password",
"ssh_port": 22,
"hypervisor": 'XenServer',
"privateport": 22,
@ -57,9 +57,9 @@ class Services:
"firstname": "Test",
"lastname": "User",
"username": "testuser",
"password": "fr3sca",
"password": "password",
},
"ostypeid":'946b031b-0e10-4f4a-a3fc-d212ae2ea07f',
"ostypeid":'1a568aed-db2d-41ca-b644-416b0bdc067e',
"sleep": 60,
"timeout": 10,
"mode": 'advanced', #Networking mode: Basic, Advanced
@ -155,7 +155,7 @@ class TestRouterServices(cloudstackTestCase):
zoneid=router.zoneid,
type='Routing',
state='Up',
virtualmachineid=self.vm_1.id
id=router.hostid
)
self.assertEqual(
isinstance(hosts, list),
@ -217,7 +217,7 @@ class TestRouterServices(cloudstackTestCase):
zoneid=router.zoneid,
type='Routing',
state='Up',
virtualmachineid=self.vm_1.id
id=router.hostid
)
self.assertEqual(
isinstance(hosts, list),
@ -403,7 +403,7 @@ class TestRouterServices(cloudstackTestCase):
zoneid=router.zoneid,
type='Routing',
state='Up',
virtualmachineid=self.vm_1.id
id=router.hostid
)
self.assertEqual(
isinstance(hosts, list),

View File

@ -42,14 +42,6 @@ class Services:
"hypervisor": "XenServer",
"templatefilter": "self",
},
1: {
"hypervisor": "KVM",
"templatefilter": "self",
},
2: {
"hypervisor": "VMWare",
"templatefilter": "self",
},
},
"sleep": 60,
"timeout": 5,
@ -92,6 +84,7 @@ class TestSecStorageServices(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@unittest.skip("do not add secondary storage")
def test_01_add_sec_storage(self):
"""Test secondary storage
"""
@ -380,4 +373,4 @@ class TestSecStorageServices(cloudstackTestCase):
True,
"Check whether state of template is ready or not"
)
return
return

View File

@ -20,10 +20,10 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.remoteSSHClient import remoteSSHClient
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
class Services:

View File

@ -37,7 +37,7 @@ class Services:
self.services = {
"host": {
"username": 'root', # Credentials for SSH
"password": 'fr3sca',
"password": 'password',
"publicport": 22,
},
"sleep": 60,
@ -81,7 +81,6 @@ class TestSSVMs(cloudstackTestCase):
self.apiclient,
systemvmtype='secondarystoragevm',
state='Running',
zoneid=self.zone.id
)
self.assertEqual(
isinstance(list_ssvm_response, list),
@ -199,7 +198,6 @@ class TestSSVMs(cloudstackTestCase):
self.apiclient,
systemvmtype='consoleproxy',
state='Running',
zoneid=self.zone.id
)
self.assertEqual(
isinstance(list_cpvm_response, list),

View File

@ -20,7 +20,7 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
@ -45,7 +45,7 @@ class Services:
"username": "test",
# Random characters are appended in create account to
# ensure unique username generated each time
"password": "fr3sca",
"password": "password",
},
"small":
# Create a small virtual machine instance with disk offering
@ -87,7 +87,7 @@ class Services:
"name": "Small Instance",
"displaytext": "Small Instance",
"cpunumber": 1,
"cpuspeed": 500,
"cpuspeed": 100,
"memory": 256
},
"medium":
@ -97,17 +97,17 @@ class Services:
"name": "Medium Instance",
"displaytext": "Medium Instance",
"cpunumber": 1,
"cpuspeed": 1000,
"memory": 1024
"cpuspeed": 100,
"memory": 256
}
},
"iso": # ISO settings for Attach/Detach ISO tests
{
"displaytext": "Test ISO",
"name": "testISO",
"url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso",
"url": "http://nfs1.lab.vmops.com/isos_32bit/dsl-4.4.10.iso",
# Source URL where ISO is located
"ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9',
"ostypeid": '1a568aed-db2d-41ca-b644-416b0bdc067e',
"mode": 'HTTP_DOWNLOAD', # Downloading existing ISO
},
"template": {
@ -121,7 +121,7 @@ class Services:
"sleep": 60,
"timeout": 10,
#Migrate VM to hostid
"ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9',
"ostypeid": '1a568aed-db2d-41ca-b644-416b0bdc067e',
# CentOS 5.3 (64-bit)
"mode":'advanced',
}
@ -754,18 +754,15 @@ class TestVMLifeCycle(cloudstackTestCase):
True,
"Check the number of hosts in the zone"
)
self.assertEqual(
self.assertGreaterEqual(
len(hosts),
2,
"Atleast 2 hosts should be present in a zone for VM migration"
)
# Remove the host of current VM from the hosts list
hosts[:] = [host for host in hosts if host.id != self.medium_virtual_machine.hostid]
# Find the host of VM and also the new host to migrate VM.
if self.medium_virtual_machine.hostid == hosts[0].id:
host = hosts[1]
else:
host = hosts[0]
host = hosts[0]
self.debug("Migrating VM-ID: %s to Host: %s" % (
self.medium_virtual_machine.id,
host.id

View File

@ -20,10 +20,10 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.remoteSSHClient import remoteSSHClient
from integration.lib.utils import *
from integration.lib.base import *
from integration.lib.common import *
from marvin import remoteSSHClient
#Import System modules
import os
import urllib