Skip to content

Commit 07eb32f

Browse files
committed
CLOUDSTACK-10109: Fix regression from PR #2295
This fixes regression introduced in PR #2295: - Pass assign=true to fetch new public IP - Use wait_until instead of sleep+wait in tests - Loop through list of public IP ranges to match the systemvm gateway Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 981286f commit 07eb32f

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

server/src/com/cloud/network/IpAddressManagerImpl.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -964,13 +964,7 @@ public PublicIp doInTransaction(TransactionStatus status) throws InsufficientAdd
964964
VpcVO vpc = _vpcDao.findById(vpcId);
965965
displayIp = vpc.isDisplay();
966966
}
967-
PublicIp ip = fetchNewPublicIp(dcId, null, null, owner, VlanType.VirtualNetwork, guestNtwkId, isSourceNat, false, null, false, vpcId, displayIp, false);
968-
IPAddressVO publicIp = ip.ip();
969-
970-
markPublicIpAsAllocated(publicIp);
971-
_ipAddressDao.update(publicIp.getId(), publicIp);
972-
973-
return ip;
967+
return fetchNewPublicIp(dcId, null, null, owner, VlanType.VirtualNetwork, guestNtwkId, isSourceNat, true, null, false, vpcId, displayIp, false);
974968
}
975969
});
976970
if (ip.getState() != State.Allocated) {

test/integration/smoke/test_public_ip_range.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -204,25 +204,24 @@ def is_ip_in_range(self, start_ip, end_ip, ip_to_test):
204204
ip = self.get_ip_as_number(ip_to_test)
205205
return start <= ip and ip <= end
206206

207-
def wait_for_system_vm_start(self, domain_id, srv_timeout, srv_sleep, systemvmtype):
207+
def wait_for_system_vm_start(self, domain_id, systemvmtype):
208208
""" Wait until system vm is Running
209209
"""
210-
timeout = srv_timeout
211-
while True:
212-
list_systemvm_response = list_ssvms(
210+
def checkSystemVMUp():
211+
response = list_ssvms(
213212
self.apiclient,
214213
systemvmtype=systemvmtype,
215214
domainid=domain_id
216215
)
217-
if isinstance(list_systemvm_response, list):
218-
if list_systemvm_response[0].state == 'Running':
219-
return list_systemvm_response[0].id
220-
if timeout == 0:
221-
raise Exception("List System VM call failed!")
216+
if isinstance(response, list):
217+
if response[0].state == 'Running':
218+
return True, response[0].id
219+
return False, None
222220

223-
time.sleep(srv_sleep)
224-
timeout = timeout - 1
225-
return None
221+
res, systemvmId = wait_until(3, 100, checkSystemVMUp)
222+
if not res:
223+
raise Exception("Failed to wait for systemvm to be running")
224+
return systemvmId
226225

227226
def base_system_vm(self, services, systemvmtype):
228227
"""
@@ -264,8 +263,6 @@ def base_system_vm(self, services, systemvmtype):
264263
# Wait for CPVM to start
265264
systemvm_id = self.wait_for_system_vm_start(
266265
public_ip_range.vlan.domainid,
267-
self.services["timeout"],
268-
self.services["sleep"],
269266
systemvmtype
270267
)
271268
self.assertNotEqual(
@@ -312,8 +309,6 @@ def base_system_vm(self, services, systemvmtype):
312309
# Wait for System VM to start and check System VM public IP
313310
systemvm_id = self.wait_for_system_vm_start(
314311
domain_id,
315-
self.services["timeout"],
316-
self.services["sleep"],
317312
systemvmtype
318313
)
319314
list_systemvm_response = list_ssvms(
@@ -386,4 +381,4 @@ def test_dedicate_public_ip_range_for_system_vms_ssvm(self):
386381
services,
387382
'secondarystoragevm'
388383
)
389-
return
384+
return

test/integration/smoke/test_ssvm.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,13 @@ def test_02_list_cpvm_vm(self):
348348
self.apiclient,
349349
physicalnetworkid=listphyntwk[0].id),
350350
list) is True):
351-
self.assertEqual(
352-
cpvm.gateway,
353-
iprange.gateway,
351+
cpvmValidGateway = False
352+
for iprange in ipranges_response:
353+
if iprange.gateway == cpvm.gateway:
354+
cpvmValidGateway = True
355+
break
356+
self.assertTrue(
357+
cpvmValidGateway,
354358
"Check gateway with that of corresponding ip range"
355359
)
356360

0 commit comments

Comments
 (0)