mirror of https://github.com/apache/cloudstack.git
Modified virtual router startup procedure - initial start happens with control nic only; then we plug Public and then Guest nic to it
This commit is contained in:
parent
460bab4a7d
commit
3ae5b0b5c8
|
|
@ -26,6 +26,7 @@ import com.cloud.api.response.VirtualRouterProviderResponse;
|
|||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.network.element.VirtualRouterElementService;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
|
@ -92,7 +93,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VirtualRouterProvider result = _service.addElement(getNspId());
|
||||
VirtualRouterProvider result = _service.addElement(getNspId(), VirtualRouterProviderType.VirtualRouter);
|
||||
if (result != null) {
|
||||
setEntityId(result.getId());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ public interface VirtualNetworkApplianceService {
|
|||
* @throws ResourceUnavailableException
|
||||
* @throws InsufficientCapacityException
|
||||
*/
|
||||
boolean addRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
boolean addRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
|
||||
/**
|
||||
* @param router
|
||||
|
|
@ -77,5 +78,6 @@ public interface VirtualNetworkApplianceService {
|
|||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
boolean removeRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
boolean removeRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@ import java.util.List;
|
|||
import com.cloud.api.commands.ConfigureVirtualRouterElementCmd;
|
||||
import com.cloud.api.commands.ListVirtualRouterElementsCmd;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
public interface VirtualRouterElementService extends PluggableService{
|
||||
VirtualRouterProvider configure(ConfigureVirtualRouterElementCmd cmd);
|
||||
VirtualRouterProvider addElement(Long nspId);
|
||||
VirtualRouterProvider addElement(Long nspId, VirtualRouterProviderType providerType);
|
||||
VirtualRouterProvider getCreatedElement(long id);
|
||||
List<? extends VirtualRouterProvider> searchForVirtualRouterElement(ListVirtualRouterElementsCmd cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,8 @@ import com.cloud.agent.api.PingCommand;
|
|||
import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
|
||||
import com.cloud.agent.api.PingRoutingWithOvsCommand;
|
||||
import com.cloud.agent.api.PingTestCommand;
|
||||
import com.cloud.agent.api.PlugNicAnswer;
|
||||
import com.cloud.agent.api.PlugNicCommand;
|
||||
import com.cloud.agent.api.PoolEjectCommand;
|
||||
import com.cloud.agent.api.PrepareForMigrationAnswer;
|
||||
import com.cloud.agent.api.PrepareForMigrationCommand;
|
||||
|
|
@ -115,6 +117,8 @@ import com.cloud.agent.api.SecurityGroupRuleAnswer;
|
|||
import com.cloud.agent.api.SecurityGroupRulesCmd;
|
||||
import com.cloud.agent.api.SetupAnswer;
|
||||
import com.cloud.agent.api.SetupCommand;
|
||||
import com.cloud.agent.api.SetupGuestNetworkAnswer;
|
||||
import com.cloud.agent.api.SetupGuestNetworkCommand;
|
||||
import com.cloud.agent.api.StartAnswer;
|
||||
import com.cloud.agent.api.StartCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
|
|
@ -123,6 +127,8 @@ import com.cloud.agent.api.StartupStorageCommand;
|
|||
import com.cloud.agent.api.StopAnswer;
|
||||
import com.cloud.agent.api.StopCommand;
|
||||
import com.cloud.agent.api.StoragePoolInfo;
|
||||
import com.cloud.agent.api.UnPlugNicAnswer;
|
||||
import com.cloud.agent.api.UnPlugNicCommand;
|
||||
import com.cloud.agent.api.UpdateHostPasswordCommand;
|
||||
import com.cloud.agent.api.UpgradeSnapshotCommand;
|
||||
import com.cloud.agent.api.VmStatsEntry;
|
||||
|
|
@ -512,12 +518,17 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return execute((GetDomRVersionCmd)cmd);
|
||||
} else if (clazz == CheckNetworkCommand.class) {
|
||||
return execute((CheckNetworkCommand) cmd);
|
||||
} else {
|
||||
} else if (clazz == SetupGuestNetworkCommand.class) {
|
||||
return execute((SetupGuestNetworkCommand) cmd);
|
||||
} else if (clazz == PlugNicCommand.class) {
|
||||
return execute((PlugNicCommand) cmd);
|
||||
} else if (clazz == UnPlugNicCommand.class) {
|
||||
return execute((UnPlugNicCommand) cmd);
|
||||
}else {
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected XsLocalNetwork getNativeNetworkForTraffic(Connection conn, TrafficType type, String name) throws XenAPIException, XmlRpcException {
|
||||
if (name != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
@ -6944,7 +6955,32 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cmd
|
||||
* @return
|
||||
*/
|
||||
private UnPlugNicAnswer execute(UnPlugNicCommand cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cmd
|
||||
* @return
|
||||
*/
|
||||
private PlugNicAnswer execute(PlugNicCommand cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cmd
|
||||
* @return
|
||||
*/
|
||||
private SetupGuestNetworkAnswer execute(SetupGuestNetworkCommand cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ import com.cloud.user.Account;
|
|||
import com.cloud.utils.Pair;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ import com.cloud.network.Networks.BroadcastDomainType;
|
|||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork.BroadcastDomainRange;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
|
|
@ -6437,7 +6438,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (element == null) {
|
||||
throw new CloudRuntimeException("Unable to find the Network Element implementing the VirtualRouter Provider");
|
||||
}
|
||||
element.addElement(nsp.getId());
|
||||
element.addElement(nsp.getId(), VirtualRouterProviderType.VirtualRouter);
|
||||
|
||||
return nsp;
|
||||
}
|
||||
|
|
@ -6451,7 +6452,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (element == null) {
|
||||
throw new CloudRuntimeException("Unable to find the Network Element implementing the VPCVirtualRouter Provider");
|
||||
}
|
||||
element.addElement(nsp.getId());
|
||||
element.addElement(nsp.getId(), VirtualRouterProviderType.VPCVirtualRouter);
|
||||
|
||||
return nsp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -696,13 +696,13 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
}
|
||||
|
||||
@Override
|
||||
public VirtualRouterProvider addElement(Long nspId) {
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(nspId, VirtualRouterProviderType.VirtualRouter);
|
||||
public VirtualRouterProvider addElement(Long nspId, VirtualRouterProviderType providerType) {
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(nspId, providerType);
|
||||
if (element != null) {
|
||||
s_logger.debug("There is already a virtual router element with service provider id " + nspId);
|
||||
return null;
|
||||
}
|
||||
element = new VirtualRouterProviderVO(nspId, VirtualRouterProviderType.VirtualRouter);
|
||||
element = new VirtualRouterProviderVO(nspId, providerType);
|
||||
_vrProviderDao.persist(element);
|
||||
return element;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ import com.cloud.agent.api.UnPlugNicCommand;
|
|||
import com.cloud.agent.api.check.CheckSshAnswer;
|
||||
import com.cloud.agent.api.check.CheckSshCommand;
|
||||
import com.cloud.agent.api.routing.DhcpEntryCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocAnswer;
|
||||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.NetworkElementCommand;
|
||||
|
|
@ -200,7 +201,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
import com.cloud.utils.net.MacAddress;
|
||||
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.ReservationContext;
|
||||
|
|
@ -1259,11 +1259,15 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
|
||||
//3) Deploy Virtual Router(s)
|
||||
PublicIp sourceNatIp = null;
|
||||
if (publicNetwork) {
|
||||
sourceNatIp = _networkMgr.assignSourceNatIpAddressToGuestNetwork(owner, guestNetwork);
|
||||
}
|
||||
try {
|
||||
int count = routerCount - routers.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
DomainRouterVO router = deployRouter(owner, dest, plan, params, isRedundant, vrProvider, offeringId,
|
||||
null);
|
||||
null, sourceNatIp);
|
||||
routers.add(router);
|
||||
}
|
||||
} finally {
|
||||
|
|
@ -1276,7 +1280,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
protected DomainRouterVO deployRouter(Account owner, DeployDestination dest, DeploymentPlan plan, Map<Param, Object> params,
|
||||
boolean isRedundant, VirtualRouterProvider vrProvider, long svcOffId,
|
||||
Long vpcId) throws ConcurrentOperationException,
|
||||
Long vpcId, PublicIp sourceNatIp) throws ConcurrentOperationException,
|
||||
InsufficientAddressCapacityException, InsufficientServerCapacityException, InsufficientCapacityException,
|
||||
StorageUnavailableException, ResourceUnavailableException {
|
||||
|
||||
|
|
@ -1374,7 +1378,17 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
}
|
||||
|
||||
//3) Plug public nic
|
||||
//3) Plug public nic
|
||||
boolean addToPublicNtwk = true;
|
||||
if (sourceNatIp != null) {
|
||||
Network publicNetwork = _networkDao.listByZoneAndTrafficType(dest.getDataCenter().getId(), TrafficType.Public).get(0);
|
||||
addToPublicNtwk = addRouterToPublicNetwork(router, publicNetwork, sourceNatIp);
|
||||
}
|
||||
|
||||
if (!addToPublicNtwk) {
|
||||
s_logger.warn("Failed to add router " + router + " to public network in zone " + dest.getDataCenter() + " cleaninig up");
|
||||
destroyRouter(router.getId());
|
||||
}
|
||||
|
||||
return router;
|
||||
}
|
||||
|
|
@ -2955,9 +2969,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
InsufficientCapacityException {
|
||||
boolean result = true;
|
||||
|
||||
//FIXME - Anthony, here I send plug nic command on xen side
|
||||
try {
|
||||
|
||||
PlugNicCommand plugNicCmd = new PlugNicCommand(vm, nic);
|
||||
|
||||
Commands cmds = new Commands(OnError.Stop);
|
||||
|
|
@ -2982,7 +2994,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
public boolean unplugNic(Network network, NicTO nic, VirtualMachineTO vm,
|
||||
ReservationContext context, DeployDestination dest) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
//FIXME - Anthony, add unplug nic agent command on xen side
|
||||
boolean result = true;
|
||||
DomainRouterVO router = _routerDao.findById(vm.getId());
|
||||
try {
|
||||
|
|
@ -3012,7 +3023,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
String networkDomain = network.getNetworkDomain();
|
||||
String dhcpRange = getGuestDhcpRange(guestNic, network, _configMgr.getZone(network.getDataCenterId()));
|
||||
|
||||
//FIXME - Anthony, add setup guest network command logic on Xen side
|
||||
boolean result = true;
|
||||
long guestVlanTag = Long.parseLong(network.getBroadcastUri().getHost());
|
||||
|
||||
|
|
@ -3053,7 +3063,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
sendCommandsToRouter(router, cmds);
|
||||
|
||||
SetupGuestNetworkAnswer setupAnswer = cmds.getAnswer(SetupGuestNetworkAnswer.class);
|
||||
String setup = add ? "set" : "unset";
|
||||
String setup = add ? "set" : "destroy";
|
||||
if (!(setupAnswer != null && setupAnswer.getResult())) {
|
||||
s_logger.warn("Unable to " + setup + " guest network on router " + router);
|
||||
result = false;
|
||||
|
|
@ -3061,20 +3071,24 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException, InsufficientCapacityException {
|
||||
|
||||
//Check if router is already a part of the network
|
||||
if (network.getTrafficType() != TrafficType.Guest) {
|
||||
s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if router is already a part of the Guest network
|
||||
if (_networkMgr.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
s_logger.debug("Router " + router + " is already part of the network " + network);
|
||||
s_logger.debug("Router " + router + " is already part of the Guest network " + network);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Add router to network
|
||||
boolean result = false;
|
||||
//Add router to the Guest network
|
||||
boolean result = true;
|
||||
try {
|
||||
DomainRouterVO routerVO = _routerDao.findById(router.getId());
|
||||
s_logger.debug("Plugging nic for vpc virtual router " + router + " in network " + network);
|
||||
|
|
@ -3089,6 +3103,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Failed to add router " + router + " to network " + network);
|
||||
result = false;
|
||||
} finally {
|
||||
if (!result) {
|
||||
s_logger.debug("Removing the router " + router + " from network " + network + " as a part of cleanup");
|
||||
|
|
@ -3107,16 +3122,20 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
@Override
|
||||
public boolean removeRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
if (network.getTrafficType() != TrafficType.Guest) {
|
||||
s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if router is a part of the network
|
||||
//Check if router is a part of the Guest network
|
||||
if (!_networkMgr.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||
s_logger.debug("Router " + router + " is not a part of the network " + network);
|
||||
s_logger.debug("Router " + router + " is not a part of the Guest network " + network);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean result = setupGuestNetwork(network, router, false, isRedundant, _networkMgr.getNicProfile(router, network.getId()));
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to reset guest network config " + network + " on router " + router);
|
||||
s_logger.warn("Failed to destroy guest network config " + network + " on router " + router);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -3130,4 +3149,110 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected boolean addRouterToPublicNetwork(VirtualRouter router, Network publicNetwork, IpAddress sourceNatIp)
|
||||
throws ConcurrentOperationException,ResourceUnavailableException, InsufficientCapacityException {
|
||||
|
||||
if (publicNetwork.getTrafficType() != TrafficType.Public) {
|
||||
s_logger.warn("Network " + publicNetwork + " is not of type " + TrafficType.Public);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if router is already a part of the Public network
|
||||
if (_networkMgr.isVmPartOfNetwork(router.getId(), publicNetwork.getId())) {
|
||||
s_logger.debug("Router " + router + " is already part of the Public network " + publicNetwork);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Add router to the Public network
|
||||
boolean result = true;
|
||||
try {
|
||||
|
||||
NicProfile publicNic = _itMgr.addVmToNetwork(router, publicNetwork);
|
||||
//setup public network
|
||||
if (publicNic != null) {
|
||||
if (sourceNatIp != null) {
|
||||
IPAddressVO ipVO = _ipAddressDao.findById(sourceNatIp.getId());
|
||||
PublicIp publicIp = new PublicIp(ipVO, _vlanDao.findById(ipVO.getVlanId()),
|
||||
NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress()));
|
||||
result = setupPublicNetwork(publicNetwork, router, false, publicIp);
|
||||
}
|
||||
} else {
|
||||
result = false;
|
||||
s_logger.warn("Failed to add router " + router + " to the public network " + publicNetwork);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Failed to add router " + router + " to the public network " + publicNetwork);
|
||||
} finally {
|
||||
if (!result) {
|
||||
s_logger.debug("Removing the router " + router + " from public network " + publicNetwork + " as a part of cleanup");
|
||||
if (removeRouterFromPublicNetwork(router, publicNetwork)) {
|
||||
s_logger.debug("Removed the router " + router + " from public network " + publicNetwork + " as a part of cleanup");
|
||||
} else {
|
||||
s_logger.warn("Failed to remove the router " + router + " from public network " + publicNetwork + " as a part of cleanup");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected boolean removeRouterFromPublicNetwork(VirtualRouter router, Network publicNetwork)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
|
||||
if (publicNetwork.getTrafficType() != TrafficType.Public) {
|
||||
s_logger.warn("Network " + publicNetwork + " is not of type " + TrafficType.Public);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if router is a part of the Guest network
|
||||
if (!_networkMgr.isVmPartOfNetwork(router.getId(), publicNetwork.getId())) {
|
||||
s_logger.debug("Router " + router + " is not a part of the Public network " + publicNetwork);
|
||||
return true;
|
||||
}
|
||||
|
||||
String routerIpStr = router.getPublicIpAddress();
|
||||
|
||||
IPAddressVO sourceNatIp = _ipAddressDao.findByIpAndSourceNetworkId(publicNetwork.getId(), routerIpStr);
|
||||
|
||||
assert sourceNatIp.isSourceNat() : "Ip " + sourceNatIp + " is not source nat";
|
||||
|
||||
boolean result = true;
|
||||
if (sourceNatIp != null) {
|
||||
IPAddressVO ipVO = _ipAddressDao.findById(sourceNatIp.getId());
|
||||
_networkMgr.markIpAsUnavailable(ipVO.getId());
|
||||
PublicIp publicIp = new PublicIp(ipVO, _vlanDao.findById(ipVO.getVlanId()),
|
||||
NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress()));
|
||||
result = setupPublicNetwork(publicNetwork, router, false, publicIp);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
s_logger.warn("Failed to destroy public network config " + publicNetwork + " on router " + router);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = result && _itMgr.removeVmFromNetwork(router, publicNetwork);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected boolean setupPublicNetwork(Network network, VirtualRouter router, boolean add, PublicIp sourceNatIp)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException{
|
||||
|
||||
List<PublicIp> publicIps = new ArrayList<PublicIp>(1);
|
||||
Commands cmds = new Commands(OnError.Stop);
|
||||
createAssociateIPCommands(router, publicIps, cmds, 0);
|
||||
sendCommandsToRouter(router, cmds);
|
||||
|
||||
boolean result = true;
|
||||
IpAssocAnswer ipAssocAnswer = cmds.getAnswer(IpAssocAnswer.class);
|
||||
String setup = add ? "set" : "destroy";
|
||||
if (!(ipAssocAnswer != null && ipAssocAnswer.getResult())) {
|
||||
s_logger.warn("Unable to " + setup + " guest network on router " + router);
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.cloud.exception.InsufficientCapacityException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.NetworkService;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
|
|
@ -38,6 +39,7 @@ import com.cloud.user.Account;
|
|||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.VirtualMachineProfile.Param;
|
||||
|
||||
|
|
@ -99,16 +101,25 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
List<? extends PhysicalNetwork> pNtwks = _pNtwkDao.listByZone(vpc.getZoneId());
|
||||
|
||||
VirtualRouterProvider vpcVrProvider = null;
|
||||
|
||||
for (PhysicalNetwork pNtwk : pNtwks) {
|
||||
vpcVrProvider = _vrProviderDao.findByNspIdAndType(pNtwk.getId(),
|
||||
PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(pNtwk.getId(),
|
||||
VirtualRouterProviderType.VPCVirtualRouter.toString());
|
||||
if (provider == null) {
|
||||
throw new CloudRuntimeException("Cannot find service provider " +
|
||||
VirtualRouterProviderType.VPCVirtualRouter.toString() + " in physical network " + pNtwk.getId());
|
||||
}
|
||||
vpcVrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(),
|
||||
VirtualRouterProviderType.VPCVirtualRouter);
|
||||
if (vpcVrProvider != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PublicIp sourceNatIp = _networkMgr.assignSourceNatIpAddressToVpc(owner, vpc);
|
||||
|
||||
DomainRouterVO router = deployRouter(owner, dest, plan, params, false, vpcVrProvider, offeringId,
|
||||
vpc.getId());
|
||||
vpc.getId(), sourceNatIp);
|
||||
routers.add(router);
|
||||
|
||||
} finally {
|
||||
|
|
|
|||
7
wscript
7
wscript
|
|
@ -3,11 +3,8 @@
|
|||
|
||||
# the following two variables are used by the target "waf dist"
|
||||
# if you change 'em here, you need to change it also in cloud.spec, add a %changelog entry there, and add an entry in debian/changelog
|
||||
<<<<<<< HEAD
|
||||
VERSION = '3.0.3.2012-06-04T23:35:51Z'
|
||||
=======
|
||||
VERSION = '3.0.3.2012-06-04T21:10:12Z'
|
||||
>>>>>>> Support for adding private network
|
||||
|
||||
VERSION = '3.0.3.2012-06-05T18:30:03Z'
|
||||
APPNAME = 'cloud'
|
||||
|
||||
import shutil,os
|
||||
|
|
|
|||
Loading…
Reference in New Issue