Skip to content

Commit 0ac2eb4

Browse files
author
sanjeev
committed
CLOUDSTACK: Static IP address assignment for VM
Signed-off-by: sanjeev <sanjeev@apache.org> Incorporated review comments for review request 23614
1 parent c43b569 commit 0ac2eb4

1 file changed

Lines changed: 112 additions & 3 deletions

File tree

test/integration/component/test_escalations_instances.py

Lines changed: 112 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from marvin.codes import SUCCESS
2828
from nose.plugins.attrib import attr
2929
from time import sleep
30-
from ctypes.wintypes import BOOLEAN
30+
# from ctypes.wintypes import BOOLEAN
3131

3232
class TestListInstances(cloudstackTestCase):
3333

@@ -84,7 +84,7 @@ def setUpClass(cls):
8484
cls.api_client,
8585
account=cls.account.name,
8686
domainid=cls.domain.id,
87-
max=-1,
87+
max= -1,
8888
resourcetype=i
8989
)
9090

@@ -1924,7 +1924,7 @@ def setUpClass(cls):
19241924
cls.api_client,
19251925
account=cls.account.name,
19261926
domainid=cls.domain.id,
1927-
max=-1,
1927+
max= -1,
19281928
resourcetype=i
19291929
)
19301930
cls._cleanup.append(cls.account)
@@ -3458,3 +3458,112 @@ def test_23_deploy_vm_multiple_securitygroups(self):
34583458
"Security Groups in VM are not same as created"
34593459
)
34603460
return
3461+
3462+
@attr(tags=["advanced", "selfservice"])
3463+
def test_24_deploy_vm_with_static_ip_ES1662(self):
3464+
"""
3465+
@Desc: Test to verify deploy VM with static ip address assignment
3466+
@Steps:
3467+
Step1: Create a network for the user
3468+
Step2: List the network and check that it is created for the user
3469+
Step3: Deploy vm with ip address in the above network
3470+
Step4: List the vm and verify the ip address in the response
3471+
"""
3472+
# Listing Network Offerings
3473+
network_offerings_list = NetworkOffering.list(
3474+
self.apiClient,
3475+
forvpc="false",
3476+
guestiptype="Isolated",
3477+
state="Enabled",
3478+
supportedservices="SourceNat",
3479+
zoneid=self.zone.id
3480+
)
3481+
status = validateList(network_offerings_list)
3482+
self.assertEquals(
3483+
PASS,
3484+
status[0],
3485+
"Isolated Network Offerings with sourceNat enabled are not found"
3486+
)
3487+
"""
3488+
Create Isolated netwrok with ip range
3489+
"""
3490+
self.services["network"]["startip"] = "10.1.1.2"
3491+
self.services["network"]["endip"] = "10.1.1.254"
3492+
self.services["network"]["gateway"] = "10.1.1.1"
3493+
self.services["network"]["netmask"] = "255.255.255.0"
3494+
vm_ip = "10.1.1.10"
3495+
"""
3496+
Creating isolated/guest network with ip range
3497+
"""
3498+
network = Network.create(
3499+
self.userapiclient,
3500+
self.services["network"],
3501+
accountid=self.account.name,
3502+
domainid=self.domain.id,
3503+
networkofferingid=network_offerings_list[0].id,
3504+
zoneid=self.zone.id
3505+
)
3506+
self.assertIsNotNone(
3507+
network,
3508+
"Network creation failed"
3509+
)
3510+
# Deploying a VM
3511+
vm_created = VirtualMachine.create(
3512+
self.userapiclient,
3513+
self.services["virtual_machine"],
3514+
accountid=self.account.name,
3515+
domainid=self.account.domainid,
3516+
networkids=network.id,
3517+
ipaddress=vm_ip,
3518+
serviceofferingid=self.service_offering.id,
3519+
)
3520+
self.assertIsNotNone(
3521+
vm_created,
3522+
"VM creation failed"
3523+
)
3524+
# self.cleanup.append(vm_created)
3525+
self.cleanup.append(network)
3526+
# Listing all the VMs for a user again
3527+
vm_response = VirtualMachine.list(
3528+
self.userapiclient,
3529+
id=vm_created.id,
3530+
)
3531+
status = validateList(vm_response)
3532+
self.assertEquals(
3533+
PASS,
3534+
status[0],
3535+
"vm list returned invalid response"
3536+
)
3537+
# Verifying that the size of the list is 1
3538+
self.assertEquals(
3539+
1,
3540+
len(vm_response),
3541+
"VM list count is not matching"
3542+
)
3543+
# Verifying that the NIC's in VM created are same as provided
3544+
vm_nics = vm_created.nic
3545+
status = validateList(vm_nics)
3546+
self.assertEquals(
3547+
PASS,
3548+
status[0],
3549+
"vm list returned invalid response for vm nics"
3550+
)
3551+
# Verifying that the size of nics is 1
3552+
self.assertEquals(
3553+
1,
3554+
len(vm_nics),
3555+
"VM is created with more than one nic which is not expected"
3556+
)
3557+
"""
3558+
Verifying that NIC IP address is as expected
3559+
"""
3560+
self.assertEquals(
3561+
str(vm_nics[0].ipaddress),
3562+
vm_ip,
3563+
"VM is not created with static ip address used in vm deployment"
3564+
)
3565+
try:
3566+
vm_created.delete(self.apiClient, expunge=True)
3567+
except Exception as e:
3568+
raise Exception("Warning: Exception in expunging vm : %s" % e)
3569+
return

0 commit comments

Comments
 (0)