use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class NetworkServiceImpl method listTrafficTypeImplementor.
@Override
public List<Pair<TrafficType, String>> listTrafficTypeImplementor(ListTrafficTypeImplementorsCmd cmd) {
String type = cmd.getTrafficType();
List<Pair<TrafficType, String>> results = new ArrayList<Pair<TrafficType, String>>();
if (type != null) {
for (NetworkGuru guru : _networkGurus) {
if (guru.isMyTrafficType(TrafficType.getTrafficType(type))) {
results.add(new Pair<TrafficType, String>(TrafficType.getTrafficType(type), guru.getName()));
break;
}
}
} else {
for (NetworkGuru guru : _networkGurus) {
TrafficType[] allTypes = guru.getSupportedTrafficType();
for (TrafficType t : allTypes) {
results.add(new Pair<TrafficType, String>(t, guru.getName()));
}
}
}
return results;
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class ContrailElementImpl method isReady.
@Override
public boolean isReady(PhysicalNetworkServiceProvider provider) {
Map<String, String> serviceMap = ((ConfigurationServerImpl) _configServer).getServicesAndProvidersForNetwork(_manager.getRouterOffering().getId());
List<TrafficType> types = new ArrayList<TrafficType>();
types.add(TrafficType.Control);
types.add(TrafficType.Management);
types.add(TrafficType.Storage);
List<NetworkVO> systemNets = _manager.findSystemNetworks(types);
if (systemNets != null && !systemNets.isEmpty()) {
for (NetworkVO net : systemNets) {
s_logger.debug("update system network service: " + net.getName() + "; service provider: " + serviceMap);
_networksDao.update(net.getId(), net, serviceMap);
}
} else {
s_logger.debug("no system networks created yet");
}
serviceMap = ((ConfigurationServerImpl) _configServer).getServicesAndProvidersForNetwork(_manager.getPublicRouterOffering().getId());
types = new ArrayList<TrafficType>();
types.add(TrafficType.Public);
systemNets = _manager.findSystemNetworks(types);
if (systemNets != null && !systemNets.isEmpty()) {
for (NetworkVO net : systemNets) {
s_logger.debug("update system network service: " + net.getName() + "; service provider: " + serviceMap);
_networksDao.update(net.getId(), net, serviceMap);
}
} else {
s_logger.debug("no system networks created yet");
}
return true;
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class ContrailManagerImpl method findManagedNetworks.
/*
* Returns list of networks managed by Juniper VRouter filtered by traffic types
*/
@Override
public List<NetworkVO> findManagedNetworks(List<TrafficType> types) {
SearchBuilder<NetworkVO> searchBuilder = _networksDao.createSearchBuilder();
searchBuilder.and("trafficType", searchBuilder.entity().getTrafficType(), Op.IN);
searchBuilder.and("networkOfferingId", searchBuilder.entity().getNetworkOfferingId(), Op.IN);
SearchCriteria<NetworkVO> sc = searchBuilder.create();
List<Long> offerings = new ArrayList<Long>();
offerings.add(getRouterOffering().getId());
offerings.add(getVpcRouterOffering().getId());
offerings.add(getPublicRouterOffering().getId());
sc.setParameters("networkOfferingId", offerings.toArray());
if (types == null || types.isEmpty()) {
types = new ArrayList<TrafficType>();
types.add(TrafficType.Control);
types.add(TrafficType.Management);
types.add(TrafficType.Public);
types.add(TrafficType.Storage);
types.add(TrafficType.Guest);
}
sc.setParameters("trafficType", types.toArray());
List<NetworkVO> dbNets = _networksDao.search(sc, null);
if (dbNets == null) {
s_logger.debug("no juniper managed networks for the given traffic types: " + types.toString());
dbNets = new ArrayList<NetworkVO>();
}
List<PhysicalNetworkVO> phys_list = _physicalNetworkDao.listAll();
final String provider = Network.Provider.JuniperContrailRouter.getName();
final String vpcProvider = Provider.JuniperContrailVpcRouter.getName();
for (Iterator<PhysicalNetworkVO> iter = phys_list.iterator(); iter.hasNext(); ) {
PhysicalNetworkVO phys = iter.next();
if (_physProviderDao.findByServiceProvider(phys.getId(), provider) != null || _physProviderDao.findByServiceProvider(phys.getId(), vpcProvider) != null) {
List<NetworkVO> infraNets = new ArrayList<NetworkVO>();
findInfrastructureNetworks(phys, infraNets);
for (NetworkVO net : infraNets) {
if (types == null || types.isEmpty()) {
if (!dbNets.contains(net)) {
dbNets.add(net);
}
continue;
}
for (TrafficType type : types) {
if (net.getTrafficType() == type) {
if (!dbNets.contains(net)) {
dbNets.add(net);
}
break;
}
}
}
}
}
return dbNets;
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class ContrailManagerImpl method lookupPublicNetworkModel.
@Override
public VirtualNetworkModel lookupPublicNetworkModel() {
List<TrafficType> types = new ArrayList<TrafficType>();
types.add(TrafficType.Public);
List<NetworkVO> dbNets = findManagedNetworks(types);
if (dbNets == null) {
return null;
}
NetworkVO net = dbNets.get(0);
VirtualNetworkModel vnModel = getDatabase().lookupVirtualNetwork(net.getUuid(), getCanonicalName(net), TrafficType.Public);
if (vnModel == null) {
vnModel = new VirtualNetworkModel(net, net.getUuid(), getCanonicalName(net), net.getTrafficType());
vnModel.setProperties(getModelController(), net);
}
try {
if (!vnModel.verify(getModelController())) {
vnModel.update(getModelController());
}
getDatabase().getVirtualNetworks().add(vnModel);
} catch (Exception ex) {
s_logger.warn("virtual-network update: ", ex);
}
return vnModel;
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class VmwareResource method getTargetSwitch.
// return Ternary <switch name, switch tyep, vlan tagging>
private Ternary<String, String, String> getTargetSwitch(NicTO nicTo) throws CloudException {
TrafficType[] supportedTrafficTypes = new TrafficType[] { TrafficType.Guest, TrafficType.Public, TrafficType.Control, TrafficType.Management, TrafficType.Storage };
TrafficType trafficType = nicTo.getType();
if (!Arrays.asList(supportedTrafficTypes).contains(trafficType)) {
throw new CloudException("Traffic type " + trafficType.toString() + " for nic " + nicTo.toString() + " is not supported.");
}
String switchName = null;
VirtualSwitchType switchType = VirtualSwitchType.StandardVirtualSwitch;
String vlanId = Vlan.UNTAGGED;
if (nicTo.getName() != null && !nicTo.getName().isEmpty()) {
// Format of network traffic label is <VSWITCH>,<VLANID>,<VSWITCHTYPE>
// If all 3 fields are mentioned then number of tokens would be 3.
// If only <VSWITCH>,<VLANID> are mentioned then number of tokens would be 2.
// Get switch details from the nicTO object
String networkName = nicTo.getName();
VmwareTrafficLabel mgmtTrafficLabelObj = new VmwareTrafficLabel(networkName, trafficType);
switchName = mgmtTrafficLabelObj.getVirtualSwitchName();
vlanId = mgmtTrafficLabelObj.getVlanId();
switchType = mgmtTrafficLabelObj.getVirtualSwitchType();
} else {
if (trafficType == TrafficType.Guest && _guestTrafficInfo != null) {
switchType = _guestTrafficInfo.getVirtualSwitchType();
switchName = _guestTrafficInfo.getVirtualSwitchName();
} else if (trafficType == TrafficType.Public && _publicTrafficInfo != null) {
switchType = _publicTrafficInfo.getVirtualSwitchType();
switchName = _publicTrafficInfo.getVirtualSwitchName();
}
}
if (switchName == null && (nicTo.getType() == Networks.TrafficType.Control || nicTo.getType() == Networks.TrafficType.Management || nicTo.getType() == Networks.TrafficType.Storage)) {
switchName = _privateNetworkVSwitchName;
}
if (switchType == VirtualSwitchType.NexusDistributedVirtualSwitch) {
if (trafficType == TrafficType.Management || trafficType == TrafficType.Storage) {
throw new CloudException("Unable to configure NIC " + nicTo.toString() + " as traffic type " + trafficType.toString() + " is not supported over virtual switch type " + switchType + ". Please specify only supported type of virtual switches i.e. {vmwaresvs, vmwaredvs} in physical network traffic label.");
}
}
return new Ternary<String, String, String>(switchName, switchType.toString(), vlanId);
}
Aggregations