You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/01/15 03:04:54 UTC
[19/44] Revert "Merge remote-tracking branch 'origin/javelin' into
javelin"
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
index c28f259..e17d99d 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
@@ -11,7 +11,7 @@
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
+// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network;
@@ -49,7 +49,7 @@ import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
@Inject
- CiscoNexusVSMDeviceDao _ciscoNexusVSMDeviceDao;
+ CiscoNexusVSMDeviceDao _ciscoNexusVSMDeviceDao;
@Inject
ClusterDao _clusterDao;
@Inject
@@ -66,9 +66,9 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
PortProfileDao _ppDao;
@Inject
ConfigurationDao _configDao;
-
+
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(ExternalLoadBalancerDeviceManagerImpl.class);
-
+
@DB
//public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress, String username, String password, ServerResource resource, String vsmName) {
public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress, String username, String password, String vCenterIpaddr, String vCenterDcName) {
@@ -78,7 +78,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
// First check if the cluster is of type vmware. If not,
// throw an exception. VSMs are tightly integrated with vmware clusters.
-
+
ClusterVO cluster = _clusterDao.findById(clusterId);
if (cluster == null) {
throw new InvalidParameterValueException("Cluster with specified ID not found!");
@@ -91,21 +91,21 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
// Next, check if the cluster already has a VSM associated with it.
// If so, throw an exception disallowing this operation. The user must first
// delete the current VSM and then only attempt to add the new one.
-
+
if (_clusterVSMDao.findByClusterId(clusterId) != null) {
// We can't have two VSMs for the same cluster. Throw exception.
throw new InvalidParameterValueException("Cluster with specified id already has a VSM tied to it. Please remove that first and retry the operation.");
}
// TODO: Confirm whether we should be checking for VSM reachability here.
-
+
// Next, check if this VSM is reachable. Use the XML-RPC VSM API Java bindings to talk to
// the VSM.
//NetconfHelper (String ip, String username, String password)
NetconfHelper netconfClient;
try {
- netconfClient = new NetconfHelper(ipaddress, username, password);
+ netconfClient = new NetconfHelper(ipaddress, username, password);
} catch(CloudRuntimeException e) {
String msg = "Failed to connect to Nexus VSM " + ipaddress + " with credentials of user " + username;
s_logger.error(msg);
@@ -119,7 +119,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
// First, check if VSM already exists in the table "virtual_supervisor_module".
// If it's not there already, create it.
// If it's there already, return success.
-
+
// TODO - Right now, we only check if the ipaddress matches for both requests.
// We must really check whether every field of the VSM matches. Anyway, the
// advantage of our approach for now is that existing infrastructure using
@@ -132,7 +132,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
throw new CloudRuntimeException(e.getMessage());
}
- if (VSMObj == null) {
+ if (VSMObj == null) {
// Create the VSM record. For now, we aren't using the vsmName field.
VSMObj = new CiscoNexusVSMDeviceVO(ipaddress, username, password);
Transaction txn = Transaction.currentTxn();
@@ -145,7 +145,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
throw new CloudRuntimeException(e.getMessage());
}
}
-
+
// At this stage, we have a VSM record for sure. Connect the VSM to the cluster Id.
long vsmId = _ciscoNexusVSMDeviceDao.getVSMbyIpaddress(ipaddress).getId();
ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsmId);
@@ -158,22 +158,22 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
txn.rollback();
throw new CloudRuntimeException(e.getMessage());
}
-
+
// Now, get a list of all the ESXi servers in this cluster.
// This is effectively a select * from host where cluster_id=clusterId;
// All ESXi servers are stored in the host table, and their resource
// type is vmwareresource.
-
+
//List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
-
+
//TODO: Activate the code below if we make the Nexus VSM a separate resource.
// Iterate through each of the hosts in this list. Each host has a host id.
// Given this host id, we can reconfigure the in-memory resource representing
// the host via the agent manager. Thus we inject VSM related information
// into each host's resource. Also, we first configure each resource's
// entries in the database to contain this VSM information before the injection.
-
- //for (HostVO host : hosts) {
+
+ //for (HostVO host : hosts) {
// Create a host details VO object and write it out for this hostid.
//Long hostid = new Long(vsmId);
//DetailVO vsmDetail = new DetailVO(host.getId(), "vsmId", hostid.toString());
@@ -194,28 +194,28 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
//hostDetails.put(ApiConstants.USERNAME, username);
//hostDetails.put(ApiConstants.PASSWORD, password);
//_agentMrg.send(host.getId(), )
-
+
return VSMObj;
-
+
}
-
+
@DB
- public boolean deleteCiscoNexusVSM(long vsmId) throws ResourceInUseException {
+ public boolean deleteCiscoNexusVSM(long vsmId) throws ResourceInUseException {
CiscoNexusVSMDeviceVO cisconexusvsm = _ciscoNexusVSMDeviceDao.findById(vsmId);
if (cisconexusvsm == null) {
// This entry is already not present. Return success.
return true;
}
-
+
// First, check whether this VSM is part of any non-empty cluster.
// Search ClusterVSMMap's table for a list of clusters using this vsmId.
-
+
List<ClusterVSMMapVO> clusterList = _clusterVSMDao.listByVSMId(vsmId);
-
- if (clusterList != null) {
+
+ if (clusterList != null) {
for (ClusterVSMMapVO record : clusterList) {
// If this cluster id has any hosts in it, fail this operation.
- Long clusterId = record.getClusterId();
+ Long clusterId = record.getClusterId();
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
if (hosts != null && hosts.size() > 0) {
for (Host host: hosts) {
@@ -223,26 +223,26 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
s_logger.info("Non-empty cluster with id" + clusterId + "still has a host that uses this VSM. Please empty the cluster first");
throw new ResourceInUseException("Non-empty cluster with id" + clusterId + "still has a host that uses this VSM. Please empty the cluster first");
}
- }
+ }
}
}
}
-
+
// Iterate through the cluster list again, this time, delete the VSM.
Transaction txn = Transaction.currentTxn();
try {
txn.start();
- // Remove the VSM entry in CiscoNexusVSMDeviceVO's table.
+ // Remove the VSM entry in CiscoNexusVSMDeviceVO's table.
_ciscoNexusVSMDeviceDao.remove(vsmId);
- // Remove the current record as well from ClusterVSMMapVO's table.
+ // Remove the current record as well from ClusterVSMMapVO's table.
_clusterVSMDao.removeByVsmId(vsmId);
// There are no hosts at this stage in the cluster, so we don't need
- // to notify any resources or remove host details.
- txn.commit();
+ // to notify any resources or remove host details.
+ txn.commit();
} catch (Exception e) {
- s_logger.info("Caught exception when trying to delete VSM record.." + e.getMessage());
+ s_logger.info("Caught exception when trying to delete VSM record.." + e.getMessage());
throw new CloudRuntimeException("Failed to delete VSM");
- }
+ }
return true;
}
@@ -250,10 +250,10 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
public CiscoNexusVSMDeviceVO enableCiscoNexusVSM(long vsmId) {
CiscoNexusVSMDeviceVO cisconexusvsm = _ciscoNexusVSMDeviceDao.findById(vsmId);
if (cisconexusvsm == null) {
- throw new InvalidParameterValueException("Invalid vsm Id specified");
+ throw new InvalidParameterValueException("Invalid vsm Id specified");
}
// Else, check if this db record shows that this VSM is enabled or not.
- if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Disabled) {
+ if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Disabled) {
// it's currently disabled. So change it to enabled and write it out to the db.
cisconexusvsm.setVsmDeviceState(CiscoNexusVSMDeviceVO.VSMDeviceState.Enabled);
Transaction txn = Transaction.currentTxn();
@@ -266,18 +266,18 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
throw new CloudRuntimeException(e.getMessage());
}
}
-
+
return cisconexusvsm;
}
-
- @DB
+
+ @DB
public CiscoNexusVSMDeviceVO disableCiscoNexusVSM(long vsmId) {
CiscoNexusVSMDeviceVO cisconexusvsm = _ciscoNexusVSMDeviceDao.findById(vsmId);
if (cisconexusvsm == null) {
- throw new InvalidParameterValueException("Invalid vsm Id specified");
+ throw new InvalidParameterValueException("Invalid vsm Id specified");
}
// Else, check if this db record shows that this VSM is enabled or not.
- if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Enabled) {
+ if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Enabled) {
// it's currently disabled. So change it to enabled and write it out to the db.
cisconexusvsm.setVsmDeviceState(CiscoNexusVSMDeviceVO.VSMDeviceState.Disabled);
Transaction txn = Transaction.currentTxn();
@@ -290,15 +290,15 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
throw new CloudRuntimeException(e.getMessage());
}
}
-
+
return cisconexusvsm;
}
-
+
@DB
public CiscoNexusVSMDeviceVO getCiscoVSMbyVSMId(long vsmId) {
return _ciscoNexusVSMDeviceDao.findById(vsmId);
}
-
+
@DB
public CiscoNexusVSMDeviceVO getCiscoVSMbyClusId(long clusterId) {
ClusterVSMMapVO mapVO = _clusterVSMDao.findByClusterId(clusterId);
@@ -310,12 +310,12 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
CiscoNexusVSMDeviceVO result = _ciscoNexusVSMDeviceDao.findById(mapVO.getVsmId());
return result;
}
-
+
public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
// TODO Auto-generated method stub
return null;
}
-
+
@DB
public boolean vliadateVsmCluster(String vsmIp, String vsmUser, String vsmPassword, long clusterId, String clusterName) throws ResourceInUseException {
// Check if we're associating a Cisco Nexus VSM with a vmware cluster.
@@ -343,7 +343,9 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
s_logger.error("Failed to add cluster: specified Nexus VSM is already associated with another cluster");
_clusterDao.remove(clusterId);
ResourceInUseException ex = new ResourceInUseException("Failed to add cluster: specified Nexus VSM is already associated with another cluster with specified Id");
- ex.addProxyObject("cluster", clusterList.get(0).getClusterId(), "clusterId");
+ // get clusterUuid to report error
+ ClusterVO cluster = _clusterDao.findById(clusterList.get(0).getClusterId());
+ ex.addProxyObject(cluster.getUuid());
throw ex;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
index 71683dc..f6a812d 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
@@ -17,6 +17,7 @@
package com.cloud.network.element;
+import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
@@ -25,6 +26,7 @@ import java.util.Set;
import javax.ejb.Local;
import javax.inject.Inject;
+import com.cloud.utils.PropertiesUtil;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -239,7 +241,8 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
}
@Override
- public String[] getPropertiesFiles() {
- return new String[] { "cisconexusvsm_commands.properties" };
+ public Map<String, String> getProperties() {
+ return PropertiesUtil.processConfigFile(new String[]
+ { "cisconexusvsm_commands.properties" });
}
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageResource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageResource.java
index d47da9b..009ed7b 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageResource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageResource.java
@@ -22,6 +22,7 @@ import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -30,37 +31,50 @@ import java.util.UUID;
import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreAnswer;
import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
import org.apache.cloudstack.storage.command.CopyCmd;
-import org.apache.cloudstack.storage.command.CopyCmdAnswer;
+import org.apache.cloudstack.storage.command.CopyTemplateToPrimaryStorageAnswer;
import org.apache.cloudstack.storage.command.CreatePrimaryDataStoreCmd;
import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
import org.apache.cloudstack.storage.command.CreateVolumeCommand;
import org.apache.cloudstack.storage.command.CreateVolumeFromBaseImageCommand;
+import org.apache.cloudstack.storage.command.DeleteVolumeCommand;
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
import org.apache.cloudstack.storage.datastore.protocol.DataStoreProtocol;
+import org.apache.cloudstack.storage.to.ImageDataStoreTO;
import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
import org.apache.cloudstack.storage.to.NfsPrimaryDataStoreTO;
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
import org.apache.cloudstack.storage.to.TemplateTO;
import org.apache.cloudstack.storage.to.VolumeTO;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpHead;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.log4j.Logger;
import org.apache.xmlrpc.XmlRpcException;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
-import com.cloud.agent.api.storage.DeleteVolumeCommand;
+import com.cloud.agent.api.ModifyStoragePoolAnswer;
+import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
+import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.hypervisor.xen.resource.CitrixResourceBase.SRType;
import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.storage.template.TemplateInfo;
import com.cloud.utils.exception.CloudRuntimeException;
import com.xensource.xenapi.Connection;
import com.xensource.xenapi.Host;
import com.xensource.xenapi.PBD;
+import com.xensource.xenapi.Pool;
import com.xensource.xenapi.SR;
import com.xensource.xenapi.Types;
+import com.xensource.xenapi.VBD;
import com.xensource.xenapi.Types.BadServerResponse;
import com.xensource.xenapi.Types.XenAPIException;
import com.xensource.xenapi.VDI;
@@ -115,7 +129,7 @@ public class XenServerStorageResource {
}
protected CreateVolumeAnswer execute(CreateVolumeCommand cmd) {
- VolumeTO volume = null;
+ VolumeTO volume = cmd.getVolume();
PrimaryDataStoreTO primaryDataStore = volume.getDataStore();
Connection conn = hypervisorResource.getConnection();
VDI vdi = null;
@@ -150,7 +164,7 @@ public class XenServerStorageResource {
}
protected Answer execute(DeleteVolumeCommand cmd) {
- VolumeTO volume = null;
+ VolumeTO volume = cmd.getVolume();
Connection conn = hypervisorResource.getConnection();
String errorMsg = null;
try {
@@ -502,7 +516,7 @@ public class XenServerStorageResource {
//downloadHttpToLocalFile(vdiPath, template.getPath());
hypervisorResource.callHostPlugin(conn, "storagePlugin", "downloadTemplateFromUrl", "destPath", vdiPath, "srcUrl", template.getPath());
result = true;
- return new CopyCmdAnswer(cmd, vdi.getUuid(conn));
+ return new CopyTemplateToPrimaryStorageAnswer(cmd, vdi.getUuid(conn));
} catch (BadServerResponse e) {
s_logger.debug("Failed to download template", e);
} catch (XenAPIException e) {
@@ -528,7 +542,7 @@ public class XenServerStorageResource {
}
protected Answer execute(AttachPrimaryDataStoreCmd cmd) {
- PrimaryDataStoreTO dataStore = null;
+ PrimaryDataStoreTO dataStore = cmd.getDataStore();
Connection conn = hypervisorResource.getConnection();
try {
SR sr = hypervisorResource.getStorageRepository(conn, dataStore.getUuid());
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/dao/ElasticLbVmMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/dao/ElasticLbVmMapDaoImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/dao/ElasticLbVmMapDaoImpl.java
index ba8c82d..be61f58 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/dao/ElasticLbVmMapDaoImpl.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/dao/ElasticLbVmMapDaoImpl.java
@@ -30,7 +30,7 @@ import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.LoadBalancerDaoImpl;
import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.network.router.VirtualRouter.Role;
-import com.cloud.utils.component.ComponentLocator;
+
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.JoinBuilder.JoinType;
import com.cloud.utils.db.SearchBuilder;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/network-elements/f5/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java
index 3ee8d48..72313aa 100644
--- a/plugins/network-elements/f5/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java
+++ b/plugins/network-elements/f5/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java
@@ -26,6 +26,7 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
import com.cloud.host.Host;
import com.cloud.network.element.F5ExternalLoadBalancerElementService;
import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse;
@@ -40,7 +41,7 @@ public class ListExternalLoadBalancersCmd extends BaseListCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneRespones.class,
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
description="zone Id")
private long zoneId;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java b/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java
index 4ec98f0..bf1164b 100644
--- a/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java
+++ b/plugins/network-elements/f5/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java
@@ -31,6 +31,7 @@ import org.apache.cloudstack.api.PlugService;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
+import com.cloud.api.response.F5LoadBalancerResponse;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java b/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
index 33fae86..1773026 100644
--- a/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
+++ b/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
@@ -16,6 +16,7 @@
// under the License.
package com.cloud.network.element;
+import java.lang.String;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -25,6 +26,7 @@ import java.util.Set;
import javax.ejb.Local;
import javax.inject.Inject;
+import com.cloud.utils.PropertiesUtil;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -262,8 +264,9 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
}
@Override
- public String getPropertiesFile() {
- return "f5bigip_commands.properties";
+ public Map<String, String> getProperties() {
+ return PropertiesUtil.processConfigFile(new String[]
+ { "f5bigip_commands.properties" });
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java b/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
index ba0d7a8..63781bb 100644
--- a/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
+++ b/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
@@ -16,6 +16,7 @@
// under the License.
package com.cloud.network.element;
+import java.lang.String;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -25,6 +26,7 @@ import java.util.Set;
import javax.ejb.Local;
import javax.inject.Inject;
+import com.cloud.utils.PropertiesUtil;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -404,8 +406,9 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
}
@Override
- public String getPropertiesFile() {
- return "junipersrx_commands.properties";
+ public Map<String, String> getProperties() {
+ return PropertiesUtil.processConfigFile(new String[]
+ { "junipersrx_commands.properties"});
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancerNetworksCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancerNetworksCmd.java b/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancerNetworksCmd.java
index b5935f3..52476df 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancerNetworksCmd.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/api/commands/ListNetscalerLoadBalancerNetworksCmd.java
@@ -49,7 +49,7 @@ public class ListNetscalerLoadBalancerNetworksCmd extends BaseListCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
- @Parameter(name=ApiConstants.LOAD_BALANCER_DEVICE_ID, type=CommandType.UUID, entityType = NetscalerLoadBalancerResponse.class, ,
+ @Parameter(name=ApiConstants.LOAD_BALANCER_DEVICE_ID, type=CommandType.UUID, entityType = NetscalerLoadBalancerResponse.class,
required = true, description="netscaler load balancer device ID")
private Long lbDeviceId;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
index 30c51ee..faff153 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
@@ -27,6 +27,7 @@ import java.util.Set;
import javax.ejb.Local;
import javax.inject.Inject;
+import com.cloud.utils.PropertiesUtil;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -466,8 +467,9 @@ StaticNatServiceProvider {
}
@Override
- public String getPropertiesFile() {
- return "netscalerloadbalancer_commands.properties";
+ public Map<String, String> getProperties() {
+ return PropertiesUtil.processConfigFile(new String[]
+ { "netscalerloadbalancer_commands.properties" });
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
index 78fa083..cf8d43a 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
@@ -28,8 +28,8 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.ConfigurePortForwardingRulesOnLogicalRouterAnswer;
@@ -72,16 +72,15 @@ import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.host.dao.HostDetailsDao;
+import com.cloud.network.IpAddress;
import com.cloud.network.Network;
-import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
+import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks;
import com.cloud.network.Networks.BroadcastDomainType;
-import com.cloud.network.IpAddress;
-import com.cloud.network.NetworkManager;
import com.cloud.network.NiciraNvpDeviceVO;
import com.cloud.network.NiciraNvpNicMappingVO;
import com.cloud.network.NiciraNvpRouterMappingVO;
@@ -108,6 +107,7 @@ import com.cloud.resource.ResourceStateAdapter;
import com.cloud.resource.ServerResource;
import com.cloud.resource.UnableDeleteHostException;
import com.cloud.user.Account;
+import com.cloud.utils.PropertiesUtil;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
@@ -120,17 +120,16 @@ import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.NicDao;
-@Component
@Local(value = NetworkElement.class)
public class NiciraNvpElement extends AdapterBase implements
- ConnectivityProvider, SourceNatServiceProvider,
- PortForwardingServiceProvider, StaticNatServiceProvider,
- NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
- private static final Logger s_logger = Logger
- .getLogger(NiciraNvpElement.class);
-
+ConnectivityProvider, SourceNatServiceProvider,
+PortForwardingServiceProvider, StaticNatServiceProvider,
+NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
+ private static final Logger s_logger = Logger
+ .getLogger(NiciraNvpElement.class);
+
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
-
+
@Inject
NicDao _nicDao;
@Inject
@@ -150,18 +149,18 @@ public class NiciraNvpElement extends AdapterBase implements
@Inject
NiciraNvpNicMappingDao _niciraNvpNicMappingDao;
@Inject
- NiciraNvpRouterMappingDao _niciraNvpRouterMappingDao;
- @Inject
+ NiciraNvpRouterMappingDao _niciraNvpRouterMappingDao;
+ @Inject
NetworkDao _networkDao;
- @Inject
- NetworkManager _networkManager;
- @Inject
- ConfigurationManager _configMgr;
- @Inject
- NetworkServiceMapDao _ntwkSrvcDao;
- @Inject
- VlanDao _vlanDao;
-
+ @Inject
+ NetworkManager _networkManager;
+ @Inject
+ ConfigurationManager _configMgr;
+ @Inject
+ NetworkServiceMapDao _ntwkSrvcDao;
+ @Inject
+ VlanDao _vlanDao;
+
@Override
public Map<Service, Map<Capability, String>> getCapabilities() {
return capabilities;
@@ -171,130 +170,130 @@ public class NiciraNvpElement extends AdapterBase implements
public Provider getProvider() {
return Provider.NiciraNvp;
}
-
- protected boolean canHandle(Network network, Service service) {
- s_logger.debug("Checking if NiciraNvpElement can handle service "
- + service.getName() + " on network " + network.getDisplayText());
+
+ protected boolean canHandle(Network network, Service service) {
+ s_logger.debug("Checking if NiciraNvpElement can handle service "
+ + service.getName() + " on network " + network.getDisplayText());
if (network.getBroadcastDomainType() != BroadcastDomainType.Lswitch) {
return false;
}
-
- if (!_networkManager.isProviderForNetwork(getProvider(),
- network.getId())) {
- s_logger.debug("NiciraNvpElement is not a provider for network "
- + network.getDisplayText());
- return false;
- }
-
- if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(),
- service, Network.Provider.NiciraNvp)) {
- s_logger.debug("NiciraNvpElement can't provide the "
- + service.getName() + " service on network "
- + network.getDisplayText());
- return false;
- }
+
+ if (!_networkManager.isProviderForNetwork(getProvider(),
+ network.getId())) {
+ s_logger.debug("NiciraNvpElement is not a provider for network "
+ + network.getDisplayText());
+ return false;
+ }
+
+ if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(),
+ service, Network.Provider.NiciraNvp)) {
+ s_logger.debug("NiciraNvpElement can't provide the "
+ + service.getName() + " service on network "
+ + network.getDisplayText());
+ return false;
+ }
return true;
}
-
+
@Override
public boolean configure(String name, Map<String, Object> params)
throws ConfigurationException {
super.configure(name, params);
- _resourceMgr.registerResourceStateAdapter(this.getClass()
- .getSimpleName(), this);
+ _resourceMgr.registerResourceStateAdapter(this.getClass()
+ .getSimpleName(), this);
return true;
}
@Override
public boolean implement(Network network, NetworkOffering offering,
DeployDestination dest, ReservationContext context)
- throws ConcurrentOperationException, ResourceUnavailableException,
- InsufficientCapacityException {
- s_logger.debug("entering NiciraNvpElement implement function for network "
- + network.getDisplayText()
- + " (state "
- + network.getState()
- + ")");
-
- if (!canHandle(network, Service.Connectivity)) {
- return false;
- }
-
- if (network.getBroadcastUri() == null) {
- s_logger.error("Nic has no broadcast Uri with the LSwitch Uuid");
+ throws ConcurrentOperationException, ResourceUnavailableException,
+ InsufficientCapacityException {
+ s_logger.debug("entering NiciraNvpElement implement function for network "
+ + network.getDisplayText()
+ + " (state "
+ + network.getState()
+ + ")");
+
+ if (!canHandle(network, Service.Connectivity)) {
+ return false;
+ }
+
+ if (network.getBroadcastUri() == null) {
+ s_logger.error("Nic has no broadcast Uri with the LSwitch Uuid");
+ return false;
+ }
+
+ List<NiciraNvpDeviceVO> devices = _niciraNvpDao
+ .listByPhysicalNetwork(network.getPhysicalNetworkId());
+ if (devices.isEmpty()) {
+ s_logger.error("No NiciraNvp Controller on physical network "
+ + network.getPhysicalNetworkId());
return false;
}
-
- List<NiciraNvpDeviceVO> devices = _niciraNvpDao
- .listByPhysicalNetwork(network.getPhysicalNetworkId());
- if (devices.isEmpty()) {
- s_logger.error("No NiciraNvp Controller on physical network "
- + network.getPhysicalNetworkId());
- return false;
- }
- NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
- HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
- _hostDao.loadDetails(niciraNvpHost);
-
- Account owner = context.getAccount();
-
- /**
- * Lock the network as we might need to do multiple operations that
- * should be done only once.
- */
- Network lock = _networkDao.acquireInLockTable(network.getId(),
- _networkManager.getNetworkLockTimeout());
- if (lock == null) {
- throw new ConcurrentOperationException("Unable to lock network "
- + network.getId());
- }
- try {
- // Implement SourceNat immediately as we have al the info already
- if (_networkManager.isProviderSupportServiceInNetwork(
- network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
- s_logger.debug("Apparently we are supposed to provide SourceNat on this network");
-
- PublicIp sourceNatIp = _networkManager
- .assignSourceNatIpAddressToGuestNetwork(owner, network);
- String publicCidr = sourceNatIp.getAddress().addr() + "/"
- + NetUtils.getCidrSize(sourceNatIp.getVlanNetmask());
- String internalCidr = network.getGateway() + "/"
- + network.getCidr().split("/")[1];
- long vlanid = (Vlan.UNTAGGED.equals(sourceNatIp.getVlanTag())) ? 0
- : Long.parseLong(sourceNatIp.getVlanTag());
-
- CreateLogicalRouterCommand cmd = new CreateLogicalRouterCommand(
- niciraNvpHost.getDetail("l3gatewayserviceuuid"), vlanid,
- network.getBroadcastUri().getSchemeSpecificPart(),
- "router-" + network.getDisplayText(), publicCidr,
- sourceNatIp.getGateway(), internalCidr, context
- .getDomain().getName()
- + "-"
- + context.getAccount().getAccountName());
- CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer) _agentMgr
- .easySend(niciraNvpHost.getId(), cmd);
- if (answer.getResult() == false) {
- s_logger.error("Failed to create Logical Router for network "
- + network.getDisplayText());
- return false;
- }
-
- // Store the uuid so we can easily find it during cleanup
- NiciraNvpRouterMappingVO routermapping =
- new NiciraNvpRouterMappingVO(answer.getLogicalRouterUuid(), network.getId());
- _niciraNvpRouterMappingDao.persist(routermapping);
- }
- } finally {
- if (lock != null) {
- _networkDao.releaseFromLockTable(lock.getId());
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Lock is released for network id "
- + lock.getId() + " as a part of router startup in "
- + dest);
- }
- }
- }
+ NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
+ HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
+ _hostDao.loadDetails(niciraNvpHost);
+
+ Account owner = context.getAccount();
+
+ /**
+ * Lock the network as we might need to do multiple operations that
+ * should be done only once.
+ */
+ Network lock = _networkDao.acquireInLockTable(network.getId(),
+ _networkManager.getNetworkLockTimeout());
+ if (lock == null) {
+ throw new ConcurrentOperationException("Unable to lock network "
+ + network.getId());
+ }
+ try {
+ // Implement SourceNat immediately as we have al the info already
+ if (_networkManager.isProviderSupportServiceInNetwork(
+ network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
+ s_logger.debug("Apparently we are supposed to provide SourceNat on this network");
+
+ PublicIp sourceNatIp = _networkManager
+ .assignSourceNatIpAddressToGuestNetwork(owner, network);
+ String publicCidr = sourceNatIp.getAddress().addr() + "/"
+ + NetUtils.getCidrSize(sourceNatIp.getVlanNetmask());
+ String internalCidr = network.getGateway() + "/"
+ + network.getCidr().split("/")[1];
+ long vlanid = (Vlan.UNTAGGED.equals(sourceNatIp.getVlanTag())) ? 0
+ : Long.parseLong(sourceNatIp.getVlanTag());
+
+ CreateLogicalRouterCommand cmd = new CreateLogicalRouterCommand(
+ niciraNvpHost.getDetail("l3gatewayserviceuuid"), vlanid,
+ network.getBroadcastUri().getSchemeSpecificPart(),
+ "router-" + network.getDisplayText(), publicCidr,
+ sourceNatIp.getGateway(), internalCidr, context
+ .getDomain().getName()
+ + "-"
+ + context.getAccount().getAccountName());
+ CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer) _agentMgr
+ .easySend(niciraNvpHost.getId(), cmd);
+ if (answer.getResult() == false) {
+ s_logger.error("Failed to create Logical Router for network "
+ + network.getDisplayText());
+ return false;
+ }
+
+ // Store the uuid so we can easily find it during cleanup
+ NiciraNvpRouterMappingVO routermapping =
+ new NiciraNvpRouterMappingVO(answer.getLogicalRouterUuid(), network.getId());
+ _niciraNvpRouterMappingDao.persist(routermapping);
+ }
+ } finally {
+ if (lock != null) {
+ _networkDao.releaseFromLockTable(lock.getId());
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Lock is released for network id "
+ + lock.getId() + " as a part of router startup in "
+ + dest);
+ }
+ }
+ }
return true;
}
@@ -302,10 +301,10 @@ public class NiciraNvpElement extends AdapterBase implements
public boolean prepare(Network network, NicProfile nic,
VirtualMachineProfile<? extends VirtualMachine> vm,
DeployDestination dest, ReservationContext context)
- throws ConcurrentOperationException, ResourceUnavailableException,
- InsufficientCapacityException {
-
- if (!canHandle(network, Service.Connectivity)) {
+ throws ConcurrentOperationException, ResourceUnavailableException,
+ InsufficientCapacityException {
+
+ if (!canHandle(network, Service.Connectivity)) {
return false;
}
@@ -316,60 +315,60 @@ public class NiciraNvpElement extends AdapterBase implements
NicVO nicVO = _nicDao.findById(nic.getId());
- List<NiciraNvpDeviceVO> devices = _niciraNvpDao
- .listByPhysicalNetwork(network.getPhysicalNetworkId());
+ List<NiciraNvpDeviceVO> devices = _niciraNvpDao
+ .listByPhysicalNetwork(network.getPhysicalNetworkId());
if (devices.isEmpty()) {
- s_logger.error("No NiciraNvp Controller on physical network "
- + network.getPhysicalNetworkId());
+ s_logger.error("No NiciraNvp Controller on physical network "
+ + network.getPhysicalNetworkId());
return false;
}
NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
- NiciraNvpNicMappingVO existingNicMap = _niciraNvpNicMappingDao
- .findByNicUuid(nicVO.getUuid());
+ NiciraNvpNicMappingVO existingNicMap = _niciraNvpNicMappingDao
+ .findByNicUuid(nicVO.getUuid());
if (existingNicMap != null) {
- FindLogicalSwitchPortCommand findCmd = new FindLogicalSwitchPortCommand(
- existingNicMap.getLogicalSwitchUuid(),
- existingNicMap.getLogicalSwitchPortUuid());
- FindLogicalSwitchPortAnswer answer = (FindLogicalSwitchPortAnswer) _agentMgr
- .easySend(niciraNvpHost.getId(), findCmd);
-
+ FindLogicalSwitchPortCommand findCmd = new FindLogicalSwitchPortCommand(
+ existingNicMap.getLogicalSwitchUuid(),
+ existingNicMap.getLogicalSwitchPortUuid());
+ FindLogicalSwitchPortAnswer answer = (FindLogicalSwitchPortAnswer) _agentMgr
+ .easySend(niciraNvpHost.getId(), findCmd);
+
if (answer.getResult()) {
- s_logger.warn("Existing Logical Switchport found for nic "
- + nic.getName() + " with uuid "
- + existingNicMap.getLogicalSwitchPortUuid());
- UpdateLogicalSwitchPortCommand cmd = new UpdateLogicalSwitchPortCommand(
- existingNicMap.getLogicalSwitchPortUuid(), network
- .getBroadcastUri().getSchemeSpecificPart(),
- nicVO.getUuid(), context.getDomain().getName() + "-"
- + context.getAccount().getAccountName(),
- nic.getName());
- _agentMgr.easySend(niciraNvpHost.getId(), cmd);
- return true;
- } else {
- s_logger.error("Stale entry found for nic " + nic.getName()
- + " with logical switchport uuid "
- + existingNicMap.getLogicalSwitchPortUuid());
- _niciraNvpNicMappingDao.remove(existingNicMap.getId());
+ s_logger.warn("Existing Logical Switchport found for nic "
+ + nic.getName() + " with uuid "
+ + existingNicMap.getLogicalSwitchPortUuid());
+ UpdateLogicalSwitchPortCommand cmd = new UpdateLogicalSwitchPortCommand(
+ existingNicMap.getLogicalSwitchPortUuid(), network
+ .getBroadcastUri().getSchemeSpecificPart(),
+ nicVO.getUuid(), context.getDomain().getName() + "-"
+ + context.getAccount().getAccountName(),
+ nic.getName());
+ _agentMgr.easySend(niciraNvpHost.getId(), cmd);
+ return true;
+ } else {
+ s_logger.error("Stale entry found for nic " + nic.getName()
+ + " with logical switchport uuid "
+ + existingNicMap.getLogicalSwitchPortUuid());
+ _niciraNvpNicMappingDao.remove(existingNicMap.getId());
}
}
-
- CreateLogicalSwitchPortCommand cmd = new CreateLogicalSwitchPortCommand(
- network.getBroadcastUri().getSchemeSpecificPart(),
- nicVO.getUuid(), context.getDomain().getName() + "-"
- + context.getAccount().getAccountName(), nic.getName());
- CreateLogicalSwitchPortAnswer answer = (CreateLogicalSwitchPortAnswer) _agentMgr
- .easySend(niciraNvpHost.getId(), cmd);
-
+
+ CreateLogicalSwitchPortCommand cmd = new CreateLogicalSwitchPortCommand(
+ network.getBroadcastUri().getSchemeSpecificPart(),
+ nicVO.getUuid(), context.getDomain().getName() + "-"
+ + context.getAccount().getAccountName(), nic.getName());
+ CreateLogicalSwitchPortAnswer answer = (CreateLogicalSwitchPortAnswer) _agentMgr
+ .easySend(niciraNvpHost.getId(), cmd);
+
if (answer == null || !answer.getResult()) {
- s_logger.error("CreateLogicalSwitchPortCommand failed");
+ s_logger.error("CreateLogicalSwitchPortCommand failed");
return false;
}
-
- NiciraNvpNicMappingVO nicMap = new NiciraNvpNicMappingVO(network
- .getBroadcastUri().getSchemeSpecificPart(),
- answer.getLogicalSwitchPortUuid(), nicVO.getUuid());
+
+ NiciraNvpNicMappingVO nicMap = new NiciraNvpNicMappingVO(network
+ .getBroadcastUri().getSchemeSpecificPart(),
+ answer.getLogicalSwitchPortUuid(), nicVO.getUuid());
_niciraNvpNicMappingDao.persist(nicMap);
return true;
@@ -381,7 +380,7 @@ public class NiciraNvpElement extends AdapterBase implements
ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
- if (!canHandle(network, Service.Connectivity)) {
+ if (!canHandle(network, Service.Connectivity)) {
return false;
}
@@ -389,39 +388,39 @@ public class NiciraNvpElement extends AdapterBase implements
s_logger.error("Nic has no broadcast Uri with the LSwitch Uuid");
return false;
}
-
+
NicVO nicVO = _nicDao.findById(nic.getId());
- List<NiciraNvpDeviceVO> devices = _niciraNvpDao
- .listByPhysicalNetwork(network.getPhysicalNetworkId());
+ List<NiciraNvpDeviceVO> devices = _niciraNvpDao
+ .listByPhysicalNetwork(network.getPhysicalNetworkId());
if (devices.isEmpty()) {
- s_logger.error("No NiciraNvp Controller on physical network "
- + network.getPhysicalNetworkId());
+ s_logger.error("No NiciraNvp Controller on physical network "
+ + network.getPhysicalNetworkId());
return false;
}
NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
-
- NiciraNvpNicMappingVO nicMap = _niciraNvpNicMappingDao
- .findByNicUuid(nicVO.getUuid());
+
+ NiciraNvpNicMappingVO nicMap = _niciraNvpNicMappingDao
+ .findByNicUuid(nicVO.getUuid());
if (nicMap == null) {
s_logger.error("No mapping for nic " + nic.getName());
return false;
}
-
- DeleteLogicalSwitchPortCommand cmd = new DeleteLogicalSwitchPortCommand(
- nicMap.getLogicalSwitchUuid(),
- nicMap.getLogicalSwitchPortUuid());
- DeleteLogicalSwitchPortAnswer answer = (DeleteLogicalSwitchPortAnswer) _agentMgr
- .easySend(niciraNvpHost.getId(), cmd);
-
+
+ DeleteLogicalSwitchPortCommand cmd = new DeleteLogicalSwitchPortCommand(
+ nicMap.getLogicalSwitchUuid(),
+ nicMap.getLogicalSwitchPortUuid());
+ DeleteLogicalSwitchPortAnswer answer = (DeleteLogicalSwitchPortAnswer) _agentMgr
+ .easySend(niciraNvpHost.getId(), cmd);
+
if (answer == null || !answer.getResult()) {
- s_logger.error("DeleteLogicalSwitchPortCommand failed");
+ s_logger.error("DeleteLogicalSwitchPortCommand failed");
return false;
}
-
+
_niciraNvpNicMappingDao.remove(nicMap.getId());
-
+
return true;
}
@@ -429,54 +428,54 @@ public class NiciraNvpElement extends AdapterBase implements
public boolean shutdown(Network network, ReservationContext context,
boolean cleanup) throws ConcurrentOperationException,
ResourceUnavailableException {
- if (!canHandle(network, Service.Connectivity)) {
- return false;
- }
-
- List<NiciraNvpDeviceVO> devices = _niciraNvpDao
- .listByPhysicalNetwork(network.getPhysicalNetworkId());
- if (devices.isEmpty()) {
- s_logger.error("No NiciraNvp Controller on physical network "
- + network.getPhysicalNetworkId());
- return false;
- }
- NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
- HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
-
- if (_networkManager.isProviderSupportServiceInNetwork(network.getId(),
- Service.SourceNat, Provider.NiciraNvp)) {
- s_logger.debug("Apparently we were providing SourceNat on this network");
-
- // Deleting the LogicalRouter will also take care of all provisioned
- // nat rules.
- NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
- .findByNetworkId(network.getId());
- if (routermapping == null) {
- s_logger.warn("No logical router uuid found for network "
- + network.getDisplayText());
- // This might be cause by a failed deployment, so don't make shutdown fail as well.
- return true;
- }
-
- DeleteLogicalRouterCommand cmd = new DeleteLogicalRouterCommand(routermapping.getLogicalRouterUuid());
- DeleteLogicalRouterAnswer answer =
- (DeleteLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
- if (answer.getResult() == false) {
- s_logger.error("Failed to delete LogicalRouter for network "
- + network.getDisplayText());
+ if (!canHandle(network, Service.Connectivity)) {
+ return false;
+ }
+
+ List<NiciraNvpDeviceVO> devices = _niciraNvpDao
+ .listByPhysicalNetwork(network.getPhysicalNetworkId());
+ if (devices.isEmpty()) {
+ s_logger.error("No NiciraNvp Controller on physical network "
+ + network.getPhysicalNetworkId());
return false;
}
+ NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
+ HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
+
+ if (_networkManager.isProviderSupportServiceInNetwork(network.getId(),
+ Service.SourceNat, Provider.NiciraNvp)) {
+ s_logger.debug("Apparently we were providing SourceNat on this network");
+
+ // Deleting the LogicalRouter will also take care of all provisioned
+ // nat rules.
+ NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
+ .findByNetworkId(network.getId());
+ if (routermapping == null) {
+ s_logger.warn("No logical router uuid found for network "
+ + network.getDisplayText());
+ // This might be cause by a failed deployment, so don't make shutdown fail as well.
+ return true;
+ }
+
+ DeleteLogicalRouterCommand cmd = new DeleteLogicalRouterCommand(routermapping.getLogicalRouterUuid());
+ DeleteLogicalRouterAnswer answer =
+ (DeleteLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
+ if (answer.getResult() == false) {
+ s_logger.error("Failed to delete LogicalRouter for network "
+ + network.getDisplayText());
+ return false;
+ }
- _niciraNvpRouterMappingDao.remove(routermapping.getId());
- }
+ _niciraNvpRouterMappingDao.remove(routermapping.getId());
+ }
return true;
}
@Override
- public boolean destroy(Network network, ReservationContext context)
+ public boolean destroy(Network network, ReservationContext context)
throws ConcurrentOperationException, ResourceUnavailableException {
- if (!canHandle(network, Service.Connectivity)) {
+ if (!canHandle(network, Service.Connectivity)) {
return false;
}
@@ -491,59 +490,60 @@ public class NiciraNvpElement extends AdapterBase implements
@Override
public boolean shutdownProviderInstances(
PhysicalNetworkServiceProvider provider, ReservationContext context)
- throws ConcurrentOperationException, ResourceUnavailableException {
+ throws ConcurrentOperationException, ResourceUnavailableException {
// Nothing to do here.
return true;
}
@Override
public boolean canEnableIndividualServices() {
- return true;
+ return true;
}
@Override
public boolean verifyServicesCombination(Set<Service> services) {
- // This element can only function in a Nicra Nvp based
- // SDN network, so Connectivity needs to be present here
- if (!services.contains(Service.Connectivity)) {
- s_logger.warn("Unable to provide services without Connectivity service enabled for this element");
- return false;
- }
- if ((services.contains(Service.PortForwarding) || services.contains(Service.StaticNat)) && !services.contains(Service.SourceNat)) {
- s_logger.warn("Unable to provide StaticNat and/or PortForwarding without the SourceNat service");
- return false;
- }
+ // This element can only function in a Nicra Nvp based
+ // SDN network, so Connectivity needs to be present here
+ if (!services.contains(Service.Connectivity)) {
+ s_logger.warn("Unable to provide services without Connectivity service enabled for this element");
+ return false;
+ }
+ if ((services.contains(Service.PortForwarding) || services.contains(Service.StaticNat)) && !services.contains(Service.SourceNat)) {
+ s_logger.warn("Unable to provide StaticNat and/or PortForwarding without the SourceNat service");
+ return false;
+ }
return true;
}
private static Map<Service, Map<Capability, String>> setCapabilities() {
Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
- // L2 Support : SDN provisioning
+ // L2 Support : SDN provisioning
capabilities.put(Service.Connectivity, null);
- // L3 Support : Generic?
- capabilities.put(Service.Gateway, null);
+ // L3 Support : Generic?
+ capabilities.put(Service.Gateway, null);
- // L3 Support : SourceNat
- Map<Capability, String> sourceNatCapabilities = new HashMap<Capability, String>();
- sourceNatCapabilities.put(Capability.SupportedSourceNatTypes,
- "peraccount");
- sourceNatCapabilities.put(Capability.RedundantRouter, "false");
- capabilities.put(Service.SourceNat, sourceNatCapabilities);
+ // L3 Support : SourceNat
+ Map<Capability, String> sourceNatCapabilities = new HashMap<Capability, String>();
+ sourceNatCapabilities.put(Capability.SupportedSourceNatTypes,
+ "peraccount");
+ sourceNatCapabilities.put(Capability.RedundantRouter, "false");
+ capabilities.put(Service.SourceNat, sourceNatCapabilities);
- // L3 Support : Port Forwarding
- capabilities.put(Service.PortForwarding, null);
+ // L3 Support : Port Forwarding
+ capabilities.put(Service.PortForwarding, null);
- // L3 support : StaticNat
- capabilities.put(Service.StaticNat, null);
+ // L3 support : StaticNat
+ capabilities.put(Service.StaticNat, null);
return capabilities;
}
@Override
- public String[] getPropertiesFiles() {
- return new String[] { "nicira-nvp_commands.properties" };
+ public Map<String, String> getProperties() {
+ return PropertiesUtil.processConfigFile(new String[]
+ { "nicira-nvp_commands.properties" });
}
@Override
@@ -551,41 +551,41 @@ public class NiciraNvpElement extends AdapterBase implements
public NiciraNvpDeviceVO addNiciraNvpDevice(AddNiciraNvpDeviceCmd cmd) {
ServerResource resource = new NiciraNvpResource();
String deviceName = Network.Provider.NiciraNvp.getName();
- NetworkDevice networkDevice = NetworkDevice
- .getNetworkDevice(deviceName);
+ NetworkDevice networkDevice = NetworkDevice
+ .getNetworkDevice(deviceName);
Long physicalNetworkId = cmd.getPhysicalNetworkId();
NiciraNvpDeviceVO niciraNvpDevice = null;
-
- PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
- .findById(physicalNetworkId);
+
+ PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
+ .findById(physicalNetworkId);
if (physicalNetwork == null) {
- throw new InvalidParameterValueException(
- "Could not find phyical network with ID: "
- + physicalNetworkId);
+ throw new InvalidParameterValueException(
+ "Could not find phyical network with ID: "
+ + physicalNetworkId);
}
long zoneId = physicalNetwork.getDataCenterId();
- PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao
- .findByServiceProvider(physicalNetwork.getId(),
- networkDevice.getNetworkServiceProvder());
+ PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao
+ .findByServiceProvider(physicalNetwork.getId(),
+ networkDevice.getNetworkServiceProvder());
if (ntwkSvcProvider == null) {
- throw new CloudRuntimeException("Network Service Provider: "
- + networkDevice.getNetworkServiceProvder()
- + " is not enabled in the physical network: "
- + physicalNetworkId + "to add this device");
+ throw new CloudRuntimeException("Network Service Provider: "
+ + networkDevice.getNetworkServiceProvder()
+ + " is not enabled in the physical network: "
+ + physicalNetworkId + "to add this device");
} else if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) {
- throw new CloudRuntimeException("Network Service Provider: "
- + ntwkSvcProvider.getProviderName()
- + " is in shutdown state in the physical network: "
- + physicalNetworkId + "to add this device");
+ throw new CloudRuntimeException("Network Service Provider: "
+ + ntwkSvcProvider.getProviderName()
+ + " is in shutdown state in the physical network: "
+ + physicalNetworkId + "to add this device");
}
-
+
if (_niciraNvpDao.listByPhysicalNetwork(physicalNetworkId).size() != 0) {
- throw new CloudRuntimeException(
- "A NiciraNvp device is already configured on this physical network");
+ throw new CloudRuntimeException(
+ "A NiciraNvp device is already configured on this physical network");
}
-
- Map<String, String> params = new HashMap<String, String>();
+
+ Map<String, String> params = new HashMap<String, String>();
params.put("guid", UUID.randomUUID().toString());
params.put("zoneId", String.valueOf(physicalNetwork.getDataCenterId()));
params.put("physicalNetworkId", String.valueOf(physicalNetwork.getId()));
@@ -594,40 +594,40 @@ public class NiciraNvpElement extends AdapterBase implements
params.put("adminuser", cmd.getUsername());
params.put("adminpass", cmd.getPassword());
params.put("transportzoneuuid", cmd.getTransportzoneUuid());
- // FIXME What to do with multiple isolation types
- params.put("transportzoneisotype",
- physicalNetwork.getIsolationMethods().get(0).toLowerCase());
- if (cmd.getL3GatewayServiceUuid() != null) {
- params.put("l3gatewayserviceuuid", cmd.getL3GatewayServiceUuid());
- }
-
- Map<String, Object> hostdetails = new HashMap<String, Object>();
+ // FIXME What to do with multiple isolation types
+ params.put("transportzoneisotype",
+ physicalNetwork.getIsolationMethods().get(0).toLowerCase());
+ if (cmd.getL3GatewayServiceUuid() != null) {
+ params.put("l3gatewayserviceuuid", cmd.getL3GatewayServiceUuid());
+ }
+
+ Map<String, Object> hostdetails = new HashMap<String, Object>();
hostdetails.putAll(params);
-
+
Transaction txn = Transaction.currentTxn();
try {
resource.configure(cmd.getHost(), hostdetails);
-
- Host host = _resourceMgr.addHost(zoneId, resource,
- Host.Type.L2Networking, params);
+
+ Host host = _resourceMgr.addHost(zoneId, resource,
+ Host.Type.L2Networking, params);
if (host != null) {
txn.start();
-
- niciraNvpDevice = new NiciraNvpDeviceVO(host.getId(),
- physicalNetworkId, ntwkSvcProvider.getProviderName(),
- deviceName);
+
+ niciraNvpDevice = new NiciraNvpDeviceVO(host.getId(),
+ physicalNetworkId, ntwkSvcProvider.getProviderName(),
+ deviceName);
_niciraNvpDao.persist(niciraNvpDevice);
-
- DetailVO detail = new DetailVO(host.getId(),
- "niciranvpdeviceid", String.valueOf(niciraNvpDevice
- .getId()));
+
+ DetailVO detail = new DetailVO(host.getId(),
+ "niciranvpdeviceid", String.valueOf(niciraNvpDevice
+ .getId()));
_hostDetailsDao.persist(detail);
txn.commit();
return niciraNvpDevice;
} else {
- throw new CloudRuntimeException(
- "Failed to add Nicira Nvp Device due to internal error.");
+ throw new CloudRuntimeException(
+ "Failed to add Nicira Nvp Device due to internal error.");
}
} catch (ConfigurationException e) {
txn.rollback();
@@ -638,8 +638,8 @@ public class NiciraNvpElement extends AdapterBase implements
@Override
public NiciraNvpDeviceResponse createNiciraNvpDeviceResponse(
NiciraNvpDeviceVO niciraNvpDeviceVO) {
- HostVO niciraNvpHost = _hostDao.findById(niciraNvpDeviceVO.getHostId());
- _hostDao.loadDetails(niciraNvpHost);
+ HostVO niciraNvpHost = _hostDao.findById(niciraNvpDeviceVO.getHostId());
+ _hostDao.loadDetails(niciraNvpHost);
NiciraNvpDeviceResponse response = new NiciraNvpDeviceResponse();
response.setDeviceName(niciraNvpDeviceVO.getDeviceName());
@@ -647,118 +647,118 @@ public class NiciraNvpElement extends AdapterBase implements
if (pnw != null) {
response.setPhysicalNetworkId(pnw.getUuid());
}
- response.setId(niciraNvpDeviceVO.getUuid());
+ response.setId(niciraNvpDeviceVO.getUuid());
response.setProviderName(niciraNvpDeviceVO.getProviderName());
- response.setHostName(niciraNvpHost.getDetail("ip"));
- response.setTransportZoneUuid(niciraNvpHost.getDetail("transportzoneuuid"));
- response.setL3GatewayServiceUuid(niciraNvpHost.getDetail("l3gatewayserviceuuid"));
- response.setObjectName("niciranvpdevice");
+ response.setHostName(niciraNvpHost.getDetail("ip"));
+ response.setTransportZoneUuid(niciraNvpHost.getDetail("transportzoneuuid"));
+ response.setL3GatewayServiceUuid(niciraNvpHost.getDetail("l3gatewayserviceuuid"));
+ response.setObjectName("niciranvpdevice");
return response;
}
-
+
@Override
public boolean deleteNiciraNvpDevice(DeleteNiciraNvpDeviceCmd cmd) {
Long niciraDeviceId = cmd.getNiciraNvpDeviceId();
- NiciraNvpDeviceVO niciraNvpDevice = _niciraNvpDao
- .findById(niciraDeviceId);
+ NiciraNvpDeviceVO niciraNvpDevice = _niciraNvpDao
+ .findById(niciraDeviceId);
if (niciraNvpDevice == null) {
- throw new InvalidParameterValueException(
- "Could not find a nicira device with id " + niciraDeviceId);
+ throw new InvalidParameterValueException(
+ "Could not find a nicira device with id " + niciraDeviceId);
}
-
+
// Find the physical network we work for
Long physicalNetworkId = niciraNvpDevice.getPhysicalNetworkId();
- PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
- .findById(physicalNetworkId);
+ PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
+ .findById(physicalNetworkId);
if (physicalNetwork != null) {
// Lets see if there are networks that use us
// Find the nicira networks on this physical network
- List<NetworkVO> networkList = _networkDao
- .listByPhysicalNetwork(physicalNetworkId);
-
+ List<NetworkVO> networkList = _networkDao
+ .listByPhysicalNetwork(physicalNetworkId);
+
// Networks with broadcast type lswitch are ours
for (NetworkVO network : networkList) {
if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.Lswitch) {
- if ((network.getState() != Network.State.Shutdown)
- && (network.getState() != Network.State.Destroy)) {
- throw new CloudRuntimeException(
- "This Nicira Nvp device can not be deleted as there are one or more logical networks provisioned by cloudstack.");
+ if ((network.getState() != Network.State.Shutdown)
+ && (network.getState() != Network.State.Destroy)) {
+ throw new CloudRuntimeException(
+ "This Nicira Nvp device can not be deleted as there are one or more logical networks provisioned by cloudstack.");
}
}
}
}
-
+
HostVO niciraHost = _hostDao.findById(niciraNvpDevice.getHostId());
Long hostId = niciraHost.getId();
-
+
niciraHost.setResourceState(ResourceState.Maintenance);
_hostDao.update(hostId, niciraHost);
_resourceMgr.deleteHost(hostId, false, false);
-
+
_niciraNvpDao.remove(niciraDeviceId);
return true;
}
-
+
@Override
- public List<NiciraNvpDeviceVO> listNiciraNvpDevices(
- ListNiciraNvpDevicesCmd cmd) {
+ public List<NiciraNvpDeviceVO> listNiciraNvpDevices(
+ ListNiciraNvpDevicesCmd cmd) {
Long physicalNetworkId = cmd.getPhysicalNetworkId();
Long niciraNvpDeviceId = cmd.getNiciraNvpDeviceId();
List<NiciraNvpDeviceVO> responseList = new ArrayList<NiciraNvpDeviceVO>();
-
+
if (physicalNetworkId == null && niciraNvpDeviceId == null) {
- throw new InvalidParameterValueException(
- "Either physical network Id or nicira device Id must be specified");
+ throw new InvalidParameterValueException(
+ "Either physical network Id or nicira device Id must be specified");
}
-
+
if (niciraNvpDeviceId != null) {
- NiciraNvpDeviceVO niciraNvpDevice = _niciraNvpDao
- .findById(niciraNvpDeviceId);
+ NiciraNvpDeviceVO niciraNvpDevice = _niciraNvpDao
+ .findById(niciraNvpDeviceId);
if (niciraNvpDevice == null) {
- throw new InvalidParameterValueException(
- "Could not find Nicira Nvp device with id: "
- + niciraNvpDevice);
+ throw new InvalidParameterValueException(
+ "Could not find Nicira Nvp device with id: "
+ + niciraNvpDevice);
}
responseList.add(niciraNvpDevice);
- } else {
- PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
- .findById(physicalNetworkId);
+ } else {
+ PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
+ .findById(physicalNetworkId);
if (physicalNetwork == null) {
- throw new InvalidParameterValueException(
- "Could not find a physical network with id: "
- + physicalNetworkId);
+ throw new InvalidParameterValueException(
+ "Could not find a physical network with id: "
+ + physicalNetworkId);
}
- responseList = _niciraNvpDao
- .listByPhysicalNetwork(physicalNetworkId);
+ responseList = _niciraNvpDao
+ .listByPhysicalNetwork(physicalNetworkId);
}
-
+
return responseList;
}
-
+
@Override
- public List<? extends Network> listNiciraNvpDeviceNetworks(
- ListNiciraNvpDeviceNetworksCmd cmd) {
+ public List<? extends Network> listNiciraNvpDeviceNetworks(
+ ListNiciraNvpDeviceNetworksCmd cmd) {
Long niciraDeviceId = cmd.getNiciraNvpDeviceId();
- NiciraNvpDeviceVO niciraNvpDevice = _niciraNvpDao
- .findById(niciraDeviceId);
+ NiciraNvpDeviceVO niciraNvpDevice = _niciraNvpDao
+ .findById(niciraDeviceId);
if (niciraNvpDevice == null) {
- throw new InvalidParameterValueException(
- "Could not find a nicira device with id " + niciraDeviceId);
+ throw new InvalidParameterValueException(
+ "Could not find a nicira device with id " + niciraDeviceId);
}
-
+
// Find the physical network we work for
Long physicalNetworkId = niciraNvpDevice.getPhysicalNetworkId();
- PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
- .findById(physicalNetworkId);
+ PhysicalNetworkVO physicalNetwork = _physicalNetworkDao
+ .findById(physicalNetworkId);
if (physicalNetwork == null) {
// No such physical network, so no provisioned networks
return Collections.emptyList();
}
-
+
// Find the nicira networks on this physical network
- List<NetworkVO> networkList = _networkDao
- .listByPhysicalNetwork(physicalNetworkId);
-
+ List<NetworkVO> networkList = _networkDao
+ .listByPhysicalNetwork(physicalNetworkId);
+
// Networks with broadcast type lswitch are ours
List<NetworkVO> responseList = new ArrayList<NetworkVO>();
for (NetworkVO network : networkList) {
@@ -766,10 +766,10 @@ public class NiciraNvpElement extends AdapterBase implements
responseList.add(network);
}
}
-
+
return responseList;
}
-
+
@Override
public HostVO createHostVOForConnectedAgent(HostVO host,
StartupCommand[] cmd) {
@@ -797,156 +797,156 @@ public class NiciraNvpElement extends AdapterBase implements
return new DeleteHostAnswer(true);
}
- /**
- * From interface SourceNatServiceProvider
- */
- @Override
- public IpDeployer getIpDeployer(Network network) {
- return this;
- }
-
- /**
- * From interface IpDeployer
- *
- * @param network
- * @param ipAddress
- * @param services
- * @return
- * @throws ResourceUnavailableException
- */
- @Override
- public boolean applyIps(Network network,
- List<? extends PublicIpAddress> ipAddress, Set<Service> services)
- throws ResourceUnavailableException {
- if (services.contains(Service.SourceNat)) {
- // Only if we need to provide SourceNat we need to configure the logical router
- // SourceNat is required for StaticNat and PortForwarding
- List<NiciraNvpDeviceVO> devices = _niciraNvpDao
- .listByPhysicalNetwork(network.getPhysicalNetworkId());
- if (devices.isEmpty()) {
- s_logger.error("No NiciraNvp Controller on physical network "
- + network.getPhysicalNetworkId());
- return false;
- }
- NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
- HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
- _hostDao.loadDetails(niciraNvpHost);
-
- NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
- .findByNetworkId(network.getId());
- if (routermapping == null) {
- s_logger.error("No logical router uuid found for network "
- + network.getDisplayText());
- return false;
- }
-
- List<String> cidrs = new ArrayList<String>();
- for (PublicIpAddress ip : ipAddress) {
- cidrs.add(ip.getAddress().addr() + "/" + NetUtils.getCidrSize(ip.getNetmask()));
- }
- ConfigurePublicIpsOnLogicalRouterCommand cmd = new ConfigurePublicIpsOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(),
- niciraNvpHost.getDetail("l3gatewayserviceuuid"), cidrs);
- ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
- //FIXME answer can be null if the host is down
- return answer.getResult();
- }
- else {
- s_logger.debug("No need to provision ip addresses as we are not providing L3 services.");
- }
-
- return true;
- }
-
- /**
- * From interface StaticNatServiceProvider
- */
- @Override
- public boolean applyStaticNats(Network network,
- List<? extends StaticNat> rules)
- throws ResourceUnavailableException {
+ /**
+ * From interface SourceNatServiceProvider
+ */
+ @Override
+ public IpDeployer getIpDeployer(Network network) {
+ return this;
+ }
+
+ /**
+ * From interface IpDeployer
+ *
+ * @param network
+ * @param ipAddress
+ * @param services
+ * @return
+ * @throws ResourceUnavailableException
+ */
+ @Override
+ public boolean applyIps(Network network,
+ List<? extends PublicIpAddress> ipAddress, Set<Service> services)
+ throws ResourceUnavailableException {
+ if (services.contains(Service.SourceNat)) {
+ // Only if we need to provide SourceNat we need to configure the logical router
+ // SourceNat is required for StaticNat and PortForwarding
+ List<NiciraNvpDeviceVO> devices = _niciraNvpDao
+ .listByPhysicalNetwork(network.getPhysicalNetworkId());
+ if (devices.isEmpty()) {
+ s_logger.error("No NiciraNvp Controller on physical network "
+ + network.getPhysicalNetworkId());
+ return false;
+ }
+ NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
+ HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
+ _hostDao.loadDetails(niciraNvpHost);
+
+ NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
+ .findByNetworkId(network.getId());
+ if (routermapping == null) {
+ s_logger.error("No logical router uuid found for network "
+ + network.getDisplayText());
+ return false;
+ }
+
+ List<String> cidrs = new ArrayList<String>();
+ for (PublicIpAddress ip : ipAddress) {
+ cidrs.add(ip.getAddress().addr() + "/" + NetUtils.getCidrSize(ip.getNetmask()));
+ }
+ ConfigurePublicIpsOnLogicalRouterCommand cmd = new ConfigurePublicIpsOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(),
+ niciraNvpHost.getDetail("l3gatewayserviceuuid"), cidrs);
+ ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
+ //FIXME answer can be null if the host is down
+ return answer.getResult();
+ }
+ else {
+ s_logger.debug("No need to provision ip addresses as we are not providing L3 services.");
+ }
+
+ return true;
+ }
+
+ /**
+ * From interface StaticNatServiceProvider
+ */
+ @Override
+ public boolean applyStaticNats(Network network,
+ List<? extends StaticNat> rules)
+ throws ResourceUnavailableException {
if (!canHandle(network, Service.StaticNat)) {
return false;
}
- List<NiciraNvpDeviceVO> devices = _niciraNvpDao
- .listByPhysicalNetwork(network.getPhysicalNetworkId());
- if (devices.isEmpty()) {
- s_logger.error("No NiciraNvp Controller on physical network "
- + network.getPhysicalNetworkId());
- return false;
- }
- NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
- HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
-
- NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
- .findByNetworkId(network.getId());
- if (routermapping == null) {
- s_logger.error("No logical router uuid found for network "
- + network.getDisplayText());
- return false;
- }
-
- List<StaticNatRuleTO> staticNatRules = new ArrayList<StaticNatRuleTO>();
+ List<NiciraNvpDeviceVO> devices = _niciraNvpDao
+ .listByPhysicalNetwork(network.getPhysicalNetworkId());
+ if (devices.isEmpty()) {
+ s_logger.error("No NiciraNvp Controller on physical network "
+ + network.getPhysicalNetworkId());
+ return false;
+ }
+ NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
+ HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
+
+ NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
+ .findByNetworkId(network.getId());
+ if (routermapping == null) {
+ s_logger.error("No logical router uuid found for network "
+ + network.getDisplayText());
+ return false;
+ }
+
+ List<StaticNatRuleTO> staticNatRules = new ArrayList<StaticNatRuleTO>();
for (StaticNat rule : rules) {
IpAddress sourceIp = _networkManager.getIp(rule.getSourceIpAddressId());
// Force the nat rule into the StaticNatRuleTO, no use making a new TO object
// we only need the source and destination ip. Unfortunately no mention if a rule
// is new.
StaticNatRuleTO ruleTO = new StaticNatRuleTO(1,
- sourceIp.getAddress().addr(), 0, 65535,
- rule.getDestIpAddress(), 0, 65535,
- "any", rule.isForRevoke(), false);
+ sourceIp.getAddress().addr(), 0, 65535,
+ rule.getDestIpAddress(), 0, 65535,
+ "any", rule.isForRevoke(), false);
staticNatRules.add(ruleTO);
}
ConfigureStaticNatRulesOnLogicalRouterCommand cmd =
- new ConfigureStaticNatRulesOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), staticNatRules);
+ new ConfigureStaticNatRulesOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), staticNatRules);
ConfigureStaticNatRulesOnLogicalRouterAnswer answer = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
return answer.getResult();
- }
-
- /**
- * From interface PortForwardingServiceProvider
- */
- @Override
- public boolean applyPFRules(Network network, List<PortForwardingRule> rules)
- throws ResourceUnavailableException {
+ }
+
+ /**
+ * From interface PortForwardingServiceProvider
+ */
+ @Override
+ public boolean applyPFRules(Network network, List<PortForwardingRule> rules)
+ throws ResourceUnavailableException {
if (!canHandle(network, Service.PortForwarding)) {
return false;
}
- List<NiciraNvpDeviceVO> devices = _niciraNvpDao
- .listByPhysicalNetwork(network.getPhysicalNetworkId());
- if (devices.isEmpty()) {
- s_logger.error("No NiciraNvp Controller on physical network "
- + network.getPhysicalNetworkId());
- return false;
- }
- NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
- HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
-
- NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
- .findByNetworkId(network.getId());
- if (routermapping == null) {
- s_logger.error("No logical router uuid found for network "
- + network.getDisplayText());
- return false;
- }
-
- List<PortForwardingRuleTO> portForwardingRules = new ArrayList<PortForwardingRuleTO>();
+ List<NiciraNvpDeviceVO> devices = _niciraNvpDao
+ .listByPhysicalNetwork(network.getPhysicalNetworkId());
+ if (devices.isEmpty()) {
+ s_logger.error("No NiciraNvp Controller on physical network "
+ + network.getPhysicalNetworkId());
+ return false;
+ }
+ NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
+ HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
+
+ NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
+ .findByNetworkId(network.getId());
+ if (routermapping == null) {
+ s_logger.error("No logical router uuid found for network "
+ + network.getDisplayText());
+ return false;
+ }
+
+ List<PortForwardingRuleTO> portForwardingRules = new ArrayList<PortForwardingRuleTO>();
for (PortForwardingRule rule : rules) {
IpAddress sourceIp = _networkManager.getIp(rule.getSourceIpAddressId());
Vlan vlan = _vlanDao.findById(sourceIp.getVlanId());
- PortForwardingRuleTO ruleTO = new PortForwardingRuleTO((PortForwardingRule) rule, vlan.getVlanTag(), sourceIp.getAddress().addr());
+ PortForwardingRuleTO ruleTO = new PortForwardingRuleTO(rule, vlan.getVlanTag(), sourceIp.getAddress().addr());
portForwardingRules.add(ruleTO);
}
ConfigurePortForwardingRulesOnLogicalRouterCommand cmd =
- new ConfigurePortForwardingRulesOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), portForwardingRules);
+ new ConfigurePortForwardingRulesOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), portForwardingRules);
ConfigurePortForwardingRulesOnLogicalRouterAnswer answer = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
return answer.getResult();
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index 6bc08f6..ebae660 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -22,8 +22,6 @@ import java.util.Set;
import javax.ejb.Local;
import javax.inject.Inject;
-import org.springframework.stereotype.Component;
-
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
@@ -42,7 +40,6 @@ import com.cloud.vm.ReservationContext;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
-@Component
@Local(value = NetworkElement.class)
public class OvsElement extends AdapterBase implements NetworkElement {
@Inject
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index d1d1bed..8c68c28 100644
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -40,7 +40,6 @@
<module>hypervisors/ovm</module>
<module>hypervisors/xen</module>
<module>hypervisors/kvm</module>
- <module>hypervisors/simulator</module>
<module>network-elements/elastic-loadbalancer</module>
<module>network-elements/ovs</module>
<module>network-elements/nicira-nvp</module>
@@ -50,8 +49,6 @@
<module>user-authenticators/plain-text</module>
<module>user-authenticators/sha256salted</module>
<module>network-elements/dns-notifier</module>
- <module>storage/image/s3</module>
- <module>storage/volume/solidfire</module>
</modules>
<dependencies>