mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Extract general behavior to Router and Vpc delegates
Conflicts: server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
This commit is contained in:
parent
1a85213bbf
commit
f28426e1a2
@ -186,6 +186,10 @@
|
||||
class="com.cloud.network.rules.VirtualNetworkApplianceFactory" />
|
||||
<bean id="routerControlHelper"
|
||||
class="com.cloud.network.router.RouterControlHelper" />
|
||||
<bean id="networkGeneralHelper"
|
||||
class="com.cloud.network.router.NetworkGeneralHelper" />
|
||||
<bean id="vpcVirtualNetworkHelper"
|
||||
class="com.cloud.network.router.VpcVirtualNetworkHelperImpl" />
|
||||
|
||||
|
||||
<bean id="ApiAsyncJobDispatcher" class="com.cloud.api.ApiAsyncJobDispatcher">
|
||||
|
||||
738
server/src/com/cloud/network/router/NetworkGeneralHelper.java
Normal file
738
server/src/com/cloud/network/router/NetworkGeneralHelper.java
Normal file
@ -0,0 +1,738 @@
|
||||
package com.cloud.network.router;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.maint.Version;
|
||||
import com.cloud.network.IpAddressManager;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.VirtualNetworkApplianceService;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.UserIpv6AddressDao;
|
||||
import com.cloud.network.router.VirtualRouter.RedundantState;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.network.vpn.Site2SiteVpnManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
|
||||
public class NetworkGeneralHelper {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(NetworkGeneralHelper.class);
|
||||
|
||||
|
||||
@Inject
|
||||
NicDao _nicDao;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
DomainRouterDao _routerDao;
|
||||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
VirtualMachineManager _itMgr;
|
||||
@Inject
|
||||
AccountManager _accountMgr;
|
||||
@Inject
|
||||
Site2SiteVpnManager _s2sVpnMgr;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
VolumeDao _volumeDao;
|
||||
@Inject
|
||||
ServiceOfferingDao _serviceOfferingDao;
|
||||
@Inject
|
||||
VMTemplateDao _templateDao;
|
||||
@Inject
|
||||
ResourceManager _resourceMgr;
|
||||
@Inject
|
||||
ClusterDao _clusterDao;
|
||||
@Inject
|
||||
IPAddressDao _ipAddressDao;
|
||||
@Inject
|
||||
IpAddressManager _ipAddrMgr;
|
||||
@Inject
|
||||
UserIpv6AddressDao _ipv6Dao;
|
||||
@Inject
|
||||
NetworkOrchestrationService _networkMgr;
|
||||
|
||||
public String getRouterControlIp(final long routerId) {
|
||||
String routerControlIpAddress = null;
|
||||
final List<NicVO> nics = _nicDao.listByVmId(routerId);
|
||||
for (final NicVO n : nics) {
|
||||
final NetworkVO nc = _networkDao.findById(n.getNetworkId());
|
||||
if (nc != null && nc.getTrafficType() == TrafficType.Control) {
|
||||
routerControlIpAddress = n.getIp4Address();
|
||||
// router will have only one control ip
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (routerControlIpAddress == null) {
|
||||
s_logger.warn("Unable to find router's control ip in its attached NICs!. routerId: " + routerId);
|
||||
final DomainRouterVO router = _routerDao.findById(routerId);
|
||||
return router.getPrivateIpAddress();
|
||||
}
|
||||
|
||||
return routerControlIpAddress;
|
||||
}
|
||||
|
||||
public String getRouterIpInNetwork(final long networkId, final long instanceId) {
|
||||
return _nicDao.getIpAddress(networkId, instanceId);
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
public boolean sendCommandsToRouter(final VirtualRouter router, final Commands cmds) throws AgentUnavailableException {
|
||||
if(!checkRouterVersion(router)){
|
||||
s_logger.debug("Router requires upgrade. Unable to send command to router:" + router.getId() + ", router template version : " + router.getTemplateVersion()
|
||||
+ ", minimal required version : " + VirtualNetworkApplianceService.MinVRVersion);
|
||||
throw new CloudRuntimeException("Unable to send command. Upgrade in progress. Please contact administrator.");
|
||||
}
|
||||
Answer[] answers = null;
|
||||
try {
|
||||
answers = _agentMgr.send(router.getHostId(), cmds);
|
||||
} catch (final OperationTimedoutException e) {
|
||||
s_logger.warn("Timed Out", e);
|
||||
throw new AgentUnavailableException("Unable to send commands to virtual router ", router.getHostId(), e);
|
||||
}
|
||||
|
||||
if (answers == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (answers.length != cmds.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: Have to return state for individual command in the future
|
||||
boolean result = true;
|
||||
if (answers.length > 0) {
|
||||
for (final Answer answer : answers) {
|
||||
if (!answer.getResult()) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
public NicTO getNicTO(final VirtualRouter router, Long networkId, String broadcastUri) {
|
||||
NicProfile nicProfile = _networkModel.getNicProfile(router, networkId, broadcastUri);
|
||||
|
||||
return _itMgr.toNicTO(nicProfile, router.getHypervisorType());
|
||||
}
|
||||
|
||||
// @Override
|
||||
public VirtualRouter destroyRouter(final long routerId, final Account caller, final Long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Attempting to destroy router " + routerId);
|
||||
}
|
||||
|
||||
final DomainRouterVO router = _routerDao.findById(routerId);
|
||||
if (router == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
_accountMgr.checkAccess(caller, null, true, router);
|
||||
|
||||
_itMgr.expunge(router.getUuid());
|
||||
_routerDao.remove(router.getId());
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the router is at the required version. Compares MS version and router version.
|
||||
*
|
||||
* @param router
|
||||
* @return
|
||||
*/
|
||||
// @Override
|
||||
public boolean checkRouterVersion(final VirtualRouter router) {
|
||||
if(!VirtualNetworkApplianceManagerImpl.routerVersionCheckEnabled.value()){
|
||||
//Router version check is disabled.
|
||||
return true;
|
||||
}
|
||||
if(router.getTemplateVersion() == null){
|
||||
return false;
|
||||
}
|
||||
final String trimmedVersion = Version.trimRouterVersion(router.getTemplateVersion());
|
||||
return (Version.compare(trimmedVersion, VirtualNetworkApplianceService.MinVRVersion) >= 0);
|
||||
}
|
||||
|
||||
|
||||
protected DomainRouterVO start(DomainRouterVO router, final User user, final Account caller, final Map<Param, Object> params, final DeploymentPlan planToDeploy)
|
||||
throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
s_logger.debug("Starting router " + router);
|
||||
try {
|
||||
_itMgr.advanceStart(router.getUuid(), params, planToDeploy, null);
|
||||
} catch (final OperationTimedoutException e) {
|
||||
throw new ResourceUnavailableException("Starting router " + router + " failed! " + e.toString(), DataCenter.class, router.getDataCenterId());
|
||||
}
|
||||
if (router.isStopPending()) {
|
||||
s_logger.info("Clear the stop pending flag of router " + router.getHostName() + " after start router successfully!");
|
||||
router.setStopPending(false);
|
||||
router = _routerDao.persist(router);
|
||||
}
|
||||
// We don't want the failure of VPN Connection affect the status of router, so we try to make connection
|
||||
// only after router start successfully
|
||||
final Long vpcId = router.getVpcId();
|
||||
if (vpcId != null) {
|
||||
_s2sVpnMgr.reconnectDisconnectedVpnByVpc(vpcId);
|
||||
}
|
||||
return _routerDao.findById(router.getId());
|
||||
}
|
||||
|
||||
protected DomainRouterVO waitRouter(DomainRouterVO router) {
|
||||
DomainRouterVO vm = _routerDao.findById(router.getId());
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Router " + router.getInstanceName() + " is not fully up yet, we will wait");
|
||||
while (vm.getState() == State.Starting) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
// reload to get the latest state info
|
||||
vm = _routerDao.findById(router.getId());
|
||||
}
|
||||
|
||||
if (vm.getState() == State.Running) {
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Router " + router.getInstanceName() + " is now fully up");
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
s_logger.warn("Router " + router.getInstanceName() + " failed to start. current state: " + vm.getState());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
public List<DomainRouterVO> startRouters(final Map<Param, Object> params, final List<DomainRouterVO> routers) throws StorageUnavailableException,
|
||||
InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
List<DomainRouterVO> runningRouters = null;
|
||||
|
||||
if (routers != null) {
|
||||
runningRouters = new ArrayList<DomainRouterVO>();
|
||||
}
|
||||
|
||||
for (DomainRouterVO router : routers) {
|
||||
boolean skip = false;
|
||||
final State state = router.getState();
|
||||
if (router.getHostId() != null && state != State.Running) {
|
||||
final HostVO host = _hostDao.findById(router.getHostId());
|
||||
if (host == null || host.getState() != Status.Up) {
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
if (!skip) {
|
||||
if (state != State.Running) {
|
||||
router = startVirtualRouter(router, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount(), params);
|
||||
}
|
||||
if (router != null) {
|
||||
runningRouters.add(router);
|
||||
}
|
||||
}
|
||||
}
|
||||
return runningRouters;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public DomainRouterVO startVirtualRouter(DomainRouterVO router, User user, Account caller, Map<Param, Object> params)
|
||||
throws StorageUnavailableException, InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
if (router.getRole() != Role.VIRTUAL_ROUTER || !router.getIsRedundantRouter()) {
|
||||
return this.start(router, user, caller, params, null);
|
||||
}
|
||||
|
||||
if (router.getState() == State.Running) {
|
||||
s_logger.debug("Redundant router " + router.getInstanceName() + " is already running!");
|
||||
return router;
|
||||
}
|
||||
|
||||
//
|
||||
// If another thread has already requested a VR start, there is a transition period for VR to transit from
|
||||
// Starting to Running, there exist a race conditioning window here
|
||||
// We will wait until VR is up or fail
|
||||
if (router.getState() == State.Starting) {
|
||||
return waitRouter(router);
|
||||
}
|
||||
|
||||
DataCenterDeployment plan = new DataCenterDeployment(0, null, null, null, null, null);
|
||||
DomainRouterVO result = null;
|
||||
assert router.getIsRedundantRouter();
|
||||
final List<Long> networkIds = _routerDao.getRouterNetworks(router.getId());
|
||||
//Not support VPC now
|
||||
if (networkIds.size() > 1) {
|
||||
throw new ResourceUnavailableException("Unable to support more than one guest network for redundant router now!", DataCenter.class, router.getDataCenterId());
|
||||
}
|
||||
DomainRouterVO routerToBeAvoid = null;
|
||||
if (networkIds.size() != 0) {
|
||||
final List<DomainRouterVO> routerList = _routerDao.findByNetwork(networkIds.get(0));
|
||||
for (final DomainRouterVO rrouter : routerList) {
|
||||
if (rrouter.getHostId() != null && rrouter.getIsRedundantRouter() && rrouter.getState() == State.Running) {
|
||||
if (routerToBeAvoid != null) {
|
||||
throw new ResourceUnavailableException("Try to start router " + router.getInstanceName() + "(" + router.getId() + ")" +
|
||||
", but there are already two redundant routers with IP " + router.getPublicIpAddress() + ", they are " + rrouter.getInstanceName() + "(" +
|
||||
rrouter.getId() + ") and " + routerToBeAvoid.getInstanceName() + "(" + routerToBeAvoid.getId() + ")", DataCenter.class,
|
||||
rrouter.getDataCenterId());
|
||||
}
|
||||
routerToBeAvoid = rrouter;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (routerToBeAvoid == null) {
|
||||
return this.start(router, user, caller, params, null);
|
||||
}
|
||||
// We would try best to deploy the router to another place
|
||||
final int retryIndex = 5;
|
||||
final ExcludeList[] avoids = new ExcludeList[5];
|
||||
avoids[0] = new ExcludeList();
|
||||
avoids[0].addPod(routerToBeAvoid.getPodIdToDeployIn());
|
||||
avoids[1] = new ExcludeList();
|
||||
avoids[1].addCluster(_hostDao.findById(routerToBeAvoid.getHostId()).getClusterId());
|
||||
avoids[2] = new ExcludeList();
|
||||
final List<VolumeVO> volumes = _volumeDao.findByInstanceAndType(routerToBeAvoid.getId(), Volume.Type.ROOT);
|
||||
if (volumes != null && volumes.size() != 0) {
|
||||
avoids[2].addPool(volumes.get(0).getPoolId());
|
||||
}
|
||||
avoids[2].addHost(routerToBeAvoid.getHostId());
|
||||
avoids[3] = new ExcludeList();
|
||||
avoids[3].addHost(routerToBeAvoid.getHostId());
|
||||
avoids[4] = new ExcludeList();
|
||||
|
||||
for (int i = 0; i < retryIndex; i++) {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("Try to deploy redundant virtual router:" + router.getHostName() + ", for " + i + " time");
|
||||
}
|
||||
plan.setAvoids(avoids[i]);
|
||||
try {
|
||||
result = this.start(router, user, caller, params, plan);
|
||||
} catch (final InsufficientServerCapacityException ex) {
|
||||
result = null;
|
||||
}
|
||||
if (result != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
public DomainRouterVO deployRouter(Account owner,
|
||||
DeployDestination dest, DeploymentPlan plan,
|
||||
Map<Param, Object> params, boolean isRedundant,
|
||||
VirtualRouterProvider vrProvider, long svcOffId, Long vpcId,
|
||||
LinkedHashMap<Network, List<? extends NicProfile>> networks,
|
||||
boolean startRouter, List<HypervisorType> supportedHypervisors)
|
||||
throws InsufficientAddressCapacityException,
|
||||
InsufficientServerCapacityException, InsufficientCapacityException,
|
||||
StorageUnavailableException, ResourceUnavailableException {
|
||||
|
||||
final ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(svcOffId);
|
||||
|
||||
// Router is the network element, we don't know the hypervisor type yet.
|
||||
// Try to allocate the domR twice using diff hypervisors, and when failed both times, throw the exception up
|
||||
final List<HypervisorType> hypervisors = getHypervisors(dest, plan, supportedHypervisors);
|
||||
|
||||
int allocateRetry = 0;
|
||||
int startRetry = 0;
|
||||
DomainRouterVO router = null;
|
||||
for (final Iterator<HypervisorType> iter = hypervisors.iterator(); iter.hasNext();) {
|
||||
final HypervisorType hType = iter.next();
|
||||
try {
|
||||
final long id = _routerDao.getNextInSequence(Long.class, "id");
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Allocating the VR i=" + id + " in datacenter " + dest.getDataCenter() + "with the hypervisor type " + hType);
|
||||
}
|
||||
|
||||
String templateName = null;
|
||||
switch (hType) {
|
||||
case XenServer:
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateXen.valueIn(dest.getDataCenter().getId());
|
||||
break;
|
||||
case KVM:
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateKvm.valueIn(dest.getDataCenter().getId());
|
||||
break;
|
||||
case VMware:
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateVmware.valueIn(dest.getDataCenter().getId());
|
||||
break;
|
||||
case Hyperv:
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateHyperV.valueIn(dest.getDataCenter().getId());
|
||||
break;
|
||||
case LXC:
|
||||
templateName = VirtualNetworkApplianceManager.RouterTemplateLxc.valueIn(dest.getDataCenter().getId());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
final VMTemplateVO template = _templateDao.findRoutingTemplate(hType, templateName);
|
||||
|
||||
if (template == null) {
|
||||
s_logger.debug(hType + " won't support system vm, skip it");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean offerHA = routerOffering.getOfferHA();
|
||||
/* We don't provide HA to redundant router VMs, admin should own it all, and redundant router themselves are HA */
|
||||
if (isRedundant) {
|
||||
offerHA = false;
|
||||
}
|
||||
|
||||
router =
|
||||
new DomainRouterVO(id, routerOffering.getId(), vrProvider.getId(),
|
||||
VirtualMachineName.getRouterName(id, VirtualNwStatus.instance), template.getId(), template.getHypervisorType(),
|
||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), isRedundant, 0, false, RedundantState.UNKNOWN,
|
||||
offerHA, false, vpcId);
|
||||
router.setDynamicallyScalable(template.isDynamicallyScalable());
|
||||
router.setRole(Role.VIRTUAL_ROUTER);
|
||||
router = _routerDao.persist(router);
|
||||
_itMgr.allocate(router.getInstanceName(), template, routerOffering, networks, plan, null);
|
||||
router = _routerDao.findById(router.getId());
|
||||
} catch (final InsufficientCapacityException ex) {
|
||||
if (allocateRetry < 2 && iter.hasNext()) {
|
||||
s_logger.debug("Failed to allocate the VR with hypervisor type " + hType + ", retrying one more time");
|
||||
continue;
|
||||
} else {
|
||||
throw ex;
|
||||
}
|
||||
} finally {
|
||||
allocateRetry++;
|
||||
}
|
||||
|
||||
if (startRouter) {
|
||||
try {
|
||||
router = startVirtualRouter(router, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount(), params);
|
||||
break;
|
||||
} catch (final InsufficientCapacityException ex) {
|
||||
if (startRetry < 2 && iter.hasNext()) {
|
||||
s_logger.debug("Failed to start the VR " + router + " with hypervisor type " + hType + ", " + "destroying it and recreating one more time");
|
||||
// destroy the router
|
||||
destroyRouter(router.getId(), _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM), User.UID_SYSTEM);
|
||||
continue;
|
||||
} else {
|
||||
throw ex;
|
||||
}
|
||||
} finally {
|
||||
startRetry++;
|
||||
}
|
||||
} else {
|
||||
//return stopped router
|
||||
return router;
|
||||
}
|
||||
}
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
protected List<HypervisorType> getHypervisors(final DeployDestination dest, final DeploymentPlan plan, final List<HypervisorType> supportedHypervisors)
|
||||
throws InsufficientServerCapacityException {
|
||||
List<HypervisorType> hypervisors = new ArrayList<HypervisorType>();
|
||||
|
||||
if (dest.getCluster() != null) {
|
||||
if (dest.getCluster().getHypervisorType() == HypervisorType.Ovm) {
|
||||
hypervisors.add(getClusterToStartDomainRouterForOvm(dest.getCluster().getPodId()));
|
||||
} else {
|
||||
hypervisors.add(dest.getCluster().getHypervisorType());
|
||||
}
|
||||
} else {
|
||||
final HypervisorType defaults = _resourceMgr.getDefaultHypervisor(dest.getDataCenter().getId());
|
||||
if (defaults != HypervisorType.None) {
|
||||
hypervisors.add(defaults);
|
||||
} else {
|
||||
//if there is no default hypervisor, get it from the cluster
|
||||
hypervisors = _resourceMgr.getSupportedHypervisorTypes(dest.getDataCenter().getId(), true, plan.getPodId());
|
||||
}
|
||||
}
|
||||
|
||||
//keep only elements defined in supported hypervisors
|
||||
final StringBuilder hTypesStr = new StringBuilder();
|
||||
if (supportedHypervisors != null && !supportedHypervisors.isEmpty()) {
|
||||
hypervisors.retainAll(supportedHypervisors);
|
||||
for (final HypervisorType hType : supportedHypervisors) {
|
||||
hTypesStr.append(hType).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
if (hypervisors.isEmpty()) {
|
||||
final String errMsg = (hTypesStr.capacity() > 0) ? "supporting hypervisors " + hTypesStr.toString() : "";
|
||||
if (plan.getPodId() != null) {
|
||||
throw new InsufficientServerCapacityException("Unable to create virtual router, " + "there are no clusters in the pod " + errMsg, Pod.class,
|
||||
plan.getPodId());
|
||||
}
|
||||
throw new InsufficientServerCapacityException("Unable to create virtual router, " + "there are no clusters in the zone " + errMsg, DataCenter.class,
|
||||
dest.getDataCenter().getId());
|
||||
}
|
||||
return hypervisors;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ovm won't support any system. So we have to choose a partner cluster in the same pod to start domain router for us
|
||||
*/
|
||||
protected HypervisorType getClusterToStartDomainRouterForOvm(final long podId) {
|
||||
final List<ClusterVO> clusters = _clusterDao.listByPodId(podId);
|
||||
for (final ClusterVO cv : clusters) {
|
||||
if (cv.getHypervisorType() == HypervisorType.Ovm || cv.getHypervisorType() == HypervisorType.BareMetal) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(cv.getId());
|
||||
if (hosts == null || hosts.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (final HostVO h : hosts) {
|
||||
if (h.getState() == Status.Up) {
|
||||
s_logger.debug("Pick up host that has hypervisor type " + h.getHypervisorType() + " in cluster " + cv.getId() + " to start domain router for OVM");
|
||||
return h.getHypervisorType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final String errMsg =
|
||||
"Cannot find an available cluster in Pod " + podId + " to start domain router for Ovm. \n Ovm won't support any system vm including domain router, " +
|
||||
"please make sure you have a cluster with hypervisor type of any of xenserver/KVM/Vmware in the same pod" +
|
||||
" with Ovm cluster. And there is at least one host in UP status in that cluster.";
|
||||
throw new CloudRuntimeException(errMsg);
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
public LinkedHashMap<Network, List<? extends NicProfile>> createRouterNetworks(
|
||||
Account owner, boolean isRedundant, DeploymentPlan plan,
|
||||
Network guestNetwork, Pair<Boolean, PublicIp> publicNetwork)
|
||||
throws ConcurrentOperationException,
|
||||
InsufficientAddressCapacityException {
|
||||
|
||||
boolean setupPublicNetwork = false;
|
||||
if (publicNetwork != null) {
|
||||
setupPublicNetwork = publicNetwork.first();
|
||||
}
|
||||
|
||||
// Form networks
|
||||
LinkedHashMap<Network, List<? extends NicProfile>> networks = new LinkedHashMap<Network, List<? extends NicProfile>>(
|
||||
3);
|
||||
// 1) Guest network
|
||||
boolean hasGuestNetwork = false;
|
||||
if (guestNetwork != null) {
|
||||
s_logger.debug("Adding nic for Virtual Router in Guest network "
|
||||
+ guestNetwork);
|
||||
String defaultNetworkStartIp = null, defaultNetworkStartIpv6 = null;
|
||||
if (!setupPublicNetwork) {
|
||||
final Nic placeholder = _networkModel
|
||||
.getPlaceholderNicForRouter(guestNetwork,
|
||||
plan.getPodId());
|
||||
if (guestNetwork.getCidr() != null) {
|
||||
if (placeholder != null
|
||||
&& placeholder.getIp4Address() != null) {
|
||||
s_logger.debug("Requesting ipv4 address "
|
||||
+ placeholder.getIp4Address()
|
||||
+ " stored in placeholder nic for the network "
|
||||
+ guestNetwork);
|
||||
defaultNetworkStartIp = placeholder.getIp4Address();
|
||||
} else {
|
||||
final String startIp = _networkModel
|
||||
.getStartIpAddress(guestNetwork.getId());
|
||||
if (startIp != null
|
||||
&& _ipAddressDao.findByIpAndSourceNetworkId(
|
||||
guestNetwork.getId(), startIp)
|
||||
.getAllocatedTime() == null) {
|
||||
defaultNetworkStartIp = startIp;
|
||||
} else if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("First ipv4 "
|
||||
+ startIp
|
||||
+ " in network id="
|
||||
+ guestNetwork.getId()
|
||||
+ " is already allocated, can't use it for domain router; will get random ip address from the range");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (guestNetwork.getIp6Cidr() != null) {
|
||||
if (placeholder != null
|
||||
&& placeholder.getIp6Address() != null) {
|
||||
s_logger.debug("Requesting ipv6 address "
|
||||
+ placeholder.getIp6Address()
|
||||
+ " stored in placeholder nic for the network "
|
||||
+ guestNetwork);
|
||||
defaultNetworkStartIpv6 = placeholder.getIp6Address();
|
||||
} else {
|
||||
final String startIpv6 = _networkModel
|
||||
.getStartIpv6Address(guestNetwork.getId());
|
||||
if (startIpv6 != null
|
||||
&& _ipv6Dao.findByNetworkIdAndIp(
|
||||
guestNetwork.getId(), startIpv6) == null) {
|
||||
defaultNetworkStartIpv6 = startIpv6;
|
||||
} else if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("First ipv6 "
|
||||
+ startIpv6
|
||||
+ " in network id="
|
||||
+ guestNetwork.getId()
|
||||
+ " is already allocated, can't use it for domain router; will get random ipv6 address from the range");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final NicProfile gatewayNic = new NicProfile(defaultNetworkStartIp,
|
||||
defaultNetworkStartIpv6);
|
||||
if (setupPublicNetwork) {
|
||||
if (isRedundant) {
|
||||
gatewayNic.setIp4Address(_ipAddrMgr.acquireGuestIpAddress(
|
||||
guestNetwork, null));
|
||||
} else {
|
||||
gatewayNic.setIp4Address(guestNetwork.getGateway());
|
||||
}
|
||||
gatewayNic.setBroadcastUri(guestNetwork.getBroadcastUri());
|
||||
gatewayNic.setBroadcastType(guestNetwork
|
||||
.getBroadcastDomainType());
|
||||
gatewayNic.setIsolationUri(guestNetwork.getBroadcastUri());
|
||||
gatewayNic.setMode(guestNetwork.getMode());
|
||||
final String gatewayCidr = guestNetwork.getCidr();
|
||||
gatewayNic.setNetmask(NetUtils.getCidrNetmask(gatewayCidr));
|
||||
} else {
|
||||
gatewayNic.setDefaultNic(true);
|
||||
}
|
||||
|
||||
networks.put(guestNetwork,
|
||||
new ArrayList<NicProfile>(Arrays.asList(gatewayNic)));
|
||||
hasGuestNetwork = true;
|
||||
}
|
||||
|
||||
// 2) Control network
|
||||
s_logger.debug("Adding nic for Virtual Router in Control network ");
|
||||
List<? extends NetworkOffering> offerings = _networkModel
|
||||
.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork);
|
||||
NetworkOffering controlOffering = offerings.get(0);
|
||||
Network controlConfig = _networkMgr.setupNetwork(VirtualNwStatus.account,
|
||||
controlOffering, plan, null, null, false).get(0);
|
||||
networks.put(controlConfig, new ArrayList<NicProfile>());
|
||||
// 3) Public network
|
||||
if (setupPublicNetwork) {
|
||||
final PublicIp sourceNatIp = publicNetwork.second();
|
||||
s_logger.debug("Adding nic for Virtual Router in Public network ");
|
||||
// if source nat service is supported by the network, get the source
|
||||
// nat ip address
|
||||
final NicProfile defaultNic = new NicProfile();
|
||||
defaultNic.setDefaultNic(true);
|
||||
defaultNic.setIp4Address(sourceNatIp.getAddress().addr());
|
||||
defaultNic.setGateway(sourceNatIp.getGateway());
|
||||
defaultNic.setNetmask(sourceNatIp.getNetmask());
|
||||
defaultNic.setMacAddress(sourceNatIp.getMacAddress());
|
||||
// get broadcast from public network
|
||||
final Network pubNet = _networkDao.findById(sourceNatIp
|
||||
.getNetworkId());
|
||||
if (pubNet.getBroadcastDomainType() == BroadcastDomainType.Vxlan) {
|
||||
defaultNic.setBroadcastType(BroadcastDomainType.Vxlan);
|
||||
defaultNic.setBroadcastUri(BroadcastDomainType.Vxlan
|
||||
.toUri(sourceNatIp.getVlanTag()));
|
||||
defaultNic.setIsolationUri(BroadcastDomainType.Vxlan
|
||||
.toUri(sourceNatIp.getVlanTag()));
|
||||
} else {
|
||||
defaultNic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
defaultNic.setBroadcastUri(BroadcastDomainType.Vlan
|
||||
.toUri(sourceNatIp.getVlanTag()));
|
||||
defaultNic.setIsolationUri(IsolationType.Vlan.toUri(sourceNatIp
|
||||
.getVlanTag()));
|
||||
}
|
||||
if (hasGuestNetwork) {
|
||||
defaultNic.setDeviceId(2);
|
||||
}
|
||||
final NetworkOffering publicOffering = _networkModel
|
||||
.getSystemAccountNetworkOfferings(
|
||||
NetworkOffering.SystemPublicNetwork).get(0);
|
||||
final List<? extends Network> publicNetworks = _networkMgr
|
||||
.setupNetwork(VirtualNwStatus.account, publicOffering, plan, null,
|
||||
null, false);
|
||||
final String publicIp = defaultNic.getIp4Address();
|
||||
// We want to use the identical MAC address for RvR on public
|
||||
// interface if possible
|
||||
final NicVO peerNic = _nicDao.findByIp4AddressAndNetworkId(
|
||||
publicIp, publicNetworks.get(0).getId());
|
||||
if (peerNic != null) {
|
||||
s_logger.info("Use same MAC as previous RvR, the MAC is "
|
||||
+ peerNic.getMacAddress());
|
||||
defaultNic.setMacAddress(peerNic.getMacAddress());
|
||||
}
|
||||
networks.put(publicNetworks.get(0), new ArrayList<NicProfile>(
|
||||
Arrays.asList(defaultNic)));
|
||||
}
|
||||
|
||||
return networks;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
10
server/src/com/cloud/network/router/VirtualNwStatus.java
Normal file
10
server/src/com/cloud/network/router/VirtualNwStatus.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.cloud.network.router;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
|
||||
public class VirtualNwStatus {
|
||||
|
||||
public static String instance = "";
|
||||
|
||||
public static Account account = null;
|
||||
}
|
||||
@ -39,6 +39,22 @@ import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
public interface VpcVirtualNetworkApplianceManager extends VirtualNetworkApplianceManager, VpcVirtualNetworkApplianceService {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param vpc
|
||||
* @param dest
|
||||
* @param owner
|
||||
* @param params
|
||||
* @param isRedundant
|
||||
* @return
|
||||
* @throws InsufficientCapacityException
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner, Map<Param, Object> params, boolean isRedundant) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param vpc
|
||||
* @param dest
|
||||
* @param owner
|
||||
@ -49,7 +65,7 @@ public interface VpcVirtualNetworkApplianceManager extends VirtualNetworkApplian
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner, Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException;
|
||||
ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -51,7 +51,6 @@ import com.cloud.agent.api.routing.SetStaticRouteCommand;
|
||||
import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand;
|
||||
import com.cloud.agent.api.to.IpAddressTO;
|
||||
import com.cloud.agent.api.to.NetworkACLTO;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
@ -172,6 +171,11 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
|
||||
@Inject
|
||||
protected NetworkGeneralHelper nwHelper;
|
||||
@Inject
|
||||
protected VpcVirtualNetworkHelper vpcHelper;
|
||||
|
||||
@Override
|
||||
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
|
||||
_itMgr.registerGuru(VirtualMachine.Type.DomainRouter, this);
|
||||
@ -179,12 +183,17 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner, Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
|
||||
Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
return this.deployVirtualRouterInVpc(vpc, dest, owner, params, false);
|
||||
}
|
||||
|
||||
List<DomainRouterVO> routers = findOrDeployVirtualRouterInVpc(vpc, dest, owner, params);
|
||||
|
||||
return startRouters(params, routers);
|
||||
@Override
|
||||
public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
|
||||
Map<Param, Object> params, final boolean isRedundant) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
return this.vpcHelper.deployVirtualRouterInVpc(vpc, dest, owner, params, isRedundant);
|
||||
}
|
||||
|
||||
@DB
|
||||
@ -334,7 +343,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
|
||||
LinkedHashMap<Network, List<? extends NicProfile>> networks = createVpcRouterNetworks(owner, isRedundant, plan, new Pair<Boolean, PublicIp>(true, sourceNatIp),vpcId);
|
||||
DomainRouterVO router =
|
||||
super.deployRouter(owner, dest, plan, params, isRedundant, vrProvider, svcOffId, vpcId, networks, true, _vpcMgr.getSupportedVpcHypervisors());
|
||||
nwHelper.deployRouter(owner, dest, plan, params, isRedundant, vrProvider, svcOffId, vpcId, networks, true, _vpcMgr.getSupportedVpcHypervisors());
|
||||
|
||||
return router;
|
||||
}
|
||||
@ -478,12 +487,6 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
}
|
||||
|
||||
protected NicTO getNicTO(final VirtualRouter router, Long networkId, String broadcastUri) {
|
||||
NicProfile nicProfile = _networkModel.getNicProfile(router, networkId, broadcastUri);
|
||||
|
||||
return _itMgr.toNicTO(nicProfile, router.getHypervisorType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean associatePublicIP(Network network, final List<? extends PublicIpAddress> ipAddress, List<? extends VirtualRouter> routers)
|
||||
throws ResourceUnavailableException {
|
||||
@ -677,7 +680,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
}
|
||||
|
||||
SetNetworkACLCommand cmd = new SetNetworkACLCommand(rulesTO, getNicTO(router, guestNetworkId, null));
|
||||
SetNetworkACLCommand cmd = new SetNetworkACLCommand(rulesTO, nwHelper.getNicTO(router, guestNetworkId, null));
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(guestNetworkId, router.getId()));
|
||||
cmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, guestVlan);
|
||||
@ -752,7 +755,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
}
|
||||
}
|
||||
PlugNicCommand plugNicCmd =
|
||||
new PlugNicCommand(getNicTO(router, publicNic.getNetworkId(), publicNic.getBroadcastUri().toString()), router.getInstanceName(), router.getType());
|
||||
new PlugNicCommand(nwHelper.getNicTO(router, publicNic.getNetworkId(), publicNic.getBroadcastUri().toString()), router.getInstanceName(), router.getType());
|
||||
cmds.addCommand(plugNicCmd);
|
||||
VpcVO vpc = _vpcDao.findById(router.getVpcId());
|
||||
NetworkUsageCommand netUsageCmd =
|
||||
@ -778,7 +781,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
for (Pair<Nic, Network> nicNtwk : guestNics) {
|
||||
Nic guestNic = nicNtwk.first();
|
||||
//plug guest nic
|
||||
PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, guestNic.getNetworkId(), null), router.getInstanceName(), router.getType());
|
||||
PlugNicCommand plugNicCmd = new PlugNicCommand(nwHelper.getNicTO(router, guestNic.getNetworkId(), null), router.getInstanceName(), router.getType());
|
||||
cmds.addCommand(plugNicCmd);
|
||||
if (!_networkModel.isPrivateGateway(guestNic.getNetworkId())) {
|
||||
//set guest network
|
||||
@ -920,7 +923,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||
Network network = _networkModel.getNetwork(gateway.getNetworkId());
|
||||
NicProfile requested = createPrivateNicProfileForGateway(gateway);
|
||||
|
||||
if (!checkRouterVersion(router)) {
|
||||
if (!nwHelper.checkRouterVersion(router)) {
|
||||
s_logger.warn("Router requires upgrade. Unable to send command to router: " + router.getId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package com.cloud.network.router;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.network.vpc.VpcGateway;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
|
||||
public interface VpcVirtualNetworkHelper {
|
||||
|
||||
List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc,
|
||||
DeployDestination dest, Account owner, Map<Param, Object> params, boolean isRedundant)
|
||||
throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
ResourceUnavailableException;
|
||||
|
||||
NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway);
|
||||
|
||||
List<DomainRouterVO> getVpcRouters(long vpcId);
|
||||
}
|
||||
@ -0,0 +1,386 @@
|
||||
// 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 java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkService;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.Type;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||
import com.cloud.network.dao.Site2SiteVpnConnectionDao;
|
||||
import com.cloud.network.dao.Site2SiteVpnGatewayDao;
|
||||
import com.cloud.network.dao.VirtualRouterProviderDao;
|
||||
import com.cloud.network.vpc.NetworkACLItemDao;
|
||||
import com.cloud.network.vpc.NetworkACLManager;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.PrivateIpAddress;
|
||||
import com.cloud.network.vpc.PrivateIpVO;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.network.vpc.VpcGateway;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpc.dao.PrivateIpDao;
|
||||
import com.cloud.network.vpc.dao.StaticRouteDao;
|
||||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.network.vpc.dao.VpcGatewayDao;
|
||||
import com.cloud.network.vpc.dao.VpcOfferingDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
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 = {VpcVirtualNetworkHelper.class})
|
||||
public class VpcVirtualNetworkHelperImpl implements VpcVirtualNetworkHelper {
|
||||
//implements VpcVirtualNetworkApplianceManager {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(VpcVirtualNetworkHelperImpl.class);
|
||||
String _name;
|
||||
@Inject
|
||||
VpcDao _vpcDao;
|
||||
@Inject
|
||||
VpcOfferingDao _vpcOffDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _pNtwkDao;
|
||||
@Inject
|
||||
NetworkService _ntwkService;
|
||||
@Inject
|
||||
NetworkACLManager _networkACLMgr;
|
||||
@Inject
|
||||
VMInstanceDao _vmDao;
|
||||
@Inject
|
||||
StaticRouteDao _staticRouteDao;
|
||||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
@Inject
|
||||
PrivateIpDao _privateIpDao;
|
||||
@Inject
|
||||
Site2SiteVpnGatewayDao _vpnGatewayDao;
|
||||
@Inject
|
||||
Site2SiteVpnConnectionDao _vpnConnectionDao;
|
||||
@Inject
|
||||
FirewallRulesDao _firewallDao;
|
||||
@Inject
|
||||
VpcGatewayDao _vpcGatewayDao;
|
||||
@Inject
|
||||
NetworkACLItemDao _networkACLItemDao;
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
@Inject
|
||||
PhysicalNetworkServiceProviderDao _physicalProviderDao;
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
@Inject
|
||||
VlanDao _vlanDao;
|
||||
@Inject
|
||||
FirewallRulesDao _rulesDao;
|
||||
@Inject
|
||||
IPAddressDao _ipAddressDao;
|
||||
@Inject
|
||||
DomainRouterDao _routerDao;
|
||||
@Inject
|
||||
ConfigurationServer _configServer;
|
||||
@Inject
|
||||
NetworkOrchestrationService _networkMgr;
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
NetworkDao _networkDao;
|
||||
@Inject
|
||||
NicDao _nicDao;
|
||||
@Inject
|
||||
VirtualRouterProviderDao _vrProviderDao;
|
||||
|
||||
protected ServiceOfferingVO _offering;
|
||||
|
||||
protected NetworkGeneralHelper nwHelper = new NetworkGeneralHelper();
|
||||
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
|
||||
Map<Param, Object> params, boolean isRedundant)
|
||||
throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
List<DomainRouterVO> routers = findOrDeployVirtualRouterInVpc(vpc, dest, owner, params, isRedundant);
|
||||
|
||||
return this.nwHelper.startRouters(params, routers);
|
||||
}
|
||||
|
||||
@DB
|
||||
protected List<DomainRouterVO> findOrDeployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner,
|
||||
Map<Param, Object> params, boolean isRedundant)
|
||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||
|
||||
s_logger.debug("Deploying Virtual Router in VPC " + vpc);
|
||||
Vpc vpcLock = _vpcDao.acquireInLockTable(vpc.getId());
|
||||
if (vpcLock == null) {
|
||||
throw new ConcurrentOperationException("Unable to lock vpc " + vpc.getId());
|
||||
}
|
||||
|
||||
//1) Get deployment plan and find out the list of routers
|
||||
Pair<DeploymentPlan, List<DomainRouterVO>> planAndRouters = getDeploymentPlanAndRouters(vpc.getId(), dest);
|
||||
DeploymentPlan plan = planAndRouters.first();
|
||||
List<DomainRouterVO> routers = planAndRouters.second();
|
||||
try {
|
||||
//2) Return routers if exist
|
||||
if (routers.size() >= 1) {
|
||||
return routers;
|
||||
}
|
||||
|
||||
Long offeringId = _vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId();
|
||||
if (offeringId == null) {
|
||||
offeringId = _offering.getId();
|
||||
}
|
||||
//3) Deploy Virtual Router
|
||||
List<? extends PhysicalNetwork> pNtwks = _pNtwkDao.listByZone(vpc.getZoneId());
|
||||
|
||||
VirtualRouterProvider vpcVrProvider = null;
|
||||
|
||||
for (PhysicalNetwork pNtwk : pNtwks) {
|
||||
PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(pNtwk.getId(), Type.VPCVirtualRouter.toString());
|
||||
if (provider == null) {
|
||||
throw new CloudRuntimeException("Cannot find service provider " + Type.VPCVirtualRouter.toString() + " in physical network " + pNtwk.getId());
|
||||
}
|
||||
vpcVrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(), Type.VPCVirtualRouter);
|
||||
if (vpcVrProvider != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PublicIp sourceNatIp = _vpcMgr.assignSourceNatIpAddressToVpc(owner, vpc);
|
||||
|
||||
DomainRouterVO router = deployVpcRouter(owner, dest, plan, params, isRedundant, vpcVrProvider, offeringId, vpc.getId(), sourceNatIp);
|
||||
routers.add(router);
|
||||
|
||||
} finally {
|
||||
// TODO Should we do this after the pre or after the whole??
|
||||
if (vpcLock != null) {
|
||||
_vpcDao.releaseFromLockTable(vpc.getId());
|
||||
}
|
||||
}
|
||||
return routers;
|
||||
}
|
||||
|
||||
protected Pair<DeploymentPlan, List<DomainRouterVO>> getDeploymentPlanAndRouters(long vpcId, DeployDestination dest) {
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
DeploymentPlan plan = new DataCenterDeployment(dcId);
|
||||
List<DomainRouterVO> routers = getVpcRouters(vpcId);
|
||||
|
||||
return new Pair<DeploymentPlan, List<DomainRouterVO>>(plan, routers);
|
||||
}
|
||||
|
||||
|
||||
protected DomainRouterVO deployVpcRouter(Account owner, DeployDestination dest, DeploymentPlan plan, Map<Param, Object> params, boolean isRedundant,
|
||||
VirtualRouterProvider vrProvider, long svcOffId, Long vpcId, PublicIp sourceNatIp) throws ConcurrentOperationException, InsufficientAddressCapacityException,
|
||||
InsufficientServerCapacityException, InsufficientCapacityException, StorageUnavailableException, ResourceUnavailableException {
|
||||
|
||||
LinkedHashMap<Network, List<? extends NicProfile>> networks = createVpcRouterNetworks(owner, isRedundant, plan, new Pair<Boolean, PublicIp>(true, sourceNatIp),vpcId);
|
||||
|
||||
DomainRouterVO router =
|
||||
this.nwHelper.deployRouter(owner, dest, plan, params, isRedundant, vrProvider, svcOffId, vpcId, networks, true, _vpcMgr.getSupportedVpcHypervisors());
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
protected LinkedHashMap<Network, List<? extends NicProfile>> createVpcRouterNetworks(Account owner, boolean isRedundant, DeploymentPlan plan, Pair<Boolean, PublicIp> sourceNatIp,
|
||||
long vpcId) throws ConcurrentOperationException, InsufficientAddressCapacityException {
|
||||
|
||||
LinkedHashMap<Network, List<? extends NicProfile>> networks = new LinkedHashMap<Network, List<? extends NicProfile>>(4);
|
||||
|
||||
TreeSet<String> publicVlans = new TreeSet<String>();
|
||||
publicVlans.add(sourceNatIp.second().getVlanTag());
|
||||
|
||||
//1) allocate nic for control and source nat public ip
|
||||
networks = this.nwHelper.createRouterNetworks(owner, isRedundant, plan, null, sourceNatIp);
|
||||
|
||||
|
||||
//2) allocate nic for private gateways if needed
|
||||
List<PrivateGateway> privateGateways = _vpcMgr.getVpcPrivateGateways(vpcId);
|
||||
if (privateGateways != null && !privateGateways.isEmpty()) {
|
||||
for (PrivateGateway privateGateway : privateGateways) {
|
||||
NicProfile privateNic = createPrivateNicProfileForGateway(privateGateway);
|
||||
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
|
||||
networks.put(privateNetwork, new ArrayList<NicProfile>(Arrays.asList(privateNic)));
|
||||
}
|
||||
}
|
||||
|
||||
//3) allocate nic for guest gateway if needed
|
||||
List<? extends Network> guestNetworks = _vpcMgr.getVpcNetworks(vpcId);
|
||||
for (Network guestNetwork : guestNetworks) {
|
||||
if (_networkModel.isPrivateGateway(guestNetwork.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (guestNetwork.getState() == Network.State.Implemented || guestNetwork.getState() == Network.State.Setup) {
|
||||
NicProfile guestNic = createGuestNicProfileForVpcRouter(guestNetwork);
|
||||
networks.put(guestNetwork, new ArrayList<NicProfile>(Arrays.asList(guestNic)));
|
||||
}
|
||||
}
|
||||
|
||||
//4) allocate nic for additional public network(s)
|
||||
List<IPAddressVO> ips = _ipAddressDao.listByAssociatedVpc(vpcId, false);
|
||||
List<NicProfile> publicNics = new ArrayList<NicProfile>();
|
||||
Network publicNetwork = null;
|
||||
for (IPAddressVO ip : ips) {
|
||||
PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId()));
|
||||
if ((ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating) && _vpcMgr.isIpAllocatedToVpc(ip) &&
|
||||
!publicVlans.contains(publicIp.getVlanTag())) {
|
||||
s_logger.debug("Allocating nic for router in vlan " + publicIp.getVlanTag());
|
||||
NicProfile publicNic = new NicProfile();
|
||||
publicNic.setDefaultNic(false);
|
||||
publicNic.setIp4Address(publicIp.getAddress().addr());
|
||||
publicNic.setGateway(publicIp.getGateway());
|
||||
publicNic.setNetmask(publicIp.getNetmask());
|
||||
publicNic.setMacAddress(publicIp.getMacAddress());
|
||||
publicNic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
publicNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(publicIp.getVlanTag()));
|
||||
publicNic.setIsolationUri(IsolationType.Vlan.toUri(publicIp.getVlanTag()));
|
||||
NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
|
||||
if (publicNetwork == null) {
|
||||
List<? extends Network> publicNetworks = _networkMgr.setupNetwork(VirtualNwStatus.account,
|
||||
publicOffering, plan, null, null, false);
|
||||
publicNetwork = publicNetworks.get(0);
|
||||
}
|
||||
publicNics.add(publicNic);
|
||||
publicVlans.add(publicIp.getVlanTag());
|
||||
}
|
||||
}
|
||||
if (publicNetwork != null) {
|
||||
if (networks.get(publicNetwork) != null) {
|
||||
List<NicProfile> publicNicProfiles = (List<NicProfile>)networks.get(publicNetwork);
|
||||
publicNicProfiles.addAll(publicNics);
|
||||
networks.put(publicNetwork, publicNicProfiles);
|
||||
} else {
|
||||
networks.put(publicNetwork, publicNics);
|
||||
}
|
||||
}
|
||||
|
||||
return networks;
|
||||
}
|
||||
|
||||
protected NicProfile createGuestNicProfileForVpcRouter(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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> getVpcRouters(long vpcId) {
|
||||
return _routerDao.listByVpcId(vpcId);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -23,10 +23,9 @@ import java.util.Map;
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterTemplateCmd;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
@ -64,7 +63,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#sendSshKeysToHost(java.lang.Long, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean sendSshKeysToHost(Long hostId, String pubKey, String prvKey) {
|
||||
public boolean sendSshKeysToHost(final Long hostId, final String pubKey, final String prvKey) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@ -73,14 +72,14 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#savePasswordToRouter(com.cloud.network.Network, com.cloud.vm.NicProfile, com.cloud.vm.VirtualMachineProfile, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean savePasswordToRouter(Network network, NicProfile nic, VirtualMachineProfile profile, List<? extends VirtualRouter> routers)
|
||||
public boolean savePasswordToRouter(final Network network, final NicProfile nic, final VirtualMachineProfile profile, final List<? extends VirtualRouter> routers)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveSSHPublicKeyToRouter(Network network, NicProfile nic, VirtualMachineProfile profile, List<? extends VirtualRouter> routers, String sshPublicKey)
|
||||
public boolean saveSSHPublicKeyToRouter(final Network network, final NicProfile nic, final VirtualMachineProfile profile, final List<? extends VirtualRouter> routers, final String sshPublicKey)
|
||||
throws ResourceUnavailableException {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
@ -89,7 +88,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#saveUserDataToRouter(com.cloud.network.Network, com.cloud.vm.NicProfile, com.cloud.vm.VirtualMachineProfile, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean saveUserDataToRouter(Network network, NicProfile nic, VirtualMachineProfile profile, List<? extends VirtualRouter> routers)
|
||||
public boolean saveUserDataToRouter(final Network network, final NicProfile nic, final VirtualMachineProfile profile, final List<? extends VirtualRouter> routers)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
@ -99,8 +98,8 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#deployVirtualRouterInGuestNetwork(com.cloud.network.Network, com.cloud.deploy.DeployDestination, com.cloud.user.Account, java.util.Map, boolean)
|
||||
*/
|
||||
@Override
|
||||
public List<DomainRouterVO> deployVirtualRouterInGuestNetwork(Network guestNetwork, DeployDestination dest, Account owner, Map<Param, Object> params,
|
||||
boolean isRedundant) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
|
||||
public List<DomainRouterVO> deployVirtualRouterInGuestNetwork(final Network guestNetwork, final DeployDestination dest, final Account owner, final Map<Param, Object> params,
|
||||
final boolean isRedundant) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@ -109,7 +108,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#startRemoteAccessVpn(com.cloud.network.Network, com.cloud.network.RemoteAccessVpn, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean startRemoteAccessVpn(Network network, RemoteAccessVpn vpn, List<? extends VirtualRouter> routers) throws ResourceUnavailableException {
|
||||
public boolean startRemoteAccessVpn(final Network network, final RemoteAccessVpn vpn, final List<? extends VirtualRouter> routers) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@ -118,7 +117,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#deleteRemoteAccessVpn(com.cloud.network.Network, com.cloud.network.RemoteAccessVpn, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteRemoteAccessVpn(Network network, RemoteAccessVpn vpn, List<? extends VirtualRouter> routers) throws ResourceUnavailableException {
|
||||
public boolean deleteRemoteAccessVpn(final Network network, final RemoteAccessVpn vpn, final List<? extends VirtualRouter> routers) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@ -127,7 +126,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#associatePublicIP(com.cloud.network.Network, java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean associatePublicIP(Network network, List<? extends PublicIpAddress> ipAddress, List<? extends VirtualRouter> routers)
|
||||
public boolean associatePublicIP(final Network network, final List<? extends PublicIpAddress> ipAddress, final List<? extends VirtualRouter> routers)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
@ -137,7 +136,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#applyFirewallRules(com.cloud.network.Network, java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean applyFirewallRules(Network network, List<? extends FirewallRule> rules, List<? extends VirtualRouter> routers) throws ResourceUnavailableException {
|
||||
public boolean applyFirewallRules(final Network network, final List<? extends FirewallRule> rules, final List<? extends VirtualRouter> routers) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@ -146,7 +145,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#getRoutersForNetwork(long)
|
||||
*/
|
||||
@Override
|
||||
public List<VirtualRouter> getRoutersForNetwork(long networkId) {
|
||||
public List<VirtualRouter> getRoutersForNetwork(final long networkId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@ -155,7 +154,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#applyVpnUsers(com.cloud.network.Network, java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public String[] applyVpnUsers(Network network, List<? extends VpnUser> users, List<DomainRouterVO> routers) throws ResourceUnavailableException {
|
||||
public String[] applyVpnUsers(final Network network, final List<? extends VpnUser> users, final List<DomainRouterVO> routers) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@ -164,7 +163,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#stop(com.cloud.network.router.VirtualRouter, boolean, com.cloud.user.User, com.cloud.user.Account)
|
||||
*/
|
||||
@Override
|
||||
public VirtualRouter stop(VirtualRouter router, boolean forced, User callingUser, Account callingAccount) throws ConcurrentOperationException,
|
||||
public VirtualRouter stop(final VirtualRouter router, final boolean forced, final User callingUser, final Account callingAccount) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
@ -183,7 +182,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#applyStaticNats(com.cloud.network.Network, java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean applyStaticNats(Network network, List<? extends StaticNat> rules, List<? extends VirtualRouter> routers) throws ResourceUnavailableException {
|
||||
public boolean applyStaticNats(final Network network, final List<? extends StaticNat> rules, final List<? extends VirtualRouter> routers) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@ -192,7 +191,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#applyDhcpEntry(com.cloud.network.Network, com.cloud.vm.NicProfile, com.cloud.vm.VirtualMachineProfile, com.cloud.deploy.DeployDestination, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean applyDhcpEntry(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, List<DomainRouterVO> routers)
|
||||
public boolean applyDhcpEntry(final Network config, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final List<DomainRouterVO> routers)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
@ -202,20 +201,20 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VirtualNetworkApplianceManager#applyUserData(com.cloud.network.Network, com.cloud.vm.NicProfile, com.cloud.vm.VirtualMachineProfile, com.cloud.deploy.DeployDestination, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean applyUserData(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, List<DomainRouterVO> routers)
|
||||
public boolean applyUserData(final Network config, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final List<DomainRouterVO> routers)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configDhcpForSubnet(Network network, NicProfile nic, VirtualMachineProfile uservm, DeployDestination dest, List<DomainRouterVO> routers)
|
||||
public boolean configDhcpForSubnet(final Network network, final NicProfile nic, final VirtualMachineProfile uservm, final DeployDestination dest, final List<DomainRouterVO> routers)
|
||||
throws ResourceUnavailableException {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeDhcpSupportForSubnet(Network network, List<DomainRouterVO> routers) throws ResourceUnavailableException {
|
||||
public boolean removeDhcpSupportForSubnet(final Network network, final List<DomainRouterVO> routers) throws ResourceUnavailableException {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@ -223,7 +222,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.VirtualNetworkApplianceService#startRouter(long, boolean)
|
||||
*/
|
||||
@Override
|
||||
public VirtualRouter startRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
public VirtualRouter startRouter(final long routerId, final boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
@ -233,7 +232,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.VirtualNetworkApplianceService#rebootRouter(long, boolean)
|
||||
*/
|
||||
@Override
|
||||
public VirtualRouter rebootRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
public VirtualRouter rebootRouter(final long routerId, final boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException,
|
||||
InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
@ -243,7 +242,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.VirtualNetworkApplianceService#upgradeRouter(com.cloud.api.commands.UpgradeRouterCmd)
|
||||
*/
|
||||
@Override
|
||||
public VirtualRouter upgradeRouter(UpgradeRouterCmd cmd) {
|
||||
public VirtualRouter upgradeRouter(final UpgradeRouterCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@ -252,7 +251,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.VirtualNetworkApplianceService#stopRouter(long, boolean)
|
||||
*/
|
||||
@Override
|
||||
public VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
public VirtualRouter stopRouter(final long routerId, final boolean forced) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@ -261,7 +260,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.VirtualNetworkApplianceService#startRouter(long)
|
||||
*/
|
||||
@Override
|
||||
public VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
public VirtualRouter startRouter(final long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@ -270,7 +269,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.VirtualNetworkApplianceService#destroyRouter(long, com.cloud.user.Account, java.lang.Long)
|
||||
*/
|
||||
@Override
|
||||
public VirtualRouter destroyRouter(long routerId, Account caller, Long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
public VirtualRouter destroyRouter(final long routerId, final Account caller, final Long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@ -279,7 +278,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.utils.component.Manager#configure(java.lang.String, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -314,7 +313,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.VpcVirtualNetworkApplianceService#addVpcRouterToGuestNetwork(com.cloud.network.router.VirtualRouter, com.cloud.network.Network, boolean)
|
||||
*/
|
||||
@Override
|
||||
public boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant, Map<VirtualMachineProfile.Param, Object> params)
|
||||
public boolean addVpcRouterToGuestNetwork(final VirtualRouter router, final Network network, final boolean isRedundant, final Map<VirtualMachineProfile.Param, Object> params)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
@ -324,7 +323,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.VpcVirtualNetworkApplianceService#removeVpcRouterFromGuestNetwork(com.cloud.network.router.VirtualRouter, com.cloud.network.Network, boolean)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeVpcRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) throws ConcurrentOperationException,
|
||||
public boolean removeVpcRouterFromGuestNetwork(final VirtualRouter router, final Network network, final boolean isRedundant) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
@ -334,14 +333,14 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VpcVirtualNetworkApplianceManager#deployVirtualRouterInVpc(com.cloud.network.vpc.Vpc, com.cloud.deploy.DeployDestination, com.cloud.user.Account, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public List<DomainRouterVO> deployVirtualRouterInVpc(Vpc vpc, DeployDestination dest, Account owner, Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
public List<DomainRouterVO> deployVirtualRouterInVpc(final Vpc vpc, final DeployDestination dest, final Account owner, final Map<Param, Object> params) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyNetworkACLs(Network network, List<? extends NetworkACLItem> rules, List<? extends VirtualRouter> routers, boolean privateGateway)
|
||||
public boolean applyNetworkACLs(final Network network, final List<? extends NetworkACLItem> rules, final List<? extends VirtualRouter> routers, final boolean privateGateway)
|
||||
throws ResourceUnavailableException {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
@ -350,7 +349,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VpcVirtualNetworkApplianceManager#setupPrivateGateway(com.cloud.network.vpc.PrivateGateway, com.cloud.network.router.VirtualRouter)
|
||||
*/
|
||||
@Override
|
||||
public boolean setupPrivateGateway(PrivateGateway gateway, VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
public boolean setupPrivateGateway(final PrivateGateway gateway, final VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@ -359,7 +358,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VpcVirtualNetworkApplianceManager#destroyPrivateGateway(com.cloud.network.vpc.PrivateGateway, com.cloud.network.router.VirtualRouter)
|
||||
*/
|
||||
@Override
|
||||
public boolean destroyPrivateGateway(PrivateGateway gateway, VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
public boolean destroyPrivateGateway(final PrivateGateway gateway, final VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@ -368,7 +367,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VpcVirtualNetworkApplianceManager#applyStaticRoutes(java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public boolean applyStaticRoutes(List<StaticRouteProfile> routes, List<DomainRouterVO> routers) throws ResourceUnavailableException {
|
||||
public boolean applyStaticRoutes(final List<StaticRouteProfile> routes, final List<DomainRouterVO> routers) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@ -377,7 +376,7 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VpcVirtualNetworkApplianceManager#startSite2SiteVpn(com.cloud.network.Site2SiteVpnConnection, com.cloud.network.router.VirtualRouter)
|
||||
*/
|
||||
@Override
|
||||
public boolean startSite2SiteVpn(Site2SiteVpnConnection conn, VirtualRouter router) throws ResourceUnavailableException {
|
||||
public boolean startSite2SiteVpn(final Site2SiteVpnConnection conn, final VirtualRouter router) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@ -386,65 +385,74 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
||||
* @see com.cloud.network.router.VpcVirtualNetworkApplianceManager#stopSite2SiteVpn(com.cloud.network.Site2SiteVpnConnection, com.cloud.network.router.VirtualRouter)
|
||||
*/
|
||||
@Override
|
||||
public boolean stopSite2SiteVpn(Site2SiteVpnConnection conn, VirtualRouter router) throws ResourceUnavailableException {
|
||||
public boolean stopSite2SiteVpn(final Site2SiteVpnConnection conn, final VirtualRouter router) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> getVpcRouters(long vpcId) {
|
||||
public List<DomainRouterVO> getVpcRouters(final long vpcId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyLoadBalancingRules(Network network, List<? extends LoadBalancingRule> rules, List<? extends VirtualRouter> routers)
|
||||
public boolean applyLoadBalancingRules(final Network network, final List<? extends LoadBalancingRule> rules, final List<? extends VirtualRouter> routers)
|
||||
throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualRouter findRouter(long routerId) {
|
||||
public VirtualRouter findRouter(final long routerId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> upgradeRouterTemplate(UpgradeRouterTemplateCmd cmd) {
|
||||
public List<Long> upgradeRouterTemplate(final UpgradeRouterTemplateCmd cmd) {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setupDhcpForPvlan(boolean add, DomainRouterVO router, Long hostId, NicProfile nic) {
|
||||
public boolean setupDhcpForPvlan(final boolean add, final DomainRouterVO router, final Long hostId, final NicProfile nic) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepareAggregatedExecution(Network network, List<DomainRouterVO> routers) throws AgentUnavailableException {
|
||||
public boolean prepareAggregatedExecution(final Network network, final List<DomainRouterVO> routers) throws AgentUnavailableException {
|
||||
return true; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean completeAggregatedExecution(Network network, List<DomainRouterVO> routers) throws AgentUnavailableException {
|
||||
public boolean completeAggregatedExecution(final Network network, final List<DomainRouterVO> routers) throws AgentUnavailableException {
|
||||
return true; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startRemoteAccessVpn(RemoteAccessVpn vpn, VirtualRouter router) throws ResourceUnavailableException {
|
||||
public boolean startRemoteAccessVpn(final RemoteAccessVpn vpn, final VirtualRouter router) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopRemoteAccessVpn(RemoteAccessVpn vpn, VirtualRouter router) throws ResourceUnavailableException {
|
||||
public boolean stopRemoteAccessVpn(final RemoteAccessVpn vpn, final VirtualRouter router) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] applyVpnUsers(RemoteAccessVpn vpn, List<? extends VpnUser> users, VirtualRouter router) throws ResourceUnavailableException {
|
||||
public String[] applyVpnUsers(final RemoteAccessVpn vpn, final List<? extends VpnUser> users, final VirtualRouter router) throws ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> deployVirtualRouterInVpc(final Vpc vpc,
|
||||
final DeployDestination dest, final Account owner, final Map<Param, Object> params,
|
||||
final boolean isRedundant) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user