CLOUDSTACK-10109: Fix regression from PR #2295 (#2394)

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
- Fix potential NPE seen when adding simulator host(s)
- Removes aria2 installation from setup_agent.sh using yum, it's already
  dependency for cloudstack-agent package

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2018-01-10 00:44:00 +05:30 committed by GitHub
parent e01dd89c93
commit b0d7844cf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 39 deletions

View File

@ -74,6 +74,11 @@ public class SolidFireHostListener implements HypervisorHostListener {
public boolean hostAdded(long hostId) { public boolean hostAdded(long hostId) {
HostVO host = _hostDao.findById(hostId); HostVO host = _hostDao.findById(hostId);
if (host == null) {
s_logger.error("Failed to add host by SolidFireHostListener as host was not found with id=" + hostId);
return false;
}
SolidFireUtil.hostAddedToOrRemovedFromCluster(hostId, host.getClusterId(), true, SolidFireUtil.PROVIDER_NAME, SolidFireUtil.hostAddedToOrRemovedFromCluster(hostId, host.getClusterId(), true, SolidFireUtil.PROVIDER_NAME,
_clusterDao, _clusterDetailsDao, _storagePoolDao, _storagePoolDetailsDao, _hostDao); _clusterDao, _clusterDetailsDao, _storagePoolDao, _storagePoolDetailsDao, _hostDao);

View File

@ -68,6 +68,11 @@ public class SolidFireSharedHostListener implements HypervisorHostListener {
public boolean hostAdded(long hostId) { public boolean hostAdded(long hostId) {
HostVO host = hostDao.findById(hostId); HostVO host = hostDao.findById(hostId);
if (host == null) {
LOGGER.error("Failed to add host by SolidFireSharedHostListener as host was not found with id=" + hostId);
return false;
}
SolidFireUtil.hostAddedToOrRemovedFromCluster(hostId, host.getClusterId(), true, SolidFireUtil.SHARED_PROVIDER_NAME, SolidFireUtil.hostAddedToOrRemovedFromCluster(hostId, host.getClusterId(), true, SolidFireUtil.SHARED_PROVIDER_NAME,
clusterDao, clusterDetailsDao, storagePoolDao, storagePoolDetailsDao, hostDao); clusterDao, clusterDetailsDao, storagePoolDao, storagePoolDetailsDao, hostDao);

View File

@ -224,17 +224,5 @@ then
setenforce 0 setenforce 0
fi fi
which aria2c
if [ $? -gt 0 ]
then
yum install epel-release -y
yum install aria2 -y
if [ $? -gt 0 ]
then
printf "failed to install aria2"
exit 1
fi
fi
cloudstack-setup-agent --host=$host --zone=$zone --pod=$pod --cluster=$cluster --guid=$guid $paramters -a > /dev/null cloudstack-setup-agent --host=$host --zone=$zone --pod=$pod --cluster=$cluster --guid=$guid $paramters -a > /dev/null
#cloud_consoleP_setup $host $zone $pod #cloud_consoleP_setup $host $zone $pod

View File

@ -964,13 +964,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
VpcVO vpc = _vpcDao.findById(vpcId); VpcVO vpc = _vpcDao.findById(vpcId);
displayIp = vpc.isDisplay(); displayIp = vpc.isDisplay();
} }
PublicIp ip = fetchNewPublicIp(dcId, null, null, owner, VlanType.VirtualNetwork, guestNtwkId, isSourceNat, false, null, false, vpcId, displayIp, false); return fetchNewPublicIp(dcId, null, null, owner, VlanType.VirtualNetwork, guestNtwkId, isSourceNat, true, null, false, vpcId, displayIp, false);
IPAddressVO publicIp = ip.ip();
markPublicIpAsAllocated(publicIp);
_ipAddressDao.update(publicIp.getId(), publicIp);
return ip;
} }
}); });
if (ip.getState() != State.Allocated) { if (ip.getState() != State.Allocated) {

View File

@ -204,25 +204,24 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
ip = self.get_ip_as_number(ip_to_test) ip = self.get_ip_as_number(ip_to_test)
return start <= ip and ip <= end return start <= ip and ip <= end
def wait_for_system_vm_start(self, domain_id, srv_timeout, srv_sleep, systemvmtype): def wait_for_system_vm_start(self, domain_id, systemvmtype):
""" Wait until system vm is Running """ Wait until system vm is Running
""" """
timeout = srv_timeout def checkSystemVMUp():
while True: response = list_ssvms(
list_systemvm_response = list_ssvms(
self.apiclient, self.apiclient,
systemvmtype=systemvmtype, systemvmtype=systemvmtype,
domainid=domain_id domainid=domain_id
) )
if isinstance(list_systemvm_response, list): if isinstance(response, list):
if list_systemvm_response[0].state == 'Running': if response[0].state == 'Running':
return list_systemvm_response[0].id return True, response[0].id
if timeout == 0: return False, None
raise Exception("List System VM call failed!")
time.sleep(srv_sleep) res, systemvmId = wait_until(3, 100, checkSystemVMUp)
timeout = timeout - 1 if not res:
return None raise Exception("Failed to wait for systemvm to be running")
return systemvmId
def base_system_vm(self, services, systemvmtype): def base_system_vm(self, services, systemvmtype):
""" """
@ -264,8 +263,6 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
# Wait for CPVM to start # Wait for CPVM to start
systemvm_id = self.wait_for_system_vm_start( systemvm_id = self.wait_for_system_vm_start(
public_ip_range.vlan.domainid, public_ip_range.vlan.domainid,
self.services["timeout"],
self.services["sleep"],
systemvmtype systemvmtype
) )
self.assertNotEqual( self.assertNotEqual(
@ -312,8 +309,6 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
# Wait for System VM to start and check System VM public IP # Wait for System VM to start and check System VM public IP
systemvm_id = self.wait_for_system_vm_start( systemvm_id = self.wait_for_system_vm_start(
domain_id, domain_id,
self.services["timeout"],
self.services["sleep"],
systemvmtype systemvmtype
) )
list_systemvm_response = list_ssvms( list_systemvm_response = list_ssvms(
@ -386,4 +381,4 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
services, services,
'secondarystoragevm' 'secondarystoragevm'
) )
return return

View File

@ -348,9 +348,13 @@ class TestSSVMs(cloudstackTestCase):
self.apiclient, self.apiclient,
physicalnetworkid=listphyntwk[0].id), physicalnetworkid=listphyntwk[0].id),
list) is True): list) is True):
self.assertEqual( cpvmValidGateway = False
cpvm.gateway, for iprange in ipranges_response:
iprange.gateway, if iprange.gateway == cpvm.gateway:
cpvmValidGateway = True
break
self.assertTrue(
cpvmValidGateway,
"Check gateway with that of corresponding ip range" "Check gateway with that of corresponding ip range"
) )