mirror of https://github.com/apache/cloudstack.git
1) Added VpcVirtualNetworkApplianceService interface
2) Pass dns1/dns2 to setupGuestNetworkCommand 3) Network implement - don't get source nat ip address for Vpc if it already has one
This commit is contained in:
parent
52d93071c8
commit
cf1882a2c8
|
|
@ -62,6 +62,7 @@ public interface VirtualNetworkApplianceService {
|
||||||
* @param router
|
* @param router
|
||||||
* @param network
|
* @param network
|
||||||
* @param isRedundant TODO
|
* @param isRedundant TODO
|
||||||
|
* @param setupDns TODO
|
||||||
* @return
|
* @return
|
||||||
* @throws ConcurrentOperationException
|
* @throws ConcurrentOperationException
|
||||||
* @throws ResourceUnavailableException
|
* @throws ResourceUnavailableException
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||||
|
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||||
|
// file except in compliance with the License. Citrix Systems, Inc.
|
||||||
|
// reserves all rights not expressly granted by 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.
|
||||||
|
//
|
||||||
|
// Automatically generated by addcopyright.py at 04/03/2012
|
||||||
|
package com.cloud.network;
|
||||||
|
|
||||||
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
|
import com.cloud.exception.ResourceUnavailableException;
|
||||||
|
import com.cloud.network.router.VirtualRouter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Alena Prokharchyk
|
||||||
|
*/
|
||||||
|
public interface VpcVirtualNetworkApplianceService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param router
|
||||||
|
* @param network
|
||||||
|
* @param isRedundant
|
||||||
|
* @return
|
||||||
|
* @throws ConcurrentOperationException
|
||||||
|
* @throws ResourceUnavailableException
|
||||||
|
* @throws InsufficientCapacityException
|
||||||
|
*/
|
||||||
|
boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -425,4 +425,12 @@ public interface NetworkManager extends NetworkService {
|
||||||
NicProfile getNicProfile(VirtualMachine vm, long networkId);
|
NicProfile getNicProfile(VirtualMachine vm, long networkId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param network
|
||||||
|
* @param provider
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean setupDns(Network network, Provider provider);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1932,7 +1932,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
@DB
|
||||||
public Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException,
|
public Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination dest, ReservationContext context)
|
||||||
|
throws ConcurrentOperationException, ResourceUnavailableException,
|
||||||
InsufficientCapacityException {
|
InsufficientCapacityException {
|
||||||
Transaction.currentTxn();
|
Transaction.currentTxn();
|
||||||
Pair<NetworkGuru, NetworkVO> implemented = new Pair<NetworkGuru, NetworkVO>(null, null);
|
Pair<NetworkGuru, NetworkVO> implemented = new Pair<NetworkGuru, NetworkVO>(null, null);
|
||||||
|
|
@ -1993,7 +1994,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context, NetworkVO network, NetworkOfferingVO offering)
|
private void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context,
|
||||||
|
NetworkVO network, NetworkOfferingVO offering)
|
||||||
throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException {
|
throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException {
|
||||||
// If this is a 1) guest virtual network 2) network has sourceNat service 3) network offering does not support a
|
// If this is a 1) guest virtual network 2) network has sourceNat service 3) network offering does not support a
|
||||||
// Shared source NAT rule,
|
// Shared source NAT rule,
|
||||||
|
|
@ -2001,14 +2003,29 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||||
|
|
||||||
boolean sharedSourceNat = offering.getSharedSourceNat();
|
boolean sharedSourceNat = offering.getSharedSourceNat();
|
||||||
|
|
||||||
if (network.getGuestType() == Network.GuestType.Isolated && areServicesSupportedInNetwork(network.getId(), Service.SourceNat)
|
if (network.getGuestType() == Network.GuestType.Isolated
|
||||||
|
&& areServicesSupportedInNetwork(network.getId(), Service.SourceNat)
|
||||||
&& !sharedSourceNat) {
|
&& !sharedSourceNat) {
|
||||||
List<IPAddressVO> ips = _ipAddressDao.listByAssociatedNetwork(network.getId(), true);
|
|
||||||
|
List<IPAddressVO> ips = null;
|
||||||
|
Vpc vpc = null;
|
||||||
|
if (network.getVpcId() != null) {
|
||||||
|
vpc = _vpcMgr.getVpc(network.getVpcId());
|
||||||
|
ips = _ipAddressDao.listByAssociatedVpc(vpc.getId(), true);
|
||||||
|
} else {
|
||||||
|
ips = _ipAddressDao.listByAssociatedNetwork(network.getId(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ips.isEmpty()) {
|
if (ips.isEmpty()) {
|
||||||
s_logger.debug("Creating a source nat ip for " + network);
|
String target = vpc != null ? vpc.toString() : network.toString();
|
||||||
|
s_logger.debug("Creating a source nat ip for " + target);
|
||||||
Account owner = _accountMgr.getAccount(network.getAccountId());
|
Account owner = _accountMgr.getAccount(network.getAccountId());
|
||||||
assignSourceNatIpAddressToGuestNetwork(owner, network);
|
if (vpc != null) {
|
||||||
|
assignSourceNatIpAddressToVpc(owner, vpc);
|
||||||
|
} else {
|
||||||
|
assignSourceNatIpAddressToGuestNetwork(owner, network);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2109,14 +2126,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
|
||||||
public NicProfile prepareNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, DeployDestination
|
public NicProfile prepareNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, DeployDestination
|
||||||
dest, ReservationContext context, long nicId, NetworkVO network)
|
dest, ReservationContext context, long nicId, NetworkVO network)
|
||||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException,
|
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException,
|
||||||
ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Integer networkRate = getNetworkRate(network.getId(), vmProfile.getId());
|
Integer networkRate = getNetworkRate(network.getId(), vmProfile.getId());
|
||||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||||
NicVO nic = _nicDao.findById(nicId);
|
NicVO nic = _nicDao.findById(nicId);
|
||||||
|
|
@ -6989,4 +7003,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||||
return privateNetwork;
|
return privateNetwork;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setupDns(Network network, Provider provider) {
|
||||||
|
boolean dnsProvided = isProviderSupportServiceInNetwork(network.getId(), Service.Dns, provider );
|
||||||
|
boolean dhcpProvided =isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
|
||||||
|
provider);
|
||||||
|
|
||||||
|
boolean setupDns = dnsProvided || dhcpProvided;
|
||||||
|
return setupDns;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,11 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_networkMgr.isProviderEnabledInPhysicalNetwork(physicalNetworkId, "VirtualRouter")) {
|
if (network.getVpcId() != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_networkMgr.isProviderEnabledInPhysicalNetwork(physicalNetworkId, Network.Provider.VirtualRouter.getName())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,18 +174,16 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||||
DataCenter.class, network.getDataCenterId());
|
DataCenter.class, network.getDataCenterId());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = true;
|
|
||||||
for (VirtualRouter router : routers) {
|
for (VirtualRouter router : routers) {
|
||||||
//Add router to guest network
|
//Add router to guest network
|
||||||
success = success && _routerMgr.addRouterToGuestNetwork(router, network, false);
|
if (!_routerMgr.addRouterToGuestNetwork(router, network, false)) {
|
||||||
if (!success) {
|
throw new CloudRuntimeException("Failed to add router " + router + " to guest network " + network);
|
||||||
s_logger.warn("Failed to plug nic in network " + network + " for virtual router router " + router);
|
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Successfully plugged nic in network " + network + " for virtual router " + router);
|
s_logger.debug("Successfully added router " + router + " to guest network " + network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -214,18 +216,16 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
||||||
DataCenter.class, network.getDataCenterId());
|
DataCenter.class, network.getDataCenterId());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = true;
|
|
||||||
for (VirtualRouter router : routers) {
|
for (VirtualRouter router : routers) {
|
||||||
//Add router to guest network
|
//Add router to guest network
|
||||||
success = success && _routerMgr.addRouterToGuestNetwork(router, network, false);
|
if (!_routerMgr.addRouterToGuestNetwork(router, network, false)) {
|
||||||
if (!success) {
|
throw new CloudRuntimeException("Failed to add router " + router + " to guest network " + network);
|
||||||
s_logger.warn("Failed to plug nic in network " + network + " for virtual router " + router);
|
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Successfully plugged nic in network " + network + " for virtual router " + router);
|
s_logger.debug("Successfully added router " + router + " to guest network " + network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,14 @@ import com.cloud.network.Network.Capability;
|
||||||
import com.cloud.network.Network.Provider;
|
import com.cloud.network.Network.Provider;
|
||||||
import com.cloud.network.Network.Service;
|
import com.cloud.network.Network.Service;
|
||||||
import com.cloud.network.NetworkService;
|
import com.cloud.network.NetworkService;
|
||||||
|
import com.cloud.network.VpcVirtualNetworkApplianceService;
|
||||||
import com.cloud.network.router.VirtualRouter;
|
import com.cloud.network.router.VirtualRouter;
|
||||||
import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
||||||
import com.cloud.network.vpc.Vpc;
|
import com.cloud.network.vpc.Vpc;
|
||||||
import com.cloud.network.vpc.VpcService;
|
import com.cloud.network.vpc.VpcService;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.utils.component.Inject;
|
import com.cloud.utils.component.Inject;
|
||||||
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.DomainRouterVO;
|
import com.cloud.vm.DomainRouterVO;
|
||||||
import com.cloud.vm.NicProfile;
|
import com.cloud.vm.NicProfile;
|
||||||
import com.cloud.vm.ReservationContext;
|
import com.cloud.vm.ReservationContext;
|
||||||
|
|
@ -53,6 +55,8 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
|
||||||
NetworkService _ntwkService;
|
NetworkService _ntwkService;
|
||||||
@Inject
|
@Inject
|
||||||
VpcService _vpcService;
|
VpcService _vpcService;
|
||||||
|
@Inject
|
||||||
|
VpcVirtualNetworkApplianceService _vpcMgr;
|
||||||
|
|
||||||
|
|
||||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||||
|
|
@ -60,6 +64,39 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
|
||||||
@Inject
|
@Inject
|
||||||
VpcVirtualNetworkApplianceManager _vpcRouterMgr;
|
VpcVirtualNetworkApplianceManager _vpcRouterMgr;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canHandle(Network network, Service service) {
|
||||||
|
Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(network);
|
||||||
|
if (physicalNetworkId == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (network.getVpcId() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_networkMgr.isProviderEnabledInPhysicalNetwork(physicalNetworkId, Network.Provider.VPCVirtualRouter.getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (service == null) {
|
||||||
|
if (!_networkMgr.isProviderForNetwork(getProvider(), network.getId())) {
|
||||||
|
s_logger.trace("Element " + getProvider().getName() + " is not a provider for the network " + network);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!_networkMgr.isProviderSupportServiceInNetwork(network.getId(), service, getProvider())) {
|
||||||
|
s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName()
|
||||||
|
+ " in the network " + network);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
||||||
ResourceUnavailableException, InsufficientCapacityException {
|
ResourceUnavailableException, InsufficientCapacityException {
|
||||||
|
|
@ -111,19 +148,16 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
|
||||||
DataCenter.class, network.getDataCenterId());
|
DataCenter.class, network.getDataCenterId());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = true;
|
|
||||||
for (VirtualRouter router : routers) {
|
for (VirtualRouter router : routers) {
|
||||||
//Add router to guest network
|
//Add router to guest network
|
||||||
success = success && _routerMgr.addRouterToGuestNetwork(router, network, false);
|
if (!_vpcMgr.addVpcRouterToGuestNetwork(router, network, false)) {
|
||||||
|
throw new CloudRuntimeException("Failed to add VPC router " + router + " to guest network " + network);
|
||||||
|
} else {
|
||||||
|
s_logger.debug("Successfully added VPC router " + router + " to guest network " + network);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
return true;
|
||||||
s_logger.warn("Failed to plug nic in network " + network + " for virtual router in vpc id=" + vpcId);
|
|
||||||
} else {
|
|
||||||
s_logger.debug("Successfully plugged nic in network " + network + " for virtual router in vpc id=" + vpcId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -153,18 +187,16 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc
|
||||||
DataCenter.class, network.getDataCenterId());
|
DataCenter.class, network.getDataCenterId());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = true;
|
|
||||||
for (VirtualRouter router : routers) {
|
for (VirtualRouter router : routers) {
|
||||||
//2) Add router to guest network
|
//Add router to guest network
|
||||||
success = success && _routerMgr.addRouterToGuestNetwork(router, network, false);
|
if (!_vpcMgr.addVpcRouterToGuestNetwork(router, network, false)) {
|
||||||
if (!success) {
|
throw new CloudRuntimeException("Failed to add VPC router " + router + " to guest network " + network);
|
||||||
s_logger.warn("Failed to plug nic in network " + network + " for virtual router " + router);
|
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Successfully plugged nic in network " + network + " for virtual router " + router);
|
s_logger.debug("Successfully added VPC router " + router + " to guest network " + network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -93,4 +93,5 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
|
||||||
|
|
||||||
boolean applyUserData(Network config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest,
|
boolean applyUserData(Network config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest,
|
||||||
List<DomainRouterVO> routers) throws ResourceUnavailableException;
|
List<DomainRouterVO> routers) throws ResourceUnavailableException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1948,7 +1948,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//add router to public and guest networks
|
//add router to public and guest networks
|
||||||
for (Nic publicNic : publicNics.keySet()) {
|
for (Nic publicNic : publicNics.keySet()) {
|
||||||
Network publicNtwk = publicNics.get(publicNic);
|
Network publicNtwk = publicNics.get(publicNic);
|
||||||
if (!addRouterToPublicNetwork(router, publicNtwk, _ipAddressDao.findByIpAndSourceNetworkId(publicNtwk.getId(),
|
if (!addRouterToPublicNetwork(router, publicNtwk, _ipAddressDao.findByIpAndSourceNetworkId(publicNtwk.getId(),
|
||||||
|
|
@ -1960,7 +1960,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
|
|
||||||
for (Nic guestNic : guestNics.keySet()) {
|
for (Nic guestNic : guestNics.keySet()) {
|
||||||
Network guestNtwk = guestNics.get(guestNic);
|
Network guestNtwk = guestNics.get(guestNic);
|
||||||
if (!addRouterToGuestNetwork(router, guestNtwk, false)) {
|
//FIXME - move vpc code to the vpc manager
|
||||||
|
boolean setupDnsRouter = _networkMgr.setupDns(guestNtwk, Provider.VirtualRouter);
|
||||||
|
boolean setupDnsVpc = _networkMgr.setupDns(guestNtwk, Provider.VPCVirtualRouter);
|
||||||
|
|
||||||
|
boolean setupDns = setupDnsRouter ? setupDnsRouter : setupDnsVpc;
|
||||||
|
|
||||||
|
if (!addRouterToGuestNetwork(router, guestNtwk, false, setupDns)) {
|
||||||
s_logger.warn("Failed to plug nic " + guestNic + " to router " + router);
|
s_logger.warn("Failed to plug nic " + guestNic + " to router " + router);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1970,7 +1976,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3057,7 +3062,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean setupGuestNetwork(Network network, VirtualRouter router, boolean add, boolean isRedundant,
|
protected boolean setupGuestNetwork(Network network, VirtualRouter router, boolean add, boolean isRedundant,
|
||||||
NicProfile guestNic)
|
NicProfile guestNic, boolean setupDns)
|
||||||
throws ConcurrentOperationException, ResourceUnavailableException{
|
throws ConcurrentOperationException, ResourceUnavailableException{
|
||||||
|
|
||||||
String networkDomain = network.getNetworkDomain();
|
String networkDomain = network.getNetworkDomain();
|
||||||
|
|
@ -3081,16 +3086,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
String defaultDns1 = null;
|
String defaultDns1 = null;
|
||||||
String defaultDns2 = null;
|
String defaultDns2 = null;
|
||||||
|
|
||||||
boolean dnsProvided = _networkMgr.isProviderSupportServiceInNetwork(guestNic.getNetworkId(), Service.Dns, Provider.VirtualRouter);
|
if (setupDns) {
|
||||||
boolean dhcpProvided = _networkMgr.isProviderSupportServiceInNetwork(guestNic.getNetworkId(), Service.Dhcp, Provider.VirtualRouter);
|
|
||||||
|
|
||||||
if (guestNic.isDefaultNic() && (dnsProvided || dhcpProvided)) {
|
|
||||||
defaultDns1 = guestNic.getDns1();
|
defaultDns1 = guestNic.getDns1();
|
||||||
defaultDns2 = guestNic.getDns2();
|
defaultDns2 = guestNic.getDns2();
|
||||||
}
|
}
|
||||||
|
|
||||||
NicVO nic = _nicDao.findByInstanceIdAndNetworkId(network.getId(), router.getId());
|
NicVO nic = _nicDao.findByInstanceIdAndNetworkId(network.getId(), router.getId());
|
||||||
NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), _networkMgr.getNetworkRate(network.getId(), router.getId()),
|
NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
|
||||||
|
_networkMgr.getNetworkRate(network.getId(), router.getId()),
|
||||||
_networkMgr.isSecurityGroupSupportedInNetwork(network), _networkMgr.getNetworkTag(router.getHypervisorType(), network));
|
_networkMgr.isSecurityGroupSupportedInNetwork(network), _networkMgr.getNetworkTag(router.getHypervisorType(), network));
|
||||||
|
|
||||||
SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, isRedundant, priority,
|
SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, isRedundant, priority,
|
||||||
|
|
@ -3117,8 +3120,17 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) throws ConcurrentOperationException,
|
public boolean addRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||||
ResourceUnavailableException, InsufficientCapacityException {
|
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||||
|
boolean setupDns = _networkMgr.setupDns(network, Provider.VirtualRouter);
|
||||||
|
|
||||||
|
return addRouterToGuestNetwork(router, network, isRedundant, setupDns);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean addRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant, boolean setupDns)
|
||||||
|
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||||
|
|
||||||
if (network.getTrafficType() != TrafficType.Guest) {
|
if (network.getTrafficType() != TrafficType.Guest) {
|
||||||
s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest);
|
s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest);
|
||||||
|
|
@ -3128,19 +3140,22 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
//Add router to the Guest network
|
//Add router to the Guest network
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
try {
|
try {
|
||||||
DomainRouterVO routerVO = _routerDao.findById(router.getId());
|
if (_routerDao.isRouterPartOfGuestNetwork(router.getId(), network.getId())) {
|
||||||
s_logger.debug("Plugging nic for vpc virtual router " + router + " in network " + network);
|
DomainRouterVO routerVO = _routerDao.findById(router.getId());
|
||||||
_routerDao.addRouterToGuestNetwork(routerVO, network);
|
s_logger.debug("Plugging nic for virtual router " + router + " in network " + network);
|
||||||
|
_routerDao.addRouterToGuestNetwork(routerVO, network);
|
||||||
|
}
|
||||||
|
|
||||||
NicProfile guestNic = _itMgr.addVmToNetwork(router, network);
|
NicProfile guestNic = _itMgr.addVmToNetwork(router, network);
|
||||||
//setup guest network
|
//setup guest network
|
||||||
if (guestNic != null) {
|
if (guestNic != null) {
|
||||||
result = setupGuestNetwork(network, router, true, isRedundant, guestNic);
|
result = setupGuestNetwork(network, router, true, isRedundant, guestNic, setupDns);
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("Failed to add router " + router + " to guest network " + network);
|
s_logger.warn("Failed to add router " + router + " to guest network " + network);
|
||||||
|
result = false;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
s_logger.warn("Failed to add router " + router + " to network " + network);
|
s_logger.warn("Failed to add router " + router + " to network " + network + " due to ", ex);
|
||||||
result = false;
|
result = false;
|
||||||
} finally {
|
} finally {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
@ -3156,7 +3171,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
public boolean removeRouterFromGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||||
|
|
@ -3165,13 +3179,19 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check if router is already part of network
|
||||||
|
if (!_routerDao.isRouterPartOfGuestNetwork(router.getId(), network.getId())) {
|
||||||
|
s_logger.debug("Router " + router + " is not a part of guest network " + network + "; no need to unplug guest nic");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//Check if router is a part of the Guest network
|
//Check if router is a part of the Guest network
|
||||||
if (!_networkMgr.isVmPartOfNetwork(router.getId(), network.getId())) {
|
if (!_networkMgr.isVmPartOfNetwork(router.getId(), network.getId())) {
|
||||||
s_logger.debug("Router " + router + " is not a part of the Guest network " + network);
|
s_logger.debug("Router " + router + " is not a part of the Guest network " + network);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean result = setupGuestNetwork(network, router, false, isRedundant, _networkMgr.getNicProfile(router, network.getId()));
|
boolean result = setupGuestNetwork(network, router, false, isRedundant, _networkMgr.getNicProfile(router, network.getId()), false);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
s_logger.warn("Failed to destroy guest network config " + network + " on router " + router);
|
s_logger.warn("Failed to destroy guest network config " + network + " on router " + router);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -3203,6 +3223,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
NicProfile publicNic = _itMgr.addVmToNetwork(router, publicNetwork);
|
NicProfile publicNic = _itMgr.addVmToNetwork(router, publicNetwork);
|
||||||
//setup public network
|
//setup public network
|
||||||
if (publicNic != null) {
|
if (publicNic != null) {
|
||||||
|
publicNic.setDefaultNic(true);
|
||||||
if (publicIpAddr != null) {
|
if (publicIpAddr != null) {
|
||||||
IPAddressVO ipVO = _ipAddressDao.findById(publicIpAddr.getId());
|
IPAddressVO ipVO = _ipAddressDao.findById(publicIpAddr.getId());
|
||||||
PublicIp publicIp = new PublicIp(ipVO, _vlanDao.findById(ipVO.getVlanId()),
|
PublicIp publicIp = new PublicIp(ipVO, _vlanDao.findById(ipVO.getVlanId()),
|
||||||
|
|
@ -3214,7 +3235,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||||
s_logger.warn("Failed to add router " + router + " to the public network " + publicNetwork);
|
s_logger.warn("Failed to add router " + router + " to the public network " + publicNetwork);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
s_logger.warn("Failed to add router " + router + " to the public network " + publicNetwork);
|
s_logger.warn("Failed to add router " + router + " to the public network " + publicNetwork + " due to ", ex);
|
||||||
} finally {
|
} finally {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
s_logger.debug("Removing the router " + router + " from public network " + publicNetwork + " as a part of cleanup");
|
s_logger.debug("Removing the router " + router + " from public network " + publicNetwork + " as a part of cleanup");
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import com.cloud.deploy.DeployDestination;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
import com.cloud.exception.ResourceUnavailableException;
|
||||||
|
import com.cloud.network.VpcVirtualNetworkApplianceService;
|
||||||
import com.cloud.network.vpc.Vpc;
|
import com.cloud.network.vpc.Vpc;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.vm.DomainRouterVO;
|
import com.cloud.vm.DomainRouterVO;
|
||||||
|
|
@ -27,7 +28,7 @@ import com.cloud.vm.VirtualMachineProfile.Param;
|
||||||
/**
|
/**
|
||||||
* @author Alena Prokharchyk
|
* @author Alena Prokharchyk
|
||||||
*/
|
*/
|
||||||
public interface VpcVirtualNetworkApplianceManager extends VirtualNetworkApplianceManager{
|
public interface VpcVirtualNetworkApplianceManager extends VirtualNetworkApplianceManager, VpcVirtualNetworkApplianceService{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param vpc
|
* @param vpc
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,23 @@ import javax.ejb.Local;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import sun.security.jca.ProviderList;
|
||||||
|
|
||||||
import com.cloud.deploy.DataCenterDeployment;
|
import com.cloud.deploy.DataCenterDeployment;
|
||||||
import com.cloud.deploy.DeployDestination;
|
import com.cloud.deploy.DeployDestination;
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
import com.cloud.deploy.DeploymentPlan;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
import com.cloud.exception.ResourceUnavailableException;
|
||||||
|
import com.cloud.network.Network;
|
||||||
|
import com.cloud.network.Network.Provider;
|
||||||
|
import com.cloud.network.Network.Service;
|
||||||
import com.cloud.network.NetworkService;
|
import com.cloud.network.NetworkService;
|
||||||
import com.cloud.network.PhysicalNetwork;
|
import com.cloud.network.PhysicalNetwork;
|
||||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||||
import com.cloud.network.VirtualRouterProvider;
|
import com.cloud.network.VirtualRouterProvider;
|
||||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||||
|
import com.cloud.network.VpcVirtualNetworkApplianceService;
|
||||||
import com.cloud.network.addr.PublicIp;
|
import com.cloud.network.addr.PublicIp;
|
||||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||||
import com.cloud.network.vpc.Vpc;
|
import com.cloud.network.vpc.Vpc;
|
||||||
|
|
@ -47,7 +53,7 @@ import com.cloud.vm.VirtualMachineProfile.Param;
|
||||||
* @author Alena Prokharchyk
|
* @author Alena Prokharchyk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Local(value = {VpcVirtualNetworkApplianceManager.class})
|
@Local(value = {VpcVirtualNetworkApplianceManager.class, VpcVirtualNetworkApplianceService.class})
|
||||||
public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplianceManagerImpl implements VpcVirtualNetworkApplianceManager{
|
public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplianceManagerImpl implements VpcVirtualNetworkApplianceManager{
|
||||||
private static final Logger s_logger = Logger.getLogger(VpcVirtualNetworkApplianceManagerImpl.class);
|
private static final Logger s_logger = Logger.getLogger(VpcVirtualNetworkApplianceManagerImpl.class);
|
||||||
|
|
||||||
|
|
@ -139,4 +145,16 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
||||||
return new Pair<DeploymentPlan, List<DomainRouterVO>>(plan, routers);
|
return new Pair<DeploymentPlan, List<DomainRouterVO>>(plan, routers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant)
|
||||||
|
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||||
|
boolean dnsProvided = _networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter);
|
||||||
|
boolean dhcpProvided = _networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp,
|
||||||
|
Provider.VPCVirtualRouter);
|
||||||
|
|
||||||
|
boolean setupDns = dnsProvided || dhcpProvided;
|
||||||
|
|
||||||
|
return super.addRouterToGuestNetwork(router, network, isRedundant, setupDns);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2432,7 +2432,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@DB
|
|
||||||
public NicProfile addVmToNetwork(VirtualMachine vm, Network network) throws ConcurrentOperationException,
|
public NicProfile addVmToNetwork(VirtualMachine vm, Network network) throws ConcurrentOperationException,
|
||||||
ResourceUnavailableException, InsufficientCapacityException {
|
ResourceUnavailableException, InsufficientCapacityException {
|
||||||
|
|
||||||
|
|
@ -2451,27 +2450,27 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
||||||
NicProfile nic = null;
|
NicProfile nic = null;
|
||||||
NicVO nicVO = _nicsDao.findByInstanceIdAndNetworkId(network.getId(), vm.getId());
|
NicVO nicVO = _nicsDao.findByInstanceIdAndNetworkId(network.getId(), vm.getId());
|
||||||
if (nicVO != null) {
|
if (nicVO != null) {
|
||||||
nic = new NicProfile(nicVO, network, nicVO.getBroadcastUri(), nicVO.getIsolationUri(), _networkMgr.getNetworkRate(network.getId(), vm.getId()),
|
nic = _networkMgr.getNicProfile(vm, network.getId());
|
||||||
_networkMgr.isSecurityGroupSupportedInNetwork(network), _networkMgr.getNetworkTag(vm.getHypervisorType(), network));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nic == null) {
|
if (nic == null) {
|
||||||
s_logger.debug("Allocating nic for the " + vm + " in network " + network);
|
s_logger.debug("Allocating nic for the " + vm + " in network " + network);
|
||||||
Transaction txn = Transaction.currentTxn();
|
|
||||||
txn.start();
|
|
||||||
//1) allocate nic and prepare nic if needed
|
//1) allocate nic and prepare nic if needed
|
||||||
int deviceId = _nicsDao.countNics(vm.getId());
|
int deviceId = _nicsDao.countNics(vm.getId());
|
||||||
|
|
||||||
nic = _networkMgr.allocateNic(null, network, false,
|
nic = _networkMgr.allocateNic(null, network, false,
|
||||||
deviceId, vmProfile).first();
|
deviceId, vmProfile).first();
|
||||||
|
|
||||||
|
if (nic == null) {
|
||||||
|
throw new CloudRuntimeException("Failed to allocate nic for vm " + vm + " in network " + network);
|
||||||
|
}
|
||||||
|
|
||||||
s_logger.debug("Nic is allocated successfully for vm " + vm + " in network " + network);
|
s_logger.debug("Nic is allocated successfully for vm " + vm + " in network " + network);
|
||||||
|
|
||||||
nic = _networkMgr.prepareNic(vmProfile, dest, context, nic.getId(), networkVO);
|
nic = _networkMgr.prepareNic(vmProfile, dest, context, nic.getId(), networkVO);
|
||||||
|
|
||||||
s_logger.debug("Nic is prepared successfully for vm " + vm + " in network " + network);
|
s_logger.debug("Nic is prepared successfully for vm " + vm + " in network " + network);
|
||||||
|
|
||||||
txn.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//2) Convert vmProfile to vmTO
|
//2) Convert vmProfile to vmTO
|
||||||
|
|
|
||||||
|
|
@ -124,4 +124,11 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long> {
|
||||||
*/
|
*/
|
||||||
void removeRouterFromNetwork(long routerId, long guestNetworkId);
|
void removeRouterFromNetwork(long routerId, long guestNetworkId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param routerId
|
||||||
|
* @param guestNetworkId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean isRouterPartOfGuestNetwork(long routerId, long guestNetworkId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -310,4 +310,10 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRouterPartOfGuestNetwork(long routerId, long guestNetworkId) {
|
||||||
|
RouterNetworkVO routerNtwkMap = _routerNetworkDao.findByRouterAndNetwork(routerId, guestNetworkId);
|
||||||
|
return routerNtwkMap != null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2189,7 +2189,8 @@ CREATE TABLE `cloud`.`router_network_ref` (
|
||||||
`guest_type` char(32) COMMENT 'type of guest network that can be shared or isolated',
|
`guest_type` char(32) COMMENT 'type of guest network that can be shared or isolated',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
CONSTRAINT `fk_router_network_ref__router_id` FOREIGN KEY (`router_id`) REFERENCES `domain_router`(`id`) ON DELETE CASCADE,
|
CONSTRAINT `fk_router_network_ref__router_id` FOREIGN KEY (`router_id`) REFERENCES `domain_router`(`id`) ON DELETE CASCADE,
|
||||||
CONSTRAINT `fk_router_network_ref__networks_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE
|
CONSTRAINT `fk_router_network_ref__networks_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE,
|
||||||
|
UNIQUE `i_router_network_ref__router_id__network_id`(`router_id`, `network_id`),
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
3
wscript
3
wscript
|
|
@ -4,7 +4,8 @@
|
||||||
# the following two variables are used by the target "waf dist"
|
# 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
|
# 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
|
||||||
|
|
||||||
VERSION = '3.0.3.2012-06-08T01:50:26Z'
|
|
||||||
|
VERSION = '3.0.3.2012-06-10T19:26:47Z'
|
||||||
APPNAME = 'cloud'
|
APPNAME = 'cloud'
|
||||||
|
|
||||||
import shutil,os
|
import shutil,os
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue