Skip to content

Commit dcbb0ec

Browse files
committed
Fix CLOUDSTACK-936: fix nonoss build due to CloudException IdentityProxy
removal.
1 parent 3dfd81f commit dcbb0ec

File tree

2 files changed

+48
-54
lines changed

2 files changed

+48
-54
lines changed

api/src/com/cloud/exception/CloudException.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ public void addProxyObject(String uuid) {
5656
return;
5757
}
5858

59-
public void addProxyObject(Object voObj, Long id, String idFieldName) {
60-
// Get the VO object's table name.
61-
String tablename = AnnotationHelper.getTableName(voObj);
62-
if (tablename != null) {
63-
addProxyObject(tablename, id, idFieldName);
64-
}
65-
return;
66-
}
6759

6860
public ArrayList<String> getIdProxyList() {
6961
return idList;

plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Unless required by applicable law or agreed to in writing,
1212
// software distributed under the License is distributed on an
1313
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14-
// KIND, either express or implied. See the License for the
14+
// KIND, either express or implied. See the License for the
1515
// specific language governing permissions and limitations
1616
// under the License.
1717
package com.cloud.network;
@@ -48,7 +48,7 @@
4848
public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
4949

5050
@Inject
51-
CiscoNexusVSMDeviceDao _ciscoNexusVSMDeviceDao;
51+
CiscoNexusVSMDeviceDao _ciscoNexusVSMDeviceDao;
5252
@Inject
5353
ClusterDao _clusterDao;
5454
@Inject
@@ -65,9 +65,9 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
6565
PortProfileDao _ppDao;
6666
@Inject
6767
ConfigurationDao _configDao;
68-
68+
6969
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(ExternalLoadBalancerDeviceManagerImpl.class);
70-
70+
7171
@DB
7272
//public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress, String username, String password, ServerResource resource, String vsmName) {
7373
public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress, String username, String password, String vCenterIpaddr, String vCenterDcName) {
@@ -77,7 +77,7 @@ public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress,
7777

7878
// First check if the cluster is of type vmware. If not,
7979
// throw an exception. VSMs are tightly integrated with vmware clusters.
80-
80+
8181
ClusterVO cluster = _clusterDao.findById(clusterId);
8282
if (cluster == null) {
8383
throw new InvalidParameterValueException("Cluster with specified ID not found!");
@@ -90,21 +90,21 @@ public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress,
9090
// Next, check if the cluster already has a VSM associated with it.
9191
// If so, throw an exception disallowing this operation. The user must first
9292
// delete the current VSM and then only attempt to add the new one.
93-
93+
9494
if (_clusterVSMDao.findByClusterId(clusterId) != null) {
9595
// We can't have two VSMs for the same cluster. Throw exception.
9696
throw new InvalidParameterValueException("Cluster with specified id already has a VSM tied to it. Please remove that first and retry the operation.");
9797
}
9898

9999
// TODO: Confirm whether we should be checking for VSM reachability here.
100-
100+
101101
// Next, check if this VSM is reachable. Use the XML-RPC VSM API Java bindings to talk to
102102
// the VSM.
103103
//NetconfHelper (String ip, String username, String password)
104104

105105
NetconfHelper netconfClient;
106106
try {
107-
netconfClient = new NetconfHelper(ipaddress, username, password);
107+
netconfClient = new NetconfHelper(ipaddress, username, password);
108108
} catch(CloudRuntimeException e) {
109109
String msg = "Failed to connect to Nexus VSM " + ipaddress + " with credentials of user " + username;
110110
s_logger.error(msg);
@@ -118,7 +118,7 @@ public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress,
118118
// First, check if VSM already exists in the table "virtual_supervisor_module".
119119
// If it's not there already, create it.
120120
// If it's there already, return success.
121-
121+
122122
// TODO - Right now, we only check if the ipaddress matches for both requests.
123123
// We must really check whether every field of the VSM matches. Anyway, the
124124
// advantage of our approach for now is that existing infrastructure using
@@ -131,7 +131,7 @@ public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress,
131131
throw new CloudRuntimeException(e.getMessage());
132132
}
133133

134-
if (VSMObj == null) {
134+
if (VSMObj == null) {
135135
// Create the VSM record. For now, we aren't using the vsmName field.
136136
VSMObj = new CiscoNexusVSMDeviceVO(ipaddress, username, password);
137137
Transaction txn = Transaction.currentTxn();
@@ -144,7 +144,7 @@ public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress,
144144
throw new CloudRuntimeException(e.getMessage());
145145
}
146146
}
147-
147+
148148
// At this stage, we have a VSM record for sure. Connect the VSM to the cluster Id.
149149
long vsmId = _ciscoNexusVSMDeviceDao.getVSMbyIpaddress(ipaddress).getId();
150150
ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsmId);
@@ -157,22 +157,22 @@ public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress,
157157
txn.rollback();
158158
throw new CloudRuntimeException(e.getMessage());
159159
}
160-
160+
161161
// Now, get a list of all the ESXi servers in this cluster.
162162
// This is effectively a select * from host where cluster_id=clusterId;
163163
// All ESXi servers are stored in the host table, and their resource
164164
// type is vmwareresource.
165-
165+
166166
//List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
167-
167+
168168
//TODO: Activate the code below if we make the Nexus VSM a separate resource.
169169
// Iterate through each of the hosts in this list. Each host has a host id.
170170
// Given this host id, we can reconfigure the in-memory resource representing
171171
// the host via the agent manager. Thus we inject VSM related information
172172
// into each host's resource. Also, we first configure each resource's
173173
// entries in the database to contain this VSM information before the injection.
174-
175-
//for (HostVO host : hosts) {
174+
175+
//for (HostVO host : hosts) {
176176
// Create a host details VO object and write it out for this hostid.
177177
//Long hostid = new Long(vsmId);
178178
//DetailVO vsmDetail = new DetailVO(host.getId(), "vsmId", hostid.toString());
@@ -193,66 +193,66 @@ public CiscoNexusVSMDeviceVO addCiscoNexusVSM(long clusterId, String ipaddress,
193193
//hostDetails.put(ApiConstants.USERNAME, username);
194194
//hostDetails.put(ApiConstants.PASSWORD, password);
195195
//_agentMrg.send(host.getId(), )
196-
196+
197197
return VSMObj;
198-
198+
199199
}
200-
200+
201201
@DB
202-
public boolean deleteCiscoNexusVSM(long vsmId) throws ResourceInUseException {
202+
public boolean deleteCiscoNexusVSM(long vsmId) throws ResourceInUseException {
203203
CiscoNexusVSMDeviceVO cisconexusvsm = _ciscoNexusVSMDeviceDao.findById(vsmId);
204204
if (cisconexusvsm == null) {
205205
// This entry is already not present. Return success.
206206
return true;
207207
}
208-
208+
209209
// First, check whether this VSM is part of any non-empty cluster.
210210
// Search ClusterVSMMap's table for a list of clusters using this vsmId.
211-
211+
212212
List<ClusterVSMMapVO> clusterList = _clusterVSMDao.listByVSMId(vsmId);
213-
214-
if (clusterList != null) {
213+
214+
if (clusterList != null) {
215215
for (ClusterVSMMapVO record : clusterList) {
216216
// If this cluster id has any hosts in it, fail this operation.
217-
Long clusterId = record.getClusterId();
217+
Long clusterId = record.getClusterId();
218218
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
219219
if (hosts != null && hosts.size() > 0) {
220220
for (Host host: hosts) {
221221
if (host.getType() == Host.Type.Routing) {
222222
s_logger.info("Non-empty cluster with id" + clusterId + "still has a host that uses this VSM. Please empty the cluster first");
223223
throw new ResourceInUseException("Non-empty cluster with id" + clusterId + "still has a host that uses this VSM. Please empty the cluster first");
224224
}
225-
}
225+
}
226226
}
227227
}
228228
}
229-
229+
230230
// Iterate through the cluster list again, this time, delete the VSM.
231231
Transaction txn = Transaction.currentTxn();
232232
try {
233233
txn.start();
234-
// Remove the VSM entry in CiscoNexusVSMDeviceVO's table.
234+
// Remove the VSM entry in CiscoNexusVSMDeviceVO's table.
235235
_ciscoNexusVSMDeviceDao.remove(vsmId);
236-
// Remove the current record as well from ClusterVSMMapVO's table.
236+
// Remove the current record as well from ClusterVSMMapVO's table.
237237
_clusterVSMDao.removeByVsmId(vsmId);
238238
// There are no hosts at this stage in the cluster, so we don't need
239-
// to notify any resources or remove host details.
240-
txn.commit();
239+
// to notify any resources or remove host details.
240+
txn.commit();
241241
} catch (Exception e) {
242-
s_logger.info("Caught exception when trying to delete VSM record.." + e.getMessage());
242+
s_logger.info("Caught exception when trying to delete VSM record.." + e.getMessage());
243243
throw new CloudRuntimeException("Failed to delete VSM");
244-
}
244+
}
245245
return true;
246246
}
247247

248248
@DB
249249
public CiscoNexusVSMDeviceVO enableCiscoNexusVSM(long vsmId) {
250250
CiscoNexusVSMDeviceVO cisconexusvsm = _ciscoNexusVSMDeviceDao.findById(vsmId);
251251
if (cisconexusvsm == null) {
252-
throw new InvalidParameterValueException("Invalid vsm Id specified");
252+
throw new InvalidParameterValueException("Invalid vsm Id specified");
253253
}
254254
// Else, check if this db record shows that this VSM is enabled or not.
255-
if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Disabled) {
255+
if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Disabled) {
256256
// it's currently disabled. So change it to enabled and write it out to the db.
257257
cisconexusvsm.setVsmDeviceState(CiscoNexusVSMDeviceVO.VSMDeviceState.Enabled);
258258
Transaction txn = Transaction.currentTxn();
@@ -265,18 +265,18 @@ public CiscoNexusVSMDeviceVO enableCiscoNexusVSM(long vsmId) {
265265
throw new CloudRuntimeException(e.getMessage());
266266
}
267267
}
268-
268+
269269
return cisconexusvsm;
270270
}
271-
272-
@DB
271+
272+
@DB
273273
public CiscoNexusVSMDeviceVO disableCiscoNexusVSM(long vsmId) {
274274
CiscoNexusVSMDeviceVO cisconexusvsm = _ciscoNexusVSMDeviceDao.findById(vsmId);
275275
if (cisconexusvsm == null) {
276-
throw new InvalidParameterValueException("Invalid vsm Id specified");
276+
throw new InvalidParameterValueException("Invalid vsm Id specified");
277277
}
278278
// Else, check if this db record shows that this VSM is enabled or not.
279-
if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Enabled) {
279+
if (cisconexusvsm.getvsmDeviceState() == CiscoNexusVSMDeviceVO.VSMDeviceState.Enabled) {
280280
// it's currently disabled. So change it to enabled and write it out to the db.
281281
cisconexusvsm.setVsmDeviceState(CiscoNexusVSMDeviceVO.VSMDeviceState.Disabled);
282282
Transaction txn = Transaction.currentTxn();
@@ -289,15 +289,15 @@ public CiscoNexusVSMDeviceVO disableCiscoNexusVSM(long vsmId) {
289289
throw new CloudRuntimeException(e.getMessage());
290290
}
291291
}
292-
292+
293293
return cisconexusvsm;
294294
}
295-
295+
296296
@DB
297297
public CiscoNexusVSMDeviceVO getCiscoVSMbyVSMId(long vsmId) {
298298
return _ciscoNexusVSMDeviceDao.findById(vsmId);
299299
}
300-
300+
301301
@DB
302302
public CiscoNexusVSMDeviceVO getCiscoVSMbyClusId(long clusterId) {
303303
ClusterVSMMapVO mapVO = _clusterVSMDao.findByClusterId(clusterId);
@@ -309,12 +309,12 @@ public CiscoNexusVSMDeviceVO getCiscoVSMbyClusId(long clusterId) {
309309
CiscoNexusVSMDeviceVO result = _ciscoNexusVSMDeviceDao.findById(mapVO.getVsmId());
310310
return result;
311311
}
312-
312+
313313
public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
314314
// TODO Auto-generated method stub
315315
return null;
316316
}
317-
317+
318318
@DB
319319
public boolean vliadateVsmCluster(String vsmIp, String vsmUser, String vsmPassword, long clusterId, String clusterName) throws ResourceInUseException {
320320
// Check if we're associating a Cisco Nexus VSM with a vmware cluster.
@@ -342,7 +342,9 @@ public boolean vliadateVsmCluster(String vsmIp, String vsmUser, String vsmPasswo
342342
s_logger.error("Failed to add cluster: specified Nexus VSM is already associated with another cluster");
343343
_clusterDao.remove(clusterId);
344344
ResourceInUseException ex = new ResourceInUseException("Failed to add cluster: specified Nexus VSM is already associated with another cluster with specified Id");
345-
ex.addProxyObject("cluster", clusterList.get(0).getClusterId(), "clusterId");
345+
// get clusterUuid to report error
346+
ClusterVO cluster = _clusterDao.findById(clusterList.get(0).getClusterId());
347+
ex.addProxyObject(cluster.getUuid());
346348
throw ex;
347349
}
348350
}

0 commit comments

Comments
 (0)