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

This commit is contained in:
Chirag Jog 2012-06-06 12:29:55 +05:30
parent 13f2e71530
commit cdc196b1b8
23 changed files with 115 additions and 91 deletions

View File

@ -19,7 +19,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

@ -21,7 +21,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

@ -18,7 +18,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

@ -21,7 +21,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
@ -168,7 +168,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

@ -21,7 +21,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
@ -1576,7 +1576,7 @@ class TestNetworkUpgrade(cloudstackTestCase):
vpns = Vpn.list(
self.apiclient,
publicipid=src_nat.id,
listall=True,
listall=True,
)
self.assertEqual(

View File

@ -20,7 +20,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,7 +20,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

@ -20,7 +20,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

@ -17,10 +17,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
@ -77,6 +77,7 @@ class Services:
# Algorithm used for load balancing
"privateport": 22,
"publicport": 2222,
"protocol": 'TCP',
},
"fw_rule":{
"startport": 1,

View File

@ -18,10 +18,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

@ -20,7 +20,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

@ -20,7 +20,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

@ -20,7 +20,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

@ -598,7 +598,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
@ -690,10 +692,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
@ -725,12 +729,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
@ -1140,7 +1144,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
@ -1151,8 +1155,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"""
@ -1401,6 +1437,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

@ -18,7 +18,7 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
from utils import *
from base import *
@ -103,12 +103,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

@ -16,7 +16,7 @@
import marvin
import time
from marvin import remoteSSHClient
from marvin.remoteSSHClient import remoteSSHClient
from marvin.cloudstackAPI import *
from marvin import cloudstackConnection
#from cloudstackConnection import cloudConnection
@ -111,12 +111,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
@ -158,12 +153,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

@ -31,7 +31,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
@ -457,7 +457,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,
@ -573,7 +573,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,
@ -778,7 +778,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,
@ -803,7 +803,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,
@ -836,7 +836,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,
@ -859,7 +859,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,
@ -969,7 +969,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,
@ -988,7 +988,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,
@ -1016,7 +1016,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,
@ -1042,7 +1042,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,
@ -1195,7 +1195,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,
@ -1273,7 +1273,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:
@ -1347,7 +1347,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,
@ -1364,7 +1364,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,
@ -1406,7 +1406,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,
@ -1428,13 +1428,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,
@ -1599,7 +1599,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

@ -42,7 +42,7 @@ class Services:
{
"displayname": "Test VM",
"username": "root",
"password": "fr3sca",
"password": "password",
"ssh_port": 22,
"hypervisor": 'XenServer',
"privateport": 22,
@ -54,9 +54,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
@ -152,7 +152,7 @@ class TestRouterServices(cloudstackTestCase):
zoneid=router.zoneid,
type='Routing',
state='Up',
virtualmachineid=self.vm_1.id
id=router.hostid
)
self.assertEqual(
isinstance(hosts, list),
@ -214,7 +214,7 @@ class TestRouterServices(cloudstackTestCase):
zoneid=router.zoneid,
type='Routing',
state='Up',
virtualmachineid=self.vm_1.id
id=router.hostid
)
self.assertEqual(
isinstance(hosts, list),
@ -400,7 +400,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

@ -39,14 +39,6 @@ class Services:
"hypervisor": "XenServer",
"templatefilter": "self",
},
1: {
"hypervisor": "KVM",
"templatefilter": "self",
},
2: {
"hypervisor": "VMWare",
"templatefilter": "self",
},
},
"sleep": 60,
"timeout": 5,
@ -89,6 +81,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
"""
@ -377,4 +370,4 @@ class TestSecStorageServices(cloudstackTestCase):
True,
"Check whether state of template is ready or not"
)
return
return

View File

@ -17,10 +17,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

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

View File

@ -17,7 +17,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 *
@ -42,7 +42,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
@ -84,7 +84,7 @@ class Services:
"name": "Small Instance",
"displaytext": "Small Instance",
"cpunumber": 1,
"cpuspeed": 500,
"cpuspeed": 100,
"memory": 256
},
"medium":
@ -94,17 +94,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": {
@ -118,7 +118,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',
}
@ -751,18 +751,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

@ -17,10 +17,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