Skip to content

Commit fdc354a

Browse files
author
Sheng Yang
committed
NaaS: Add VirtualRouterElements table
It would cover the configuration of DHCPElement, VirtualRouterElement and RedundantVirtualRouterElement. Also add foreign key in domain_router table to reflect the domain_router is created from which element and use what configuration.
1 parent 04f106a commit fdc354a

8 files changed

Lines changed: 393 additions & 10 deletions

File tree

‎core/src/com/cloud/vm/DomainRouterVO.java‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
@PrimaryKeyJoinColumn(name="id")
3737
@DiscriminatorValue(value="DomainRouter")
3838
public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
39+
@Column(name="element_id")
40+
private long elementId;
41+
3942
@Column(name="public_ip_address")
4043
private String publicIpAddress;
4144

@@ -79,6 +82,7 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
7982

8083
public DomainRouterVO(long id,
8184
long serviceOfferingId,
85+
long elementId,
8286
String name,
8387
long templateId,
8488
HypervisorType hypervisorType,
@@ -90,9 +94,9 @@ public DomainRouterVO(long id,
9094
int priority,
9195
boolean isPriorityBumpUp,
9296
RedundantState redundantState,
93-
boolean haEnabled,
94-
boolean stopPending) {
97+
boolean haEnabled, boolean stopPending) {
9598
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
99+
this.elementId = elementId;
96100
this.networkId = networkId;
97101
this.isRedundantRouter = isRedundantRouter;
98102
this.priority = priority;
@@ -103,6 +107,7 @@ public DomainRouterVO(long id,
103107

104108
public DomainRouterVO(long id,
105109
long serviceOfferingId,
110+
long elementId,
106111
String name,
107112
long templateId,
108113
HypervisorType hypervisorType,
@@ -115,9 +120,9 @@ public DomainRouterVO(long id,
115120
boolean isPriorityBumpUp,
116121
RedundantState redundantState,
117122
boolean haEnabled,
118-
boolean stopPending,
119-
VirtualMachine.Type vmType) {
123+
boolean stopPending, VirtualMachine.Type vmType) {
120124
super(id, serviceOfferingId, name, name, vmType, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
125+
this.elementId = elementId;
121126
this.networkId = networkId;
122127
this.isRedundantRouter = isRedundantRouter;
123128
this.priority = priority;
@@ -126,6 +131,10 @@ public DomainRouterVO(long id,
126131
this.stopPending = stopPending;
127132
}
128133

134+
public long getElementId() {
135+
return elementId;
136+
}
137+
129138
public void setPublicIpAddress(String publicIpAddress) {
130139
this.publicIpAddress = publicIpAddress;
131140
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
package com.cloud.network.dao;
19+
20+
import java.util.List;
21+
22+
import com.cloud.network.element.VirtualRouterElementsVO;
23+
import com.cloud.network.element.VirtualRouterElements.VirtualRouterElementsType;
24+
import com.cloud.utils.db.GenericDao;
25+
26+
public interface VirtualRouterElementsDao extends GenericDao<VirtualRouterElementsVO, Long> {
27+
public List<VirtualRouterElementsVO> findByNspIdAndType(long nspId, VirtualRouterElementsType type);
28+
public VirtualRouterElementsVO findByUUID(String uuid);
29+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
package com.cloud.network.dao;
19+
20+
import java.util.List;
21+
22+
import javax.ejb.Local;
23+
24+
import com.cloud.network.element.VirtualRouterElementsVO;
25+
import com.cloud.network.element.VirtualRouterElements.VirtualRouterElementsType;
26+
import com.cloud.utils.db.DB;
27+
import com.cloud.utils.db.GenericDaoBase;
28+
import com.cloud.utils.db.SearchBuilder;
29+
import com.cloud.utils.db.SearchCriteria;
30+
31+
@Local(value=VirtualRouterElementsDao.class) @DB(txn=false)
32+
public class VirtualRouterElementsDaoImpl extends GenericDaoBase<VirtualRouterElementsVO, Long> implements VirtualRouterElementsDao {
33+
final SearchBuilder<VirtualRouterElementsVO> AllFieldsSearch;
34+
35+
public VirtualRouterElementsDaoImpl() {
36+
super();
37+
AllFieldsSearch = createSearchBuilder();
38+
AllFieldsSearch.and("nsp_id", AllFieldsSearch.entity().getNspId(), SearchCriteria.Op.EQ);
39+
AllFieldsSearch.and("uuid", AllFieldsSearch.entity().getUUID(), SearchCriteria.Op.EQ);
40+
AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), SearchCriteria.Op.EQ);
41+
AllFieldsSearch.done();
42+
}
43+
44+
@Override
45+
public List<VirtualRouterElementsVO> findByNspIdAndType(long nspId, VirtualRouterElementsType type) {
46+
SearchCriteria<VirtualRouterElementsVO> sc = AllFieldsSearch.create();
47+
sc.setParameters("nsp_id", nspId);
48+
sc.setParameters("type", type);
49+
return listBy(sc);
50+
}
51+
52+
@Override
53+
public VirtualRouterElementsVO findByUUID(String uuid) {
54+
SearchCriteria<VirtualRouterElementsVO> sc = AllFieldsSearch.create();
55+
sc.setParameters("uuid", uuid);
56+
return findOneBy(sc);
57+
}
58+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
19+
package com.cloud.network.element;
20+
21+
public interface VirtualRouterElements {
22+
public enum VirtualRouterElementsType {
23+
DhcpElement,
24+
VirtualRouterElement,
25+
RedundantVirtualRouterElement,
26+
}
27+
public VirtualRouterElementsType getType();
28+
}

0 commit comments

Comments
 (0)