Skip to content

Commit 9debd3a

Browse files
author
Alena Prokharchyk
committed
1) Added start logic to the VPC
2) VirtualRouterManagerImpl - refactored deployVirtualRouter method 3) Added vpcId to domain_router/user_ip_address tables and corresponding vo objects Conflicts: server/src/com/cloud/network/IPAddressVO.java
1 parent afd2d03 commit 9debd3a

25 files changed

Lines changed: 765 additions & 302 deletions

api/src/com/cloud/api/commands/CreateVPCCmd.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
import com.cloud.api.ServerApiException;
2323
import com.cloud.api.response.VpcResponse;
2424
import com.cloud.event.EventTypes;
25+
import com.cloud.exception.ConcurrentOperationException;
26+
import com.cloud.exception.InsufficientCapacityException;
2527
import com.cloud.exception.ResourceAllocationException;
28+
import com.cloud.exception.ResourceUnavailableException;
2629
import com.cloud.network.vpc.Vpc;
2730
import com.cloud.user.UserContext;
2831

@@ -111,7 +114,20 @@ public void create() throws ResourceAllocationException {
111114
@Override
112115
public void execute() {
113116
//TODO - prepare vpc here (call start() method, it should start the VR, associate source nat ip address, etc)
114-
Vpc vpc = _vpcService.getVpc(this.getEntityId());
117+
Vpc vpc = null;
118+
try {
119+
vpc = _vpcService.startVpc(this.getEntityId());
120+
} catch (ResourceUnavailableException ex) {
121+
s_logger.warn("Exception: ", ex);
122+
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
123+
} catch (ConcurrentOperationException ex) {
124+
s_logger.warn("Exception: ", ex);
125+
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
126+
} catch (InsufficientCapacityException ex) {
127+
s_logger.info(ex);
128+
s_logger.trace(ex);
129+
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
130+
}
115131
if (vpc != null) {
116132
VpcResponse response = _responseGenerator.createVpcResponse(vpc);
117133
response.setResponseName(getCommandName());

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,14 @@ enum Purpose {
8080

8181
boolean getSystem();
8282

83+
/**
84+
* @return
85+
*/
86+
Long getVpcId();
87+
88+
/**
89+
* @param vpcId
90+
*/
91+
void setVpcId(Long vpcId);
92+
8393
}

api/src/com/cloud/network/element/NetworkElement.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public interface NetworkElement extends Adapter {
5656
* @return true if network configuration is now usable; false if not; null if not handled by this element.
5757
* @throws InsufficientNetworkCapacityException TODO
5858
*/
59-
boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
59+
boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context)
60+
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
6061

6162
/**
6263
* Prepare for a nic to be added into this network.
@@ -70,7 +71,9 @@ public interface NetworkElement extends Adapter {
7071
* @throws ResourceUnavailableException
7172
* @throws InsufficientNetworkCapacityException
7273
*/
73-
boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
74+
boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
75+
DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
76+
ResourceUnavailableException, InsufficientCapacityException;
7477

7578
/**
7679
* A nic is released from this network.
@@ -82,7 +85,8 @@ public interface NetworkElement extends Adapter {
8285
* @throws ConcurrentOperationException
8386
* @throws ResourceUnavailableException
8487
*/
85-
boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
88+
boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
89+
ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
8690

8791
/**
8892
* The network is being shutdown.
@@ -93,7 +97,8 @@ public interface NetworkElement extends Adapter {
9397
* @throws ConcurrentOperationException
9498
* @throws ResourceUnavailableException
9599
*/
96-
boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException;
100+
boolean shutdown(Network network, ReservationContext context, boolean cleanup)
101+
throws ConcurrentOperationException, ResourceUnavailableException;
97102

98103
/**
99104
* The network is being destroyed.
@@ -118,7 +123,8 @@ public interface NetworkElement extends Adapter {
118123
* @throws ConcurrentOperationException
119124
* @throws ResourceUnavailableException
120125
*/
121-
boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
126+
boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context)
127+
throws ConcurrentOperationException, ResourceUnavailableException;
122128

123129
/**
124130
* This should return true if out of multiple services provided by this element, only some can be enabled. If all the services MUST be provided, this should return false.

api/src/com/cloud/network/element/UserDataServiceProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.cloud.exception.InsufficientCapacityException;
2222
import com.cloud.exception.ResourceUnavailableException;
2323
import com.cloud.network.Network;
24-
import com.cloud.uservm.UserVm;
2524
import com.cloud.vm.NicProfile;
2625
import com.cloud.vm.ReservationContext;
2726
import com.cloud.vm.VirtualMachine;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.network.element;
14+
15+
import com.cloud.deploy.DeployDestination;
16+
import com.cloud.exception.ConcurrentOperationException;
17+
import com.cloud.exception.InsufficientCapacityException;
18+
import com.cloud.exception.InsufficientNetworkCapacityException;
19+
import com.cloud.exception.ResourceUnavailableException;
20+
import com.cloud.network.vpc.Vpc;
21+
import com.cloud.vm.ReservationContext;
22+
23+
/**
24+
* @author Alena Prokharchyk
25+
*/
26+
public interface VpcProvider extends NetworkElement{
27+
/**
28+
* Start vpc element as specified
29+
* @param vpc fully specified vpc configuration.
30+
* @throws InsufficientNetworkCapacityException TODO
31+
*/
32+
boolean startVpc(Vpc vpc, DeployDestination dest, ReservationContext context)
33+
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
34+
35+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ public enum RedundantState {
3838
String getPublicIpAddress();
3939
boolean isStopPending();
4040
void setStopPending(boolean stopPending);
41+
/**
42+
* @return
43+
*/
44+
Long getVpcId();
4145
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ public enum State {
3838

3939
boolean isDefault();
4040

41+
/**
42+
* @return
43+
*/
44+
Long getServiceOfferingId();
45+
4146
}

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import java.util.Map;
1717
import java.util.Set;
1818

19+
import com.cloud.exception.ConcurrentOperationException;
20+
import com.cloud.exception.InsufficientCapacityException;
21+
import com.cloud.exception.ResourceUnavailableException;
1922
import com.cloud.network.Network;
2023
import com.cloud.network.Network.Provider;
2124
import com.cloud.network.Network.Service;
@@ -30,9 +33,7 @@ public interface VpcService {
3033
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices);
3134

3235
public Vpc getVpc(long vpcId);
33-
34-
public Vpc createVpc(long zoneId, String name, String cidr, long ownerId);
35-
36+
3637
public List<Network> getVpcNetworks(long vpcId);
3738

3839
Map<Service, Set<Provider>> getVpcOffSvcProvidersMap(long vpcOffId);
@@ -102,4 +103,13 @@ public List<? extends Vpc> listVpcs(Long id, String vpcName, String displayText,
102103
List<String> supportedServicesStr, String cidr, Long vpcOffId, String state, String accountName, Long domainId,
103104
String keyword, Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll);
104105

106+
/**
107+
* @param vpcId
108+
* @return
109+
* @throws InsufficientCapacityException
110+
* @throws ResourceUnavailableException
111+
* @throws ConcurrentOperationException
112+
*/
113+
Vpc startVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
114+
105115
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
7171
@Column(name="scripts_version")
7272
private String scriptsVersion;
7373

74+
@Column(name="vpc_id")
75+
private Long vpcId;
76+
7477
public DomainRouterVO(long id,
7578
long serviceOfferingId,
7679
long elementId,
@@ -240,4 +243,9 @@ public String getScriptsVersion() {
240243
public void setScriptsVersion(String scriptsVersion) {
241244
this.scriptsVersion = scriptsVersion;
242245
}
246+
247+
@Override
248+
public Long getVpcId() {
249+
return vpcId;
250+
}
243251
}

server/src/com/cloud/configuration/DefaultComponentLibrary.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
import com.cloud.maint.dao.AgentUpgradeDaoImpl;
7171
import com.cloud.network.ExternalLoadBalancerUsageManagerImpl;
7272
import com.cloud.network.NetworkManagerImpl;
73-
import com.cloud.network.RouterNetworkDaoImpl;
7473
import com.cloud.network.StorageNetworkManagerImpl;
7574
import com.cloud.network.dao.CiscoNexusVSMDeviceDaoImpl;
7675
import com.cloud.network.dao.ExternalFirewallDeviceDaoImpl;
@@ -114,6 +113,7 @@
114113
import com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl;
115114
import com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl;
116115
import com.cloud.network.router.VirtualNetworkApplianceManagerImpl;
116+
import com.cloud.network.router.VpcVirtualNetworkApplianceManagerImpl;
117117
import com.cloud.network.rules.RulesManagerImpl;
118118
import com.cloud.network.rules.dao.PortForwardingRulesDaoImpl;
119119
import com.cloud.network.security.SecurityGroupManagerImpl2;
@@ -394,6 +394,7 @@ protected void populateManagers() {
394394
addManager("ExternalLoadBalancerUsageManager", ExternalLoadBalancerUsageManagerImpl.class);
395395
addManager("HA Manager", HighAvailabilityManagerImpl.class);
396396
addManager("VPC Manager", VpcManagerImpl.class);
397+
addManager("VpcVirtualRouterManager", VpcVirtualNetworkApplianceManagerImpl.class);
397398
}
398399

399400
@Override

0 commit comments

Comments
 (0)