cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject git commit: updated refs/heads/4.3 to 5a8ea8a
Date Wed, 08 Jan 2014 00:06:15 GMT
Updated Branches:
  refs/heads/4.3 6fd030cbf -> 5a8ea8ae7


CLOUDSTACK-5697 This patchset fixes a bug with the recently merged
vxlan code. Users can set a physical network to isolation type 'vxlan',
put public traffic on that physical network, and it will still attempt
to use 'vlan' isolation on the KVM hosts. This is going to be an issue
for other isolation types as well, but I'm not familiar with them, so
I'm just fixing vxlan for now.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5a8ea8ae
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5a8ea8ae
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5a8ea8ae

Branch: refs/heads/4.3
Commit: 5a8ea8ae7171bff3c0cc79517b330bf8321c0c4c
Parents: 6fd030c
Author: Marcus Sorensen <marcus@betterservers.com>
Authored: Tue Jan 7 17:03:36 2014 -0700
Committer: Marcus Sorensen <marcus@betterservers.com>
Committed: Tue Jan 7 17:03:36 2014 -0700

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkService.java      |  2 +-
 api/src/com/cloud/network/Networks.java            | 15 ++++++++++++++-
 .../org/apache/cloudstack/api/ApiConstants.java    |  1 +
 .../api/command/admin/usage/AddTrafficTypeCmd.java | 13 ++++++++++++-
 .../kvm/resource/LibvirtComputingResource.java     |  9 +++++++++
 .../contrail/management/ManagementServerMock.java  |  6 +++---
 .../configuration/ConfigurationManagerImpl.java    |  2 +-
 .../src/com/cloud/network/NetworkServiceImpl.java  | 17 ++++++++++++++++-
 .../com/cloud/network/guru/PublicNetworkGuru.java  | 14 ++++++++++----
 .../router/VirtualNetworkApplianceManagerImpl.java | 14 +++++++++++---
 .../test/com/cloud/vpc/MockNetworkManagerImpl.java |  4 ++--
 11 files changed, 80 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/api/src/com/cloud/network/NetworkService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java
index 85668b5..1b805a6 100755
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@ -115,7 +115,7 @@ public interface NetworkService {
 
     long findPhysicalNetworkId(long zoneId, String tag, TrafficType trafficType);
 
-    PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String
trafficType,
+    PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String
trafficType, String isolationMethod,
             String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel,
String vlan, String hypervLabel);
 
     PhysicalNetworkTrafficType getPhysicalNetworkTrafficType(Long id);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/api/src/com/cloud/network/Networks.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/Networks.java b/api/src/com/cloud/network/Networks.java
index 0412bf4..3159f6e 100755
--- a/api/src/com/cloud/network/Networks.java
+++ b/api/src/com/cloud/network/Networks.java
@@ -108,7 +108,20 @@ public class Networks {
         },
         Mido("mido", String.class),
         Pvlan("pvlan", String.class),
-        Vxlan("vxlan", Long.class),
+        Vxlan("vxlan", Long.class) {
+            @Override
+            public <T> URI toUri(T value) {
+                try {
+                    if (value.toString().contains("://"))
+                        return new URI(value.toString());
+                    else
+                        return new URI("vxlan://" + value.toString());
+                } catch (URISyntaxException e) {
+                    throw new CloudRuntimeException(
+                            "Unable to convert to broadcast URI: " + value);
+                }
+            }
+        },
         UnDecided(null, null);
 
         private final String scheme;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index e08923c..fbd3df8 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -343,6 +343,7 @@ public class ApiConstants {
     public static final String CAPACITY_IOPS = "capacityiops";
     public static final String NETWORK_SPEED = "networkspeed";
     public static final String BROADCAST_DOMAIN_RANGE = "broadcastdomainrange";
+    public static final String ISOLATION_METHOD = "isolationmethod";
     public static final String ISOLATION_METHODS = "isolationmethods";
     public static final String PHYSICAL_NETWORK_ID = "physicalnetworkid";
     public static final String DEST_PHYSICAL_NETWORK_ID = "destinationphysicalnetworkid";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficTypeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficTypeCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficTypeCmd.java
index f6e4319..9cb713b 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficTypeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficTypeCmd.java
@@ -66,6 +66,9 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
     @Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="The VLAN id
to be used for Management traffic by VMware host")
     private String vlan;
 
+    @Parameter(name=ApiConstants.ISOLATION_METHOD, type=CommandType.STRING, description="Used
if physical network has multiple isolation types and traffic type is public. Choose which
isolation method. Valid options currently 'vlan' or 'vxlan', defaults to 'vlan'.")
+    private String isolationMethod;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -108,6 +111,14 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
         return vlan;
     }
 
+    public String getIsolationMethod() {
+        if (isolationMethod != null && !isolationMethod.isEmpty()) {
+            return isolationMethod;
+        } else {
+            return "vlan";
+        }
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////
@@ -137,7 +148,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
 
     @Override
     public void create() throws ResourceAllocationException {
-        PhysicalNetworkTrafficType result = _networkService.addTrafficTypeToPhysicalNetwork(getPhysicalNetworkId(),
getTrafficType(), getXenLabel(), getKvmLabel(), getVmwareLabel(), getSimulatorLabel(), getVlan(),
getHypervLabel());
+        PhysicalNetworkTrafficType result = _networkService.addTrafficTypeToPhysicalNetwork(getPhysicalNetworkId(),
getTrafficType(), getIsolationMethod(), getXenLabel(), getKvmLabel(), getVmwareLabel(), getSimulatorLabel(),
getVlan(), getHypervLabel());
         if (result != null) {
             setEntityId(result.getId());
             setEntityUuid(result.getUuid());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 66608a8..de139fc 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1805,6 +1805,15 @@ ServerResource {
 
     private PlugNicAnswer execute(PlugNicCommand cmd) {
         NicTO nic = cmd.getNic();
+        // rely on broadcastType as authoritiative rather than broadcast uri
+        // TODO: fix mismatches in mgmt server
+        if (nic.getBroadcastType() == BroadcastDomainType.Vxlan && !nic.getBroadcastUri().getScheme().equals("vxlan"))
{
+            s_logger.error("mismatch in broadcast type and uri for nic " + nic +" find what
is doing this and fix it");
+            String vnet = nic.getBroadcastUri().getAuthority();
+            nic.setBroadcastUri(BroadcastDomainType.Vxlan.toUri(vnet));
+            nic.setIsolationuri(BroadcastDomainType.Vxlan.toUri(vnet));
+            s_logger.error("mismatch now resolved to " + nic);
+        }
         String vmName = cmd.getVmName();
         Domain vm = null;
         try {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/ManagementServerMock.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/ManagementServerMock.java
b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/ManagementServerMock.java
index 86750ca..ac93cbd 100644
--- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/ManagementServerMock.java
+++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/ManagementServerMock.java
@@ -315,7 +315,7 @@ public class ManagementServerMock {
             _znet = _networkService.getPhysicalNetwork(id);
             List<PhysicalNetworkVO> nets = _physicalNetworkDao.listByZoneAndTrafficType(_zone.getId(),
TrafficType.Public);
             if (nets == null || nets.isEmpty()) {
-                _networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(),
null, null, null, null, null, null);
+                _networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(),
"vlan", null, null, null, null, null, null);
             }
         } catch (InvalidParameterValueException e) {
             List<String> isolationMethods = new ArrayList<String>();
@@ -325,7 +325,7 @@ public class ManagementServerMock {
                     null, "znet");
             List<PhysicalNetworkVO> nets = _physicalNetworkDao.listByZoneAndTrafficType(_zone.getId(),
TrafficType.Public);
             if (nets == null || nets.isEmpty()) {
-                _networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(),
null, null, null, null, null, null);
+                _networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(),
"vlan", null, null, null, null, null, null);
             }
         }
         if (_znet.getState() != PhysicalNetwork.State.Enabled) {
@@ -343,7 +343,7 @@ public class ManagementServerMock {
             }
         }
         if (!found) {
-            _networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Guest.toString(),
+            _networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Guest.toString(),
"vlan",
                     null, null, null, null, null, null);
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 4b2ade2..f9d282f 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -1758,7 +1758,7 @@ ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager,
Co
                                 PhysicalNetworkTrafficTypeVO mgmtTraffic = _trafficTypeDao.findBy(mgmtPhyNetwork.getId(),
                                         TrafficType.Management);
                                 _networkSvc.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(),
-                                        TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(),
+                                        TrafficType.Storage.toString(), "vlan", mgmtTraffic.getXenNetworkLabel(),
                                         mgmtTraffic.getKvmNetworkLabel(), mgmtTraffic.getVmwareNetworkLabel(),
                                         mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan(),
mgmtTraffic.getHypervNetworkLabel());
                                 s_logger.info("No storage traffic type was specified by admin,
create default storage traffic on physical network "

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 5bbb1ca..11313d5 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -3519,7 +3519,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService
{
     @Override
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_TRAFFIC_TYPE_CREATE, eventDescription = "Creating
Physical Network TrafficType", create = true)
-    public PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId,
String trafficTypeStr, String xenLabel, String kvmLabel, String vmwareLabel,
+    public PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId,
String trafficTypeStr, String isolationMethod, String xenLabel, String kvmLabel, String vmwareLabel,
             String simulatorLabel, String vlan, String hypervLabel) {
 
         // verify input parameters
@@ -3573,8 +3573,23 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService
{
             }
             PhysicalNetworkTrafficTypeVO pNetworktrafficType = new PhysicalNetworkTrafficTypeVO(physicalNetworkId,
trafficType, xenLabel, kvmLabel, vmwareLabel, simulatorLabel,
                     vlan, hypervLabel);
+
             pNetworktrafficType = _pNTrafficTypeDao.persist(pNetworktrafficType);
 
+            // For public traffic, get isolation method of physical network and update the
public network accordingly
+            // each broadcast type will individually need to be qualified for support of
public traffic
+            List<String> isolationMethods = network.getIsolationMethods();
+            if ((isolationMethods.size() == 1 && isolationMethods.get(0).toLowerCase().equals("vxlan"))
+                || (isolationMethod != null && isolationMethods.contains(isolationMethod)
&& isolationMethod.toLowerCase().equals("vxlan"))) {
+                // find row in networks table that is defined as 'Public', created when zone
was deployed
+                NetworkVO publicNetwork = _networksDao.listByZoneAndTrafficType(network.getDataCenterId(),TrafficType.Public).get(0);
+                if (publicNetwork != null) {
+                    s_logger.debug("setting public network " + publicNetwork + " to broadcast
type vxlan");
+                    publicNetwork.setBroadcastDomainType(BroadcastDomainType.Vxlan);
+                    _networksDao.persist(publicNetwork);
+                }
+            }
+
             return pNetworktrafficType;
         } catch (Exception ex) {
             s_logger.warn("Exception: ", ex);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/server/src/com/cloud/network/guru/PublicNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/PublicNetworkGuru.java b/server/src/com/cloud/network/guru/PublicNetworkGuru.java
index 6fed1a6..c56c68e 100755
--- a/server/src/com/cloud/network/guru/PublicNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/PublicNetworkGuru.java
@@ -101,7 +101,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru
{
         }
 
         if (offering.getTrafficType() == TrafficType.Public) {
-            NetworkVO ntwk = new NetworkVO(offering.getTrafficType(), Mode.Static, BroadcastDomainType.Vlan,
offering.getId(), State.Setup, plan.getDataCenterId(), plan.getPhysicalNetworkId());
+            NetworkVO ntwk = new NetworkVO(offering.getTrafficType(), Mode.Static, network.getBroadcastDomainType(),
offering.getId(), State.Setup, plan.getDataCenterId(), plan.getPhysicalNetworkId());
             return ntwk;
         } else {
             return null;
@@ -119,9 +119,15 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru
{
             nic.setIp4Address(ip.getAddress().toString());
             nic.setGateway(ip.getGateway());
             nic.setNetmask(ip.getNetmask());
-            nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
-            nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag()));
-            nic.setBroadcastType(BroadcastDomainType.Vlan);
+            if (network.getBroadcastDomainType() == BroadcastDomainType.Vxlan) {
+                nic.setIsolationUri(BroadcastDomainType.Vxlan.toUri(ip.getVlanTag()));
+                nic.setBroadcastUri(BroadcastDomainType.Vxlan.toUri(ip.getVlanTag()));
+                nic.setBroadcastType(BroadcastDomainType.Vxlan);
+            } else {
+                nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
+                nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag()));
+                nic.setBroadcastType(BroadcastDomainType.Vlan);
+            }
             nic.setFormat(AddressFormat.Ip4);
             nic.setReservationId(String.valueOf(ip.getVlanTag()));
             nic.setMacAddress(ip.getMacAddress());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 1a37c9b..37e2c65 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -1718,9 +1718,17 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
             defaultNic.setGateway(sourceNatIp.getGateway());
             defaultNic.setNetmask(sourceNatIp.getNetmask());
             defaultNic.setMacAddress(sourceNatIp.getMacAddress());
-            defaultNic.setBroadcastType(BroadcastDomainType.Vlan);
-            defaultNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(sourceNatIp.getVlanTag()));
-            defaultNic.setIsolationUri(IsolationType.Vlan.toUri(sourceNatIp.getVlanTag()));
+            // get broadcast from public network
+            Network pubNet = _networkDao.findById(sourceNatIp.getNetworkId());
+            if (pubNet.getBroadcastDomainType() == BroadcastDomainType.Vxlan) {
+                defaultNic.setBroadcastType(BroadcastDomainType.Vxlan);
+                defaultNic.setBroadcastUri(BroadcastDomainType.Vxlan.toUri(sourceNatIp.getVlanTag()));
+                defaultNic.setIsolationUri(BroadcastDomainType.Vxlan.toUri(sourceNatIp.getVlanTag()));
+            } else {
+                defaultNic.setBroadcastType(BroadcastDomainType.Vlan);
+                defaultNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(sourceNatIp.getVlanTag()));
+                defaultNic.setIsolationUri(IsolationType.Vlan.toUri(sourceNatIp.getVlanTag()));
+            }
             if (hasGuestNetwork) {
                 defaultNic.setDeviceId(2);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a8ea8ae/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
index bb5bfcd..9eda6b9 100644
--- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
@@ -515,10 +515,10 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
 
 
     /* (non-Javadoc)
-     * @see com.cloud.network.NetworkService#addTrafficTypeToPhysicalNetwork(java.lang.Long,
java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String,
java.lang.String)
+     * @see com.cloud.network.NetworkService#addTrafficTypeToPhysicalNetwork(java.lang.Long,
java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String,
java.lang.String, java.lang.String)
      */
     @Override
-    public PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId,
String trafficType,
+    public PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId,
String trafficType, String isolationMethod,
             String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel,
String vlan, String hypervLabel) {
         // TODO Auto-generated method stub
         return null;


Mime
View raw message