You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2012/05/28 00:30:43 UTC
[16/50] git commit: CS-9919: Support for Nexus Swiches (Cisco
Vswitches)
CS-9919: Support for Nexus Swiches (Cisco Vswitches)
Description:
Incorporating more changes post review by Alena.
1. Renamed the ListCiscoVSMDetailsCmd command
to ListCiscoNexusVSMsCmd. The command will
return a list of VSMs always, depending on
what parameter is passed to it. If a clusterId
is passed to it, it will return the VSM
associated to that cluster, if present. If
a zoneId is passed in, it will return a list
of all VSMs configured for any clusters of
type VMware within that zone. If neither is
passed, it will return a list of all VSMs
configured in the management server. If no
VSMs are found, it will return an exception
response.
2. Cleaned up miscellaneous code.
Conflicts:
client/tomcatconf/cisconexusvsm_commands.properties.in
server/src/com/cloud/server/ManagementServerImpl.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/ed0ba1a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/ed0ba1a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/ed0ba1a0
Branch: refs/heads/master
Commit: ed0ba1a0e66eb2a386177f37fe82ce38139a074a
Parents: 5fc5b7a
Author: Vijayendra Bhamidipati <vi...@citrix.com>
Authored: Tue May 22 17:22:29 2012 -0700
Committer: Vijayendra Bhamidipati <vi...@citrix.com>
Committed: Fri May 25 18:27:29 2012 -0700
----------------------------------------------------------------------
api/src/com/cloud/api/BaseCmd.java | 4 +
.../com/cloud/api/commands/ListClustersCmd.java | 1 -
api/src/com/cloud/server/ManagementService.java | 7 +
.../cisconexusvsm_commands.properties.in | 4 +-
.../cloud/api/commands/ListCiscoNexusVSMsCmd.java | 117 +++++++++++++++
.../cloud/api/commands/ListCiscoVSMDetailsCmd.java | 91 -----------
.../cloud/network/dao/CiscoNexusVSMDeviceDao.java | 7 +
.../network/dao/CiscoNexusVSMDeviceDaoImpl.java | 9 +
.../network/element/CiscoNexusVSMElement.java | 87 ++++++-----
.../element/CiscoNexusVSMElementService.java | 12 +-
.../src/com/cloud/server/ManagementServerImpl.java | 14 ++
11 files changed, 212 insertions(+), 141 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/api/src/com/cloud/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/BaseCmd.java b/api/src/com/cloud/api/BaseCmd.java
index a0d5d77..3a83abd 100755
--- a/api/src/com/cloud/api/BaseCmd.java
+++ b/api/src/com/cloud/api/BaseCmd.java
@@ -184,6 +184,10 @@ public abstract class BaseCmd {
_responseObject = responseObject;
}
+ public ManagementService getMgmtServiceRef() {
+ return _mgr;
+ }
+
public static String getDateString(Date date) {
if (date == null) {
return "";
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/api/src/com/cloud/api/commands/ListClustersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListClustersCmd.java b/api/src/com/cloud/api/commands/ListClustersCmd.java
index 9dc6da0..c8af568 100755
--- a/api/src/com/cloud/api/commands/ListClustersCmd.java
+++ b/api/src/com/cloud/api/commands/ListClustersCmd.java
@@ -22,7 +22,6 @@ import com.cloud.api.BaseListCmd;
import com.cloud.api.IdentityMapper;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
-import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.ClusterResponse;
import com.cloud.api.response.ListResponse;
import com.cloud.org.Cluster;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/api/src/com/cloud/server/ManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index e36cc81..84c4d0d 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -127,6 +127,13 @@ public interface ManagementService {
* @return
*/
List<? extends Cluster> searchForClusters(ListClustersCmd c);
+
+ /**
+ * Searches for Clusters by the specified zone Id.
+ * @param zoneId
+ * @return
+ */
+ List<? extends Cluster> searchForClusters(long zoneId, Long startIndex, Long pageSizeVal, String hypervisorType);
/**
* Searches for Pods by the specified search criteria Can search by: pod name and/or zone name
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/client/tomcatconf/cisconexusvsm_commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/cisconexusvsm_commands.properties.in b/client/tomcatconf/cisconexusvsm_commands.properties.in
index 8732357..17b9c79 100644
--- a/client/tomcatconf/cisconexusvsm_commands.properties.in
+++ b/client/tomcatconf/cisconexusvsm_commands.properties.in
@@ -4,5 +4,5 @@
#### Cisco Nexus 1000v Virtual Supervisor Module (VSM) commands
deleteCiscoNexusVSM = com.cloud.api.commands.DeleteCiscoNexusVSMCmd;1
enableCiscoNexusVSM = com.cloud.api.commands.EnableCiscoNexusVSMCmd;1
-disableCiscoNexusVSM = com.cloud.api.commands.DisableCiscoNexusVSMCmd;1
-listCiscoVSMDetails = com.cloud.api.commands.ListCiscoVSMDetailsCmd;1
+disableCiscoNexusVSM = com.cloud.api.commands.DisableCiscoNexusVSMCmd;1
+listCiscoNexusVSMs = com.cloud.api.commands.ListCiscoNexusVSMsCmd;1
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/server/src/com/cloud/api/commands/ListCiscoNexusVSMsCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/ListCiscoNexusVSMsCmd.java b/server/src/com/cloud/api/commands/ListCiscoNexusVSMsCmd.java
new file mode 100755
index 0000000..40bd36e
--- /dev/null
+++ b/server/src/com/cloud/api/commands/ListCiscoNexusVSMsCmd.java
@@ -0,0 +1,117 @@
+/**
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.cloud.api.commands;
+
+import org.apache.log4j.Logger;
+import com.cloud.api.ApiConstants;
+import com.cloud.api.BaseListCmd;
+import com.cloud.api.IdentityMapper;
+import com.cloud.api.Implementation;
+import com.cloud.api.Parameter;
+import com.cloud.api.PlugService;
+import com.cloud.api.ServerApiException;
+import com.cloud.api.response.CiscoNexusVSMResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.CiscoNexusVSMDevice;
+import com.cloud.network.element.CiscoNexusVSMElementService;
+import com.cloud.user.Account;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Implementation(responseObject=CiscoNexusVSMResponse.class, description="Retrieves a Cisco Nexus 1000v Virtual Switch Manager device associated with a Cluster")
+public class ListCiscoNexusVSMsCmd extends BaseListCmd {
+
+ /**
+ * This command returns a list of all the VSMs configured in the management server.
+ * If a clusterId is specified, it will return a list containing only that VSM
+ * that is associated with that cluster. If a zone is specified, it will pull
+ * up all the clusters of type vmware in that zone, and prepare a list of VSMs
+ * associated with those clusters.
+ */
+ public static final Logger s_logger = Logger.getLogger(ListCiscoNexusVSMsCmd.class.getName());
+ private static final String s_name = "listcisconexusvsmscmdresponse";
+ @PlugService CiscoNexusVSMElementService _ciscoNexusVSMService;
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @IdentityMapper(entityTableName="cluster")
+ @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, required = false, description="Id of the CloudStack cluster in which the Cisco Nexus 1000v VSM appliance.")
+ private long clusterId;
+
+ @IdentityMapper(entityTableName="data_center")
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required = false, description="Id of the CloudStack cluster in which the Cisco Nexus 1000v VSM appliance.")
+ private long zoneId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public long getClusterId() {
+ return clusterId;
+ }
+
+ public long getZoneId() {
+ return zoneId;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ // NOTE- The uuid that is sent in during the invocation of the API AddCiscoNexusVSM()
+ // automagically gets translated to the corresponding db id before this execute() method
+ // is invoked. That's the reason why we don't have any uuid-dbid translation code here.
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
+ List<? extends CiscoNexusVSMDevice> vsmDeviceList = _ciscoNexusVSMService.getCiscoNexusVSMs(this);
+
+ if (vsmDeviceList.size() > 0) {
+ ListResponse<CiscoNexusVSMResponse> response = new ListResponse<CiscoNexusVSMResponse>();
+ List<CiscoNexusVSMResponse> vsmResponses = new ArrayList<CiscoNexusVSMResponse>();
+ for (CiscoNexusVSMDevice vsmDevice : vsmDeviceList) {
+ CiscoNexusVSMResponse vsmresponse = _ciscoNexusVSMService.createCiscoNexusVSMDetailedResponse(vsmDevice);
+ vsmresponse.setObjectName("cisconexusvsm");
+ response.setResponseName(getCommandName());
+ vsmResponses.add(vsmresponse);
+ }
+ response.setResponses(vsmResponses);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseListCmd.INTERNAL_ERROR, "No VSM found.");
+ }
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/server/src/com/cloud/api/commands/ListCiscoVSMDetailsCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/ListCiscoVSMDetailsCmd.java b/server/src/com/cloud/api/commands/ListCiscoVSMDetailsCmd.java
deleted file mode 100755
index 5a9c049..0000000
--- a/server/src/com/cloud/api/commands/ListCiscoVSMDetailsCmd.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * 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 <http://www.gnu.org/licenses/>.
- *
- */
-
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.CiscoNexusVSMResponse;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.CiscoNexusVSMDevice;
-import com.cloud.network.element.CiscoNexusVSMElementService;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(responseObject=CiscoNexusVSMResponse.class, description="Retrieves a Cisco Nexus 1000v Virtual Switch Manager device associated with a Cluster")
-public class ListCiscoVSMDetailsCmd extends BaseCmd {
-
- public static final Logger s_logger = Logger.getLogger(ListCiscoVSMDetailsCmd.class.getName());
- private static final String s_name = "listciscovsmdetailscmdresponse";
- @PlugService CiscoNexusVSMElementService _ciscoNexusVSMService;
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="cluster")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required = true, description="Id of the CloudStack cluster in which the Cisco Nexus 1000v VSM appliance.")
- private long clusterId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public long getClusterId() {
- return clusterId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- // NOTE- The uuid that is sent in during the invocation of the API AddCiscoNexusVSM()
- // automagically gets translated to the corresponding db id before this execute() method
- // is invoked. That's the reason why we don't have any uuid-dbid translation code here.
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
- CiscoNexusVSMDevice vsmDevice = _ciscoNexusVSMService.getCiscoNexusVSMByClusId(this);
- if (vsmDevice != null) {
- CiscoNexusVSMResponse response = _ciscoNexusVSMService.createCiscoNexusVSMDetailedResponse(vsmDevice);
- response.setObjectName("cisconexusvsm");
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to retrieve Cisco Nexus Virtual Switch Manager for the specified cluster due to an internal error.");
- }
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java b/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java
index 5c659b3..95771a5 100644
--- a/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java
+++ b/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java
@@ -54,6 +54,13 @@ public interface CiscoNexusVSMDeviceDao extends GenericDao<CiscoNexusVSMDeviceVO
List<CiscoNexusVSMDeviceVO> listByMgmtVlan(int vlanId);
/**
+ * Lists all configured VSMs on the management server.
+ * @return
+ */
+ List<CiscoNexusVSMDeviceVO> listAllVSMs();
+
+
+ /**
* Below is a big list of other functions that we may need, but will declare/define/implement once we implement
* the functions above. Pasting those below to not lose track of them.
*
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDaoImpl.java b/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDaoImpl.java
index c4c7e5c..02d9e44 100644
--- a/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDaoImpl.java
+++ b/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDaoImpl.java
@@ -32,6 +32,7 @@ public class CiscoNexusVSMDeviceDaoImpl extends GenericDaoBase<CiscoNexusVSMDevi
final SearchBuilder<CiscoNexusVSMDeviceVO> nameSearch;
final SearchBuilder<CiscoNexusVSMDeviceVO> ipaddrSearch;
final SearchBuilder<CiscoNexusVSMDeviceVO> genericVlanIdSearch;
+ final SearchBuilder<CiscoNexusVSMDeviceVO> fullTableSearch;
// We will add more searchbuilder objects.
@@ -61,6 +62,9 @@ public class CiscoNexusVSMDeviceDaoImpl extends GenericDaoBase<CiscoNexusVSMDevi
ipaddrSearch.and("ipaddr", ipaddrSearch.entity().getipaddr(), Op.EQ);
ipaddrSearch.done();
+ fullTableSearch = createSearchBuilder();
+ fullTableSearch.done();
+
// We may add more and conditions by specifying more fields, like say, accountId.
}
@@ -87,6 +91,11 @@ public class CiscoNexusVSMDeviceDaoImpl extends GenericDaoBase<CiscoNexusVSMDevi
sc.setParameters("managementVlan", vlanId);
return search(sc, null);
}
+
+ public List<CiscoNexusVSMDeviceVO> listAllVSMs() {
+ SearchCriteria<CiscoNexusVSMDeviceVO> sc = fullTableSearch.create();
+ return search(sc, null);
+ }
public List<CiscoNexusVSMDeviceVO> listByVlanId(int vlanId) {
SearchCriteria<CiscoNexusVSMDeviceVO> sc = genericVlanIdSearch.create();
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/server/src/com/cloud/network/element/CiscoNexusVSMElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/CiscoNexusVSMElement.java b/server/src/com/cloud/network/element/CiscoNexusVSMElement.java
index 0e60fdd..844d125 100644
--- a/server/src/com/cloud/network/element/CiscoNexusVSMElement.java
+++ b/server/src/com/cloud/network/element/CiscoNexusVSMElement.java
@@ -14,40 +14,32 @@ package com.cloud.network.element;
import java.util.List;
import java.util.Map;
+import java.util.ArrayList;
import javax.ejb.Local;
import org.apache.log4j.Logger;
-import com.cloud.agent.AgentManager;
import com.cloud.api.commands.DeleteCiscoNexusVSMCmd;
import com.cloud.api.commands.EnableCiscoNexusVSMCmd;
import com.cloud.api.commands.DisableCiscoNexusVSMCmd;
-import com.cloud.api.commands.ListCiscoVSMDetailsCmd;
+import com.cloud.api.commands.ListCiscoNexusVSMsCmd;
import com.cloud.api.response.CiscoNexusVSMResponse;
-import com.cloud.configuration.ConfigurationManager;
-import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.dc.dao.DataCenterDao;
import com.cloud.deploy.DeployDestination;
import com.cloud.event.ActionEvent;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.host.dao.HostDao;
-import com.cloud.host.dao.HostDetailsDao;
import com.cloud.network.CiscoNexusVSMDeviceVO;
import com.cloud.network.CiscoNexusVSMDevice;
import com.cloud.network.CiscoNexusVSMDeviceManagerImpl;
import com.cloud.network.Network;
-import com.cloud.network.NetworkManager;
import com.cloud.network.PhysicalNetworkServiceProvider;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.dao.NetworkServiceMapDao;
-import com.cloud.network.dao.PhysicalNetworkDao;
+import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
import com.cloud.utils.component.Inject;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
@@ -55,10 +47,11 @@ import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.network.element.NetworkElement;
import com.cloud.offering.NetworkOffering;
+import com.cloud.org.Cluster;
import com.cloud.utils.component.Manager;
-import com.cloud.utils.db.DB;
import com.cloud.exception.ResourceInUseException;
import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.server.ManagementService;
@Local(value = NetworkElement.class)
public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl implements CiscoNexusVSMElementService, NetworkElement, Manager {
@@ -66,30 +59,7 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
private static final Logger s_logger = Logger.getLogger(CiscoNexusVSMElement.class);
@Inject
- NetworkManager _networkManager;
- @Inject
- ConfigurationManager _configMgr;
- @Inject
- NetworkServiceMapDao _ntwkSrvcDao;
- @Inject
- AgentManager _agentMgr;
- @Inject
- NetworkManager _networkMgr;
- @Inject
- HostDao _hostDao;
- @Inject
- DataCenterDao _dcDao;
- @Inject
- HostDetailsDao _hostDetailDao;
- @Inject
- PhysicalNetworkDao _physicalNetworkDao;
- @Inject
- NetworkDao _networkDao;
- @Inject
- HostDetailsDao _detailsDao;
- @Inject
- ConfigurationDao _configDao;
-
+ CiscoNexusVSMDeviceDao _vsmDao;
@Override
public Map<Service, Map<Capability, String>> getCapabilities() {
@@ -161,7 +131,6 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
return true;
}
-
@Override
@ActionEvent(eventType = EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DELETE, eventDescription = "deleting VSM", async = true)
public boolean deleteCiscoNexusVSM(DeleteCiscoNexusVSMCmd cmd) {
@@ -178,7 +147,7 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
@Override
public boolean enableCiscoNexusVSM(EnableCiscoNexusVSMCmd cmd) {
- boolean result;
+ boolean result;
result = enableCiscoNexusVSM(cmd.getCiscoNexusVSMDeviceId());
return result;
}
@@ -191,11 +160,45 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
}
@Override
- public CiscoNexusVSMDeviceVO getCiscoNexusVSMByClusId(ListCiscoVSMDetailsCmd cmd) {
- CiscoNexusVSMDeviceVO result = getCiscoVSMbyClusId(cmd.getClusterId());
- if (result == null) {
- throw new CloudRuntimeException("No Cisco VSM associated with specified Cluster Id");
+ public List<CiscoNexusVSMDeviceVO> getCiscoNexusVSMs(ListCiscoNexusVSMsCmd cmd) {
+ // If clusterId is defined, then it takes precedence, and we will return
+ // the VSM associated with this cluster.
+
+ Long clusterId = cmd.getClusterId();
+ Long zoneId = cmd.getZoneId();
+ List<CiscoNexusVSMDeviceVO> result = new ArrayList<CiscoNexusVSMDeviceVO>();
+ if (clusterId != null && clusterId.longValue() != 0) {
+ // Find the VSM associated with this clusterId and return a list.
+ CiscoNexusVSMDeviceVO vsm = getCiscoVSMbyClusId(cmd.getClusterId());
+ if (vsm == null) {
+ throw new CloudRuntimeException("No Cisco VSM associated with specified Cluster Id");
+ }
+ // Else, add it to a list and return the list.
+ result.add(vsm);
+ return result;
+ }
+ // Else if there is only a zoneId defined, get a list of all vmware clusters
+ // in the zone, and then for each cluster, pull the VSM and prepare a list.
+ if (zoneId != null && zoneId.longValue() != 0) {
+ ManagementService ref = cmd.getMgmtServiceRef();
+ List<? extends Cluster> clusterList = ref.searchForClusters(zoneId, cmd.getStartIndex(), cmd.getPageSizeVal(), "VMware");
+
+ if (clusterList.size() == 0) {
+ throw new CloudRuntimeException("No VMWare clusters found in the specified zone!");
+ }
+ // Else, iterate through each vmware cluster, pull its VSM if it has one, and add to the list.
+ for (Cluster clus : clusterList) {
+ CiscoNexusVSMDeviceVO vsm = getCiscoVSMbyClusId(clus.getId());
+ if (vsm != null)
+ result.add(vsm);
+ }
+ return result;
}
+
+ // If neither is defined, we will simply return the entire list of VSMs
+ // configured in the management server.
+ // TODO: Is this a safe thing to do? Only ROOT admin can invoke this call.
+ result = _vsmDao.listAllVSMs();
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java b/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
index b806e7b..2912e6f 100644
--- a/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
+++ b/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
@@ -18,10 +18,12 @@
package com.cloud.network.element;
+import java.util.List;
+
import com.cloud.api.commands.DeleteCiscoNexusVSMCmd;
import com.cloud.api.commands.EnableCiscoNexusVSMCmd;
import com.cloud.api.commands.DisableCiscoNexusVSMCmd;
-import com.cloud.api.commands.ListCiscoVSMDetailsCmd;
+import com.cloud.api.commands.ListCiscoNexusVSMsCmd;
import com.cloud.api.response.CiscoNexusVSMResponse;
import com.cloud.network.CiscoNexusVSMDeviceVO;
import com.cloud.network.CiscoNexusVSMDevice;
@@ -47,11 +49,11 @@ public interface CiscoNexusVSMElementService extends PluggableService {
public boolean disableCiscoNexusVSM(DisableCiscoNexusVSMCmd cmd);
/**
- * Returns a VSM associated with a cluster.
- * @param GetCiscoVSMByClusterIdCmd
- * @return CiscoNexusVSMDeviceVO
+ * Returns a list of VSMs.
+ * @param ListCiscoNexusVSMsCmd
+ * @return List<CiscoNexusVSMDeviceVO>
*/
- public CiscoNexusVSMDeviceVO getCiscoNexusVSMByClusId(ListCiscoVSMDetailsCmd cmd);
+ public List<CiscoNexusVSMDeviceVO> getCiscoNexusVSMs(ListCiscoNexusVSMsCmd cmd);
/**
* creates API response object for Cisco Nexus VSMs
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ed0ba1a0/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 46974bb..b8fb1db 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -160,6 +160,7 @@ import com.cloud.network.NetworkVO;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.NetworkDao;
+import com.cloud.org.Cluster;
import com.cloud.org.Grouping.AllocationState;
import com.cloud.projects.Project;
import com.cloud.projects.Project.ListProjectResourcesCriteria;
@@ -793,7 +794,20 @@ public class ManagementServerImpl implements ManagementServer {
return sol;
}
+
+ @Override
+ public List<? extends Cluster> searchForClusters(long zoneId, Long startIndex, Long pageSizeVal, String hypervisorType) {
+ Filter searchFilter = new Filter(ClusterVO.class, "id", true, startIndex, pageSizeVal);
+ SearchCriteria<ClusterVO> sc = _clusterDao.createSearchCriteria();
+
+ zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), zoneId);
+ sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
+ sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, hypervisorType);
+
+ return _clusterDao.search(sc, searchFilter);
+ }
+
@Override
public List<ClusterVO> searchForClusters(ListClustersCmd cmd) {
Filter searchFilter = new Filter(ClusterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());