Skip to content

Commit a940d96

Browse files
author
Vijayendra Bhamidipati
committed
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)
Description: 1. Added a new VO class to represent a new table "cluster_vsm_map". The class is ClusterVSMMapVO in ClusterVSMMapVO.java. This table has only two fields - clusterId, VSMId. The clusterId can occur only once. But the same VSMId can be tied to different clusterIds. 2. Added the Dao interface + implementation of the interface. This provides the functions required to populate objects of type ClusterVSMMapVO with records from the cluster_vsm_map table. The interface is defined in ClusterVSMMapDao.java, and the implementation is in ClusterVSMMapDaoImpl.java. 3. Changed the table name that represents the VSM to "virtual_supervisor_module" from the earlier overly generic "external_virtual_switch_management_devices". 4. Added search/remove functions to the Dao of the VSM. This is the Dao for the Cisco Nexus VSM - CiscoNexusVSMDeviceDao:CiscoNexusVSMDeviceDaoImpl --> This is the Dao Implementation that would let us query/update records on the "virtual_supervisor_module" table that contains the records of all the VSMs that are added to the Management Server. NOTE:: ====== These were some of the changes made as part of the previous commit (apache#7): 1. Renamed CiscoNexusVSMResource.java to CiscoNexusVSM.java. 2. Changed it to not implement a true resource, but to be just a class providing functionality to talk to a VSM. 3. Modified the AddCiscoNexusVSMCmd class to take in clusterId instead of zoneId + your fix of the String to Long.
1 parent 28568e6 commit a940d96

8 files changed

Lines changed: 344 additions & 108 deletions
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2012 Citrix Systems, Inc. Licensed under the
2+
// Apache License, Version 2.0 (the "License"); you may not use this
3+
// file except in compliance with the License. Citrix Systems, Inc.
4+
// reserves all rights not expressly granted by the License.
5+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an "AS IS" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
//
12+
// Automatically generated by addcopyright.py at 04/03/2012
13+
package com.cloud.dc;
14+
15+
import javax.persistence.Column;
16+
import javax.persistence.Entity;
17+
import javax.persistence.Table;
18+
19+
20+
// NOTE: This particular table is totally internal to the CS MS.
21+
// Do not ever include a uuid/guid field in this table. We just
22+
// need it map cluster Ids with Cisco Nexus VSM Ids.
23+
24+
@Entity
25+
@Table(name="cluster_vsm_map")
26+
public class ClusterVSMMapVO {
27+
28+
@Column(name="cluster_id")
29+
long clusterId;
30+
31+
@Column(name="vsm_id")
32+
long vsmId;
33+
34+
public ClusterVSMMapVO(long clusterId, long vsmId) {
35+
this.clusterId = clusterId;
36+
this.vsmId = vsmId;
37+
}
38+
39+
public long getClusterId() {
40+
return clusterId;
41+
}
42+
43+
public long getVsmId() {
44+
return vsmId;
45+
}
46+
47+
public void setClusterId(long clusterId) {
48+
this.clusterId = clusterId;
49+
}
50+
51+
public void setVsmId(long vsmId) {
52+
this.vsmId = vsmId;
53+
}
54+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2012 Citrix Systems, Inc. Licensed under the
2+
// Apache License, Version 2.0 (the "License"); you may not use this
3+
// file except in compliance with the License. Citrix Systems, Inc.
4+
// reserves all rights not expressly granted by the License.
5+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an "AS IS" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
//
12+
// Automatically generated by addcopyright.py at 04/03/2012
13+
package com.cloud.dc.dao;
14+
15+
import java.util.List;
16+
17+
import com.cloud.dc.ClusterVSMMapVO;
18+
19+
import com.cloud.utils.db.GenericDao;
20+
21+
public interface ClusterVSMMapDao extends GenericDao<ClusterVSMMapVO, Long> {
22+
public ClusterVSMMapVO findByClusterId(long clusterId);
23+
public List<ClusterVSMMapVO> listByVSMId(long vsmId);
24+
public boolean removeByVsmId(long vsmId);
25+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright 2012 Citrix Systems, Inc. Licensed under the
2+
// Apache License, Version 2.0 (the "License"); you may not use this
3+
// file except in compliance with the License. Citrix Systems, Inc.
4+
// reserves all rights not expressly granted by the License.
5+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an "AS IS" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
//
12+
// Automatically generated by addcopyright.py at 04/03/2012
13+
package com.cloud.dc.dao;
14+
15+
import java.util.List;
16+
17+
import javax.ejb.Local;
18+
19+
import com.cloud.dc.ClusterVSMMapVO;
20+
import com.cloud.utils.db.GenericDaoBase;
21+
import com.cloud.utils.db.SearchBuilder;
22+
import com.cloud.utils.db.SearchCriteria;
23+
import com.cloud.utils.db.Transaction;
24+
25+
@Local(value=ClusterVSMMapDao.class)
26+
public class ClusterVSMMapDaoImpl extends GenericDaoBase<ClusterVSMMapVO, Long> implements ClusterVSMMapDao {
27+
28+
protected final SearchBuilder<ClusterVSMMapVO> ClusterSearch;
29+
protected final SearchBuilder<ClusterVSMMapVO> VsmSearch;
30+
31+
protected ClusterVSMMapDaoImpl() {
32+
super();
33+
34+
ClusterSearch = createSearchBuilder();
35+
ClusterSearch.and("clusterId", ClusterSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
36+
ClusterSearch.done();
37+
38+
VsmSearch = createSearchBuilder();
39+
VsmSearch.and("vsmId", VsmSearch.entity().getVsmId(), SearchCriteria.Op.EQ);
40+
VsmSearch.done();
41+
}
42+
43+
@Override
44+
public boolean removeByVsmId(long vsmId) {
45+
SearchCriteria<ClusterVSMMapVO> sc = VsmSearch.create();
46+
sc.setParameters("vsmId", vsmId);
47+
this.remove(sc);
48+
return true;
49+
}
50+
51+
@Override
52+
public ClusterVSMMapVO findByClusterId(long clusterId) {
53+
SearchCriteria<ClusterVSMMapVO> sc = ClusterSearch.create();
54+
sc.setParameters("clusterId", clusterId);
55+
return findOneBy(sc);
56+
}
57+
58+
@Override
59+
public List<ClusterVSMMapVO> listByVSMId(long vsmId) {
60+
SearchCriteria<ClusterVSMMapVO> sc = VsmSearch.create();
61+
sc.setParameters("vsmId", vsmId);
62+
return listBy(sc);
63+
}
64+
65+
public boolean remove(Long id) {
66+
Transaction txn = Transaction.currentTxn();
67+
txn.start();
68+
ClusterVSMMapVO cluster = createForUpdate();
69+
//cluster.setClusterId(null);
70+
//cluster.setVsmId(null);
71+
72+
update(id, cluster);
73+
74+
boolean result = super.remove(id);
75+
txn.commit();
76+
return result;
77+
}
78+
79+
}

0 commit comments

Comments
 (0)