mirror of https://github.com/apache/cloudstack.git
Make the changes for the new capabilities check to the plugins.
This commit is contained in:
parent
9f2d940174
commit
e1aba6aea3
|
|
@ -21,6 +21,8 @@ package com.cloud.network.guru;
|
|||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
|
@ -48,6 +50,7 @@ import com.cloud.network.Network.GuestType;
|
|||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
import com.cloud.network.dao.BigSwitchVnsDao;
|
||||
|
|
@ -67,6 +70,14 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(BigSwitchVnsGuestNetworkGuru.class);
|
||||
|
||||
/**
|
||||
* The supported networking configs
|
||||
*/
|
||||
private static final EnumSet<NetworkType> _supportedNetworkTypes = EnumSet.of(NetworkType.Advanced);
|
||||
private static final EnumSet<GuestType> _supportedGuestTypes = EnumSet.of(GuestType.Isolated);
|
||||
private static final EnumSet<IsolationMethod> _supportedIsolationMethods = EnumSet.of(IsolationMethod.VNS);
|
||||
private static final EnumSet<TrafficType> _supportedTrafficTypes = EnumSet.of(TrafficType.Guest);
|
||||
|
||||
@Inject
|
||||
DataCenterDao _zoneDao;
|
||||
@Inject
|
||||
|
|
@ -91,7 +102,7 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
|
||||
@Override
|
||||
protected boolean canHandle(NetworkOffering offering, NetworkType networkType,
|
||||
PhysicalNetwork physicalNetwork) {
|
||||
PhysicalNetwork physicalNetwork) {
|
||||
if (networkType == NetworkType.Advanced
|
||||
&& isMyTrafficType(offering.getTrafficType())
|
||||
&& offering.getGuestType() == Network.GuestType.Isolated
|
||||
|
|
@ -99,7 +110,7 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
return true;
|
||||
} else {
|
||||
s_logger.trace("We only take care of Guest networks of type " + GuestType.Isolated +
|
||||
" in zone of type " + NetworkType.Advanced);
|
||||
" in zone of type " + NetworkType.Advanced);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -107,11 +118,11 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
@Override
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan,
|
||||
Network userSpecified, Account owner) {
|
||||
// Check of the isolation type of the related physical network is VNS
|
||||
// Check of the isolation type of the related physical network is VNS
|
||||
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
|
||||
if (physnet == null ||
|
||||
physnet.getIsolationMethods() == null ||
|
||||
!physnet.getIsolationMethods().contains("VNS")) {
|
||||
physnet.getIsolationMethods() == null ||
|
||||
!physnet.getIsolationMethods().contains("VNS")) {
|
||||
s_logger.debug("Refusing to design this network, the physical isolation type is not VNS");
|
||||
return null;
|
||||
}
|
||||
|
|
@ -122,7 +133,7 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
return null;
|
||||
}
|
||||
s_logger.debug("BigSwitch Controller " + devices.get(0).getUuid() +
|
||||
" found on physical network " + physnet.getId());
|
||||
" found on physical network " + physnet.getId());
|
||||
|
||||
s_logger.debug("Physical isolation type is VNS, asking GuestNetworkGuru to design this network");
|
||||
NetworkVO networkObject = (NetworkVO) super.design(offering, plan, userSpecified, owner);
|
||||
|
|
@ -138,18 +149,18 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
@Override
|
||||
public Network implement(Network network, NetworkOffering offering,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException {
|
||||
throws InsufficientVirtualNetworkCapcityException {
|
||||
assert (network.getState() == State.Implementing) : "Why are we implementing " + network;
|
||||
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
//get physical network id
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId,
|
||||
offering.getTags(),
|
||||
offering.getTrafficType());
|
||||
offering.getTags(),
|
||||
offering.getTrafficType());
|
||||
|
||||
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(),
|
||||
network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
|
||||
network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
|
||||
network.getDataCenterId(), physicalNetworkId);
|
||||
|
||||
if (network.getGateway() != null) {
|
||||
|
|
@ -163,10 +174,10 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), context.getReservationId(), UseSystemGuestVlans.valueIn(network.getAccountId()));
|
||||
if (vnet == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a " +
|
||||
"part of network " + network + " implement ", DataCenter.class, dcId);
|
||||
"part of network " + network + " implement ", DataCenter.class, dcId);
|
||||
}
|
||||
// when supporting more types of networks this need to become
|
||||
// int vlan = Integer.parseInt(BroadcastDomainType.getValue(vnet));
|
||||
// int vlan = Integer.parseInt(BroadcastDomainType.getValue(vnet));
|
||||
int vlan = Integer.parseInt(vnet);
|
||||
|
||||
// Name is either the given name or the uuid
|
||||
|
|
@ -201,7 +212,7 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
implemented.setBroadcastUri(new URI("vns", cmd.getNetworkUuid(), null));
|
||||
implemented.setBroadcastDomainType(BroadcastDomainType.Lswitch);
|
||||
s_logger.info("Implemented OK, network " + networkUuid + " in tenant " +
|
||||
tenantId + " linked to " + implemented.getBroadcastUri().toString());
|
||||
tenantId + " linked to " + implemented.getBroadcastUri().toString());
|
||||
} catch (URISyntaxException e) {
|
||||
s_logger.error("Unable to store network id in broadcast uri, uuid = " + implemented.getUuid(), e);
|
||||
}
|
||||
|
|
@ -213,8 +224,8 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
public void reserve(NicProfile nic, Network network,
|
||||
VirtualMachineProfile vm,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
super.reserve(nic, network, vm, dest, context);
|
||||
}
|
||||
|
|
@ -257,4 +268,24 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
return super.trash(network, offering);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkType> getSupportedNetworkTypes() {
|
||||
return new ArrayList<NetworkType>(_supportedNetworkTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrafficType> getSupportedTrafficTypes() {
|
||||
return new ArrayList<TrafficType>(_supportedTrafficTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GuestType> getSupportedGuestTypes() {
|
||||
return new ArrayList<GuestType>(_supportedGuestTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IsolationMethod> getSupportedIsolationMethods() {
|
||||
return new ArrayList<IsolationMethod>(_supportedIsolationMethods);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,31 +19,48 @@
|
|||
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.*;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.vm.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Component
|
||||
@Local(value = NetworkGuru.class)
|
||||
public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(MidoNetGuestNetworkGuru.class);
|
||||
|
||||
private static final EnumSet<NetworkType> _supportedNetworkTypes = EnumSet.of(NetworkType.Advanced);
|
||||
private static final EnumSet<GuestType> _supportedGuestTypes = EnumSet.of(GuestType.Isolated);
|
||||
private static final EnumSet<IsolationMethod> _supportedIsolationMethods = EnumSet.of(IsolationMethod.MIDO);
|
||||
private static final EnumSet<TrafficType> _supportedTrafficTypes = EnumSet.of(TrafficType.Guest);
|
||||
|
||||
@Inject
|
||||
AccountDao _accountDao;
|
||||
|
||||
|
|
@ -54,7 +71,7 @@ public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
|
|||
|
||||
@Override
|
||||
protected boolean canHandle(NetworkOffering offering, NetworkType networkType,
|
||||
PhysicalNetwork physicalNetwork) {
|
||||
PhysicalNetwork physicalNetwork) {
|
||||
// This guru handles only Guest Isolated network that supports Source nat service
|
||||
if (networkType == NetworkType.Advanced
|
||||
&& isMyTrafficType(offering.getTrafficType())
|
||||
|
|
@ -70,7 +87,7 @@ public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
|
|||
|
||||
@Override
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan,
|
||||
Network userSpecified, Account owner) {
|
||||
Network userSpecified, Account owner) {
|
||||
s_logger.debug("design called");
|
||||
// Check if the isolation type of the related physical network is MIDO
|
||||
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
|
||||
|
|
@ -92,8 +109,8 @@ public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
|
|||
|
||||
@Override
|
||||
public Network implement(Network network, NetworkOffering offering,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException {
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException {
|
||||
assert (network.getState() == Network.State.Implementing) : "Why are we implementing " + network;
|
||||
s_logger.debug("implement called network: " + network.toString());
|
||||
|
||||
|
|
@ -123,8 +140,8 @@ public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
|
|||
}
|
||||
|
||||
String broadcastUriStr = accountUUIDStr + "."
|
||||
+ String.valueOf(network.getId())
|
||||
+ ":" + routerName;
|
||||
+ String.valueOf(network.getId())
|
||||
+ ":" + routerName;
|
||||
|
||||
implemented.setBroadcastUri(Networks.BroadcastDomainType.Mido.toUri(broadcastUriStr));
|
||||
s_logger.debug("Broadcast URI set to " + broadcastUriStr);
|
||||
|
|
@ -134,10 +151,10 @@ public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
|
|||
|
||||
@Override
|
||||
public void reserve(NicProfile nic, Network network,
|
||||
VirtualMachineProfile vm,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
VirtualMachineProfile vm,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
s_logger.debug("reserve called with network: " + network.toString() + " nic: " + nic.toString() + " vm: " + vm.toString());
|
||||
|
||||
super.reserve(nic, network, vm, dest, context);
|
||||
|
|
@ -145,8 +162,8 @@ public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
|
|||
|
||||
@Override
|
||||
public boolean release(NicProfile nic,
|
||||
VirtualMachineProfile vm,
|
||||
String reservationId) {
|
||||
VirtualMachineProfile vm,
|
||||
String reservationId) {
|
||||
s_logger.debug("release called with nic: " + nic.toString() + " vm: " + vm.toString());
|
||||
return super.release(nic, vm, reservationId);
|
||||
}
|
||||
|
|
@ -164,4 +181,25 @@ public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
|
|||
|
||||
return super.trash(network, offering);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkType> getSupportedNetworkTypes() {
|
||||
return new ArrayList<NetworkType>(_supportedNetworkTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrafficType> getSupportedTrafficTypes() {
|
||||
return new ArrayList<TrafficType>(_supportedTrafficTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GuestType> getSupportedGuestTypes() {
|
||||
return new ArrayList<GuestType>(_supportedGuestTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IsolationMethod> getSupportedIsolationMethods() {
|
||||
return new ArrayList<IsolationMethod>(_supportedIsolationMethods);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ package com.cloud.network.guru;
|
|||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
|
@ -47,6 +49,7 @@ import com.cloud.network.Network.State;
|
|||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.NiciraNvpDeviceVO;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
|
|
@ -62,13 +65,20 @@ import com.cloud.user.Account;
|
|||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Local(value = NetworkGuru.class)
|
||||
public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(NiciraNvpGuestNetworkGuru.class);
|
||||
|
||||
/**
|
||||
* The supported networking configs
|
||||
*/
|
||||
private static final EnumSet<NetworkType> _supportedNetworkTypes = EnumSet.of(NetworkType.Advanced);
|
||||
private static final EnumSet<GuestType> _supportedGuestTypes = EnumSet.of(GuestType.Isolated);
|
||||
private static final EnumSet<IsolationMethod> _supportedIsolationMethods = EnumSet.of(IsolationMethod.STT);
|
||||
private static final EnumSet<TrafficType> _supportedTrafficTypes = EnumSet.of(TrafficType.Guest);
|
||||
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
|
|
@ -144,7 +154,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
|||
@Override
|
||||
public Network implement(Network network, NetworkOffering offering,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException {
|
||||
throws InsufficientVirtualNetworkCapcityException {
|
||||
assert (network.getState() == State.Implementing) : "Why are we implementing " + network;
|
||||
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
|
@ -213,8 +223,8 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
|||
public void reserve(NicProfile nic, Network network,
|
||||
VirtualMachineProfile vm,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
super.reserve(nic, network, vm, dest, context);
|
||||
}
|
||||
|
|
@ -259,4 +269,25 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
|
|||
return super.trash(network, offering);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkType> getSupportedNetworkTypes() {
|
||||
return new ArrayList<NetworkType>(_supportedNetworkTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrafficType> getSupportedTrafficTypes() {
|
||||
return new ArrayList<TrafficType>(_supportedTrafficTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GuestType> getSupportedGuestTypes() {
|
||||
return new ArrayList<GuestType>(_supportedGuestTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IsolationMethod> getSupportedIsolationMethods() {
|
||||
return new ArrayList<IsolationMethod>(_supportedIsolationMethods);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@
|
|||
// under the License.
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
|
@ -35,6 +39,7 @@ import com.cloud.network.Network;
|
|||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
|
|
@ -47,6 +52,15 @@ import com.cloud.vm.ReservationContext;
|
|||
public class OvsGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(OvsGuestNetworkGuru.class);
|
||||
|
||||
/**
|
||||
* The supported networking configs
|
||||
*/
|
||||
private static final EnumSet<NetworkType> _supportedNetworkTypes = EnumSet.of(NetworkType.Advanced);
|
||||
private static final EnumSet<GuestType> _supportedGuestTypes = EnumSet.of(GuestType.Isolated);
|
||||
private static final EnumSet<IsolationMethod> _supportedIsolationMethods = EnumSet.of(IsolationMethod.GRE, IsolationMethod.L3,
|
||||
IsolationMethod.VLAN);
|
||||
private static final EnumSet<TrafficType> _supportedTrafficTypes = EnumSet.of(TrafficType.Guest);
|
||||
|
||||
@Inject OvsTunnelManager _ovsTunnelMgr;
|
||||
|
||||
OvsGuestNetworkGuru() {
|
||||
|
|
@ -114,4 +128,28 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
|
|||
return implemented;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
return super.trash(network, offering);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkType> getSupportedNetworkTypes() {
|
||||
return new ArrayList<NetworkType>(_supportedNetworkTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrafficType> getSupportedTrafficTypes() {
|
||||
return new ArrayList<TrafficType>(_supportedTrafficTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GuestType> getSupportedGuestTypes() {
|
||||
return new ArrayList<GuestType>(_supportedGuestTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IsolationMethod> getSupportedIsolationMethods() {
|
||||
return new ArrayList<IsolationMethod>(_supportedIsolationMethods);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,20 +16,27 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.network.guru;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.network.element.SspElement;
|
||||
import org.apache.cloudstack.network.element.SspManager;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.NetworkMigrationResponder;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
|
|
@ -40,7 +47,6 @@ import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
|
|||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.ReservationContextImpl;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
/**
|
||||
|
|
@ -50,6 +56,14 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
public class SspGuestNetworkGuru extends GuestNetworkGuru implements NetworkMigrationResponder {
|
||||
private static final Logger s_logger = Logger.getLogger(SspGuestNetworkGuru.class);
|
||||
|
||||
/**
|
||||
* The supported networking configs
|
||||
*/
|
||||
private static final EnumSet<NetworkType> _supportedNetworkTypes = EnumSet.of(NetworkType.Advanced);
|
||||
private static final EnumSet<GuestType> _supportedGuestTypes = EnumSet.of(GuestType.Isolated);
|
||||
private static final EnumSet<IsolationMethod> _supportedIsolationMethods = EnumSet.of(IsolationMethod.SSP);
|
||||
private static final EnumSet<TrafficType> _supportedTrafficTypes = EnumSet.of(TrafficType.Guest);
|
||||
|
||||
@Inject
|
||||
SspManager _sspMgr;
|
||||
@Inject
|
||||
|
|
@ -170,4 +184,24 @@ public class SspGuestNetworkGuru extends GuestNetworkGuru implements NetworkMigr
|
|||
ReservationContext src, ReservationContext dst) {
|
||||
release(nic, vm, src.getReservationId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkType> getSupportedNetworkTypes() {
|
||||
return new ArrayList<NetworkType>(_supportedNetworkTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrafficType> getSupportedTrafficTypes() {
|
||||
return new ArrayList<TrafficType>(_supportedTrafficTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GuestType> getSupportedGuestTypes() {
|
||||
return new ArrayList<GuestType>(_supportedGuestTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IsolationMethod> getSupportedIsolationMethods() {
|
||||
return new ArrayList<IsolationMethod>(_supportedIsolationMethods);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,17 @@
|
|||
// under the License.
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
|
|
@ -32,10 +37,11 @@ import com.cloud.event.EventVO;
|
|||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
|
|
@ -43,14 +49,21 @@ import com.cloud.offering.NetworkOffering;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
@Component
|
||||
@Local(value=NetworkGuru.class)
|
||||
public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(VxlanGuestNetworkGuru.class);
|
||||
|
||||
|
||||
/**
|
||||
* The supported networking configs
|
||||
*/
|
||||
private static final EnumSet<NetworkType> _supportedNetworkTypes = EnumSet.of(NetworkType.Advanced);
|
||||
private static final EnumSet<GuestType> _supportedGuestTypes = EnumSet.of(GuestType.Isolated);
|
||||
private static final EnumSet<IsolationMethod> _supportedIsolationMethods = EnumSet.of(IsolationMethod.VXLAN);
|
||||
private static final EnumSet<TrafficType> _supportedTrafficTypes = EnumSet.of(TrafficType.Guest);
|
||||
|
||||
public VxlanGuestNetworkGuru() {
|
||||
super();
|
||||
_isolationMethods = new IsolationMethod[] { IsolationMethod.VXLAN };
|
||||
|
|
@ -59,8 +72,8 @@ public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
|
|||
@Override
|
||||
protected boolean canHandle(NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) {
|
||||
// This guru handles only Guest Isolated network that supports Source nat service
|
||||
if (networkType == NetworkType.Advanced
|
||||
&& isMyTrafficType(offering.getTrafficType())
|
||||
if (networkType == NetworkType.Advanced
|
||||
&& isMyTrafficType(offering.getTrafficType())
|
||||
&& offering.getGuestType() == Network.GuestType.Isolated
|
||||
&& isMyIsolationMethod(physicalNetwork)) {
|
||||
return true;
|
||||
|
|
@ -69,11 +82,11 @@ public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
||||
|
||||
NetworkVO network = (NetworkVO) super.design(offering, plan, userSpecified, owner);
|
||||
|
||||
NetworkVO network = (NetworkVO) super.design(offering, plan, userSpecified, owner);
|
||||
if (network == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -82,15 +95,16 @@ public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
|
|||
|
||||
return network;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void allocateVnet(Network network, NetworkVO implemented, long dcId,
|
||||
long physicalNetworkId, String reservationId) throws InsufficientVirtualNetworkCapcityException {
|
||||
if (network.getBroadcastUri() == null) {
|
||||
String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId,
|
||||
UseSystemGuestVlans.valueIn(network.getAccountId()));
|
||||
UseSystemGuestVlans.valueIn(network.getAccountId()));
|
||||
if (vnet == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a " +
|
||||
"part of network " + network + " implement ", DataCenter.class, dcId);
|
||||
"part of network " + network + " implement ", DataCenter.class, dcId);
|
||||
}
|
||||
implemented.setBroadcastUri(BroadcastDomainType.Vxlan.toUri(vnet));
|
||||
allocateVnetComplete(network, implemented, dcId, physicalNetworkId, reservationId, vnet);
|
||||
|
|
@ -98,7 +112,7 @@ public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
|
|||
implemented.setBroadcastUri(network.getBroadcastUri());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// For Test: Mockit cannot mock static method, wrap it
|
||||
protected void allocateVnetComplete(Network network, NetworkVO implemented, long dcId,
|
||||
long physicalNetworkId, String reservationId, String vnet) {
|
||||
|
|
@ -106,28 +120,28 @@ public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
|
|||
ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), network.getAccountId(),
|
||||
EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone vNet: " + vnet + " Network Id: " + network.getId(), 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Network implement(Network network, NetworkOffering offering,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException {
|
||||
throws InsufficientVirtualNetworkCapcityException {
|
||||
assert (network.getState() == State.Implementing) : "Why are we implementing " + network;
|
||||
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
//get physical network id
|
||||
Long physicalNetworkId = network.getPhysicalNetworkId();
|
||||
|
||||
|
||||
// physical network id can be null in Guest Network in Basic zone, so locate the physical network
|
||||
if (physicalNetworkId == null) {
|
||||
if (physicalNetworkId == null) {
|
||||
physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
}
|
||||
|
||||
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
|
||||
network.getDataCenterId(), physicalNetworkId);
|
||||
|
||||
|
||||
allocateVnet(network, implemented, dcId, physicalNetworkId, context.getReservationId());
|
||||
|
||||
|
||||
if (network.getGateway() != null) {
|
||||
implemented.setGateway(network.getGateway());
|
||||
}
|
||||
|
|
@ -135,7 +149,7 @@ public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
|
|||
if (network.getCidr() != null) {
|
||||
implemented.setCidr(network.getCidr());
|
||||
}
|
||||
|
||||
|
||||
return implemented;
|
||||
}
|
||||
|
||||
|
|
@ -143,8 +157,8 @@ public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
|
|||
public void reserve(NicProfile nic, Network network,
|
||||
VirtualMachineProfile vm,
|
||||
DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
super.reserve(nic, network, vm, dest, context);
|
||||
}
|
||||
|
||||
|
|
@ -156,14 +170,14 @@ public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
|
||||
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
|
||||
NetworkVO networkObject = _networkDao.findById(profile.getId());
|
||||
if (networkObject.getBroadcastDomainType() != BroadcastDomainType.Vxlan ||
|
||||
networkObject.getBroadcastUri() == null) {
|
||||
s_logger.warn("BroadcastUri is empty or incorrect for guestnetwork " + networkObject.getDisplayText());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
super.shutdown(profile, offering);
|
||||
}
|
||||
|
||||
|
|
@ -171,9 +185,24 @@ public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
|
|||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
return super.trash(network, offering);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<NetworkType> getSupportedNetworkTypes() {
|
||||
return new ArrayList<NetworkType>(_supportedNetworkTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrafficType> getSupportedTrafficTypes() {
|
||||
return new ArrayList<TrafficType>(_supportedTrafficTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GuestType> getSupportedGuestTypes() {
|
||||
return new ArrayList<GuestType>(_supportedGuestTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IsolationMethod> getSupportedIsolationMethods() {
|
||||
return new ArrayList<IsolationMethod>(_supportedIsolationMethods);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue