This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new b0d7844  CLOUDSTACK-10109: Fix regression from PR #2295 (#2394)
b0d7844 is described below

commit b0d7844cf0cc107e15532a7f675f9c9ad8293fd9
Author: Rohit Yadav <[email protected]>
AuthorDate: Wed Jan 10 00:44:00 2018 +0530

    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 <[email protected]>
---
 .../datastore/provider/SolidFireHostListener.java  |  5 ++++
 .../provider/SolidFireSharedHostListener.java      |  5 ++++
 scripts/vm/hypervisor/kvm/setup_agent.sh           | 12 ---------
 .../com/cloud/network/IpAddressManagerImpl.java    |  8 +-----
 test/integration/smoke/test_public_ip_range.py     | 29 +++++++++-------------
 test/integration/smoke/test_ssvm.py                | 10 +++++---
 6 files changed, 30 insertions(+), 39 deletions(-)

diff --git 
a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
 
b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
index 69e1a79..21a7fad 100644
--- 
a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
+++ 
b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
@@ -74,6 +74,11 @@ public class SolidFireHostListener implements 
HypervisorHostListener {
     public boolean hostAdded(long 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,
                 _clusterDao, _clusterDetailsDao, _storagePoolDao, 
_storagePoolDetailsDao, _hostDao);
 
diff --git 
a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireSharedHostListener.java
 
b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireSharedHostListener.java
index f88041a..29c3948 100644
--- 
a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireSharedHostListener.java
+++ 
b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/provider/SolidFireSharedHostListener.java
@@ -68,6 +68,11 @@ public class SolidFireSharedHostListener implements 
HypervisorHostListener {
     public boolean hostAdded(long 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,
                 clusterDao, clusterDetailsDao, storagePoolDao, 
storagePoolDetailsDao, hostDao);
 
diff --git a/scripts/vm/hypervisor/kvm/setup_agent.sh 
b/scripts/vm/hypervisor/kvm/setup_agent.sh
index b3c2e0f..d55c6ad 100755
--- a/scripts/vm/hypervisor/kvm/setup_agent.sh
+++ b/scripts/vm/hypervisor/kvm/setup_agent.sh
@@ -224,17 +224,5 @@ then
     setenforce 0
 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
 #cloud_consoleP_setup $host $zone $pod
diff --git a/server/src/com/cloud/network/IpAddressManagerImpl.java 
b/server/src/com/cloud/network/IpAddressManagerImpl.java
index 891dddf..c00359c 100644
--- a/server/src/com/cloud/network/IpAddressManagerImpl.java
+++ b/server/src/com/cloud/network/IpAddressManagerImpl.java
@@ -964,13 +964,7 @@ public class IpAddressManagerImpl extends ManagerBase 
implements IpAddressManage
                         VpcVO vpc = _vpcDao.findById(vpcId);
                         displayIp = vpc.isDisplay();
                     }
-                    PublicIp ip = fetchNewPublicIp(dcId, null, null, owner, 
VlanType.VirtualNetwork, guestNtwkId, isSourceNat, false, null, false, vpcId, 
displayIp, false);
-                    IPAddressVO publicIp = ip.ip();
-
-                    markPublicIpAsAllocated(publicIp);
-                    _ipAddressDao.update(publicIp.getId(), publicIp);
-
-                    return ip;
+                    return fetchNewPublicIp(dcId, null, null, owner, 
VlanType.VirtualNetwork, guestNtwkId, isSourceNat, true, null, false, vpcId, 
displayIp, false);
                 }
             });
             if (ip.getState() != State.Allocated) {
diff --git a/test/integration/smoke/test_public_ip_range.py 
b/test/integration/smoke/test_public_ip_range.py
index 624a407..664fdb4 100644
--- a/test/integration/smoke/test_public_ip_range.py
+++ b/test/integration/smoke/test_public_ip_range.py
@@ -204,25 +204,24 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
         ip = self.get_ip_as_number(ip_to_test)
         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
         """
-        timeout = srv_timeout
-        while True:
-            list_systemvm_response = list_ssvms(
+        def checkSystemVMUp():
+            response = list_ssvms(
                 self.apiclient,
                 systemvmtype=systemvmtype,
                 domainid=domain_id
             )
-            if isinstance(list_systemvm_response, list):
-                if list_systemvm_response[0].state == 'Running':
-                    return list_systemvm_response[0].id
-            if timeout == 0:
-                raise Exception("List System VM call failed!")
+            if isinstance(response, list):
+                if response[0].state == 'Running':
+                    return True, response[0].id
+            return False, None
 
-            time.sleep(srv_sleep)
-            timeout = timeout - 1
-        return None
+        res, systemvmId = wait_until(3, 100, checkSystemVMUp)
+        if not res:
+            raise Exception("Failed to wait for systemvm to be running")
+        return systemvmId
 
     def base_system_vm(self, services, systemvmtype):
         """
@@ -264,8 +263,6 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
         # Wait for CPVM to start
         systemvm_id = self.wait_for_system_vm_start(
             public_ip_range.vlan.domainid,
-            self.services["timeout"],
-            self.services["sleep"],
             systemvmtype
         )
         self.assertNotEqual(
@@ -312,8 +309,6 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
         # Wait for System VM to start and check System VM public IP
         systemvm_id = self.wait_for_system_vm_start(
             domain_id,
-            self.services["timeout"],
-            self.services["sleep"],
             systemvmtype
         )
         list_systemvm_response = list_ssvms(
@@ -386,4 +381,4 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
             services,
             'secondarystoragevm'
         )
-        return
\ No newline at end of file
+        return
diff --git a/test/integration/smoke/test_ssvm.py 
b/test/integration/smoke/test_ssvm.py
index f20003b..f697619 100644
--- a/test/integration/smoke/test_ssvm.py
+++ b/test/integration/smoke/test_ssvm.py
@@ -348,9 +348,13 @@ class TestSSVMs(cloudstackTestCase):
                         self.apiclient,
                         physicalnetworkid=listphyntwk[0].id),
                     list) is True):
-                self.assertEqual(
-                    cpvm.gateway,
-                    iprange.gateway,
+                cpvmValidGateway = False
+                for iprange in ipranges_response:
+                    if iprange.gateway == cpvm.gateway:
+                        cpvmValidGateway = True
+                        break
+                self.assertTrue(
+                    cpvmValidGateway,
                     "Check gateway with that of corresponding ip range"
                 )
 

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to