You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2014/02/20 20:17:31 UTC
[25/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
CLOUDSTACK-4840: Adding first set of test cases for Multiple IPs per NIC feature
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/860b0209
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/860b0209
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/860b0209
Branch: refs/heads/ui-restyle
Commit: 860b02095087d5b8a6a32efd46992f89c1aa4c05
Parents: a369647
Author: Ashutosh K <as...@clogeny.com>
Authored: Tue Feb 18 15:51:57 2014 +0530
Committer: Girish Shilamkar <gi...@clogeny.com>
Committed: Tue Feb 18 15:51:57 2014 +0530
----------------------------------------------------------------------
tools/marvin/marvin/codes.py | 4 ++
tools/marvin/marvin/integration/lib/base.py | 29 +++++++++++
tools/marvin/marvin/integration/lib/common.py | 56 +++++++++++++++++++++-
3 files changed, 87 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/860b0209/tools/marvin/marvin/codes.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py
index 74fb05d..3882f0d 100644
--- a/tools/marvin/marvin/codes.py
+++ b/tools/marvin/marvin/codes.py
@@ -47,3 +47,7 @@ YES = "yes"
FAILED = "FAILED"
UNKNOWN_ERROR = "Unknown Error"
EXCEPTION = "EXCEPTION"
+BASIC_ZONE = "basic"
+ISOLATED_NETWORK = "ISOLATED"
+SHARED_NETWORK = "SHARED"
+VPC_NETWORK = "VPC"
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/860b0209/tools/marvin/marvin/integration/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py
index aa23029..1d8229d 100755
--- a/tools/marvin/marvin/integration/lib/base.py
+++ b/tools/marvin/marvin/integration/lib/base.py
@@ -3623,3 +3623,32 @@ class Resources:
cmd = updateResourceCount.updateResourceCountCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
return(apiclient.updateResourceCount(cmd))
+
+class NIC:
+ """NIC related API"""
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def addIp(cls, apiclient, id, ipaddress=None):
+ """Add Ip (secondary) to NIC"""
+ cmd = addIpToNic.addIpToNicCmd()
+ cmd.nicid = id
+ if ipaddress:
+ cmd.ipaddress = ipaddress
+ return(apiclient.addIpToNic(cmd))
+
+ @classmethod
+ def removeIp(cls,apiclient,ipaddressid):
+ """Remove secondary Ip from NIC"""
+ cmd = removeIpFromNic.removeIpFromNicCmd()
+ cmd.id = ipaddressid
+ return(apiclient.addIpToNic(cmd))
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List NICs belonging to a virtual machine"""
+
+ cmd = listNics.listNicsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNics(cmd))
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/860b0209/tools/marvin/marvin/integration/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py
index e202391..5b56c73 100644
--- a/tools/marvin/marvin/integration/lib/common.py
+++ b/tools/marvin/marvin/integration/lib/common.py
@@ -63,13 +63,14 @@ from marvin.integration.lib.base import (Configurations,
Resources,
PhysicalNetwork,
Host,
- PublicIPAddress)
+ PublicIPAddress,
+ NetworkOffering)
from marvin.integration.lib.utils import (get_process_status,
xsplit,
validateList)
from marvin.sshClient import SshClient
-from marvin.codes import PASS
+from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, BASIC_ZONE, FAIL
import random
#Import System modules
@@ -917,3 +918,54 @@ def is_public_ip_in_correct_state(apiclient, ipaddressid, state):
time.sleep(60)
continue
return True
+
+def setSharedNetworkParams(networkServices, range=20):
+ """Fill up the services dictionary for shared network using random subnet"""
+
+ # @range: range decides the endip. Pass the range as "x" if you want the difference between the startip
+ # and endip as "x"
+ # Set the subnet number of shared networks randomly prior to execution
+ # of each test case to avoid overlapping of ip addresses
+ shared_network_subnet_number = random.randrange(1,254)
+
+ networkServices["gateway"] = "172.16."+str(shared_network_subnet_number)+".1"
+ networkServices["startip"] = "172.16."+str(shared_network_subnet_number)+".2"
+ networkServices["endip"] = "172.16."+str(shared_network_subnet_number)+"."+str(range+1)
+ networkServices["netmask"] = "255.255.255.0"
+ return networkServices
+
+def createEnabledNetworkOffering(apiclient, networkServices):
+ """Create and enable network offering according to the type
+
+ @output: List, containing [ Result,Network Offering,Reason ]
+ Ist Argument('Result') : FAIL : If exception or assertion error occurs
+ PASS : If network offering
+ is created and enabled successfully
+ IInd Argument(Net Off) : Enabled network offering
+ In case of exception or
+ assertion error, it will be None
+ IIIrd Argument(Reason) : Reason for failure,
+ default to None
+ """
+ try:
+ resultSet = [FAIL, None, None]
+ # Create network offering
+ network_offering = NetworkOffering.create(apiclient, networkServices, conservemode=False)
+
+ # Update network offering state from disabled to enabled.
+ NetworkOffering.update(network_offering, apiclient, id=network_offering.id,
+ state="enabled")
+ except Exception as e:
+ resultSet[2] = e
+ return resultSet
+ return [PASS, network_offering, None]
+
+def shouldTestBeSkipped(networkType, zoneType):
+ """Decide which test to skip, according to type of network and zone type"""
+
+ # If network type is isolated or vpc and zone type is basic, then test should be skipped
+ skipIt = False
+ if ((networkType.lower() == str(ISOLATED_NETWORK).lower() or networkType.lower() == str(VPC_NETWORK).lower())
+ and (zoneType.lower() == BASIC_ZONE)):
+ skipIt = True
+ return skipIt