mirror of https://github.com/apache/cloudstack.git
DeployRouter includes nw creation following TellDontAsk principle
Also factor out NicProfile specific methods and fix some DI config. Conflicts: server/src/org/cloud/network/router/deployment/VpcRouterDeploymentDefinition.java server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
This commit is contained in:
parent
0de16e0398
commit
c43e6efd10
|
|
@ -200,12 +200,18 @@
|
|||
<bean id="routerControlHelper"
|
||||
class="com.cloud.network.router.RouterControlHelper" />
|
||||
|
||||
<bean id="networkGeneralHelper"
|
||||
class="com.cloud.network.router.NetworkGeneralHelper" />
|
||||
<bean id="networkHelper"
|
||||
class="com.cloud.network.router.NetworkHelperImpl" />
|
||||
|
||||
<bean id="vpcNetworkHelper"
|
||||
class="com.cloud.network.router.VpcNetworkHelperImpl" />
|
||||
|
||||
<bean id="vpcVirtualNetworkHelper"
|
||||
class="com.cloud.network.router.VpcVirtualNetworkHelperImpl" />
|
||||
|
||||
<bean id="nicProfileHelper"
|
||||
class="com.cloud.network.router.NicProfileHelperImpl" />
|
||||
|
||||
<bean id="routerDeploymentDefinitionBuilder"
|
||||
class="org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder" />
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.cloud.network.router;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -16,11 +15,9 @@ import com.cloud.exception.InsufficientServerCapacityException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
|
||||
public interface NetworkHelper {
|
||||
|
|
@ -29,7 +26,6 @@ public interface NetworkHelper {
|
|||
|
||||
public abstract String getRouterIpInNetwork(long networkId, long instanceId);
|
||||
|
||||
// @Override
|
||||
public abstract boolean sendCommandsToRouter(VirtualRouter router,
|
||||
Commands cmds) throws AgentUnavailableException;
|
||||
|
||||
|
|
@ -40,11 +36,9 @@ public interface NetworkHelper {
|
|||
|
||||
public abstract int getRealPriority(DomainRouterVO router);
|
||||
|
||||
// @Override
|
||||
public abstract NicTO getNicTO(VirtualRouter router, Long networkId,
|
||||
String broadcastUri);
|
||||
|
||||
// @Override
|
||||
public abstract VirtualRouter destroyRouter(long routerId, Account caller,
|
||||
Long callerUserId) throws ResourceUnavailableException,
|
||||
ConcurrentOperationException;
|
||||
|
|
@ -55,33 +49,23 @@ public interface NetworkHelper {
|
|||
* @param router
|
||||
* @return
|
||||
*/
|
||||
// @Override
|
||||
public abstract boolean checkRouterVersion(VirtualRouter router);
|
||||
|
||||
// @Override
|
||||
public abstract List<DomainRouterVO> startRouters(
|
||||
RouterDeploymentDefinition routerDeploymentDefinition)
|
||||
throws StorageUnavailableException, InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
// @Override
|
||||
public abstract DomainRouterVO startVirtualRouter(DomainRouterVO router,
|
||||
User user, Account caller, Map<Param, Object> params)
|
||||
throws StorageUnavailableException, InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
// @Override
|
||||
public abstract DomainRouterVO deployRouter(
|
||||
RouterDeploymentDefinition routerDeploymentDefinition,
|
||||
LinkedHashMap<Network, List<? extends NicProfile>> networks,
|
||||
boolean startRouter, List<HypervisorType> supportedHypervisors)
|
||||
throws InsufficientAddressCapacityException,
|
||||
InsufficientServerCapacityException, InsufficientCapacityException,
|
||||
StorageUnavailableException, ResourceUnavailableException;
|
||||
|
||||
public abstract LinkedHashMap<Network, List<? extends NicProfile>> createRouterNetworks(
|
||||
RouterDeploymentDefinition routerDeploymentDefinition)
|
||||
throws ConcurrentOperationException,
|
||||
InsufficientAddressCapacityException;
|
||||
|
||||
}
|
||||
|
|
@ -29,7 +29,6 @@ import javax.inject.Inject;
|
|||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.cloud.network.router.deployment.RouterDeploymentDefinition;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
|
@ -99,9 +98,7 @@ import com.cloud.vm.VirtualMachineProfile.Param;
|
|||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
|
||||
@Component
|
||||
//This will not be a public service anymore, but a helper for the only public service
|
||||
@Local(value = {NetworkHelperImpl.class})
|
||||
@Local(value = {NetworkHelper.class})
|
||||
public class NetworkHelperImpl implements NetworkHelper {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(NetworkHelperImpl.class);
|
||||
|
|
@ -506,19 +503,8 @@ public class NetworkHelperImpl implements NetworkHelper {
|
|||
return result;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploymentDefinition) {
|
||||
// routerDeploymentDefinition.createNetwork();
|
||||
// doDeployRouter
|
||||
// }
|
||||
|
||||
// @Override
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.router.NetworkHelper#deployRouter(org.cloud.network.router.deployment.RouterDeploymentDefinition, java.util.LinkedHashMap, boolean, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploymentDefinition,
|
||||
final LinkedHashMap<Network, List<? extends NicProfile>> networks,
|
||||
final boolean startRouter, final List<HypervisorType> supportedHypervisors)
|
||||
throws InsufficientAddressCapacityException,
|
||||
InsufficientServerCapacityException, InsufficientCapacityException,
|
||||
|
|
@ -587,6 +573,7 @@ public class NetworkHelperImpl implements NetworkHelper {
|
|||
router.setDynamicallyScalable(template.isDynamicallyScalable());
|
||||
router.setRole(Role.VIRTUAL_ROUTER);
|
||||
router = _routerDao.persist(router);
|
||||
LinkedHashMap<Network, List<? extends NicProfile>> networks = this.createRouterNetworks(routerDeploymentDefinition);
|
||||
_itMgr.allocate(router.getInstanceName(), template, routerOffering, networks, routerDeploymentDefinition.getPlan(), null);
|
||||
router = _routerDao.findById(router.getId());
|
||||
} catch (final InsufficientCapacityException ex) {
|
||||
|
|
@ -701,10 +688,6 @@ public class NetworkHelperImpl implements NetworkHelper {
|
|||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.router.NetworkHelper#createRouterNetworks(org.cloud.network.router.deployment.RouterDeploymentDefinition)
|
||||
*/
|
||||
@Override
|
||||
public LinkedHashMap<Network, List<? extends NicProfile>> createRouterNetworks(
|
||||
final RouterDeploymentDefinition routerDeploymentDefinition)
|
||||
throws ConcurrentOperationException, InsufficientAddressCapacityException {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.cloud.network.Network;
|
|||
import com.cloud.network.vpc.VpcGateway;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
||||
public interface VpcNetworkHelper extends NetworkHelper {
|
||||
public interface NicProfileHelper {
|
||||
|
||||
public abstract NicProfile createPrivateNicProfileForGateway(
|
||||
VpcGateway privateGateway);
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.network.router;
|
||||
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.vpc.PrivateIpAddress;
|
||||
import com.cloud.network.vpc.PrivateIpVO;
|
||||
import com.cloud.network.vpc.VpcGateway;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpc.dao.PrivateIpDao;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
|
||||
@Local(value = {NicProfileHelper.class})
|
||||
public class NicProfileHelperImpl implements NicProfileHelper {
|
||||
|
||||
@Inject
|
||||
private VMInstanceDao _vmDao;
|
||||
@Inject
|
||||
private PrivateIpDao _privateIpDao;
|
||||
@Inject
|
||||
protected NetworkModel _networkModel;
|
||||
@Inject
|
||||
protected VpcManager _vpcMgr;
|
||||
@Inject
|
||||
protected NicDao _nicDao;
|
||||
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway) {
|
||||
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
|
||||
PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(), privateNetwork.getId(), privateGateway.getIp4Address());
|
||||
Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(), privateNetwork.getId());
|
||||
|
||||
NicProfile privateNicProfile = new NicProfile();
|
||||
|
||||
if (privateNic != null) {
|
||||
VirtualMachine vm = _vmDao.findById(privateNic.getInstanceId());
|
||||
privateNicProfile =
|
||||
new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(), _networkModel.getNetworkRate(
|
||||
privateNetwork.getId(), vm.getId()), _networkModel.isSecurityGroupSupportedInNetwork(privateNetwork), _networkModel.getNetworkTag(
|
||||
vm.getHypervisorType(), privateNetwork));
|
||||
} else {
|
||||
String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());
|
||||
PrivateIpAddress ip =
|
||||
new PrivateIpAddress(ipVO, privateNetwork.getBroadcastUri().toString(), privateNetwork.getGateway(), netmask,
|
||||
NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress())));
|
||||
|
||||
URI netUri = BroadcastDomainType.fromString(ip.getBroadcastUri());
|
||||
privateNicProfile.setIp4Address(ip.getIpAddress());
|
||||
privateNicProfile.setGateway(ip.getGateway());
|
||||
privateNicProfile.setNetmask(ip.getNetmask());
|
||||
privateNicProfile.setIsolationUri(netUri);
|
||||
privateNicProfile.setBroadcastUri(netUri);
|
||||
// can we solve this in setBroadcastUri()???
|
||||
// or more plugable construct is desirable
|
||||
privateNicProfile.setBroadcastType(BroadcastDomainType.getSchemeValue(netUri));
|
||||
privateNicProfile.setFormat(AddressFormat.Ip4);
|
||||
privateNicProfile.setReservationId(String.valueOf(ip.getBroadcastUri()));
|
||||
privateNicProfile.setMacAddress(ip.getMacAddress());
|
||||
}
|
||||
|
||||
return privateNicProfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicProfile createGuestNicProfileForVpcRouter(final Network guestNetwork) {
|
||||
NicProfile guestNic = new NicProfile();
|
||||
guestNic.setIp4Address(guestNetwork.getGateway());
|
||||
guestNic.setBroadcastUri(guestNetwork.getBroadcastUri());
|
||||
guestNic.setBroadcastType(guestNetwork.getBroadcastDomainType());
|
||||
guestNic.setIsolationUri(guestNetwork.getBroadcastUri());
|
||||
guestNic.setMode(guestNetwork.getMode());
|
||||
String gatewayCidr = guestNetwork.getCidr();
|
||||
guestNic.setNetmask(NetUtils.getCidrNetmask(gatewayCidr));
|
||||
|
||||
return guestNic;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -17,120 +17,44 @@
|
|||
package com.cloud.network.router;
|
||||
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.cloud.network.router.deployment.RouterDeploymentDefinition;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.PrivateIpAddress;
|
||||
import com.cloud.network.vpc.PrivateIpVO;
|
||||
import com.cloud.network.vpc.VpcGateway;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpc.dao.PrivateIpDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
|
||||
@Component
|
||||
// This will not be a public service anymore, but a helper for the only public service
|
||||
@Local(value = {VpcNetworkHelperImpl.class})
|
||||
public class VpcNetworkHelperImpl extends NetworkHelperImpl implements VpcNetworkHelper {
|
||||
public class VpcNetworkHelperImpl extends NetworkHelperImpl {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(VpcNetworkHelperImpl.class);
|
||||
|
||||
@Inject
|
||||
private VMInstanceDao _vmDao;
|
||||
@Inject
|
||||
private PrivateIpDao _privateIpDao;
|
||||
@Inject
|
||||
private VlanDao _vlanDao;
|
||||
@Inject
|
||||
protected VpcManager _vpcMgr;
|
||||
@Inject
|
||||
protected NicProfileHelper nicProfileHelper;
|
||||
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway) {
|
||||
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
|
||||
PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(), privateNetwork.getId(), privateGateway.getIp4Address());
|
||||
Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(), privateNetwork.getId());
|
||||
|
||||
NicProfile privateNicProfile = new NicProfile();
|
||||
|
||||
if (privateNic != null) {
|
||||
VirtualMachine vm = _vmDao.findById(privateNic.getInstanceId());
|
||||
privateNicProfile =
|
||||
new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(), _networkModel.getNetworkRate(
|
||||
privateNetwork.getId(), vm.getId()), _networkModel.isSecurityGroupSupportedInNetwork(privateNetwork), _networkModel.getNetworkTag(
|
||||
vm.getHypervisorType(), privateNetwork));
|
||||
} else {
|
||||
String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());
|
||||
PrivateIpAddress ip =
|
||||
new PrivateIpAddress(ipVO, privateNetwork.getBroadcastUri().toString(), privateNetwork.getGateway(), netmask,
|
||||
NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress())));
|
||||
|
||||
URI netUri = BroadcastDomainType.fromString(ip.getBroadcastUri());
|
||||
privateNicProfile.setIp4Address(ip.getIpAddress());
|
||||
privateNicProfile.setGateway(ip.getGateway());
|
||||
privateNicProfile.setNetmask(ip.getNetmask());
|
||||
privateNicProfile.setIsolationUri(netUri);
|
||||
privateNicProfile.setBroadcastUri(netUri);
|
||||
// can we solve this in setBroadcastUri()???
|
||||
// or more plugable construct is desirable
|
||||
privateNicProfile.setBroadcastType(BroadcastDomainType.getSchemeValue(netUri));
|
||||
privateNicProfile.setFormat(AddressFormat.Ip4);
|
||||
privateNicProfile.setReservationId(String.valueOf(ip.getBroadcastUri()));
|
||||
privateNicProfile.setMacAddress(ip.getMacAddress());
|
||||
}
|
||||
|
||||
return privateNicProfile;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.router.VpcNetworkHelper#createGuestNicProfileForVpcRouter(com.cloud.network.Network)
|
||||
*/
|
||||
@Override
|
||||
public NicProfile createGuestNicProfileForVpcRouter(final Network guestNetwork) {
|
||||
NicProfile guestNic = new NicProfile();
|
||||
guestNic.setIp4Address(guestNetwork.getGateway());
|
||||
guestNic.setBroadcastUri(guestNetwork.getBroadcastUri());
|
||||
guestNic.setBroadcastType(guestNetwork.getBroadcastDomainType());
|
||||
guestNic.setIsolationUri(guestNetwork.getBroadcastUri());
|
||||
guestNic.setMode(guestNetwork.getMode());
|
||||
String gatewayCidr = guestNetwork.getCidr();
|
||||
guestNic.setNetmask(NetUtils.getCidrNetmask(gatewayCidr));
|
||||
|
||||
return guestNic;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.router.VpcNetworkHelper#createVpcRouterNetworks(org.cloud.network.router.deployment.VpcRouterDeploymentDefinition)
|
||||
*/
|
||||
@Override
|
||||
public LinkedHashMap<Network, List<? extends NicProfile>> createRouterNetworks(
|
||||
final RouterDeploymentDefinition vpcRouterDeploymentDefinition)
|
||||
|
|
@ -149,7 +73,7 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl implements VpcNetwor
|
|||
final List<PrivateGateway> privateGateways = this._vpcMgr.getVpcPrivateGateways(vpcId);
|
||||
if (privateGateways != null && !privateGateways.isEmpty()) {
|
||||
for (PrivateGateway privateGateway : privateGateways) {
|
||||
NicProfile privateNic = this.createPrivateNicProfileForGateway(privateGateway);
|
||||
NicProfile privateNic = this.nicProfileHelper.createPrivateNicProfileForGateway(privateGateway);
|
||||
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
|
||||
networks.put(privateNetwork, new ArrayList<NicProfile>(Arrays.asList(privateNic)));
|
||||
}
|
||||
|
|
@ -162,7 +86,7 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl implements VpcNetwor
|
|||
continue;
|
||||
}
|
||||
if (guestNetwork.getState() == Network.State.Implemented || guestNetwork.getState() == Network.State.Setup) {
|
||||
NicProfile guestNic = createGuestNicProfileForVpcRouter(guestNetwork);
|
||||
NicProfile guestNic = this.nicProfileHelper.createGuestNicProfileForVpcRouter(guestNetwork);
|
||||
networks.put(guestNetwork, new ArrayList<NicProfile>(Arrays.asList(guestNic)));
|
||||
}
|
||||
}
|
||||
|
|
@ -197,6 +121,7 @@ public class VpcNetworkHelperImpl extends NetworkHelperImpl implements VpcNetwor
|
|||
}
|
||||
if (publicNetwork != null) {
|
||||
if (networks.get(publicNetwork) != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<NicProfile> publicNicProfiles = (List<NicProfile>)networks.get(publicNetwork);
|
||||
publicNicProfiles.addAll(publicNics);
|
||||
networks.put(publicNetwork, publicNicProfiles);
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
private EntityManager _entityMgr;
|
||||
|
||||
@Inject
|
||||
private VpcNetworkHelper vpcHelper;
|
||||
private NicProfileHelper vpcHelper;
|
||||
|
||||
@Override
|
||||
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package org.cloud.network.router.deployment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -64,7 +63,6 @@ import com.cloud.utils.db.SearchBuilder;
|
|||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
|
|
@ -398,10 +396,8 @@ public class RouterDeploymentDefinition {
|
|||
|
||||
int routersToDeploy = this.getNumberOfRoutersToDeploy();
|
||||
for(int i = 0; i < routersToDeploy; i++) {
|
||||
LinkedHashMap<Network, List<? extends NicProfile>> networks =
|
||||
this.nwHelper.createRouterNetworks(this);
|
||||
//don't start the router as we are holding the network lock that needs to be released at the end of router allocation
|
||||
DomainRouterVO router = this.nwHelper.deployRouter(this, networks, false, null);
|
||||
// Don't start the router as we are holding the network lock that needs to be released at the end of router allocation
|
||||
DomainRouterVO router = this.nwHelper.deployRouter(this, false, null);
|
||||
|
||||
if (router != null) {
|
||||
this.routerDao.addRouterToGuestNetwork(router, this.guestNetwork);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
|||
import com.cloud.network.dao.UserIpv6AddressDao;
|
||||
import com.cloud.network.dao.VirtualRouterProviderDao;
|
||||
import com.cloud.network.router.NetworkHelper;
|
||||
import com.cloud.network.router.VpcNetworkHelper;
|
||||
import com.cloud.network.router.VpcNetworkHelperImpl;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
|
|
@ -95,7 +95,7 @@ public class RouterDeploymentDefinitionBuilder {
|
|||
@Inject
|
||||
protected NetworkHelper nwHelper;
|
||||
@Inject
|
||||
protected VpcNetworkHelper vpcNwHelper;
|
||||
protected VpcNetworkHelperImpl vpcNwHelper;
|
||||
|
||||
protected Long offeringId;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package org.cloud.network.router.deployment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -30,12 +29,10 @@ import com.cloud.exception.ConcurrentOperationException;
|
|||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.Type;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.router.VpcNetworkHelper;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
|
|
@ -43,7 +40,6 @@ import com.cloud.network.vpc.dao.VpcOfferingDao;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
|
||||
|
|
@ -56,7 +52,6 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
|
|||
protected PhysicalNetworkDao pNtwkDao;
|
||||
protected VpcManager vpcMgr;
|
||||
protected VlanDao vlanDao;
|
||||
protected VpcNetworkHelper vpcNetworkHelper;
|
||||
|
||||
protected Vpc vpc;
|
||||
|
||||
|
|
@ -164,9 +159,7 @@ public class VpcRouterDeploymentDefinition extends RouterDeploymentDefinition {
|
|||
@Override
|
||||
protected void deployAllVirtualRouters() throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
|
||||
LinkedHashMap<Network, List<? extends NicProfile>> networks = vpcNetworkHelper.createRouterNetworks(this);
|
||||
|
||||
DomainRouterVO router = nwHelper.deployRouter(this, networks, true, vpcMgr.getSupportedVpcHypervisors());
|
||||
DomainRouterVO router = nwHelper.deployRouter(this, true, vpcMgr.getSupportedVpcHypervisors());
|
||||
|
||||
if (router != null) {
|
||||
routers.add(router);
|
||||
|
|
|
|||
|
|
@ -798,11 +798,10 @@ public class RouterDeploymentDefinitionTest extends RouterDeploymentDefinitionTe
|
|||
//this.deployment.routers.add(routerVO1);
|
||||
RouterDeploymentDefinition deploymentUT = spy(this.deployment);
|
||||
doReturn(2).when(deploymentUT).getNumberOfRoutersToDeploy();
|
||||
doReturn(null).when(this.mockNetworkGeneralHelper).createRouterNetworks(deploymentUT);
|
||||
|
||||
final DomainRouterVO routerVO1 = mock(DomainRouterVO.class);
|
||||
final DomainRouterVO routerVO2 = mock(DomainRouterVO.class);
|
||||
when(this.mockNetworkGeneralHelper.deployRouter(deploymentUT, null, false, null))
|
||||
when(this.mockNetworkGeneralHelper.deployRouter(deploymentUT, false, null))
|
||||
.thenReturn(routerVO1).thenReturn(routerVO2);
|
||||
|
||||
// Execute
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import com.cloud.deploy.DeployDestination;
|
|||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||
import com.cloud.network.router.VpcNetworkHelper;
|
||||
import com.cloud.network.router.NicProfileHelper;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpc.VpcVO;
|
||||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
|
|
@ -64,7 +64,7 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
|
|||
@Mock
|
||||
protected VpcManager vpcMgr;
|
||||
@Mock
|
||||
protected VpcNetworkHelper vpcHelper;
|
||||
protected NicProfileHelper vpcHelper;
|
||||
|
||||
protected RouterDeploymentDefinition deployment;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue