Skip to content

Commit 3c429ee

Browse files
committed
Merge remote-tracking branch 'sbp/feature/persisten-systemvm-redundant-vpc-REBASE'
This closes #118 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2 parents 83736ab + 23c100d commit 3c429ee

File tree

262 files changed

+16561
-5645
lines changed

Some content is hidden

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

262 files changed

+16561
-5645
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ tools/cli/build/
5656
*.iso
5757
*.tar.gz
5858
*.tgz
59-
.*
59+
60+
# this ignores _all files starting with '.'. Don't do that!
61+
#.*
62+
6063
target-eclipse
6164
awsapi/modules/*
6265
!.gitignore
@@ -94,3 +97,6 @@ tools/appliance/box/
9497
.checkstyle
9598
.pmd
9699
.pmdruleset.xml
100+
.pydevproject
101+
systemvm/.pydevproject
102+
test/.pydevprojec

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ public void setIp6Address(String ip6Address) {
326326
@Override
327327
State getState();
328328

329+
boolean isRedundant();
330+
329331
long getRelated();
330332

331333
URI getBroadcastUri();

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
// under the License.
1717
package com.cloud.network;
1818

19-
import java.net.URI;
20-
2119
import com.cloud.network.Networks.BroadcastDomainType;
2220
import com.cloud.network.Networks.Mode;
2321
import com.cloud.network.Networks.TrafficType;
2422

23+
import java.net.URI;
24+
2525
public class NetworkProfile implements Network {
2626
private final long id;
2727
private final String uuid;
@@ -32,6 +32,7 @@ public class NetworkProfile implements Network {
3232
private String dns2;
3333
private URI broadcastUri;
3434
private final State state;
35+
private boolean isRedundant;
3536
private final String name;
3637
private final Mode mode;
3738
private final BroadcastDomainType broadcastDomainType;
@@ -89,6 +90,7 @@ public NetworkProfile(Network network) {
8990
networkAclId = network.getNetworkACLId();
9091
guruName = network.getGuruName();
9192
strechedL2Subnet = network.isStrechedL2Network();
93+
isRedundant = network.isRedundant();
9294
}
9395

9496
public String getDns1() {
@@ -146,6 +148,11 @@ public State getState() {
146148
return state;
147149
}
148150

151+
@Override
152+
public boolean isRedundant() {
153+
return this.isRedundant;
154+
}
155+
149156
@Override
150157
public String getName() {
151158
return name;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public interface VpcVirtualNetworkApplianceService extends VirtualNetworkApplian
3636
* @throws ResourceUnavailableException
3737
* @throws InsufficientCapacityException
3838
*/
39-
boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant, Map<VirtualMachineProfile.Param, Object> params)
39+
boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, Map<VirtualMachineProfile.Param, Object> params)
4040
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
4141

4242
/**
@@ -47,6 +47,6 @@ boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolea
4747
* @throws ConcurrentOperationException
4848
* @throws ResourceUnavailableException
4949
*/
50-
boolean removeVpcRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) throws ConcurrentOperationException, ResourceUnavailableException;
50+
boolean removeVpcRouterFromGuestNetwork(VirtualRouter router, Network network) throws ConcurrentOperationException, ResourceUnavailableException;
5151

5252
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public enum State {
7474

7575
boolean isDisplay();
7676

77+
boolean isRedundant();
78+
7779
/**
7880
*
7981
* @return true if VPC is configured to use distributed router to provides one-hop forwarding and hypervisor based ACL

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public enum State {
2626

2727
public static final String defaultVPCOfferingName = "Default VPC offering";
2828
public static final String defaultVPCNSOfferingName = "Default VPC offering with Netscaler";
29+
public static final String redundantVPCOfferingName = "Redundant VPC offering";
2930

3031
/**
3132
*
@@ -64,4 +65,7 @@ public enum State {
6465
* @return true if VPC created with the offering can span multiple zones in the region
6566
*/
6667
boolean offersRegionLevelVPC();
68+
69+
boolean getRedundantRouter();
70+
6771
}

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public interface VpcService {
4848
* @throws ResourceAllocationException TODO
4949
*/
5050
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain, Boolean displayVpc)
51-
throws ResourceAllocationException;
51+
throws ResourceAllocationException;
5252

5353
/**
5454
* Deletes a VPC
@@ -98,8 +98,8 @@ public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName
9898
* @return
9999
*/
100100
public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, String displayText, List<String> supportedServicesStr, String cidr, Long vpcOffId, String state,
101-
String accountName, Long domainId, String keyword, Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired,
102-
Map<String, String> tags, Long projectId, Boolean display);
101+
String accountName, Long domainId, String keyword, Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired,
102+
Map<String, String> tags, Long projectId, Boolean display);
103103

104104
/**
105105
* Starts VPC which includes starting VPC provider and applying all the neworking rules on the backend
@@ -127,10 +127,12 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
127127
* Restarts the VPC. VPC gets shutdown and started as a part of it
128128
*
129129
* @param id
130+
* @param cleanUp
131+
* @param makeredundant
130132
* @return
131133
* @throws InsufficientCapacityException
132134
*/
133-
boolean restartVpc(long id) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
135+
boolean restartVpc(long id, boolean cleanUp, boolean makeredundant) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
134136

135137
/**
136138
* Returns a Private gateway found in the VPC by id
@@ -160,7 +162,7 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
160162
* @throws ResourceAllocationException
161163
*/
162164
public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String vlan, String ipAddress, String gateway, String netmask, long gatewayOwnerId,
163-
Long networkOfferingId, Boolean isSoruceNat, Long aclId) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
165+
Long networkOfferingId, Boolean isSoruceNat, Long aclId) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
164166

165167
/**
166168
* Applies VPC private gateway on the backend, so it becomes functional
@@ -246,7 +248,7 @@ public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId
246248
* @throws ConcurrentOperationException
247249
*/
248250
IpAddress associateIPToVpc(long ipId, long vpcId) throws ResourceAllocationException, ResourceUnavailableException, InsufficientAddressCapacityException,
249-
ConcurrentOperationException;
251+
ConcurrentOperationException;
250252

251253
/**
252254
* @param routeId

api/src/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class ApiConstants {
4848
public static final String IP6_CIDR = "ip6cidr";
4949
public static final String CIDR_LIST = "cidrlist";
5050
public static final String CLEANUP = "cleanup";
51+
public static final String MAKEREDUNDANTE = "makeredundant";
5152
public static final String CLUSTER_ID = "clusterid";
5253
public static final String CLUSTER_NAME = "clustername";
5354
public static final String CLUSTER_TYPE = "clustertype";
@@ -450,7 +451,7 @@ public class ApiConstants {
450451
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_NAME = "vsmdevicename";
451452
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_STATE = "vsmdevicestate";
452453
// Would we need to have a capacity field for Cisco N1KV VSM? Max hosts managed by it perhaps? May remove this
453-
// later.
454+
// later.
454455
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_CAPACITY = "vsmdevicecapacity";
455456
public static final String CISCO_NEXUS_VSM_NAME = "vsmname";
456457
public static final String VSM_USERNAME = "vsmusername";
@@ -608,6 +609,7 @@ public class ApiConstants {
608609
public static final String REMAININGCAPACITY = "remainingcapacity";
609610
public static final String MAXCAPACITY = "maxcapacity";
610611
public static final String DISTRIBUTED_VPC_ROUTER = "distributedvpcrouter";
612+
public static final String REDUNDANT_VPC_ROUTER = "redundantvpcrouter";
611613
public static final String READ_ONLY = "readonly";
612614
public static final String SUPPORTS_REGION_LEVEL_VPC = "supportsregionLevelvpc";
613615
public static final String SUPPORTS_STRECHED_L2_SUBNET = "supportsstrechedl2subnet";

api/src/org/apache/cloudstack/api/command/user/vpc/RestartVPCCmd.java

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

19-
import org.apache.log4j.Logger;
20-
2119
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
2220
import org.apache.cloudstack.api.ACL;
2321
import org.apache.cloudstack.api.APICommand;
@@ -28,6 +26,7 @@
2826
import org.apache.cloudstack.api.ServerApiException;
2927
import org.apache.cloudstack.api.response.SuccessResponse;
3028
import org.apache.cloudstack.api.response.VpcResponse;
29+
import org.apache.log4j.Logger;
3130

3231
import com.cloud.event.EventTypes;
3332
import com.cloud.exception.ConcurrentOperationException;
@@ -37,7 +36,7 @@
3736
import com.cloud.user.Account;
3837

3938
@APICommand(name = "restartVPC", description = "Restarts a VPC", responseObject = VpcResponse.class, entityType = {Vpc.class},
40-
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
39+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
4140
public class RestartVPCCmd extends BaseAsyncCmd {
4241
public static final Logger s_logger = Logger.getLogger(RestartVPCCmd.class.getName());
4342
private static final String s_name = "restartvpcresponse";
@@ -49,6 +48,12 @@ public class RestartVPCCmd extends BaseAsyncCmd {
4948
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VpcResponse.class, required = true, description = "the id of the VPC")
5049
private Long id;
5150

51+
@Parameter(name = ApiConstants.CLEANUP, type = CommandType.BOOLEAN, required = false, description = "If cleanup old network elements")
52+
private Boolean cleanup;
53+
54+
@Parameter(name = ApiConstants.MAKEREDUNDANTE, type = CommandType.BOOLEAN, required = false, description = "Turn a single VPC into a redundant one.")
55+
private Boolean makeredundant;
56+
5257
/////////////////////////////////////////////////////
5358
/////////////////// Accessors ///////////////////////
5459
/////////////////////////////////////////////////////
@@ -57,6 +62,20 @@ public Long getId() {
5762
return id;
5863
}
5964

65+
public Boolean getCleanup() {
66+
if (cleanup != null) {
67+
return cleanup;
68+
}
69+
return true;
70+
}
71+
72+
public Boolean getMakeredundant() {
73+
if (makeredundant != null) {
74+
return makeredundant;
75+
}
76+
return true;
77+
}
78+
6079
/////////////////////////////////////////////////////
6180
/////////////// API Implementation///////////////////
6281
/////////////////////////////////////////////////////
@@ -67,7 +86,7 @@ public String getCommandName() {
6786

6887
@Override
6988
public long getEntityOwnerId() {
70-
Vpc vpc = _entityMgr.findById(Vpc.class, getId());
89+
final Vpc vpc = _entityMgr.findById(Vpc.class, getId());
7190
if (vpc != null) {
7291
return vpc.getAccountId();
7392
}
@@ -78,20 +97,20 @@ public long getEntityOwnerId() {
7897
@Override
7998
public void execute() {
8099
try {
81-
boolean result = _vpcService.restartVpc(getId());
100+
final boolean result = _vpcService.restartVpc(getId(), getCleanup(), getMakeredundant());
82101
if (result) {
83-
SuccessResponse response = new SuccessResponse(getCommandName());
102+
final SuccessResponse response = new SuccessResponse(getCommandName());
84103
setResponseObject(response);
85104
} else {
86105
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to restart VPC");
87106
}
88-
} catch (ResourceUnavailableException ex) {
107+
} catch (final ResourceUnavailableException ex) {
89108
s_logger.warn("Exception: ", ex);
90109
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
91-
} catch (ConcurrentOperationException ex) {
110+
} catch (final ConcurrentOperationException ex) {
92111
s_logger.warn("Exception: ", ex);
93112
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
94-
} catch (InsufficientCapacityException ex) {
113+
} catch (final InsufficientCapacityException ex) {
95114
s_logger.info(ex);
96115
s_logger.trace(ex);
97116
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());

0 commit comments

Comments
 (0)