|
63 | 63 | Resources, |
64 | 64 | PhysicalNetwork, |
65 | 65 | Host, |
66 | | - PublicIPAddress) |
| 66 | + PublicIPAddress, |
| 67 | + NetworkOffering) |
67 | 68 | from marvin.integration.lib.utils import (get_process_status, |
68 | 69 | xsplit, |
69 | 70 | validateList) |
70 | 71 |
|
71 | 72 | from marvin.sshClient import SshClient |
72 | | -from marvin.codes import PASS |
| 73 | +from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, BASIC_ZONE, FAIL |
73 | 74 | import random |
74 | 75 |
|
75 | 76 | #Import System modules |
@@ -917,3 +918,54 @@ def is_public_ip_in_correct_state(apiclient, ipaddressid, state): |
917 | 918 | time.sleep(60) |
918 | 919 | continue |
919 | 920 | return True |
| 921 | + |
| 922 | +def setSharedNetworkParams(networkServices, range=20): |
| 923 | + """Fill up the services dictionary for shared network using random subnet""" |
| 924 | + |
| 925 | + # @range: range decides the endip. Pass the range as "x" if you want the difference between the startip |
| 926 | + # and endip as "x" |
| 927 | + # Set the subnet number of shared networks randomly prior to execution |
| 928 | + # of each test case to avoid overlapping of ip addresses |
| 929 | + shared_network_subnet_number = random.randrange(1,254) |
| 930 | + |
| 931 | + networkServices["gateway"] = "172.16."+str(shared_network_subnet_number)+".1" |
| 932 | + networkServices["startip"] = "172.16."+str(shared_network_subnet_number)+".2" |
| 933 | + networkServices["endip"] = "172.16."+str(shared_network_subnet_number)+"."+str(range+1) |
| 934 | + networkServices["netmask"] = "255.255.255.0" |
| 935 | + return networkServices |
| 936 | + |
| 937 | +def createEnabledNetworkOffering(apiclient, networkServices): |
| 938 | + """Create and enable network offering according to the type |
| 939 | +
|
| 940 | + @output: List, containing [ Result,Network Offering,Reason ] |
| 941 | + Ist Argument('Result') : FAIL : If exception or assertion error occurs |
| 942 | + PASS : If network offering |
| 943 | + is created and enabled successfully |
| 944 | + IInd Argument(Net Off) : Enabled network offering |
| 945 | + In case of exception or |
| 946 | + assertion error, it will be None |
| 947 | + IIIrd Argument(Reason) : Reason for failure, |
| 948 | + default to None |
| 949 | + """ |
| 950 | + try: |
| 951 | + resultSet = [FAIL, None, None] |
| 952 | + # Create network offering |
| 953 | + network_offering = NetworkOffering.create(apiclient, networkServices, conservemode=False) |
| 954 | + |
| 955 | + # Update network offering state from disabled to enabled. |
| 956 | + NetworkOffering.update(network_offering, apiclient, id=network_offering.id, |
| 957 | + state="enabled") |
| 958 | + except Exception as e: |
| 959 | + resultSet[2] = e |
| 960 | + return resultSet |
| 961 | + return [PASS, network_offering, None] |
| 962 | + |
| 963 | +def shouldTestBeSkipped(networkType, zoneType): |
| 964 | + """Decide which test to skip, according to type of network and zone type""" |
| 965 | + |
| 966 | + # If network type is isolated or vpc and zone type is basic, then test should be skipped |
| 967 | + skipIt = False |
| 968 | + if ((networkType.lower() == str(ISOLATED_NETWORK).lower() or networkType.lower() == str(VPC_NETWORK).lower()) |
| 969 | + and (zoneType.lower() == BASIC_ZONE)): |
| 970 | + skipIt = True |
| 971 | + return skipIt |
0 commit comments