mirror of https://github.com/apache/cloudstack.git
adding setupPrivateGateway to new style;
removing methods from Vpc appliance; changing the way VpcElement calls the command; there is still work tob e done with the destroyPrivateGateway rule. Conflicts: server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
This commit is contained in:
parent
5489130ef5
commit
07be4945df
|
|
@ -384,8 +384,11 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
|
|||
}
|
||||
|
||||
VirtualRouter router = routers.get(0);
|
||||
|
||||
DataCenterVO dcVO = _dcDao.findById(gateway.getZoneId());
|
||||
NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
|
||||
|
||||
if (_vpcRouterMgr.setupPrivateGateway(gateway, router)) {
|
||||
if (networkTopology.setupPrivateGateway(gateway, router)) {
|
||||
try {
|
||||
List<NetworkACLItemVO> rules = _networkACLItemDao.listByACL(gateway.getNetworkACLId());
|
||||
if (!applyACLItemsToPrivateGw(gateway, rules)) {
|
||||
|
|
|
|||
|
|
@ -30,15 +30,6 @@ import com.cloud.vm.DomainRouterVO;
|
|||
|
||||
public interface VpcVirtualNetworkApplianceManager extends VirtualNetworkApplianceManager, VpcVirtualNetworkApplianceService {
|
||||
|
||||
/**
|
||||
* @param gateway
|
||||
* @param router TODO
|
||||
* @return
|
||||
* @throws ResourceUnavailableException
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
boolean setupPrivateGateway(PrivateGateway gateway, VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
/**
|
||||
* @param gateway
|
||||
* @param router
|
||||
|
|
|
|||
|
|
@ -649,42 +649,6 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
return _nwHelper.sendCommandsToRouter(router, cmds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setupPrivateGateway(final PrivateGateway gateway, final VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
boolean result = true;
|
||||
try {
|
||||
Network network = _networkModel.getNetwork(gateway.getNetworkId());
|
||||
NicProfile requested = vpcHelper.createPrivateNicProfileForGateway(gateway);
|
||||
|
||||
if (!_nwHelper.checkRouterVersion(router)) {
|
||||
s_logger.warn("Router requires upgrade. Unable to send command to router: " + router.getId());
|
||||
return false;
|
||||
}
|
||||
NicProfile guestNic = _itMgr.addVmToNetwork(router, network, requested);
|
||||
|
||||
//setup source nat
|
||||
if (guestNic != null) {
|
||||
result = setupVpcPrivateNetwork(router, true, guestNic);
|
||||
} else {
|
||||
s_logger.warn("Failed to setup gateway " + gateway + " on router " + router + " with the source nat");
|
||||
result = false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Failed to create private gateway " + gateway + " on router " + router + " due to ", ex);
|
||||
result = false;
|
||||
} finally {
|
||||
if (!result) {
|
||||
s_logger.debug("Removing gateway " + gateway + " from router " + router + " as a part of cleanup");
|
||||
if (destroyPrivateGateway(gateway, router)) {
|
||||
s_logger.debug("Removed the gateway " + gateway + " from router " + router + " as a part of cleanup");
|
||||
} else {
|
||||
s_logger.warn("Failed to remove the gateway " + gateway + " from router " + router + " as a part of cleanup");
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param router
|
||||
* @param add
|
||||
|
|
|
|||
|
|
@ -17,32 +17,172 @@
|
|||
|
||||
package com.cloud.network.rules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.routing.IpAssocVpcCommand;
|
||||
import com.cloud.agent.api.routing.NetworkElementCommand;
|
||||
import com.cloud.agent.api.to.IpAddressTO;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.vpc.NetworkACLItem;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.PrivateIpAddress;
|
||||
import com.cloud.network.vpc.PrivateIpVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
||||
public class PrivateGatewayRules extends RuleApplier {
|
||||
|
||||
private final List<? extends NetworkACLItem> rules;
|
||||
private static final Logger s_logger = Logger.getLogger(PrivateGatewayRules.class);
|
||||
|
||||
private final PrivateGateway _privateGateway;
|
||||
|
||||
private boolean _isAddOperation;
|
||||
private NicProfile _nicProfile;
|
||||
|
||||
public PrivateGatewayRules(final Network network, final List<? extends NetworkACLItem> rules) {
|
||||
super(network);
|
||||
this.rules = rules;
|
||||
public PrivateGatewayRules(final PrivateGateway privateGateway) {
|
||||
super(null);
|
||||
this._privateGateway = privateGateway;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
|
||||
this._router = router;
|
||||
|
||||
return visitor.visit(this);
|
||||
boolean result = false;
|
||||
try {
|
||||
_network = _networkModel.getNetwork(_privateGateway.getNetworkId());
|
||||
NicProfile requested = _vpcNetworkHelper.createPrivateNicProfileForGateway(_privateGateway);
|
||||
|
||||
if (!_networkHelper.checkRouterVersion(router)) {
|
||||
s_logger.warn("Router requires upgrade. Unable to send command to router: " + router.getId());
|
||||
return false;
|
||||
}
|
||||
_nicProfile = _itMgr.addVmToNetwork(router, _network, requested);
|
||||
|
||||
//setup source nat
|
||||
if (_nicProfile != null) {
|
||||
_isAddOperation = true;
|
||||
//result = setupVpcPrivateNetwork(router, true, guestNic);
|
||||
result = visitor.visit(this);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Failed to create private gateway " + _privateGateway + " on router " + router + " due to ", ex);
|
||||
} finally {
|
||||
if (!result) {
|
||||
s_logger.debug("Failed to setup gateway " + _privateGateway + " on router " + router + " with the source nat. Will now remove the gateway.");
|
||||
_isAddOperation = false;
|
||||
boolean isRemoved = destroyPrivateGateway(visitor);
|
||||
|
||||
if (isRemoved) {
|
||||
s_logger.debug("Removed the gateway " + _privateGateway + " from router " + router + " as a part of cleanup");
|
||||
} else {
|
||||
s_logger.warn("Failed to remove the gateway " + _privateGateway + " from router " + router + " as a part of cleanup");
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isAddOperation() {
|
||||
return _isAddOperation;
|
||||
}
|
||||
|
||||
public NicProfile getNicProfile() {
|
||||
return _nicProfile;
|
||||
}
|
||||
|
||||
public PrivateIpVO retrivePrivateIP() {
|
||||
PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(_nicProfile.getNetworkId(), _nicProfile.getIp4Address());
|
||||
return ipVO;
|
||||
}
|
||||
|
||||
public Network retrievePrivateNetwork() {
|
||||
// This network might be the same we have already as an instance in the RuleApplier super class.
|
||||
// Just doing this here, but will double check is remove if it's not needed.
|
||||
Network network = _networkDao.findById(_nicProfile.getNetworkId());
|
||||
return network;
|
||||
}
|
||||
|
||||
public List<? extends NetworkACLItem> getRules() {
|
||||
return rules;
|
||||
protected boolean destroyPrivateGateway(final NetworkTopologyVisitor visitor) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
if (!_networkModel.isVmPartOfNetwork(_router.getId(), _privateGateway.getNetworkId())) {
|
||||
s_logger.debug("Router doesn't have nic for gateway " + _privateGateway + " so no need to removed it");
|
||||
return true;
|
||||
}
|
||||
|
||||
Network privateNetwork = _networkModel.getNetwork(_privateGateway.getNetworkId());
|
||||
|
||||
s_logger.debug("Releasing private ip for gateway " + _privateGateway + " from " + _router);
|
||||
|
||||
_nicProfile = _networkModel.getNicProfile(_router, privateNetwork.getId(), null);
|
||||
boolean result = visitor.visit(this);
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to release private ip for gateway " + _privateGateway + " on router " + _router);
|
||||
return false;
|
||||
}
|
||||
|
||||
//revoke network acl on the private gateway.
|
||||
if (!_networkACLMgr.revokeACLItemsForPrivateGw(_privateGateway)) {
|
||||
s_logger.debug("Failed to delete network acl items on " + _privateGateway + " from router " + _router);
|
||||
return false;
|
||||
}
|
||||
|
||||
s_logger.debug("Removing router " + _router + " from private network " + privateNetwork + " as a part of delete private gateway");
|
||||
result = result && _itMgr.removeVmFromNetwork(_router, privateNetwork, null);
|
||||
s_logger.debug("Private gateawy " + _privateGateway + " is removed from router " + _router);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void createVpcAssociatePrivateIPCommands(final VirtualRouter router, final List<PrivateIpAddress> ips, final Commands cmds, final boolean add) {
|
||||
|
||||
// Ensure that in multiple vlans case we first send all ip addresses of vlan1, then all ip addresses of vlan2, etc..
|
||||
Map<String, ArrayList<PrivateIpAddress>> vlanIpMap = new HashMap<String, ArrayList<PrivateIpAddress>>();
|
||||
for (final PrivateIpAddress ipAddress : ips) {
|
||||
String vlanTag = ipAddress.getBroadcastUri();
|
||||
ArrayList<PrivateIpAddress> ipList = vlanIpMap.get(vlanTag);
|
||||
if (ipList == null) {
|
||||
ipList = new ArrayList<PrivateIpAddress>();
|
||||
}
|
||||
|
||||
ipList.add(ipAddress);
|
||||
vlanIpMap.put(vlanTag, ipList);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, ArrayList<PrivateIpAddress>> vlanAndIp : vlanIpMap.entrySet()) {
|
||||
List<PrivateIpAddress> ipAddrList = vlanAndIp.getValue();
|
||||
IpAddressTO[] ipsToSend = new IpAddressTO[ipAddrList.size()];
|
||||
int i = 0;
|
||||
|
||||
for (final PrivateIpAddress ipAddr : ipAddrList) {
|
||||
Network network = _networkModel.getNetwork(ipAddr.getNetworkId());
|
||||
IpAddressTO ip =
|
||||
new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(), add, false, ipAddr.getSourceNat(), ipAddr.getBroadcastUri(), ipAddr.getGateway(),
|
||||
ipAddr.getNetmask(), ipAddr.getMacAddress(), null, false);
|
||||
|
||||
ip.setTrafficType(network.getTrafficType());
|
||||
ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
|
||||
ipsToSend[i++] = ip;
|
||||
|
||||
}
|
||||
|
||||
IpAssocVpcCommand cmd = new IpAssocVpcCommand(ipsToSend);
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(ipAddrList.get(0).getNetworkId(), router.getId()));
|
||||
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
|
||||
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
|
||||
|
||||
cmds.addCommand("IPAssocVpcCommand", cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,10 @@ import com.cloud.network.lb.LoadBalancingRulesManager;
|
|||
import com.cloud.network.router.NetworkHelper;
|
||||
import com.cloud.network.router.RouterControlHelper;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.router.VpcNetworkHelper;
|
||||
import com.cloud.network.vpc.NetworkACLManager;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpc.dao.PrivateIpDao;
|
||||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
|
|
@ -95,12 +98,16 @@ public abstract class RuleApplier {
|
|||
|
||||
protected IPAddressDao _ipAddressDao;
|
||||
|
||||
protected PrivateIpDao _privateIpDao;
|
||||
|
||||
protected VpcManager _vpcMgr;
|
||||
|
||||
protected VirtualMachineManager _itMgr;
|
||||
|
||||
protected IpAddressManager _ipAddrMgr;
|
||||
|
||||
protected NetworkACLManager _networkACLMgr;
|
||||
|
||||
protected Network _network;
|
||||
|
||||
protected VirtualRouter _router;
|
||||
|
|
@ -109,6 +116,8 @@ public abstract class RuleApplier {
|
|||
|
||||
protected NetworkHelper _networkHelper;
|
||||
|
||||
protected VpcNetworkHelper _vpcNetworkHelper;
|
||||
|
||||
public RuleApplier(final Network network) {
|
||||
_network = network;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import com.cloud.network.IpAddressManager;
|
|||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
|
|
@ -41,8 +42,11 @@ import com.cloud.network.router.NetworkHelper;
|
|||
import com.cloud.network.router.RouterControlHelper;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.vpc.NetworkACLItem;
|
||||
import com.cloud.network.vpc.NetworkACLManager;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.StaticRouteProfile;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.network.vpc.dao.PrivateIpDao;
|
||||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
|
|
@ -121,6 +125,9 @@ public class VirtualNetworkApplianceFactory {
|
|||
@Inject
|
||||
protected IPAddressDao _ipAddressDao;
|
||||
|
||||
@Inject
|
||||
protected PrivateIpDao _privateIpDao;
|
||||
|
||||
@Inject
|
||||
protected RouterControlHelper _routerControlHelper;
|
||||
|
||||
|
|
@ -130,9 +137,15 @@ public class VirtualNetworkApplianceFactory {
|
|||
@Inject
|
||||
protected IpAddressManager _ipAddrMgr;
|
||||
|
||||
@Inject
|
||||
protected NetworkACLManager _networkACLMgr;
|
||||
|
||||
@Inject
|
||||
protected NetworkHelper _networkHelper;
|
||||
|
||||
@Inject
|
||||
protected VpcNetworkHelper _vpcNetworkHelper;
|
||||
|
||||
public LoadBalancingRules createLoadBalancingRules(final Network network, final List<LoadBalancingRule> rules) {
|
||||
LoadBalancingRules lbRules = new LoadBalancingRules(network, rules);
|
||||
|
||||
|
|
@ -305,11 +318,31 @@ public class VirtualNetworkApplianceFactory {
|
|||
return pvlanRules;
|
||||
}
|
||||
|
||||
public StaticRoutesRules createStaticRoutesRules(List<StaticRouteProfile> staticRoutes) {
|
||||
StaticRoutesRules routesRules = new StaticRoutesRules(staticRoutes);
|
||||
|
||||
initBeans(routesRules);
|
||||
|
||||
return routesRules;
|
||||
}
|
||||
public StaticRoutesRules createStaticRoutesRules(final List<StaticRouteProfile> staticRoutes) {
|
||||
StaticRoutesRules routesRules = new StaticRoutesRules(staticRoutes);
|
||||
|
||||
initBeans(routesRules);
|
||||
|
||||
return routesRules;
|
||||
}
|
||||
|
||||
public AdvancedVpnRules createAdvancedVpnRules(final RemoteAccessVpn remoteAccessVpn, final List<? extends VpnUser> users) {
|
||||
AdvancedVpnRules vpnRules = new AdvancedVpnRules(remoteAccessVpn, users);
|
||||
|
||||
initBeans(vpnRules);
|
||||
|
||||
return vpnRules;
|
||||
}
|
||||
|
||||
public PrivateGatewayRules createPrivateGatewayRules(final PrivateGateway gateway) {
|
||||
PrivateGatewayRules gwRules = new PrivateGatewayRules(gateway);
|
||||
|
||||
initBeans(gwRules);
|
||||
|
||||
gwRules._privateIpDao = _privateIpDao;
|
||||
gwRules._networkACLMgr = _networkACLMgr;
|
||||
gwRules._vpcNetworkHelper = _vpcNetworkHelper;
|
||||
|
||||
return gwRules;
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ import com.cloud.dc.DataCenter.NetworkType;
|
|||
import com.cloud.dc.Pod;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.network.Network;
|
||||
|
|
@ -39,12 +40,14 @@ import com.cloud.network.rules.DhcpEntryRules;
|
|||
import com.cloud.network.rules.DhcpSubNetRules;
|
||||
import com.cloud.network.rules.NetworkAclsRules;
|
||||
import com.cloud.network.rules.NicPlugInOutRules;
|
||||
import com.cloud.network.rules.PrivateGatewayRules;
|
||||
import com.cloud.network.rules.RuleApplier;
|
||||
import com.cloud.network.rules.RuleApplierWrapper;
|
||||
import com.cloud.network.rules.StaticRoutesRules;
|
||||
import com.cloud.network.rules.UserdataPwdRules;
|
||||
import com.cloud.network.rules.VpcIpAssociationRules;
|
||||
import com.cloud.network.vpc.NetworkACLItem;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.StaticRouteProfile;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
|
@ -117,6 +120,15 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
|
|||
|
||||
return subNetRules.accept(_advancedVisitor, router);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setupPrivateGateway(PrivateGateway gateway, VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
s_logger.debug("SETUP PRIVATE GATEWAY RULES");
|
||||
|
||||
PrivateGatewayRules routesRules = _virtualNetworkApplianceFactory.createPrivateGatewayRules(gateway);
|
||||
|
||||
return routesRules.accept(_advancedVisitor, router);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyUserData(final Network network, final NicProfile nic, final VirtualMachineProfile profile, final DeployDestination dest, final List<DomainRouterVO> routers)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.cloud.agent.api.Command;
|
|||
import com.cloud.agent.api.PvlanSetupCommand;
|
||||
import com.cloud.agent.api.routing.IpAliasTO;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
|
|
@ -41,9 +42,14 @@ import com.cloud.network.rules.StaticRoutesRules;
|
|||
import com.cloud.network.rules.UserdataPwdRules;
|
||||
import com.cloud.network.rules.VpcIpAssociationRules;
|
||||
import com.cloud.network.vpc.NetworkACLItem;
|
||||
import com.cloud.network.vpc.PrivateIpAddress;
|
||||
import com.cloud.network.vpc.PrivateIpVO;
|
||||
import com.cloud.network.vpc.StaticRouteProfile;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.NicIpAliasVO;
|
||||
|
||||
|
|
@ -123,7 +129,46 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
|
|||
|
||||
@Override
|
||||
public boolean visit(final PrivateGatewayRules privateGW) throws ResourceUnavailableException {
|
||||
return false;
|
||||
final VirtualRouter router = privateGW.getRouter();
|
||||
final NicProfile nicProfile = privateGW.getNicProfile();
|
||||
|
||||
final boolean isAddOperation = privateGW.isAddOperation();
|
||||
|
||||
if (router.getState() == State.Running) {
|
||||
|
||||
PrivateIpVO ipVO = privateGW.retrivePrivateIP();
|
||||
Network network = privateGW.retrievePrivateNetwork();
|
||||
|
||||
String netmask = NetUtils.getCidrNetmask(network.getCidr());
|
||||
PrivateIpAddress ip = new PrivateIpAddress(ipVO, network.getBroadcastUri().toString(), network.getGateway(), netmask, nicProfile.getMacAddress());
|
||||
|
||||
List<PrivateIpAddress> privateIps = new ArrayList<PrivateIpAddress>(1);
|
||||
privateIps.add(ip);
|
||||
|
||||
Commands cmds = new Commands(Command.OnError.Stop);
|
||||
privateGW.createVpcAssociatePrivateIPCommands(router, privateIps, cmds, isAddOperation);
|
||||
|
||||
try{
|
||||
if (_networkGeneralHelper.sendCommandsToRouter(router, cmds)) {
|
||||
s_logger.debug("Successfully applied ip association for ip " + ip + " in vpc network " + network);
|
||||
return true;
|
||||
} else {
|
||||
s_logger.warn("Failed to associate ip address " + ip + " in vpc network " + network);
|
||||
return false;
|
||||
}
|
||||
}catch (Exception ex) {
|
||||
s_logger.warn("Failed to send " + (isAddOperation ?"add ":"delete ") + " private network " + network + " commands to rotuer ");
|
||||
return false;
|
||||
}
|
||||
} else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
|
||||
s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + ", so not sending setup private network command to the backend");
|
||||
} else {
|
||||
s_logger.warn("Unable to setup private gateway, virtual router " + router + " is not in the right state " + router.getState());
|
||||
|
||||
throw new ResourceUnavailableException("Unable to setup Private gateway on the backend," + " virtual router " + router + " is not in the right state",
|
||||
DataCenter.class, router.getDataCenterId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -33,12 +33,14 @@ import com.cloud.dc.Pod;
|
|||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.router.NetworkHelper;
|
||||
|
|
@ -59,6 +61,7 @@ import com.cloud.network.rules.UserdataToRouterRules;
|
|||
import com.cloud.network.rules.VirtualNetworkApplianceFactory;
|
||||
import com.cloud.network.rules.VpnRules;
|
||||
import com.cloud.network.vpc.NetworkACLItem;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.StaticRouteProfile;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
|
|
@ -104,8 +107,13 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
}
|
||||
|
||||
@Override
|
||||
public NicProfile retrieveControlNic(final VirtualMachineProfile profile) {
|
||||
return null;
|
||||
public boolean setupPrivateGateway(final PrivateGateway gateway, final VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
throw new CloudRuntimeException("setupPrivateGateway not implemented in Basic Network Topology.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] applyVpnUsers(final RemoteAccessVpn vpn, final List<? extends VpnUser> users, final VirtualRouter router) throws ResourceUnavailableException {
|
||||
throw new CloudRuntimeException("applyVpnUsers not implemented in Basic Network Topology.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -410,7 +418,8 @@ public class BasicNetworkTopology implements NetworkTopology {
|
|||
|
||||
if (!connectedRouters.isEmpty()) {
|
||||
if (!isZoneBasic && !disconnectedRouters.isEmpty() && disconnectedRouters.get(0).getIsRedundantRouter()) {
|
||||
// These disconnected redundant virtual routers are out of sync now, stop them for synchronization
|
||||
// These disconnected redundant virtual routers are out of sync
|
||||
// now, stop them for synchronization
|
||||
_nwHelper.handleSingleWorkingRedundantRouter(connectedRouters, disconnectedRouters, msg);
|
||||
}
|
||||
} else if (!disconnectedRouters.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
|
|
@ -32,6 +33,7 @@ import com.cloud.network.rules.RuleApplier;
|
|||
import com.cloud.network.rules.RuleApplierWrapper;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.network.vpc.NetworkACLItem;
|
||||
import com.cloud.network.vpc.PrivateGateway;
|
||||
import com.cloud.network.vpc.StaticRouteProfile;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
|
@ -39,6 +41,7 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
|
||||
public interface NetworkTopology {
|
||||
|
||||
<<<<<<< HEAD
|
||||
StringBuilder createGuestBootLoadArgs(final NicProfile guestNic, final String defaultDns1, final String defaultDns2, DomainRouterVO router);
|
||||
|
||||
String retrieveGuestDhcpRange(final NicProfile guestNic, final Network guestNetwork, final DataCenter dc);
|
||||
|
|
@ -47,6 +50,9 @@ public interface NetworkTopology {
|
|||
|
||||
|
||||
// ====== USER FOR VPC ONLY ====== //
|
||||
=======
|
||||
// ====== USED FOR VPC ONLY ====== //
|
||||
>>>>>>> 0b8b22f... adding setupPrivateGateway to new style;
|
||||
|
||||
boolean setupDhcpForPvlan(final boolean add, final DomainRouterVO router, final Long hostId, final NicProfile nic) throws ResourceUnavailableException;
|
||||
|
||||
|
|
@ -57,8 +63,15 @@ public interface NetworkTopology {
|
|||
throws ResourceUnavailableException;
|
||||
|
||||
boolean applyStaticRoutes(final List<StaticRouteProfile> staticRoutes, final List<DomainRouterVO> routers) throws ResourceUnavailableException;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
boolean setupPrivateGateway(final PrivateGateway gateway, final VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
String[] applyVpnUsers(final RemoteAccessVpn vpn, final List<? extends VpnUser> users, final VirtualRouter router) throws ResourceUnavailableException;
|
||||
>>>>>>> 0b8b22f... adding setupPrivateGateway to new style;
|
||||
|
||||
// ====== USER FOR GUEST NETWORK AND VCP ====== //
|
||||
// ====== USED FOR GUEST NETWORK AND VCP ====== //
|
||||
|
||||
boolean applyDhcpEntry(final Network network, final NicProfile nic, final VirtualMachineProfile profile, final DeployDestination dest, final List<DomainRouterVO> routers)
|
||||
throws ResourceUnavailableException;
|
||||
|
|
|
|||
|
|
@ -208,15 +208,6 @@ public class MockVpcVirtualNetworkApplianceManager extends ManagerBase implement
|
|||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.router.VpcVirtualNetworkApplianceManager#setupPrivateGateway(com.cloud.network.vpc.PrivateGateway, com.cloud.network.router.VirtualRouter)
|
||||
*/
|
||||
@Override
|
||||
public boolean setupPrivateGateway(final PrivateGateway gateway, final VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.cloud.network.router.VpcVirtualNetworkApplianceManager#destroyPrivateGateway(com.cloud.network.vpc.PrivateGateway, com.cloud.network.router.VirtualRouter)
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue