CLOUDSTACK-8915 - Adding logging to tests

This commit is contained in:
Wilder Rodrigues 2015-10-01 10:46:54 +02:00
parent 7c7c0149b2
commit 5f79916eea
3 changed files with 72 additions and 60 deletions

View File

@ -52,7 +52,7 @@ class TestCreatePFOnStoppedRouter(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.testClient = super(TestRouterStopCreatePF, cls).getClsTestClient() cls.testClient = super(TestCreatePFOnStoppedRouter, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient() cls.api_client = cls.testClient.getApiClient()
cls.services = cls.testClient.getParsedTestDataConfig() cls.services = cls.testClient.getParsedTestDataConfig()
@ -96,7 +96,7 @@ class TestCreatePFOnStoppedRouter(cloudstackTestCase):
def tearDownClass(cls): def tearDownClass(cls):
try: try:
cls.api_client = super( cls.api_client = super(
TestRouterStopCreatePF, TestCreatePFOnStoppedRouter,
cls).getClsTestClient().getApiClient() cls).getClsTestClient().getApiClient()
# Clean up, terminate the created resources # Clean up, terminate the created resources
cleanup_resources(cls.api_client, cls._cleanup) cleanup_resources(cls.api_client, cls._cleanup)
@ -258,7 +258,7 @@ class TestCreateLBOnStoppedRouter(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.testClient = super(TestRouterStopCreateLB, cls).getClsTestClient() cls.testClient = super(TestCreateLBOnStoppedRouter, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient() cls.api_client = cls.testClient.getApiClient()
cls.services = cls.testClient.getParsedTestDataConfig() cls.services = cls.testClient.getParsedTestDataConfig()
@ -302,7 +302,7 @@ class TestCreateLBOnStoppedRouter(cloudstackTestCase):
def tearDownClass(cls): def tearDownClass(cls):
try: try:
cls.api_client = super( cls.api_client = super(
TestRouterStopCreateLB, TestCreateLBOnStoppedRouter,
cls).getClsTestClient().getApiClient() cls).getClsTestClient().getApiClient()
# Clean up, terminate the created resources # Clean up, terminate the created resources
cleanup_resources(cls.api_client, cls._cleanup) cleanup_resources(cls.api_client, cls._cleanup)
@ -467,7 +467,7 @@ class TestCreateFWOnStoppedRouter(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.testClient = super(TestRouterStopCreateFW, cls).getClsTestClient() cls.testClient = super(TestCreateFWOnStoppedRouter, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient() cls.api_client = cls.testClient.getApiClient()
cls.services = cls.testClient.getParsedTestDataConfig() cls.services = cls.testClient.getParsedTestDataConfig()
@ -510,7 +510,7 @@ class TestCreateFWOnStoppedRouter(cloudstackTestCase):
def tearDownClass(cls): def tearDownClass(cls):
try: try:
cls.api_client = super( cls.api_client = super(
TestRouterStopCreateFW, TestCreateFWOnStoppedRouter,
cls).getClsTestClient().getApiClient() cls).getClsTestClient().getApiClient()
# Clean up, terminate the created templates # Clean up, terminate the created templates
cleanup_resources(cls.api_client, cls._cleanup) cleanup_resources(cls.api_client, cls._cleanup)

View File

@ -41,7 +41,7 @@ from marvin.lib.utils import cleanup_resources
import socket import socket
import time import time
import inspect import inspect
import logging
class Services: class Services:
"""Test VPC network services - Port Forwarding Rules Test Data Class. """Test VPC network services - Port Forwarding Rules Test Data Class.
@ -215,6 +215,12 @@ class TestVPCRedundancy(cloudstackTestCase):
cls.api_client, cls.api_client,
cls.services["service_offering"]) cls.services["service_offering"])
cls._cleanup = [cls.service_offering] cls._cleanup = [cls.service_offering]
cls.logger = logging.getLogger('TestVPCRedundancy')
cls.stream_handler = logging.StreamHandler()
cls.logger.setLevel(logging.DEBUG)
cls.logger.addHandler(cls.stream_handler)
return return
@classmethod @classmethod
@ -237,15 +243,15 @@ class TestVPCRedundancy(cloudstackTestCase):
domainid=self.domain.id) domainid=self.domain.id)
self._cleanup = [self.account] self._cleanup = [self.account]
self.debug("Creating a VPC offering..") self.logger.debug("Creating a VPC offering..")
self.vpc_off = VpcOffering.create( self.vpc_off = VpcOffering.create(
self.apiclient, self.apiclient,
self.services["vpc_offering"]) self.services["vpc_offering"])
self.debug("Enabling the VPC offering created") self.logger.debug("Enabling the VPC offering created")
self.vpc_off.update(self.apiclient, state='Enabled') self.vpc_off.update(self.apiclient, state='Enabled')
self.debug("Creating a VPC network in the account: %s" % self.account.name) self.logger.debug("Creating a VPC network in the account: %s" % self.account.name)
self.services["vpc"]["cidr"] = '10.1.1.1/16' self.services["vpc"]["cidr"] = '10.1.1.1/16'
self.vpc = VPC.create( self.vpc = VPC.create(
self.apiclient, self.apiclient,
@ -283,7 +289,7 @@ class TestVPCRedundancy(cloudstackTestCase):
def stop_router(self, type): def stop_router(self, type):
self.check_master_status(2) self.check_master_status(2)
self.debug('Stopping %s router' % type) self.logger.debug('Stopping %s router' % type)
for router in self.routers: for router in self.routers:
if router.redundantstate == type: if router.redundantstate == type:
cmd = stopRouter.stopRouterCmd() cmd = stopRouter.stopRouterCmd()
@ -292,18 +298,18 @@ class TestVPCRedundancy(cloudstackTestCase):
def start_router(self): def start_router(self):
self.check_master_status(2, showall=True) self.check_master_status(2, showall=True)
self.debug('Starting stopped routers') self.logger.debug('Starting stopped routers')
for router in self.routers: for router in self.routers:
self.debug('Router %s has state %s' % (router.id, router.state)) self.logger.debug('Router %s has state %s' % (router.id, router.state))
if router.state == "Stopped": if router.state == "Stopped":
self.debug('Starting stopped router %s' % router.id) self.logger.debug('Starting stopped router %s' % router.id)
cmd = startRouter.startRouterCmd() cmd = startRouter.startRouterCmd()
cmd.id = router.id cmd.id = router.id
self.apiclient.startRouter(cmd) self.apiclient.startRouter(cmd)
def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None): def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None):
try: try:
self.debug('Create NetworkOffering') self.logger.debug('Create NetworkOffering')
net_offerring["name"] = "NET_OFF-" + str(gateway) net_offerring["name"] = "NET_OFF-" + str(gateway)
nw_off = NetworkOffering.create( nw_off = NetworkOffering.create(
self.apiclient, self.apiclient,
@ -311,10 +317,10 @@ class TestVPCRedundancy(cloudstackTestCase):
conservemode=False) conservemode=False)
nw_off.update(self.apiclient, state='Enabled') nw_off.update(self.apiclient, state='Enabled')
self.debug('Created and Enabled NetworkOffering') self.logger.debug('Created and Enabled NetworkOffering')
self.services["network"]["name"] = "NETWORK-" + str(gateway) self.services["network"]["name"] = "NETWORK-" + str(gateway)
self.debug('Adding Network=%s' % self.services["network"]) self.logger.debug('Adding Network=%s' % self.services["network"])
obj_network = Network.create( obj_network = Network.create(
self.apiclient, self.apiclient,
self.services["network"], self.services["network"],
@ -326,7 +332,7 @@ class TestVPCRedundancy(cloudstackTestCase):
vpcid=vpc.id if vpc else self.vpc.id vpcid=vpc.id if vpc else self.vpc.id
) )
self.debug("Created network with ID: %s" % obj_network.id) self.logger.debug("Created network with ID: %s" % obj_network.id)
except Exception, e: except Exception, e:
self.fail('Unable to create a Network with offering=%s because of %s ' % (net_offerring, e)) self.fail('Unable to create a Network with offering=%s because of %s ' % (net_offerring, e))
o = networkO(obj_network) o = networkO(obj_network)
@ -336,7 +342,7 @@ class TestVPCRedundancy(cloudstackTestCase):
def deployvm_in_network(self, network, host_id=None): def deployvm_in_network(self, network, host_id=None):
try: try:
self.debug('Creating VM in network=%s' % network.name) self.logger.debug('Creating VM in network=%s' % network.name)
vm = VirtualMachine.create( vm = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
@ -346,13 +352,13 @@ class TestVPCRedundancy(cloudstackTestCase):
networkids=[str(network.id)], networkids=[str(network.id)],
hostid=host_id hostid=host_id
) )
self.debug('Created VM=%s in network=%s' % (vm.id, network.name)) self.logger.debug('Created VM=%s in network=%s' % (vm.id, network.name))
return vm return vm
except: except:
self.fail('Unable to create VM in a Network=%s' % network.name) self.fail('Unable to create VM in a Network=%s' % network.name)
def acquire_publicip(self, network): def acquire_publicip(self, network):
self.debug("Associating public IP for network: %s" % network.name) self.logger.debug("Associating public IP for network: %s" % network.name)
public_ip = PublicIPAddress.create( public_ip = PublicIPAddress.create(
self.apiclient, self.apiclient,
accountid=self.account.name, accountid=self.account.name,
@ -361,14 +367,14 @@ class TestVPCRedundancy(cloudstackTestCase):
networkid=network.id, networkid=network.id,
vpcid=self.vpc.id vpcid=self.vpc.id
) )
self.debug("Associated %s with network %s" % ( self.logger.debug("Associated %s with network %s" % (
public_ip.ipaddress.ipaddress, public_ip.ipaddress.ipaddress,
network.id network.id
)) ))
return public_ip return public_ip
def create_natrule(self, vm, public_ip, network, services=None): def create_natrule(self, vm, public_ip, network, services=None):
self.debug("Creating NAT rule in network for vm with public IP") self.logger.debug("Creating NAT rule in network for vm with public IP")
if not services: if not services:
services = self.services["natrule"] services = self.services["natrule"]
nat_rule = NATRule.create( nat_rule = NATRule.create(
@ -380,18 +386,18 @@ class TestVPCRedundancy(cloudstackTestCase):
networkid=network.id, networkid=network.id,
vpcid=self.vpc.id) vpcid=self.vpc.id)
self.debug("Adding NetworkACL rules to make NAT rule accessible") self.logger.debug("Adding NetworkACL rules to make NAT rule accessible")
nwacl_nat = NetworkACL.create( nwacl_nat = NetworkACL.create(
self.apiclient, self.apiclient,
networkid=network.id, networkid=network.id,
services=services, services=services,
traffictype='Ingress' traffictype='Ingress'
) )
self.debug('nwacl_nat=%s' % nwacl_nat.__dict__) self.logger.debug('nwacl_nat=%s' % nwacl_nat.__dict__)
return nat_rule return nat_rule
def check_ssh_into_vm(self, vm, public_ip, expectFail=False, retries=20): def check_ssh_into_vm(self, vm, public_ip, expectFail=False, retries=20):
self.debug("Checking if we can SSH into VM=%s on public_ip=%s (%r)" % self.logger.debug("Checking if we can SSH into VM=%s on public_ip=%s (%r)" %
(vm.name, public_ip.ipaddress.ipaddress, expectFail)) (vm.name, public_ip.ipaddress.ipaddress, expectFail))
vm.ssh_client = None vm.ssh_client = None
try: try:
@ -403,18 +409,18 @@ class TestVPCRedundancy(cloudstackTestCase):
self.fail("SSH into VM=%s on public_ip=%s is successful (Not Expected)" % self.fail("SSH into VM=%s on public_ip=%s is successful (Not Expected)" %
(vm.name, public_ip.ipaddress.ipaddress)) (vm.name, public_ip.ipaddress.ipaddress))
else: else:
self.debug("SSH into VM=%s on public_ip=%s is successful" % self.logger.debug("SSH into VM=%s on public_ip=%s is successful" %
(vm.name, public_ip.ipaddress.ipaddress)) (vm.name, public_ip.ipaddress.ipaddress))
except: except:
if expectFail: if expectFail:
self.debug("Failed to SSH into VM - %s (Expected)" % (public_ip.ipaddress.ipaddress)) self.logger.debug("Failed to SSH into VM - %s (Expected)" % (public_ip.ipaddress.ipaddress))
else: else:
self.fail("Failed to SSH into VM - %s" % (public_ip.ipaddress.ipaddress)) self.fail("Failed to SSH into VM - %s" % (public_ip.ipaddress.ipaddress))
@attr(tags=["advanced", "intervlan"], required_hardware="true") @attr(tags=["advanced", "intervlan"], required_hardware="true")
def test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL(self): def test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL(self):
""" Create a redundant VPC with two networks with two VMs in each network """ """ Create a redundant VPC with two networks with two VMs in each network """
self.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL") self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
self.query_routers() self.query_routers()
self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1")) self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1")) self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
@ -443,7 +449,7 @@ class TestVPCRedundancy(cloudstackTestCase):
@attr(tags=["advanced", "intervlan"], required_hardware="true") @attr(tags=["advanced", "intervlan"], required_hardware="true")
def test_02_redundant_VPC_default_routes(self): def test_02_redundant_VPC_default_routes(self):
""" Create a redundant VPC with two networks with two VMs in each network and check default routes""" """ Create a redundant VPC with two networks with two VMs in each network and check default routes"""
self.debug("Starting test_02_redundant_VPC_default_routes") self.logger.debug("Starting test_02_redundant_VPC_default_routes")
self.query_routers() self.query_routers()
self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1")) self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1")) self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
@ -487,14 +493,14 @@ class TestVPCRedundancy(cloudstackTestCase):
try: try:
vm = vmObj.get_vm() vm = vmObj.get_vm()
public_ip = vmObj.get_ip() public_ip = vmObj.get_ip()
self.debug("SSH into VM: %s" % public_ip.ipaddress.ipaddress) self.logger.debug("SSH into VM: %s" % public_ip.ipaddress.ipaddress)
ssh = vm.get_ssh_client(ipaddress=public_ip.ipaddress.ipaddress) ssh = vm.get_ssh_client(ipaddress=public_ip.ipaddress.ipaddress)
self.debug("Ping to google.com from VM") self.logger.debug("Ping to google.com from VM")
result = ssh.execute(ssh_command) result = str(ssh.execute(ssh_command))
self.debug("SSH result: %s" % str(result)) self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count("0% packet loss")))
except Exception as e: except Exception as e:
self.fail("SSH Access failed for %s: %s" % \ self.fail("SSH Access failed for %s: %s" % \
(vmObj.get_ip(), e) (vmObj.get_ip(), e)

View File

@ -41,7 +41,7 @@ from marvin.lib.utils import cleanup_resources
import socket import socket
import time import time
import inspect import inspect
import logging
class Services: class Services:
"""Test VPC network services - Port Forwarding Rules Test Data Class. """Test VPC network services - Port Forwarding Rules Test Data Class.
@ -197,6 +197,12 @@ class TestVPCNics(cloudstackTestCase):
cls.api_client, cls.api_client,
cls.services["service_offering"]) cls.services["service_offering"])
cls._cleanup = [cls.service_offering] cls._cleanup = [cls.service_offering]
cls.logger = logging.getLogger('TestVPCNics')
cls.stream_handler = logging.StreamHandler()
cls.logger.setLevel(logging.DEBUG)
cls.logger.addHandler(cls.stream_handler)
return return
@classmethod @classmethod
@ -219,15 +225,15 @@ class TestVPCNics(cloudstackTestCase):
domainid=self.domain.id) domainid=self.domain.id)
self.cleanup = [self.account] self.cleanup = [self.account]
self.debug("Creating a VPC offering..") self.logger.debug("Creating a VPC offering..")
self.vpc_off = VpcOffering.create( self.vpc_off = VpcOffering.create(
self.apiclient, self.apiclient,
self.services["vpc_offering"]) self.services["vpc_offering"])
self.debug("Enabling the VPC offering created") self.logger.debug("Enabling the VPC offering created")
self.vpc_off.update(self.apiclient, state='Enabled') self.vpc_off.update(self.apiclient, state='Enabled')
self.debug("Creating a VPC network in the account: %s" % self.account.name) self.logger.debug("Creating a VPC network in the account: %s" % self.account.name)
self.services["vpc"]["cidr"] = '10.1.1.1/16' self.services["vpc"]["cidr"] = '10.1.1.1/16'
self.vpc = VPC.create( self.vpc = VPC.create(
self.apiclient, self.apiclient,
@ -242,7 +248,7 @@ class TestVPCNics(cloudstackTestCase):
try: try:
cleanup_resources(self.apiclient, self.cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e) self.logger.debug("Warning: Exception during cleanup : %s" % e)
return return
def query_routers(self): def query_routers(self):
@ -256,14 +262,14 @@ class TestVPCNics(cloudstackTestCase):
"Check for list routers response return valid data") "Check for list routers response return valid data")
def stop_router(self): def stop_router(self):
self.debug('Stopping router') self.logger.debug('Stopping router')
for router in self.routers: for router in self.routers:
cmd = stopRouter.stopRouterCmd() cmd = stopRouter.stopRouterCmd()
cmd.id = router.id cmd.id = router.id
self.apiclient.stopRouter(cmd) self.apiclient.stopRouter(cmd)
def destroy_router(self): def destroy_router(self):
self.debug('Stopping router') self.logger.debug('Stopping router')
for router in self.routers: for router in self.routers:
cmd = destroyRouter.destroyRouterCmd() cmd = destroyRouter.destroyRouterCmd()
cmd.id = router.id cmd.id = router.id
@ -271,7 +277,7 @@ class TestVPCNics(cloudstackTestCase):
def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None): def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None):
try: try:
self.debug('Create NetworkOffering') self.logger.debug('Create NetworkOffering')
net_offerring["name"] = "NET_OFF-" + str(gateway) net_offerring["name"] = "NET_OFF-" + str(gateway)
nw_off = NetworkOffering.create( nw_off = NetworkOffering.create(
self.apiclient, self.apiclient,
@ -279,10 +285,10 @@ class TestVPCNics(cloudstackTestCase):
conservemode=False) conservemode=False)
nw_off.update(self.apiclient, state='Enabled') nw_off.update(self.apiclient, state='Enabled')
self.debug('Created and Enabled NetworkOffering') self.logger.debug('Created and Enabled NetworkOffering')
self.services["network"]["name"] = "NETWORK-" + str(gateway) self.services["network"]["name"] = "NETWORK-" + str(gateway)
self.debug('Adding Network=%s' % self.services["network"]) self.logger.debug('Adding Network=%s' % self.services["network"])
obj_network = Network.create( obj_network = Network.create(
self.apiclient, self.apiclient,
self.services["network"], self.services["network"],
@ -294,7 +300,7 @@ class TestVPCNics(cloudstackTestCase):
vpcid=vpc.id if vpc else self.vpc.id vpcid=vpc.id if vpc else self.vpc.id
) )
self.debug("Created network with ID: %s" % obj_network.id) self.logger.debug("Created network with ID: %s" % obj_network.id)
except Exception, e: except Exception, e:
self.fail('Unable to create a Network with offering=%s because of %s ' % (net_offerring, e)) self.fail('Unable to create a Network with offering=%s because of %s ' % (net_offerring, e))
o = networkO(obj_network) o = networkO(obj_network)
@ -303,7 +309,7 @@ class TestVPCNics(cloudstackTestCase):
def deployvm_in_network(self, network): def deployvm_in_network(self, network):
try: try:
self.debug('Creating VM in network=%s' % network.name) self.logger.debug('Creating VM in network=%s' % network.name)
vm = VirtualMachine.create( vm = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
@ -312,13 +318,13 @@ class TestVPCNics(cloudstackTestCase):
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
networkids=[str(network.id)] networkids=[str(network.id)]
) )
self.debug('Created VM=%s in network=%s' % (vm.id, network.name)) self.logger.debug('Created VM=%s in network=%s' % (vm.id, network.name))
return vm return vm
except: except:
self.fail('Unable to create VM in a Network=%s' % network.name) self.fail('Unable to create VM in a Network=%s' % network.name)
def acquire_publicip(self, network): def acquire_publicip(self, network):
self.debug("Associating public IP for network: %s" % network.name) self.logger.debug("Associating public IP for network: %s" % network.name)
public_ip = PublicIPAddress.create( public_ip = PublicIPAddress.create(
self.apiclient, self.apiclient,
accountid=self.account.name, accountid=self.account.name,
@ -327,14 +333,14 @@ class TestVPCNics(cloudstackTestCase):
networkid=network.id, networkid=network.id,
vpcid=self.vpc.id vpcid=self.vpc.id
) )
self.debug("Associated %s with network %s" % ( self.logger.debug("Associated %s with network %s" % (
public_ip.ipaddress.ipaddress, public_ip.ipaddress.ipaddress,
network.id network.id
)) ))
return public_ip return public_ip
def create_natrule(self, vm, public_ip, network, services=None): def create_natrule(self, vm, public_ip, network, services=None):
self.debug("Creating NAT rule in network for vm with public IP") self.logger.debug("Creating NAT rule in network for vm with public IP")
if not services: if not services:
services = self.services["natrule"] services = self.services["natrule"]
nat_rule = NATRule.create( nat_rule = NATRule.create(
@ -346,23 +352,23 @@ class TestVPCNics(cloudstackTestCase):
networkid=network.id, networkid=network.id,
vpcid=self.vpc.id) vpcid=self.vpc.id)
self.debug("Adding NetworkACL rules to make NAT rule accessible") self.logger.debug("Adding NetworkACL rules to make NAT rule accessible")
nwacl_nat = NetworkACL.create( nwacl_nat = NetworkACL.create(
self.apiclient, self.apiclient,
networkid=network.id, networkid=network.id,
services=services, services=services,
traffictype='Ingress' traffictype='Ingress'
) )
self.debug('nwacl_nat=%s' % nwacl_nat.__dict__) self.logger.debug('nwacl_nat=%s' % nwacl_nat.__dict__)
return nat_rule return nat_rule
def check_ssh_into_vm(self, vm, public_ip): def check_ssh_into_vm(self, vm, public_ip):
self.debug("Checking if we can SSH into VM=%s on public_ip=%s" % self.logger.debug("Checking if we can SSH into VM=%s on public_ip=%s" %
(vm.name, public_ip.ipaddress.ipaddress)) (vm.name, public_ip.ipaddress.ipaddress))
vm.ssh_client = None vm.ssh_client = None
try: try:
vm.get_ssh_client(ipaddress=public_ip.ipaddress.ipaddress) vm.get_ssh_client(ipaddress=public_ip.ipaddress.ipaddress)
self.debug("SSH into VM=%s on public_ip=%s is successful" % self.logger.debug("SSH into VM=%s on public_ip=%s is successful" %
(vm.name, public_ip.ipaddress.ipaddress)) (vm.name, public_ip.ipaddress.ipaddress))
except: except:
self.fail("Failed to SSH into VM - %s" % (public_ip.ipaddress.ipaddress)) self.fail("Failed to SSH into VM - %s" % (public_ip.ipaddress.ipaddress))
@ -370,7 +376,7 @@ class TestVPCNics(cloudstackTestCase):
@attr(tags=["advanced", "intervlan"], required_hardware="true") @attr(tags=["advanced", "intervlan"], required_hardware="true")
def test_01_VPC_nics_after_destroy(self): def test_01_VPC_nics_after_destroy(self):
""" Create a VPC with two networks with one VM in each network and test nics after destroy""" """ Create a VPC with two networks with one VM in each network and test nics after destroy"""
self.debug("Starting test_01_VPC_nics_after_destroy") self.logger.debug("Starting test_01_VPC_nics_after_destroy")
self.query_routers() self.query_routers()
net1 = self.create_network(self.services["network_offering"], "10.1.1.1") net1 = self.create_network(self.services["network_offering"], "10.1.1.1")
@ -393,7 +399,7 @@ class TestVPCNics(cloudstackTestCase):
@attr(tags=["advanced", "intervlan"], required_hardware="true") @attr(tags=["advanced", "intervlan"], required_hardware="true")
def test_02_VPC_default_routes(self): def test_02_VPC_default_routes(self):
""" Create a VPC with two networks with one VM in each network and test default routes""" """ Create a VPC with two networks with one VM in each network and test default routes"""
self.debug("Starting test_02_VPC_default_routes") self.logger.debug("Starting test_02_VPC_default_routes")
self.query_routers() self.query_routers()
net1 = self.create_network(self.services["network_offering"], "10.1.1.1") net1 = self.create_network(self.services["network_offering"], "10.1.1.1")
@ -436,14 +442,14 @@ class TestVPCNics(cloudstackTestCase):
try: try:
vm = vmObj.get_vm() vm = vmObj.get_vm()
public_ip = vmObj.get_ip() public_ip = vmObj.get_ip()
self.debug("SSH into VM: %s" % public_ip.ipaddress.ipaddress) self.logger.debug("SSH into VM: %s" % public_ip.ipaddress.ipaddress)
ssh = vm.get_ssh_client(ipaddress=public_ip.ipaddress.ipaddress) ssh = vm.get_ssh_client(ipaddress=public_ip.ipaddress.ipaddress)
self.debug("Ping to google.com from VM") self.logger.debug("Ping to google.com from VM")
result = ssh.execute(ssh_command) result = str(ssh.execute(ssh_command))
self.debug("SSH result: %s" % str(result)) self.logger.debug("SSH result: %s; COUNT is ==> %s" % (result, result.count("0% packet loss")))
except Exception as e: except Exception as e:
self.fail("SSH Access failed for %s: %s" % \ self.fail("SSH Access failed for %s: %s" % \
(vmObj.get_ip(), e) (vmObj.get_ip(), e)