Skip to content

Commit 435e74e

Browse files
author
Alex Huang
committed
Commit to try something on removing getZone
1 parent 2e5bb63 commit 435e74e

122 files changed

Lines changed: 1614 additions & 2252 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/com/cloud/network/NetworkModel.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ public interface NetworkModel {
9797

9898
List<? extends Network> listAllNetworksInAllZonesByType(Network.GuestType type);
9999

100-
String getGlobalGuestDomainSuffix();
101-
102100
String getStartIpAddress(long networkId);
103101

104102
String getIpInNetwork(long vmId, long networkId);
@@ -179,11 +177,6 @@ Map<PublicIpAddress, Set<Service>> getIpToServices(List<? extends PublicIpAddres
179177
*/
180178
String getAccountNetworkDomain(long accountId, long zoneId);
181179

182-
/**
183-
* @return
184-
*/
185-
String getDefaultNetworkDomain(long zoneId);
186-
187180
/**
188181
* @param ntwkOffId
189182
* @return

api/src/com/cloud/network/router/VirtualRouter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* bridge internal and external traffic.
2323
*/
2424
public interface VirtualRouter extends VirtualMachine {
25-
public enum Role {
25+
public enum Role {
2626
VIRTUAL_ROUTER, LB, INTERNAL_LB_VM
2727
}
2828
Role getRole();

api/src/com/cloud/network/rules/RulesService.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ public interface RulesService {
6969

7070
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException;
7171

72-
PortForwardingRule getPortForwardigRule(long ruleId);
73-
74-
FirewallRule getFirewallRule(long ruleId);
75-
7672
StaticNatRule createStaticNatRule(StaticNatRule rule, boolean openFirewall) throws NetworkRuleConflictException;
7773

7874
boolean revokeStaticNatRule(long ruleId, boolean apply);
@@ -81,8 +77,6 @@ public interface RulesService {
8177

8278
StaticNatRule buildStaticNatRule(FirewallRule rule, boolean forRevoke);
8379

84-
List<String> getSourceCidrs(long ruleId);
85-
8680
boolean disableStaticNat(long ipId) throws ResourceUnavailableException, NetworkRuleConflictException, InsufficientAddressCapacityException;
8781

8882
}

api/src/com/cloud/network/vpc/VpcService.java

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,10 @@
2929
import com.cloud.exception.ResourceAllocationException;
3030
import com.cloud.exception.ResourceUnavailableException;
3131
import com.cloud.network.IpAddress;
32-
import com.cloud.network.Network;
3332
import com.cloud.utils.Pair;
3433

3534
public interface VpcService {
3635

37-
/**Returns existing VPC found by id
38-
*
39-
* @param vpcId
40-
* @return
41-
*/
42-
public Vpc getVpc(long vpcId);
43-
44-
45-
/**
46-
* Returns all the Guest networks that are part of VPC
47-
*
48-
* @param vpcId
49-
* @return
50-
*/
51-
public List<? extends Network> getVpcNetworks(long vpcId);
52-
5336
/**
5437
* Persists VPC record in the database
5538
*
@@ -63,10 +46,9 @@ public interface VpcService {
6346
* @return
6447
* @throws ResourceAllocationException TODO
6548
*/
66-
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr,
67-
String networkDomain) throws ResourceAllocationException;
49+
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain) throws ResourceAllocationException;
50+
6851

69-
7052
/**
7153
* Deletes a VPC
7254
*
@@ -78,7 +60,7 @@ public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName
7860
*/
7961
public boolean deleteVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException;
8062

81-
63+
8264
/**
8365
* Updates VPC with new name/displayText
8466
*
@@ -89,7 +71,7 @@ public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName
8971
*/
9072
public Vpc updateVpc(long vpcId, String vpcName, String displayText);
9173

92-
74+
9375
/**
9476
* Lists VPC(s) based on the parameters passed to the method call
9577
*
@@ -113,10 +95,9 @@ public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName
11395
* @param vpc
11496
* @return
11597
*/
116-
public List<? extends Vpc> listVpcs(Long id, String vpcName, String displayText,
117-
List<String> supportedServicesStr, String cidr, Long vpcOffId, String state, String accountName, Long domainId,
118-
String keyword, Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll,
119-
Boolean restartRequired, Map<String, String> tags, Long projectId);
98+
public List<? extends Vpc> listVpcs(Long id, String vpcName, String displayText, List<String> supportedServicesStr, String cidr, Long vpcOffId, String state,
99+
String accountName, Long domainId, String keyword, Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired,
100+
Map<String, String> tags, Long projectId);
120101

121102
/**
122103
* Starts VPC which includes starting VPC provider and applying all the neworking rules on the backend
@@ -128,8 +109,7 @@ public List<? extends Vpc> listVpcs(Long id, String vpcName, String displayText,
128109
* @throws ResourceUnavailableException
129110
* @throws ConcurrentOperationException
130111
*/
131-
boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperationException,
132-
ResourceUnavailableException, InsufficientCapacityException;
112+
boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
133113

134114
/**
135115
* Shuts down the VPC which includes shutting down all VPC provider and rules cleanup on the backend
@@ -141,7 +121,7 @@ boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperatio
141121
*/
142122
boolean shutdownVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException;
143123

144-
124+
145125
/**
146126
* Restarts the VPC. VPC gets shutdown and started as a part of it
147127
*
@@ -159,7 +139,6 @@ boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperatio
159139
*/
160140
PrivateGateway getVpcPrivateGateway(long id);
161141

162-
163142
/**
164143
* Persists VPC private gateway in the Database.
165144
*
@@ -178,9 +157,8 @@ boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperatio
178157
* @throws ConcurrentOperationException
179158
* @throws ResourceAllocationException
180159
*/
181-
public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String vlan, String ipAddress,
182-
String gateway, String netmask, long gatewayOwnerId, Boolean isSoruceNat, Long aclId) throws ResourceAllocationException,
183-
ConcurrentOperationException, InsufficientCapacityException;
160+
public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String vlan, String ipAddress, String gateway, String netmask, long gatewayOwnerId,
161+
Boolean isSoruceNat, Long aclId) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
184162

185163
/**
186164
* Applies VPC private gateway on the backend, so it becomes functional
@@ -193,7 +171,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
193171
*/
194172
public PrivateGateway applyVpcPrivateGateway(long gatewayId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException;
195173

196-
174+
197175
/**
198176
* Deletes VPC private gateway
199177
*
@@ -204,7 +182,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
204182
*/
205183
boolean deleteVpcPrivateGateway(long gatewayId) throws ConcurrentOperationException, ResourceUnavailableException;
206184

207-
185+
208186
/**
209187
* Returns the list of Private gateways existing in the VPC
210188
*
@@ -213,7 +191,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
213191
*/
214192
public Pair<List<PrivateGateway>, Integer> listPrivateGateway(ListPrivateGatewaysCmd listPrivateGatewaysCmd);
215193

216-
194+
217195
/**
218196
* Returns Static Route found by Id
219197
*
@@ -222,7 +200,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
222200
*/
223201
StaticRoute getStaticRoute(long routeId);
224202

225-
203+
226204
/**
227205
* Applies existing Static Routes to the VPC elements
228206
*
@@ -232,7 +210,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
232210
*/
233211
public boolean applyStaticRoutes(long vpcId) throws ResourceUnavailableException;
234212

235-
213+
236214
/**
237215
* Deletes static route from the backend and the database
238216
*
@@ -242,7 +220,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
242220
*/
243221
public boolean revokeStaticRoute(long routeId) throws ResourceUnavailableException;
244222

245-
223+
246224
/**
247225
* Persists static route entry in the Database
248226
*
@@ -252,7 +230,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
252230
*/
253231
public StaticRoute createStaticRoute(long gatewayId, String cidr) throws NetworkRuleConflictException;
254232

255-
233+
256234
/**
257235
* Lists static routes based on parameters passed to the call
258236
*
@@ -261,16 +239,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
261239
*/
262240
public Pair<List<? extends StaticRoute>, Integer> listStaticRoutes(ListStaticRoutesCmd cmd);
263241

264-
265-
/**
266-
* Returns gateway (VPN or Public) existign in the VPC
267-
*
268-
* @param id
269-
* @return
270-
*/
271-
VpcGateway getVpcGateway(long id);
272242

273-
274243
/**
275244
* Associates IP address from the Public network, to the VPC
276245
*
@@ -282,7 +251,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
282251
* @throws InsufficientAddressCapacityException
283252
* @throws ConcurrentOperationException
284253
*/
285-
IpAddress associateIPToVpc(long ipId, long vpcId) throws ResourceAllocationException, ResourceUnavailableException,
286-
InsufficientAddressCapacityException, ConcurrentOperationException;
254+
IpAddress associateIPToVpc(long ipId, long vpcId) throws ResourceAllocationException, ResourceUnavailableException, InsufficientAddressCapacityException,
255+
ConcurrentOperationException;
287256

288257
}

api/src/com/cloud/network/vpn/RemoteAccessVpnService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.cloud.utils.Pair;
3030

3131
public interface RemoteAccessVpnService {
32+
static final String RemoteAccessVpnClientIpRangeCK = "remote.access.vpn.client.iprange";
3233

3334
RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean openFirewall, long networkId)
3435
throws NetworkRuleConflictException;

api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.admin.vpc;
1818

19+
import org.apache.log4j.Logger;
20+
1921
import org.apache.cloudstack.api.APICommand;
2022
import org.apache.cloudstack.api.ApiCommandJobType;
2123
import org.apache.cloudstack.api.ApiConstants;
@@ -28,7 +30,6 @@
2830
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
2931
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
3032
import org.apache.cloudstack.api.response.VpcResponse;
31-
import org.apache.log4j.Logger;
3233

3334
import com.cloud.event.EventTypes;
3435
import com.cloud.exception.ConcurrentOperationException;
@@ -145,8 +146,8 @@ public void create() throws ResourceAllocationException {
145146
}
146147

147148
if (result != null) {
148-
this.setEntityId(result.getId());
149-
this.setEntityUuid(result.getUuid());
149+
setEntityId(result.getId());
150+
setEntityUuid(result.getUuid());
150151
} else {
151152
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private gateway");
152153
}
@@ -159,7 +160,7 @@ public void execute() throws InsufficientCapacityException, ConcurrentOperationE
159160
if (result != null) {
160161
PrivateGatewayResponse response = _responseGenerator.createPrivateGatewayResponse(result);
161162
response.setResponseName(getCommandName());
162-
this.setResponseObject(response);
163+
setResponseObject(response);
163164
} else {
164165
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private gateway");
165166
}
@@ -189,7 +190,7 @@ public String getSyncObjType() {
189190

190191
@Override
191192
public Long getSyncObjId() {
192-
Vpc vpc = _vpcService.getVpc(vpcId);
193+
Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
193194
if (vpc == null) {
194195
throw new InvalidParameterValueException("Invalid id is specified for the vpc");
195196
}

api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public long getEntityOwnerId() {
228228

229229
return network.getAccountId();
230230
} else if (vpcId != null) {
231-
Vpc vpc = _vpcService.getVpc(getVpcId());
231+
Vpc vpc = _entityMgr.findById(Vpc.class, getVpcId());
232232
if (vpc == null) {
233233
throw new InvalidParameterValueException("Can't find Enabled vpc by id specified");
234234
}

api/src/org/apache/cloudstack/api/command/user/firewall/DeletePortForwardingRuleCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.firewall;
1818

19+
import org.apache.log4j.Logger;
20+
1921
import org.apache.cloudstack.api.APICommand;
2022
import org.apache.cloudstack.api.ApiCommandJobType;
2123
import org.apache.cloudstack.api.ApiConstants;
@@ -28,8 +30,6 @@
2830
import org.apache.cloudstack.api.response.SuccessResponse;
2931
import org.apache.cloudstack.context.CallContext;
3032

31-
import org.apache.log4j.Logger;
32-
3333
import com.cloud.event.EventTypes;
3434
import com.cloud.exception.InvalidParameterValueException;
3535
import com.cloud.network.rules.PortForwardingRule;
@@ -100,7 +100,7 @@ public void execute(){
100100

101101
if (result) {
102102
SuccessResponse response = new SuccessResponse(getCommandName());
103-
this.setResponseObject(response);
103+
setResponseObject(response);
104104
} else {
105105
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete port forwarding rule");
106106
}
@@ -114,7 +114,7 @@ public String getSyncObjType() {
114114

115115
@Override
116116
public Long getSyncObjId() {
117-
return _rulesService.getPortForwardigRule(id).getNetworkId();
117+
return _entityMgr.findById(PortForwardingRule.class, id).getNetworkId();
118118
}
119119

120120
@Override

api/src/org/apache/cloudstack/api/command/user/nat/DeleteIpForwardingRuleCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.nat;
1818

19+
import org.apache.log4j.Logger;
20+
1921
import org.apache.cloudstack.api.APICommand;
2022
import org.apache.cloudstack.api.ApiCommandJobType;
2123
import org.apache.cloudstack.api.ApiConstants;
@@ -28,8 +30,6 @@
2830
import org.apache.cloudstack.api.response.SuccessResponse;
2931
import org.apache.cloudstack.context.CallContext;
3032

31-
import org.apache.log4j.Logger;
32-
3333
import com.cloud.event.EventTypes;
3434
import com.cloud.exception.InvalidParameterValueException;
3535
import com.cloud.network.rules.FirewallRule;
@@ -77,7 +77,7 @@ public void execute(){
7777

7878
if (result) {
7979
SuccessResponse response = new SuccessResponse(getCommandName());
80-
this.setResponseObject(response);
80+
setResponseObject(response);
8181
} else {
8282
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete ip forwarding rule");
8383
}
@@ -113,7 +113,7 @@ public String getSyncObjType() {
113113

114114
@Override
115115
public Long getSyncObjId() {
116-
return _rulesService.getFirewallRule(id).getNetworkId();
116+
return _entityMgr.findById(FirewallRule.class, id).getNetworkId();
117117
}
118118

119119
@Override

0 commit comments

Comments
 (0)