use of com.cloud.network.Networks.TrafficType in project CloudStack-archive by CloudStack-extras.
the class ListTrafficTypeImplementorsCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
List<Pair<TrafficType, String>> results = _networkService.listTrafficTypeImplementor(this);
ListResponse<TrafficTypeImplementorResponse> response = new ListResponse<TrafficTypeImplementorResponse>();
List<TrafficTypeImplementorResponse> responses = new ArrayList<TrafficTypeImplementorResponse>();
for (Pair<TrafficType, String> r : results) {
TrafficTypeImplementorResponse p = new TrafficTypeImplementorResponse();
p.setTrafficType(r.first().toString());
p.setImplementor(r.second());
p.setObjectName("traffictypeimplementorresponse");
responses.add(p);
}
response.setResponses(responses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class LibvirtVifDriverTest method testBadTrafficType.
@Test
public void testBadTrafficType() throws ConfigurationException {
Map<String, Object> params = new HashMap<String, Object>();
params.put(LibVirtVifDriver + "." + "NonExistentTrafficType", FakeVifDriverClassName);
res._bridgeType = BridgeType.NATIVE;
configure(params);
// Set all traffic types to use default, because bad traffic type should be ignored
for (TrafficType trafficType : TrafficType.values()) {
assertions.put(trafficType, bridgeVifDriver);
}
checkAssertions();
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class ConfigurationServerImpl method createDefaultNetworks.
private void createDefaultNetworks() {
List<DataCenterVO> zones = _dataCenterDao.listAll();
long id = 1;
HashMap<TrafficType, String> guruNames = new HashMap<TrafficType, String>();
guruNames.put(TrafficType.Public, PublicNetworkGuru.class.getSimpleName());
guruNames.put(TrafficType.Management, PodBasedNetworkGuru.class.getSimpleName());
guruNames.put(TrafficType.Control, ControlNetworkGuru.class.getSimpleName());
guruNames.put(TrafficType.Storage, StorageNetworkGuru.class.getSimpleName());
guruNames.put(TrafficType.Guest, DirectPodBasedNetworkGuru.class.getSimpleName());
for (DataCenterVO zone : zones) {
long zoneId = zone.getId();
long accountId = 1L;
Long domainId = zone.getDomainId();
if (domainId == null) {
domainId = 1L;
}
// Create default networks - system only
List<NetworkOfferingVO> ntwkOff = _networkOfferingDao.listSystemNetworkOfferings();
for (NetworkOfferingVO offering : ntwkOff) {
if (offering.isSystemOnly()) {
long related = id;
long networkOfferingId = offering.getId();
Mode mode = Mode.Static;
String networkDomain = null;
BroadcastDomainType broadcastDomainType = null;
TrafficType trafficType = offering.getTrafficType();
boolean specifyIpRanges = false;
if (trafficType == TrafficType.Management) {
broadcastDomainType = BroadcastDomainType.Native;
} else if (trafficType == TrafficType.Storage) {
broadcastDomainType = BroadcastDomainType.Native;
specifyIpRanges = true;
} else if (trafficType == TrafficType.Control) {
broadcastDomainType = BroadcastDomainType.LinkLocal;
} else if (offering.getTrafficType() == TrafficType.Public) {
if ((zone.getNetworkType() == NetworkType.Advanced && !zone.isSecurityGroupEnabled()) || zone.getNetworkType() == NetworkType.Basic) {
specifyIpRanges = true;
broadcastDomainType = BroadcastDomainType.Vlan;
} else {
continue;
}
}
if (broadcastDomainType != null) {
NetworkVO network = new NetworkVO(id, trafficType, mode, broadcastDomainType, networkOfferingId, domainId, accountId, related, null, null, networkDomain, Network.GuestType.Shared, zoneId, null, null, specifyIpRanges, null, offering.getRedundantRouter());
network.setGuruName(guruNames.get(network.getTrafficType()));
network.setDns1(zone.getDns1());
network.setDns2(zone.getDns2());
network.setState(State.Implemented);
_networkDao.persist(network, false, getServicesAndProvidersForNetwork(networkOfferingId));
id++;
}
}
}
}
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class ServerDBSyncImpl method syncVirtualNetwork.
/*
* Virtual Network Synchronization methods
*/
@SuppressWarnings({ "unchecked" })
public boolean syncVirtualNetwork() throws Exception {
final ApiConnector api = _manager.getApiConnector();
try {
List<TrafficType> types = new ArrayList<TrafficType>();
types.add(TrafficType.Public);
types.add(TrafficType.Guest);
List<NetworkVO> dbNets = _manager.findManagedNetworks(types);
List<VirtualNetwork> vList = (List<VirtualNetwork>) api.list(VirtualNetwork.class, null);
List<VirtualNetwork> vncList = new ArrayList<VirtualNetwork>();
for (VirtualNetwork vn : vList) {
if (!_manager.isSystemDefaultNetwork(vn)) {
vncList.add(vn);
}
}
s_logger.debug("sync VN - DB size: " + dbNets.size() + " VNC Size: " + vncList.size());
return _dbSync.syncGeneric(VirtualNetwork.class, dbNets, vncList);
} catch (Exception ex) {
s_logger.warn("sync virtual-networks", ex);
throw ex;
}
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class ContrailManagerImpl method findSystemNetworks.
@Override
public List<NetworkVO> findSystemNetworks(List<TrafficType> types) {
SearchBuilder<NetworkVO> searchBuilder = _networksDao.createSearchBuilder();
searchBuilder.and("trafficType", searchBuilder.entity().getTrafficType(), Op.IN);
SearchCriteria<NetworkVO> sc = searchBuilder.create();
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);
}
sc.setParameters("trafficType", types.toArray());
List<NetworkVO> dbNets = _networksDao.search(sc, null);
if (dbNets == null) {
s_logger.debug("no system networks for the given traffic types: " + types.toString());
dbNets = new ArrayList<NetworkVO>();
}
List<PhysicalNetworkVO> phys_list = _physicalNetworkDao.listAll();
final String provider = Provider.JuniperContrailRouter.getName();
for (Iterator<PhysicalNetworkVO> iter = phys_list.iterator(); iter.hasNext(); ) {
PhysicalNetworkVO phys = iter.next();
if (_physProviderDao.findByServiceProvider(phys.getId(), provider) != 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;
}
Aggregations