mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-2266: Adding automation tests for IP reservation feature
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
parent
6aef044c17
commit
ca1b911a4f
File diff suppressed because it is too large
Load Diff
|
|
@ -52,3 +52,8 @@ ISOLATED_NETWORK = "ISOLATED"
|
|||
SHARED_NETWORK = "SHARED"
|
||||
VPC_NETWORK = "VPC"
|
||||
ERROR_NO_HOST_FOR_MIGRATION = "Could not find suitable host for migration, please ensure setup has required no. of hosts"
|
||||
NAT_RULE = "nat rule"
|
||||
STATIC_NAT_RULE = "static nat rule"
|
||||
UNKNOWN = "UNKNOWN"
|
||||
FAULT = "FAULT"
|
||||
MASTER = "MASTER"
|
||||
|
|
|
|||
|
|
@ -262,6 +262,35 @@
|
|||
"StaticNat": "VirtualRouter"
|
||||
}
|
||||
},
|
||||
"nw_off_isolated_RVR": {
|
||||
"name": "Network offering-RVR services",
|
||||
"displaytext": "Network off-RVR services",
|
||||
"guestiptype": "Isolated",
|
||||
"supportedservices": "Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat",
|
||||
"traffictype": "GUEST",
|
||||
"availability": "Optional",
|
||||
"ispersistent": "False",
|
||||
"serviceProviderList": {
|
||||
"Vpn": "VirtualRouter",
|
||||
"Dhcp": "VirtualRouter",
|
||||
"Dns": "VirtualRouter",
|
||||
"SourceNat": "VirtualRouter",
|
||||
"PortForwarding": "VirtualRouter",
|
||||
"Firewall": "VirtualRouter",
|
||||
"Lb": "VirtualRouter",
|
||||
"UserData": "VirtualRouter",
|
||||
"StaticNat": "VirtualRouter"
|
||||
},
|
||||
"serviceCapabilityList": {
|
||||
"SourceNat": {
|
||||
"SupportedSourceNatTypes": "peraccount",
|
||||
"RedundantRouter": "true"
|
||||
},
|
||||
"lb": {
|
||||
"SupportedLbIsolation": "dedicated"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nw_off_persistent_RVR": {
|
||||
"name": "Network offering-RVR services",
|
||||
"displaytext": "Network off-RVR services",
|
||||
|
|
|
|||
|
|
@ -65,13 +65,17 @@ from marvin.integration.lib.base import (Configurations,
|
|||
Host,
|
||||
PublicIPAddress,
|
||||
NetworkOffering,
|
||||
Network)
|
||||
Network,
|
||||
FireWallRule,
|
||||
NATRule,
|
||||
StaticNATRule)
|
||||
from marvin.integration.lib.utils import (get_process_status,
|
||||
xsplit,
|
||||
validateList)
|
||||
|
||||
from marvin.sshClient import SshClient
|
||||
from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, BASIC_ZONE, FAIL
|
||||
from marvin.codes import (PASS, ISOLATED_NETWORK, VPC_NETWORK,
|
||||
BASIC_ZONE, FAIL, NAT_RULE, STATIC_NAT_RULE)
|
||||
import random
|
||||
|
||||
#Import System modules
|
||||
|
|
@ -994,8 +998,39 @@ def verifyComputeOfferingCreation(apiclient, computeofferingid):
|
|||
serviceOfferings = None
|
||||
try:
|
||||
serviceOfferings = apiclient.listServiceOfferings(cmd)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
return FAIL
|
||||
if not (isinstance(serviceOfferings, list) and len(serviceOfferings) > 0):
|
||||
return FAIL
|
||||
return PASS
|
||||
|
||||
def createNetworkRulesForVM(apiclient, virtualmachine, ruletype,
|
||||
account, networkruledata):
|
||||
"""Acquire IP, create Firewall and NAT/StaticNAT rule
|
||||
(associating it with given vm) for that IP"""
|
||||
|
||||
try:
|
||||
public_ip = PublicIPAddress.create(
|
||||
apiclient,accountid=account.name,
|
||||
zoneid=virtualmachine.zoneid,domainid=account.domainid,
|
||||
networkid=virtualmachine.nic[0].networkid)
|
||||
|
||||
FireWallRule.create(
|
||||
apiclient,ipaddressid=public_ip.ipaddress.id,
|
||||
protocol='TCP', cidrlist=[networkruledata["fwrule"]["cidr"]],
|
||||
startport=networkruledata["fwrule"]["startport"],
|
||||
endport=networkruledata["fwrule"]["endport"]
|
||||
)
|
||||
|
||||
if ruletype == NAT_RULE:
|
||||
# Create NAT rule
|
||||
NATRule.create(apiclient, virtualmachine,
|
||||
networkruledata["natrule"],ipaddressid=public_ip.ipaddress.id,
|
||||
networkid=virtualmachine.nic[0].networkid)
|
||||
elif ruletype == STATIC_NAT_RULE:
|
||||
# Enable Static NAT for VM
|
||||
StaticNATRule.enable(apiclient,public_ip.ipaddress.id,
|
||||
virtualmachine.id, networkid=virtualmachine.nic[0].networkid)
|
||||
except Exception as e:
|
||||
[FAIL, e]
|
||||
return [PASS, public_ip]
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import email
|
|||
import socket
|
||||
import urlparse
|
||||
import datetime
|
||||
from marvin.cloudstackAPI import cloudstackAPIClient, listHosts
|
||||
from marvin.cloudstackAPI import cloudstackAPIClient, listHosts, listRouters
|
||||
from marvin.sshClient import SshClient
|
||||
from marvin.codes import (FAIL,
|
||||
PASS,
|
||||
|
|
@ -429,3 +429,25 @@ def verifyElementInList(inp, toverify, responsevar=None, pos=0):
|
|||
else:
|
||||
return [FAIL, MATCH_NOT_FOUND]
|
||||
|
||||
def verifyRouterState(apiclient, routerid, allowedstates):
|
||||
"""List the router and verify that its state is in allowed states
|
||||
@output: List, containing [Result, Reason]
|
||||
Ist Argument ('Result'): FAIL: If router state is not
|
||||
in allowed states
|
||||
PASS: If router state is in
|
||||
allowed states"""
|
||||
|
||||
try:
|
||||
cmd = listRouters.listRoutersCmd()
|
||||
cmd.id = routerid
|
||||
cmd.listall = True
|
||||
routers = apiclient.listRouters(cmd)
|
||||
except Exception as e:
|
||||
return [FAIL, e]
|
||||
listvalidationresult = validateList(routers)
|
||||
if listvalidationresult[0] == FAIL:
|
||||
return [FAIL, listvalidationresult[2]]
|
||||
if routers[0].redundantstate not in allowedstates:
|
||||
return [FAIL, "Redundant state of the router should be in %s but is %s" %
|
||||
(allowedstates, routers[0].redundantstate)]
|
||||
return [PASS, None]
|
||||
|
|
|
|||
Loading…
Reference in New Issue