use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class ContrailManagerImpl method initializeDefaultVirtualNetworkModels.
private void initializeDefaultVirtualNetworkModels() {
List<TrafficType> types = new ArrayList<TrafficType>();
types.add(TrafficType.Management);
types.add(TrafficType.Storage);
types.add(TrafficType.Control);
List<NetworkVO> dbNets = findManagedNetworks(types);
for (NetworkVO net : dbNets) {
VirtualNetworkModel vnModel = getDatabase().lookupVirtualNetwork(null, getCanonicalName(net), net.getTrafficType());
if (vnModel == null) {
vnModel = new VirtualNetworkModel(net, null, getCanonicalName(net), net.getTrafficType());
vnModel.build(getModelController(), net);
try {
if (!vnModel.verify(getModelController())) {
vnModel.update(getModelController());
}
} catch (Exception ex) {
s_logger.warn("virtual-network update: ", ex);
}
getDatabase().getVirtualNetworks().add(vnModel);
}
}
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class NetworkModelImpl method getNetworkTag.
@Override
public String getNetworkTag(HypervisorType hType, Network network) {
// no network tag for control traffic type
TrafficType effectiveTrafficType = network.getTrafficType();
if (hType == HypervisorType.VMware && effectiveTrafficType == TrafficType.Control)
effectiveTrafficType = TrafficType.Management;
if (effectiveTrafficType == TrafficType.Control) {
return null;
}
Long physicalNetworkId = null;
if (effectiveTrafficType != TrafficType.Guest) {
physicalNetworkId = getNonGuestNetworkPhysicalNetworkId(network, effectiveTrafficType);
} else {
NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
physicalNetworkId = network.getPhysicalNetworkId();
if (physicalNetworkId == null) {
physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags(), offering.getTrafficType());
}
}
if (physicalNetworkId == null) {
assert (false) : "Can't get the physical network";
s_logger.warn("Can't get the physical network");
return null;
}
return _pNTrafficTypeDao.getNetworkTag(physicalNetworkId, effectiveTrafficType, hType);
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
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 ConsoleProxyManagerImpl method getDefaultNetworkForAdvancedZone.
/**
* Get default network for a console proxy VM starting up in an advanced zone. If the zone
* is security group-enabled, the first network found that supports SG services is returned.
* If the zone is not SG-enabled, the Public network is returned.
* @param dc - The zone.
* @return The selected default network.
* @throws CloudRuntimeException - If the zone is not a valid choice or a network couldn't be found.
*/
protected NetworkVO getDefaultNetworkForAdvancedZone(DataCenter dc) {
if (dc.getNetworkType() != NetworkType.Advanced) {
throw new CloudRuntimeException("Zone " + dc + " is not advanced.");
}
if (dc.isSecurityGroupEnabled()) {
List<NetworkVO> networks = _networkDao.listByZoneSecurityGroup(dc.getId());
if (CollectionUtils.isEmpty(networks)) {
throw new CloudRuntimeException("Can not found security enabled network in SG Zone " + dc);
}
return networks.get(0);
} else {
TrafficType defaultTrafficType = TrafficType.Public;
List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dc.getId(), defaultTrafficType);
// api should never allow this situation to happen
if (defaultNetworks.size() != 1) {
throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type " + defaultTrafficType + " when expect to find 1");
}
return defaultNetworks.get(0);
}
}
use of com.cloud.network.Networks.TrafficType in project cloudstack by apache.
the class ConsoleProxyManagerImpl method getDefaultNetworkForBasicZone.
/**
* Get default network for console proxy VM for starting up in a basic zone. Basic zones select
* the Guest network whether or not the zone is SG-enabled.
* @param dc - The zone.
* @return The default network according to the zone's network selection rules.
* @throws CloudRuntimeException - If the zone is not a valid choice or a network couldn't be found.
*/
protected NetworkVO getDefaultNetworkForBasicZone(DataCenter dc) {
if (dc.getNetworkType() != NetworkType.Basic) {
throw new CloudRuntimeException("Zone " + dc + "is not basic.");
}
TrafficType defaultTrafficType = TrafficType.Guest;
List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dc.getId(), defaultTrafficType);
// api should never allow this situation to happen
if (defaultNetworks.size() != 1) {
throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type " + defaultTrafficType + " when expect to find 1");
}
return defaultNetworks.get(0);
}
Aggregations