cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [cloudstack] branch 4.9 updated: CLOUDSTACK-9751: Fix public ip not applied, when added while VR is starting. (#1925)
Date Fri, 28 Jul 2017 08:30:45 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/4.9 by this push:
     new 0ead11e  CLOUDSTACK-9751: Fix public ip not applied, when added while VR is starting.
(#1925)
0ead11e is described below

commit 0ead11e8f1417f691851dc27341cdaf8b0eb4a4d
Author: Frank Maximus <the.evergreen@gmail.com>
AuthorDate: Fri Jul 28 10:30:43 2017 +0200

    CLOUDSTACK-9751: Fix public ip not applied, when added while VR is starting. (#1925)
    
    Public IP state wasn't passed to the vsp client, making it ignore the apply public ip.
    
    Reported-By: Raf Smeets <raf.smeets@nuagenetworks.net>
---
 .../network/guru/NuageVspGuestNetworkGuru.java     | 31 ++++++----
 .../src/com/cloud/util/NuageVspEntityBuilder.java  | 70 +++++++++++++++-------
 .../com/cloud/util/NuageVspEntityBuilderTest.java  |  2 +
 3 files changed, 68 insertions(+), 35 deletions(-)

diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
b/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
index a6c17e3..d99c71d 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
@@ -19,6 +19,22 @@
 
 package com.cloud.network.guru;
 
+import java.util.List;
+
+import javax.inject.Inject;
+
+import net.nuage.vsp.acs.client.api.model.VspNetwork;
+import net.nuage.vsp.acs.client.api.model.VspNic;
+import net.nuage.vsp.acs.client.api.model.VspStaticNat;
+import net.nuage.vsp.acs.client.api.model.VspVm;
+
+import org.apache.log4j.Logger;
+
+import com.google.common.base.Strings;
+
+import org.apache.cloudstack.resourcedetail.VpcDetailVO;
+import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
+
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.guru.DeallocateVmVspCommand;
@@ -59,6 +75,7 @@ import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
 import com.cloud.user.Account;
 import com.cloud.user.AccountVO;
 import com.cloud.user.dao.AccountDao;
+import com.cloud.util.NuageVspEntityBuilder;
 import com.cloud.utils.StringUtils;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -66,18 +83,6 @@ import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachineProfile;
-import com.google.common.base.Strings;
-import com.cloud.util.NuageVspEntityBuilder;
-import net.nuage.vsp.acs.client.api.model.VspNetwork;
-import net.nuage.vsp.acs.client.api.model.VspNic;
-import net.nuage.vsp.acs.client.api.model.VspStaticNat;
-import net.nuage.vsp.acs.client.api.model.VspVm;
-import org.apache.cloudstack.resourcedetail.VpcDetailVO;
-import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
-import org.apache.log4j.Logger;
-
-import javax.inject.Inject;
-import java.util.List;
 
 public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
     public static final Logger s_logger = Logger.getLogger(NuageVspGuestNetworkGuru.class);
@@ -256,7 +261,7 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
             VspStaticNat vspStaticNat = null;
             if (staticNatIp != null) {
                 VlanVO staticNatVlan = _vlanDao.findById(staticNatIp.getVlanId());
-                vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(null, staticNatIp,
staticNatVlan, null);
+                vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(null, staticNatIp,
staticNatVlan, vspNic);
             }
 
             HostVO nuageVspHost = getNuageVspHost(network.getPhysicalNetworkId());
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspEntityBuilder.java
b/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspEntityBuilder.java
index 8757ad0..db24050 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspEntityBuilder.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspEntityBuilder.java
@@ -19,6 +19,30 @@
 
 package com.cloud.util;
 
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.inject.Inject;
+
+import net.nuage.vsp.acs.client.api.model.VspAclRule;
+import net.nuage.vsp.acs.client.api.model.VspDomain;
+import net.nuage.vsp.acs.client.api.model.VspNetwork;
+import net.nuage.vsp.acs.client.api.model.VspNic;
+import net.nuage.vsp.acs.client.api.model.VspStaticNat;
+import net.nuage.vsp.acs.client.api.model.VspVm;
+import net.nuage.vsp.acs.client.common.model.Pair;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+
 import com.cloud.dc.VlanVO;
 import com.cloud.dc.dao.VlanDao;
 import com.cloud.domain.Domain;
@@ -44,25 +68,6 @@ import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.VirtualMachine;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import net.nuage.vsp.acs.client.api.model.VspAclRule;
-import net.nuage.vsp.acs.client.api.model.VspDomain;
-import net.nuage.vsp.acs.client.api.model.VspNetwork;
-import net.nuage.vsp.acs.client.api.model.VspNic;
-import net.nuage.vsp.acs.client.api.model.VspStaticNat;
-import net.nuage.vsp.acs.client.api.model.VspVm;
-import net.nuage.vsp.acs.client.common.model.Pair;
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-
-import javax.inject.Inject;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
 
 public class NuageVspEntityBuilder {
     private static final Logger s_logger = Logger.getLogger(NuageVspEntityBuilder.class);
@@ -270,24 +275,29 @@ public class NuageVspEntityBuilder {
         return vspNicBuilder.build();
     }
 
-    public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO
staticNatVlan, NicVO nic) {
+    public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO
staticNatVlan, VspNic vspNic) {
         VspStaticNat.Builder vspStaticNatBuilder = new VspStaticNat.Builder()
                 .ipUuid(staticNatIp.getUuid())
                 .ipAddress(staticNatIp.getAddress().addr())
                 .revoke(forRevoke)
                 .oneToOneNat(staticNatIp.isOneToOneNat())
+                .state(getEnumValue(staticNatIp.getState(), VspStaticNat.State.class))
                 .vlanUuid(staticNatVlan.getUuid())
                 .vlanGateway(staticNatVlan.getVlanGateway())
                 .vlanNetmask(staticNatVlan.getVlanNetmask());
 
-        if (nic != null) {
-            VspNic vspNic = buildVspNic(nic);
+        if (vspNic != null) {
             vspStaticNatBuilder.nic(vspNic);
         }
 
         return vspStaticNatBuilder.build();
     }
 
+    public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO
staticNatVlan, NicVO nic) {
+        VspNic vspNic = (nic != null) ?buildVspNic(nic) : null;
+        return buildVspStaticNat(forRevoke, staticNatIp, staticNatVlan, vspNic);
+    }
+
     public VspAclRule buildVspAclRule(FirewallRule firewallRule, Network network) {
         VspAclRule.Builder vspAclRuleBuilder = new VspAclRule.Builder()
                 .uuid(firewallRule.getUuid())
@@ -367,4 +377,20 @@ public class NuageVspEntityBuilder {
 
         return vspAclRuleBuilder.build();
     }
+
+    private <E extends Enum<E>> E getEnumValue(Enum cloudstackValue, Class<E>
target) {
+        try {
+            return Enum.valueOf(target, cloudstackValue.name());
+        } catch (IllegalArgumentException e) {
+            return null;
+        }
+    }
+
+    private <E extends Enum<E>> E getEnumValue(Enum cloudstackValue, E defaultValue)
{
+        try {
+            return Enum.valueOf(defaultValue.getDeclaringClass(), cloudstackValue.name());
+        } catch (IllegalArgumentException e) {
+            return defaultValue;
+        }
+    }
 }
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspEntityBuilderTest.java
b/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspEntityBuilderTest.java
index 1ddc106..ef63220 100644
--- a/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspEntityBuilderTest.java
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspEntityBuilderTest.java
@@ -24,6 +24,7 @@ import com.cloud.dc.VlanVO;
 import com.cloud.dc.dao.VlanDao;
 import com.cloud.domain.DomainVO;
 import com.cloud.domain.dao.DomainDao;
+import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.IPAddressVO;
@@ -359,6 +360,7 @@ public class NuageVspEntityBuilderTest extends NuageTest {
         when(_mockedStaticNatIp.getAddress()).thenReturn(new Ip("10.10.10.2"));
         when(_mockedStaticNatIp.isOneToOneNat()).thenReturn(true);
         when(_mockedStaticNatIp.getVmIp()).thenReturn("192.168.0.24");
+        when(_mockedStaticNatIp.getState()).thenReturn(IpAddress.State.Allocated);
     }
 
     private void setUpMockedStaticNatVlan() {

-- 
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <commits@cloudstack.apache.org>'].

Mime
View raw message