diff --git a/api/src/com/cloud/agent/api/CheckNetworkAnswer.java b/api/src/com/cloud/agent/api/CheckNetworkAnswer.java
new file mode 100644
index 00000000000..8bb0255727c
--- /dev/null
+++ b/api/src/com/cloud/agent/api/CheckNetworkAnswer.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+package com.cloud.agent.api;
+
+public class CheckNetworkAnswer extends Answer {
+ // indicate if agent reconnect is needed after setupNetworkNames command
+ private boolean _reconnect;
+ public CheckNetworkAnswer() {}
+
+
+ public CheckNetworkAnswer(CheckNetworkCommand cmd, boolean result, String details, boolean reconnect) {
+ super(cmd, result, details);
+ _reconnect = reconnect;
+ }
+
+ public CheckNetworkAnswer(CheckNetworkCommand cmd, boolean result, String details) {
+ this(cmd, result, details, false);
+ }
+
+ public boolean needReconnect() {
+ return _reconnect;
+ }
+
+}
diff --git a/api/src/com/cloud/agent/api/CheckNetworkCommand.java b/api/src/com/cloud/agent/api/CheckNetworkCommand.java
new file mode 100644
index 00000000000..14bb8109e18
--- /dev/null
+++ b/api/src/com/cloud/agent/api/CheckNetworkCommand.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+package com.cloud.agent.api;
+
+import java.util.List;
+
+import com.cloud.network.PhysicalNetworkSetupInfo;
+
+public class CheckNetworkCommand extends Command {
+
+ List networkInfoList;
+
+ public CheckNetworkCommand(List networkInfoList) {
+ this.networkInfoList = networkInfoList;
+ }
+
+ public List getPhysicalNetworkInfoList() {
+ return networkInfoList;
+ }
+
+ protected CheckNetworkCommand() {
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return true;
+ }
+}
diff --git a/api/src/com/cloud/api/commands/AddTrafficTypeCmd.java b/api/src/com/cloud/api/commands/AddTrafficTypeCmd.java
index cc10bcc9ccf..1c3b70112a5 100644
--- a/api/src/com/cloud/api/commands/AddTrafficTypeCmd.java
+++ b/api/src/com/cloud/api/commands/AddTrafficTypeCmd.java
@@ -58,6 +58,9 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.VMWARE_NETWORK_LABEL, type=CommandType.STRING, description="The network name label of the physical device dedicated to this traffic on a VMware host")
private String vmwareLabel;
+ @Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="The VLAN id to be used for Management traffic by VMware host")
+ private String vlan;
+
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -82,6 +85,14 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
return vmwareLabel;
}
+ public void setVlan(String vlan) {
+ this.vlan = vlan;
+ }
+
+ public String getVlan() {
+ return vlan;
+ }
+
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@@ -111,7 +122,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
@Override
public void create() throws ResourceAllocationException {
- PhysicalNetworkTrafficType result = _networkService.addTrafficTypeToPhysicalNetwork(getPhysicalNetworkId(), getTrafficType(), getXenLabel(), getKvmLabel(), getVmwareLabel());
+ PhysicalNetworkTrafficType result = _networkService.addTrafficTypeToPhysicalNetwork(getPhysicalNetworkId(), getTrafficType(), getXenLabel(), getKvmLabel(), getVmwareLabel(), getVlan());
if (result != null) {
setEntityId(result.getId());
} else {
@@ -128,5 +139,4 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
public String getEventDescription() {
return "Adding physical network traffic type: " + getEntityId();
}
-
}
diff --git a/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java b/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java
index 98b719b6756..90ab3f7222f 100644
--- a/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java
+++ b/api/src/com/cloud/api/commands/DeleteNetworkServiceProviderCmd.java
@@ -28,6 +28,8 @@ import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.SuccessResponse;
import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
@Implementation(description="Deletes a Network Service Provider.", responseObject=SuccessResponse.class)
@@ -69,13 +71,21 @@ public class DeleteNetworkServiceProviderCmd extends BaseAsyncCmd {
@Override
public void execute(){
- boolean result = _networkService.deleteNetworkServiceProvider(getId());
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network service provider");
- }
+ try{
+ boolean result = _networkService.deleteNetworkServiceProvider(getId());
+ if (result) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network service provider");
+ }
+ } catch (ResourceUnavailableException ex) {
+ s_logger.warn("Exception: ", ex);
+ throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
+ } catch (ConcurrentOperationException ex) {
+ s_logger.warn("Exception: ", ex);
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
+ }
}
diff --git a/api/src/com/cloud/api/commands/UpdateNetworkServiceProviderCmd.java b/api/src/com/cloud/api/commands/UpdateNetworkServiceProviderCmd.java
index a4be1038102..9d16c6b0691 100644
--- a/api/src/com/cloud/api/commands/UpdateNetworkServiceProviderCmd.java
+++ b/api/src/com/cloud/api/commands/UpdateNetworkServiceProviderCmd.java
@@ -30,8 +30,6 @@ import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.ProviderResponse;
import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.PhysicalNetworkServiceProvider;
import com.cloud.user.Account;
@@ -50,9 +48,6 @@ public class UpdateNetworkServiceProviderCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="network service provider id")
private Long id;
- @Parameter(name=ApiConstants.FORCED, type=CommandType.BOOLEAN, required=false, description="Force shutdown the service provider.")
- private Boolean forcedShutdown;
-
@Parameter(name=ApiConstants.SERVICE_LIST, type=CommandType.LIST, collectionType = CommandType.STRING, description="the list of services to be enabled for this physical network service provider")
private List enabledServices;
@@ -68,10 +63,6 @@ public class UpdateNetworkServiceProviderCmd extends BaseAsyncCmd {
return id;
}
- public boolean isForcedShutdown() {
- return (forcedShutdown != null) ? forcedShutdown : false;
- }
-
public List getEnabledServices() {
return enabledServices;
}
@@ -91,23 +82,14 @@ public class UpdateNetworkServiceProviderCmd extends BaseAsyncCmd {
@Override
public void execute(){
- PhysicalNetworkServiceProvider result;
- try {
- result = _networkService.updateNetworkServiceProvider(getId(), getState(), isForcedShutdown(), getEnabledServices());
- if (result != null) {
- ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider to physical network");
- }
- } catch (ResourceUnavailableException ex) {
- s_logger.warn("Exception: ", ex);
- throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
- } catch (ConcurrentOperationException ex) {
- s_logger.warn("Exception: ", ex);
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
- }
+ PhysicalNetworkServiceProvider result = _networkService.updateNetworkServiceProvider(getId(), getState(), getEnabledServices());
+ if (result != null) {
+ ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider to physical network");
+ }
}
@Override
diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java
index e232d3134dc..21a845a96a1 100644
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@ -102,9 +102,9 @@ public interface NetworkService {
List extends PhysicalNetworkServiceProvider> listNetworkServiceProviders(Long physicalNetworkId);
- PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, String state, boolean forcedShutdown, List enabledServices) throws ConcurrentOperationException, ResourceUnavailableException;
+ PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, String state, List enabledServices);
- boolean deleteNetworkServiceProvider(Long id);
+ boolean deleteNetworkServiceProvider(Long id) throws ConcurrentOperationException, ResourceUnavailableException;
PhysicalNetwork getPhysicalNetwork(Long physicalNetworkId);
@@ -116,7 +116,7 @@ public interface NetworkService {
long findPhysicalNetworkId(long zoneId, String tag);
- PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType, String xenLabel, String kvmLabel, String vmwareLabel);
+ PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType, String xenLabel, String kvmLabel, String vmwareLabel, String vlan);
PhysicalNetworkTrafficType getPhysicalNetworkTrafficType(Long id);
diff --git a/api/src/com/cloud/network/PhysicalNetworkSetupInfo.java b/api/src/com/cloud/network/PhysicalNetworkSetupInfo.java
new file mode 100644
index 00000000000..b51ac5a846e
--- /dev/null
+++ b/api/src/com/cloud/network/PhysicalNetworkSetupInfo.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright (C) 2010 VMOps, Inc. All rights reserved.
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+package com.cloud.network;
+
+
+/**
+ * PhysicalNetworkNames provides the labels to identify per traffic type
+ * the physical networks available to the host .
+ */
+public class PhysicalNetworkSetupInfo {
+
+ //physical network ID as seen by Mgmt server
+ Long physicalNetworkId;
+ String privateNetworkName;
+ String publicNetworkName;
+ String guestNetworkName;
+ String storageNetworkName;
+ //this is used by VmWare to identify the vlan to use for management traffic
+ String mgmtVlan;
+
+ public PhysicalNetworkSetupInfo(){
+ }
+
+ public String getPrivateNetworkName() {
+ return privateNetworkName;
+ }
+
+ public String getPublicNetworkName() {
+ return publicNetworkName;
+ }
+
+ public String getGuestNetworkName() {
+ return guestNetworkName;
+ }
+
+ public String getStorageNetworkName() {
+ return storageNetworkName;
+ }
+
+ public void setPrivateNetworkName(String privateNetworkName) {
+ this.privateNetworkName = privateNetworkName;
+ }
+
+ public void setPublicNetworkName(String publicNetworkName) {
+ this.publicNetworkName = publicNetworkName;
+ }
+
+ public void setGuestNetworkName(String guestNetworkName) {
+ this.guestNetworkName = guestNetworkName;
+ }
+
+ public void setStorageNetworkName(String storageNetworkName) {
+ this.storageNetworkName = storageNetworkName;
+ }
+
+ public Long getPhysicalNetworkId() {
+ return physicalNetworkId;
+ }
+
+ public void setPhysicalNetworkId(Long physicalNetworkId) {
+ this.physicalNetworkId = physicalNetworkId;
+ }
+
+ public String getMgmtVlan() {
+ return mgmtVlan;
+ }
+
+ public void setMgmtVlan(String mgmtVlan) {
+ this.mgmtVlan = mgmtVlan;
+ }
+
+
+}
diff --git a/api/src/com/cloud/network/element/NetworkElement.java b/api/src/com/cloud/network/element/NetworkElement.java
index c890a86cac5..a9c5060f7b6 100644
--- a/api/src/com/cloud/network/element/NetworkElement.java
+++ b/api/src/com/cloud/network/element/NetworkElement.java
@@ -116,14 +116,13 @@ public interface NetworkElement extends Adapter {
/**
* The network service provider is being shutdown. This should shutdown all instances of this element deployed for this provider.
- * @param networkServiceProvider
* @param context
- * @param forceShutdown
+ * @param networkServiceProvider
* @return boolean success/failure
* @throws ConcurrentOperationException
* @throws ResourceUnavailableException
*/
- boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException, ResourceUnavailableException;
+ boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
/**
* This should return true if out of multiple services provided by this element, only some can be enabled. If all the services MUST be provided, this should return false.
diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 6931bf5ce15..7edd0d37cf9 100755
--- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -64,6 +64,8 @@ import com.cloud.agent.api.BackupSnapshotCommand;
import com.cloud.agent.api.BumpUpPriorityCommand;
import com.cloud.agent.api.CheckHealthAnswer;
import com.cloud.agent.api.CheckHealthCommand;
+import com.cloud.agent.api.CheckNetworkAnswer;
+import com.cloud.agent.api.CheckNetworkCommand;
import com.cloud.agent.api.CheckOnHostAnswer;
import com.cloud.agent.api.CheckOnHostCommand;
import com.cloud.agent.api.CheckRouterAnswer;
@@ -71,6 +73,8 @@ import com.cloud.agent.api.CheckRouterCommand;
import com.cloud.agent.api.CheckVirtualMachineAnswer;
import com.cloud.agent.api.CheckVirtualMachineCommand;
import com.cloud.agent.api.CleanupNetworkRulesCmd;
+import com.cloud.agent.api.ClusterSyncAnswer;
+import com.cloud.agent.api.ClusterSyncCommand;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
@@ -81,6 +85,8 @@ import com.cloud.agent.api.DeleteSnapshotBackupAnswer;
import com.cloud.agent.api.DeleteSnapshotBackupCommand;
import com.cloud.agent.api.DeleteSnapshotsDirCommand;
import com.cloud.agent.api.DeleteStoragePoolCommand;
+import com.cloud.agent.api.GetDomRVersionAnswer;
+import com.cloud.agent.api.GetDomRVersionCmd;
import com.cloud.agent.api.GetHostStatsAnswer;
import com.cloud.agent.api.GetHostStatsCommand;
import com.cloud.agent.api.GetStorageStatsAnswer;
@@ -89,11 +95,7 @@ import com.cloud.agent.api.GetVmStatsAnswer;
import com.cloud.agent.api.GetVmStatsCommand;
import com.cloud.agent.api.GetVncPortAnswer;
import com.cloud.agent.api.GetVncPortCommand;
-import com.cloud.agent.api.GetDomRVersionCmd;
-import com.cloud.agent.api.GetDomRVersionAnswer;
import com.cloud.agent.api.HostStatsEntry;
-import com.cloud.agent.api.ClusterSyncAnswer;
-import com.cloud.agent.api.ClusterSyncCommand;
import com.cloud.agent.api.MaintainAnswer;
import com.cloud.agent.api.MaintainCommand;
import com.cloud.agent.api.ManageSnapshotAnswer;
@@ -105,7 +107,6 @@ import com.cloud.agent.api.ModifyStoragePoolAnswer;
import com.cloud.agent.api.ModifyStoragePoolCommand;
import com.cloud.agent.api.NetworkRulesSystemVmCommand;
import com.cloud.agent.api.PingCommand;
-import com.cloud.agent.api.PingRoutingCommand;
import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
import com.cloud.agent.api.PingRoutingWithOvsCommand;
import com.cloud.agent.api.PingTestCommand;
@@ -180,6 +181,7 @@ import com.cloud.network.Networks;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.PhysicalNetworkSetupInfo;
import com.cloud.network.ovs.OvsCreateGreTunnelAnswer;
import com.cloud.network.ovs.OvsCreateGreTunnelCommand;
import com.cloud.network.ovs.OvsCreateTunnelAnswer;
@@ -513,11 +515,14 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
return execute((ClusterSyncCommand)cmd);
} else if (cmd instanceof GetDomRVersionCmd) {
return execute((GetDomRVersionCmd)cmd);
+ } else if (clazz == CheckNetworkCommand.class) {
+ return execute((CheckNetworkCommand) cmd);
} else {
return Answer.createUnsupportedCommandAnswer(cmd);
}
}
+
protected XsLocalNetwork getNativeNetworkForTraffic(Connection conn, TrafficType type, String tag) throws XenAPIException, XmlRpcException {
if (tag != null) {
if (s_logger.isDebugEnabled()) {
@@ -4284,6 +4289,69 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
throw new CloudRuntimeException("Unable to get host information ", e);
}
}
+
+ protected CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Checking if network name setup is done on the resource");
+ }
+
+ List infoList = cmd.getPhysicalNetworkInfoList();
+
+ try{
+ boolean errorout = false;
+ String msg = "";
+ for(PhysicalNetworkSetupInfo info : infoList){
+ if(!isNetworkSetupByName(info.getGuestNetworkName())){
+ msg = "For Physical Network id:"+ info.getPhysicalNetworkId() + ", Guest Network is not configured on the backend by name " + info.getGuestNetworkName();
+ errorout = true;
+ break;
+ }
+ if(!isNetworkSetupByName(info.getPrivateNetworkName())){
+ msg = "For Physical Network id:"+ info.getPhysicalNetworkId() + ", Private Network is not configured on the backend by name " + info.getGuestNetworkName();
+ errorout = true;
+ break; }
+ if(!isNetworkSetupByName(info.getPublicNetworkName())){
+ msg = "For Physical Network id:"+ info.getPhysicalNetworkId() + ", Public Network is not configured on the backend by name " + info.getGuestNetworkName();
+ errorout = true;
+ break;
+ }
+ if(!isNetworkSetupByName(info.getStorageNetworkName())){
+ msg = "For Physical Network id:"+ info.getPhysicalNetworkId() + ", Storage Network is not configured on the backend by name " + info.getGuestNetworkName();
+ errorout = true;
+ break;
+ }
+ }
+ if(errorout){
+ s_logger.error(msg);
+ return new CheckNetworkAnswer(cmd, false, msg);
+ }else{
+ return new CheckNetworkAnswer(cmd, true , "Network Setup check by names is done");
+ }
+
+ }catch (XenAPIException e) {
+ String msg = "CheckNetworkCommand failed with XenAPIException:" + e.toString() + " host:" + _host.uuid;
+ s_logger.warn(msg, e);
+ return new CheckNetworkAnswer(cmd, false, msg);
+ }catch (Exception e) {
+ String msg = "CheckNetworkCommand failed with Exception:" + e.getMessage() + " host:" + _host.uuid;
+ s_logger.warn(msg, e);
+ return new CheckNetworkAnswer(cmd, false, msg);
+ }
+ }
+
+ protected boolean isNetworkSetupByName(String nameTag) throws XenAPIException, XmlRpcException{
+ if (nameTag != null) {
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Looking for network setup by name " + nameTag);
+ }
+ Connection conn = getConnection();
+ XsLocalNetwork network = getNetworkByName(conn, nameTag);
+ if (network == null) {
+ return false;
+ }
+ }
+ return true;
+ }
protected List getPatchFiles() {
return null;
diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java
index 757116516c4..e149ac1ae63 100644
--- a/server/src/com/cloud/configuration/ConfigurationManager.java
+++ b/server/src/com/cloud/configuration/ConfigurationManager.java
@@ -190,7 +190,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, Long networkId, Long physicalNetworkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
- void createDefaultNetworks(long zoneId, boolean isSecurityGroupEnabled) throws ConcurrentOperationException;
+ void createDefaultNetworks(long zoneId, boolean isSecurityGroupEnabled, long physicalNetworkId) throws ConcurrentOperationException;
HostPodVO getPod(long id);
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index e97163782fe..a2048f47611 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -103,6 +103,7 @@ import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.PhysicalNetwork;
import com.cloud.network.PhysicalNetworkVO;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.NetworkDao;
@@ -1361,8 +1362,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
zone = _zoneDao.persist(zone);
+ // Create default Physical Network
+ long physicalNetworkId = createDefaultPhysicalNetwork(zone.getId(), domainId);
+
// Create deafult networks
- createDefaultNetworks(zone.getId(), isSecurityGroupEnabled);
+ createDefaultNetworks(zone.getId(), isSecurityGroupEnabled, physicalNetworkId);
txn.commit();
return zone;
} catch (Exception ex) {
@@ -1374,8 +1378,27 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
}
+ private long createDefaultPhysicalNetwork(long zoneId, Long domainId){
+ //create entry
+ PhysicalNetwork defaultNetwork = _networkMgr.createPhysicalNetwork(zoneId, null, null, null, PhysicalNetwork.BroadcastDomainRange.ZONE.toString(), domainId, null);
+
+ String defaultXenLabel = "cloud-private";
+
+ //add default Traffic types to the physical network
+
+ _networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Guest.toString(), defaultXenLabel, null, null, null);
+
+ _networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Public.toString(), defaultXenLabel, null, null, null);
+
+ _networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Management.toString(), defaultXenLabel, null, null, null);
+
+ _networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Storage.toString(), defaultXenLabel, null, null, null);
+
+ return defaultNetwork.getId();
+ }
+
@Override
- public void createDefaultNetworks(long zoneId, boolean isSecurityGroupEnabled) throws ConcurrentOperationException {
+ public void createDefaultNetworks(long zoneId, boolean isSecurityGroupEnabled, long physicalNetworkId) throws ConcurrentOperationException {
DataCenterVO zone = _zoneDao.findById(zoneId);
String networkDomain = null;
// Create public, management, control and storage networks as a part of
@@ -1410,6 +1433,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (zone.getNetworkType() == NetworkType.Basic) {
isNetworkDefault = true;
broadcastDomainType = BroadcastDomainType.Native;
+ //set physicalnetworkId to the default Guest network in a basic Zone.
+ plan = new DataCenterDeployment(zone.getId(), null, null, null, null, physicalNetworkId);
} else if (offering.getGuestType() == GuestType.Shared && isSecurityGroupEnabled) {
isNetworkDefault = true;
} else {
diff --git a/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
index 9e86ea93ead..50ece801f65 100755
--- a/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
+++ b/server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
@@ -260,7 +260,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
details.put(HostInfo.HOST_OS_KERNEL_VERSION, hostKernelVer);
details.put(HostInfo.HYPERVISOR_VERSION, xenVersion);
- if (!params.containsKey("public.network.device") && _publicNic != null) {
+ /*if (!params.containsKey("public.network.device") && _publicNic != null) {
params.put("public.network.device", _publicNic);
details.put("public.network.device", _publicNic);
}
@@ -283,7 +283,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
if (!params.containsKey("storage.network.device2") && _storageNic2 != null) {
params.put("storage.network.device2", _storageNic2);
details.put("storage.network.device2", _storageNic2);
- }
+ }*/
params.put("wait", Integer.toString(_wait));
details.put("wait", Integer.toString(_wait));
params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString()));
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 72b7980abde..e1ff10768a4 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -47,8 +47,11 @@ import com.cloud.agent.Listener;
import com.cloud.agent.api.AgentControlAnswer;
import com.cloud.agent.api.AgentControlCommand;
import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckNetworkAnswer;
+import com.cloud.agent.api.CheckNetworkCommand;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.StartupCommand;
+import com.cloud.agent.api.StartupRoutingCommand;
import com.cloud.agent.api.to.NicTO;
import com.cloud.alert.AlertManager;
import com.cloud.api.commands.AssociateIPAddrCmd;
@@ -96,6 +99,7 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.UnsupportedServiceException;
import com.cloud.host.HostVO;
import com.cloud.host.Status;
+import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.IpAddress.State;
import com.cloud.network.Network.Capability;
@@ -270,6 +274,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Inject LoadBalancerDao _lbDao;
@Inject PhysicalNetworkTrafficTypeDao _pNTrafficTypeDao;
@Inject AgentManager _agentMgr;
+ @Inject HostDao _hostDao;
private final HashMap _systemNetworks = new HashMap(5);
@@ -3576,6 +3581,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
throw new InvalidParameterValueException("Please specify a valid zone.");
}
+ if(zone.getNetworkType() == NetworkType.Basic){
+ if(!_physicalNetworkDao.listByZone(zoneId).isEmpty()){
+ throw new CloudRuntimeException("Cannot add the physical network to basic zone id: "+zoneId+", there is a physical network already existing in this basic Zone");
+ }
+ }
if (tags != null && tags.size() > 1) {
throw new InvalidParameterException("Only one tag can be specified for a physical network at this time");
}
@@ -3639,11 +3649,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
txn.commit();
return pNetwork;
} catch (Exception ex) {
- txn.rollback();
s_logger.warn("Exception: ", ex);
throw new CloudRuntimeException("Fail to create a physical network");
- } finally {
- txn.close();
}
}
@@ -3794,7 +3801,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@ActionEvent(eventType = EventTypes.EVENT_PHYSICAL_NETWORK_DELETE, eventDescription = "deleting physical network", async = true)
- @DB
public boolean deletePhysicalNetwork(Long physicalNetworkId) {
// verify input parameters
@@ -3802,11 +3808,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (pNetwork == null) {
throw new InvalidParameterValueException("Network id=" + physicalNetworkId + "doesn't exist in the system");
}
- Transaction txn = Transaction.currentTxn();
checkIfPhysicalNetworkIsDeletable(physicalNetworkId);
- txn.start();
// delete vlans for this zone
List vlans = _vlanDao.listVlansByPhysicalNetworkId(physicalNetworkId);
@@ -3830,7 +3834,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
boolean success = _physicalNetworkDao.remove(physicalNetworkId);
- txn.commit();
return success;
}
@@ -4020,11 +4023,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
txn.commit();
return nsp;
} catch (Exception ex) {
- txn.rollback();
s_logger.warn("Exception: ", ex);
throw new CloudRuntimeException("Fail to add a provider to physical network");
- } finally {
- txn.close();
}
}
@@ -4041,7 +4041,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@ActionEvent(eventType = EventTypes.EVENT_SERVICE_PROVIDER_UPDATE, eventDescription = "Updating physical network ServiceProvider", async = true)
- public PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, String stateStr, boolean forcedShutdown, List enabledServices) throws ConcurrentOperationException, ResourceUnavailableException {
+ public PhysicalNetworkServiceProvider updateNetworkServiceProvider(Long id, String stateStr, List enabledServices){
PhysicalNetworkServiceProviderVO provider = _pNSPDao.findById(id);
if(provider == null){
@@ -4058,13 +4058,17 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
try {
state = PhysicalNetworkServiceProvider.State.valueOf(stateStr);
} catch (IllegalArgumentException ex) {
- throw new InvalidParameterValueException("Unable to resolve state '" + stateStr + "' to a supported value {Enabled or Disabled or Shutdown}");
+ throw new InvalidParameterValueException("Unable to resolve state '" + stateStr + "' to a supported value {Enabled or Disabled}");
}
}
boolean update = false;
if(state != null){
+ if(state == PhysicalNetworkServiceProvider.State.Shutdown){
+ throw new InvalidParameterValueException("Updating the provider state to 'Shutdown' is not supported");
+ }
+
if(s_logger.isDebugEnabled()){
s_logger.debug("updating state of the service provider id=" + id + " on physical network: "+provider.getPhysicalNetworkId() + " to state: "+stateStr);
}
@@ -4080,19 +4084,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
provider.setState(PhysicalNetworkServiceProvider.State.Disabled);
update = true;
break;
- case Shutdown:
- User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
- Account callerAccount = _accountMgr.getActiveAccountById(callerUser.getAccountId());
- //shutdown the network
- ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount);
- if(s_logger.isDebugEnabled()){
- s_logger.debug("Shutting down the service provider id=" + id + " on physical network: "+provider.getPhysicalNetworkId());
- }
- if(element != null && element.shutdownProviderInstances(provider, context, forcedShutdown)){
- provider.setState(PhysicalNetworkServiceProvider.State.Shutdown);
- update = true;
- }
- break;
}
}
@@ -4124,14 +4115,34 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@ActionEvent(eventType = EventTypes.EVENT_SERVICE_PROVIDER_DELETE, eventDescription = "Deleting physical network ServiceProvider", async = true)
- public boolean deleteNetworkServiceProvider(Long id) {
+ public boolean deleteNetworkServiceProvider(Long id) throws ConcurrentOperationException, ResourceUnavailableException {
PhysicalNetworkServiceProviderVO provider = _pNSPDao.findById(id);
if(provider == null){
throw new InvalidParameterValueException("Network Service Provider id=" + id + "doesn't exist in the system");
}
- //TODO provider instances?
+ //check if there are networks using this provider
+ List networks = _networksDao.listByPhysicalNetworkAndProvider(provider.getPhysicalNetworkId(), provider.getProviderName());
+ if(networks != null && !networks.isEmpty()){
+ throw new CloudRuntimeException("Provider is not deletable because there are existing networks using this provider, please destroy all networks first");
+ }
+
+ User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
+ Account callerAccount = _accountMgr.getActiveAccountById(callerUser.getAccountId());
+ //shutdown the provider instances
+ ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount);
+ if(s_logger.isDebugEnabled()){
+ s_logger.debug("Shutting down the service provider id=" + id + " on physical network: "+provider.getPhysicalNetworkId());
+ }
+ NetworkElement element = getElementImplementingProvider(provider.getProviderName());
+ if(element == null){
+ throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + provider.getProviderName() + "'");
+ }
+
+ if(element != null && element.shutdownProviderInstances(provider, context)){
+ provider.setState(PhysicalNetworkServiceProvider.State.Shutdown);
+ }
return _pNSPDao.remove(id);
}
@@ -4430,7 +4441,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@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 xenLabel, String kvmLabel, String vmwareLabel, String vlan) {
// verify input parameters
PhysicalNetworkVO network = _physicalNetworkDao.findById(physicalNetworkId);
@@ -4464,21 +4475,38 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
try {
txn.start();
// Create the new traffic type in the database
- PhysicalNetworkTrafficTypeVO pNetworktrafficType = new PhysicalNetworkTrafficTypeVO(physicalNetworkId, trafficType, xenLabel, kvmLabel, vmwareLabel);
+ if(xenLabel == null){
+ xenLabel = getDefaultXenNetworkLabel(trafficType);
+ }
+ PhysicalNetworkTrafficTypeVO pNetworktrafficType = new PhysicalNetworkTrafficTypeVO(physicalNetworkId, trafficType, xenLabel, kvmLabel, vmwareLabel, vlan);
pNetworktrafficType = _pNTrafficTypeDao.persist(pNetworktrafficType);
txn.commit();
return pNetworktrafficType;
} catch (Exception ex) {
- txn.rollback();
s_logger.warn("Exception: ", ex);
throw new CloudRuntimeException("Fail to add a traffic type to physical network");
- } finally {
- txn.close();
}
}
+ private String getDefaultXenNetworkLabel(TrafficType trafficType){
+ String xenLabel = null;
+ switch(trafficType){
+ case Public: xenLabel = "cloud-public";
+ break;
+ case Guest: xenLabel = "cloud-guest";
+ break;
+ case Storage: xenLabel = "cloud-storage";
+ break;
+ case Management: xenLabel = "cloud-private";
+ break;
+ case Control: xenLabel = "cloud_link_local_network";
+ break;
+ }
+ return xenLabel;
+ }
+
@Override
@ActionEvent(eventType = EventTypes.EVENT_TRAFFIC_TYPE_CREATE, eventDescription = "Creating Physical Network TrafficType", async = true)
public PhysicalNetworkTrafficType getPhysicalNetworkTrafficType(Long id){
@@ -4556,49 +4584,115 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
public boolean processAnswers(long agentId, long seq, Answer[] answers) {
- // TODO Auto-generated method stub
return false;
}
@Override
public boolean processCommands(long agentId, long seq, Command[] commands) {
- // TODO Auto-generated method stub
return false;
}
@Override
public AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd) {
- // TODO Auto-generated method stub
return null;
}
@Override
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
- // TODO Auto-generated method stub
+ if (!(cmd instanceof StartupRoutingCommand )) {
+ return;
+ }
+ long hostId = host.getId();
+ StartupRoutingCommand startup = (StartupRoutingCommand)cmd;
+ String dataCenter = startup.getDataCenter();
+
+ long dcId = -1;
+ DataCenterVO dc = _dcDao.findByName(dataCenter);
+ if (dc == null) {
+ try {
+ dcId = Long.parseLong(dataCenter);
+ dc = _dcDao.findById(dcId);
+ } catch (final NumberFormatException e) {
+ }
+ }
+ if (dc == null) {
+ throw new IllegalArgumentException("Host " + startup.getPrivateIpAddress() + " sent incorrect data center: " + dataCenter);
+ }
+ dcId = dc.getId();
+ HypervisorType hypervisorType = startup.getHypervisorType();
+
+
+ List networkInfoList = new ArrayList();
+
+ //list all physicalnetworks in the zone & for each get the network names
+ List physicalNtwkList = _physicalNetworkDao.listByZone(dcId);
+ for(PhysicalNetworkVO pNtwk : physicalNtwkList){
+ String publicName = _pNTrafficTypeDao.getNetworkTag(pNtwk.getId(), TrafficType.Public, hypervisorType);
+ String privateName = _pNTrafficTypeDao.getNetworkTag(pNtwk.getId(), TrafficType.Management, hypervisorType);
+ String guestName = _pNTrafficTypeDao.getNetworkTag(pNtwk.getId(), TrafficType.Guest, hypervisorType);
+ String storageName = _pNTrafficTypeDao.getNetworkTag(pNtwk.getId(), TrafficType.Storage, hypervisorType);
+ //String controlName = _pNTrafficTypeDao.getNetworkTag(pNtwk.getId(), TrafficType.Control, hypervisorType);
+ PhysicalNetworkSetupInfo info = new PhysicalNetworkSetupInfo();
+ info.setPhysicalNetworkId(pNtwk.getId());
+ info.setGuestNetworkName(guestName);
+ info.setPrivateNetworkName(privateName);
+ info.setPublicNetworkName(publicName);
+ info.setStorageNetworkName(storageName);
+ PhysicalNetworkTrafficTypeVO mgmtTraffic = _pNTrafficTypeDao.findBy(pNtwk.getId(), TrafficType.Management);
+ if(mgmtTraffic != null){
+ String vlan = mgmtTraffic.getVlan();
+ info.setMgmtVlan(vlan);
+ }
+ networkInfoList.add(info);
+ }
+
+ //send the names to the agent
+ if(s_logger.isDebugEnabled()){
+ s_logger.debug("Sending CheckNetworkCommand to check the Network is setup correctly on Agent");
+ }
+ CheckNetworkCommand nwCmd = new CheckNetworkCommand(networkInfoList);
+
+ CheckNetworkAnswer answer = (CheckNetworkAnswer) _agentMgr.easySend(hostId, nwCmd);
+
+ if (answer == null) {
+ s_logger.warn("Unable to get an answer to the CheckNetworkCommand from agent:" +host.getId());
+ throw new ConnectionException(true, "Unable to get an answer to the CheckNetworkCommand from agent: "+host.getId());
+ }
+
+ if (!answer.getResult()) {
+ s_logger.warn("Unable to setup agent " + hostId + " due to " + ((answer != null)?answer.getDetails():"return null"));
+ String msg = "Incorrect Network setup on agent, Reinitialize agent after network names are setup, details : " + answer.getDetails();
+ _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, host.getPodId(), msg, msg);
+ throw new ConnectionException(true, msg);
+ }else{
+ if ( answer.needReconnect() ) {
+ throw new ConnectionException(false, "Reinitialize agent after network setup.");
+ }
+ if(s_logger.isDebugEnabled()){
+ s_logger.debug("Network setup is correct on Agent");
+ }
+ return;
+ }
}
@Override
public boolean processDisconnect(long agentId, Status state) {
- // TODO Auto-generated method stub
return false;
}
@Override
public boolean isRecurring() {
- // TODO Auto-generated method stub
return false;
}
@Override
public int getTimeout() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public boolean processTimeout(long agentId, long seq) {
- // TODO Auto-generated method stub
return false;
}
diff --git a/server/src/com/cloud/network/dao/NetworkDao.java b/server/src/com/cloud/network/dao/NetworkDao.java
index 895a941644c..5fbe26f1cae 100644
--- a/server/src/com/cloud/network/dao/NetworkDao.java
+++ b/server/src/com/cloud/network/dao/NetworkDao.java
@@ -77,4 +77,7 @@ public interface NetworkDao extends GenericDao {
List listByPhysicalNetworkTrafficType(long physicalNetworkId, TrafficType trafficType);
List listBy(long accountId, long dataCenterId, Network.GuestType type, TrafficType trafficType);
+
+ List listByPhysicalNetworkAndProvider(long physicalNetworkId, String providerName);
}
+
diff --git a/server/src/com/cloud/network/dao/NetworkDaoImpl.java b/server/src/com/cloud/network/dao/NetworkDaoImpl.java
index 249de89e98c..e10f59ea1bd 100644
--- a/server/src/com/cloud/network/dao/NetworkDaoImpl.java
+++ b/server/src/com/cloud/network/dao/NetworkDaoImpl.java
@@ -369,6 +369,23 @@ public class NetworkDaoImpl extends GenericDaoBase implements N
sc.setParameters("physicalNetworkId", physicalNetworkId);
return listBy(sc);
}
+
+ @Override
+ public List listByPhysicalNetworkAndProvider(long physicalNetworkId, String providerName) {
+ SearchBuilder svcProviderMapSearch = _ntwkOffSvcMap.createSearchBuilder();
+ NetworkOfferingServiceMapVO svcProviderEntry = svcProviderMapSearch.entity();
+ svcProviderMapSearch.and("Provider", svcProviderMapSearch.entity().getProvider(), SearchCriteria.Op.EQ);
+
+ SearchBuilder networksSearch = createSearchBuilder();
+ networksSearch.and("physicalNetworkId", networksSearch.entity().getPhysicalNetworkId(), Op.EQ);
+ networksSearch.join("svcProviderMapSearch", svcProviderMapSearch, networksSearch.entity().getNetworkOfferingId(), svcProviderEntry.getNetworkOfferingId(), JoinBuilder.JoinType.INNER);
+
+ SearchCriteria sc = networksSearch.create();
+ sc.setJoinParameters("svcProviderMapSearch", "Provider", providerName);
+ sc.setParameters("physicalNetworkId", physicalNetworkId);
+
+ return listBy(sc);
+ }
@Override
public List listBy(long accountId, long dataCenterId, Network.GuestType type, TrafficType trafficType) {
diff --git a/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java b/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java
index 6b4817b8e95..660869e8ffb 100644
--- a/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java
+++ b/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDao.java
@@ -27,4 +27,5 @@ public interface PhysicalNetworkTrafficTypeDao extends GenericDao listBy(long physicalNetworkId);
boolean isTrafficTypeSupported(long physicalNetworkId, TrafficType trafficType);
String getNetworkTag (long physicalNetworkId, TrafficType trafficType, HypervisorType hType);
+ PhysicalNetworkTrafficTypeVO findBy(long physicalNetworkId, TrafficType trafficType);
}
diff --git a/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java b/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
index 856a8fc98d9..f28564cd1a3 100644
--- a/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
+++ b/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
@@ -109,4 +109,12 @@ public class PhysicalNetworkTrafficTypeDaoImpl extends GenericDaoBase sc = physicalNetworkSearch.create();
+ sc.setParameters("physicalNetworkId", physicalNetworkId);
+ sc.setParameters("trafficType", trafficType);
+ return findOneBy(sc);
+ }
}
diff --git a/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeVO.java b/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeVO.java
index 6473e4cc712..ee2b26ab0c5 100644
--- a/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeVO.java
+++ b/server/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeVO.java
@@ -52,16 +52,20 @@ public class PhysicalNetworkTrafficTypeVO implements PhysicalNetworkTrafficType
@Column(name = "vmware_network_label")
private String vmwareNetworkLabel;
+
+ @Column(name = "vlan")
+ private String vlan;
public PhysicalNetworkTrafficTypeVO() {
}
- public PhysicalNetworkTrafficTypeVO(long physicalNetworkId, TrafficType trafficType, String xenLabel, String kvmLabel, String vmwareLabel) {
+ public PhysicalNetworkTrafficTypeVO(long physicalNetworkId, TrafficType trafficType, String xenLabel, String kvmLabel, String vmwareLabel, String vlan) {
this.physicalNetworkId = physicalNetworkId;
this.trafficType = trafficType;
this.xenNetworkLabel = xenLabel;
this.kvmNetworkLabel = kvmLabel;
this.vmwareNetworkLabel = vmwareLabel;
+ this.setVlan(vlan);
}
@Override
@@ -104,6 +108,14 @@ public class PhysicalNetworkTrafficTypeVO implements PhysicalNetworkTrafficType
@Override
public String getVmwareNetworkLabel() {
return vmwareNetworkLabel;
+ }
+
+ public void setVlan(String vlan) {
+ this.vlan = vlan;
+ }
+
+ public String getVlan() {
+ return vlan;
}
}
diff --git a/server/src/com/cloud/network/element/BareMetalElement.java b/server/src/com/cloud/network/element/BareMetalElement.java
index 08b1bbbc7ad..4ff2b97c73f 100644
--- a/server/src/com/cloud/network/element/BareMetalElement.java
+++ b/server/src/com/cloud/network/element/BareMetalElement.java
@@ -114,7 +114,7 @@ public class BareMetalElement extends AdapterBase implements NetworkElement {
}
@Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException, ResourceUnavailableException {
+ public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
return true;
}
diff --git a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
index 6751b5bf5e5..5ed38e1f370 100644
--- a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
+++ b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
@@ -221,7 +221,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
}
@Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException, ResourceUnavailableException {
+ public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
// TODO Auto-generated method stub
return true;
}
diff --git a/server/src/com/cloud/network/element/ElasticLoadBalancerElement.java b/server/src/com/cloud/network/element/ElasticLoadBalancerElement.java
index 99310597edd..35394a12dd1 100644
--- a/server/src/com/cloud/network/element/ElasticLoadBalancerElement.java
+++ b/server/src/com/cloud/network/element/ElasticLoadBalancerElement.java
@@ -163,7 +163,7 @@ public class ElasticLoadBalancerElement extends AdapterBase implements LoadBalan
}
@Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException,
+ public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
// TODO Auto-generated method stub
return true;
diff --git a/server/src/com/cloud/network/element/ExternalDhcpElement.java b/server/src/com/cloud/network/element/ExternalDhcpElement.java
index 31d6e3d97d5..a6a4ef79a35 100644
--- a/server/src/com/cloud/network/element/ExternalDhcpElement.java
+++ b/server/src/com/cloud/network/element/ExternalDhcpElement.java
@@ -131,7 +131,7 @@ public class ExternalDhcpElement extends AdapterBase implements NetworkElement {
}
@Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException, ResourceUnavailableException {
+ public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
// TODO Auto-generated method stub
return true;
}
diff --git a/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java b/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
index c65b2ea224e..a77446a603e 100644
--- a/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
+++ b/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
@@ -163,7 +163,7 @@ public class F5ExternalLoadBalancerElement extends AdapterBase implements LoadBa
}
@Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException,
+ public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
// TODO Auto-generated method stub
return true;
diff --git a/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java b/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
index 0e290f69269..effbb30f90c 100644
--- a/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
+++ b/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
@@ -260,7 +260,7 @@ public class JuniperSRXExternalFirewallElement extends AdapterBase implements So
}
@Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException,
+ public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
// TODO Auto-generated method stub
return true;
diff --git a/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java b/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java
index 9098cd236d6..3567b764826 100644
--- a/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java
+++ b/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java
@@ -162,7 +162,7 @@ public class NetscalerExternalLoadBalancerElement extends AdapterBase implements
}
@Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException,
+ public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
// TODO Auto-generated method stub
return true;
diff --git a/server/src/com/cloud/network/element/OvsElement.java b/server/src/com/cloud/network/element/OvsElement.java
index 2ca17783d1a..c422485fee6 100644
--- a/server/src/com/cloud/network/element/OvsElement.java
+++ b/server/src/com/cloud/network/element/OvsElement.java
@@ -126,7 +126,7 @@ public class OvsElement extends AdapterBase implements NetworkElement {
}
@Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown)
+ public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context)
throws ConcurrentOperationException, ResourceUnavailableException {
return true;
}
diff --git a/server/src/com/cloud/network/element/SecurityGroupElement.java b/server/src/com/cloud/network/element/SecurityGroupElement.java
index ac77ab8eacf..098e2b24014 100644
--- a/server/src/com/cloud/network/element/SecurityGroupElement.java
+++ b/server/src/com/cloud/network/element/SecurityGroupElement.java
@@ -97,7 +97,7 @@ public class SecurityGroupElement extends AdapterBase implements NetworkElement
}
@Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException, ResourceUnavailableException {
+ public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
return true;
}
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java
index f213be1321c..59653783a51 100644
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -439,7 +439,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
}
@Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException,
+ public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), VirtualRouterProviderType.VirtualRouterElement);
if (element == null) {
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index dc39c4c0328..3251fda5b41 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -1770,8 +1770,9 @@ CREATE TABLE `cloud`.`physical_network_traffic_types` (
`physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network',
`traffic_type` varchar(32) NOT NULL COMMENT 'type of traffic going through this network',
`xen_network_label` varchar(255) COMMENT 'The network name label of the physical device dedicated to this traffic on a XenServer host',
- `kvm_network_label` varchar(255) COMMENT 'The network name label of the physical device dedicated to this traffic on a KVM host',
- `vmware_network_label` varchar(255) COMMENT 'The network name label of the physical device dedicated to this traffic on a VMware host',
+ `kvm_network_label` varchar(255) DEFAULT 'cloudbr0' COMMENT 'The network name label of the physical device dedicated to this traffic on a KVM host',
+ `vmware_network_label` varchar(255) DEFAULT 'vSwitch0' COMMENT 'The network name label of the physical device dedicated to this traffic on a VMware host',
+ `vlan` varchar(255) COMMENT 'The vlan tag to be sent down to a VMware host',
PRIMARY KEY (`id`),
CONSTRAINT `fk_physical_network_traffic_types__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE,
UNIQUE KEY(`physical_network_id`, `traffic_type`)