use of com.cloud.network.PhysicalNetworkTrafficType in project cloudstack by apache.
the class UpdateTrafficTypeCmd method execute.
@Override
public void execute() {
PhysicalNetworkTrafficType result = _networkService.updatePhysicalNetworkTrafficType(getId(), getXenLabel(), getKvmLabel(), getVmwareLabel(), getHypervLabel(), getOvm3Label());
if (result != null) {
TrafficTypeResponse response = _responseGenerator.createTrafficTypeResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update traffic type");
}
}
use of com.cloud.network.PhysicalNetworkTrafficType in project cloudstack by apache.
the class AddTrafficTypeCmd method create.
@Override
public void create() throws ResourceAllocationException {
PhysicalNetworkTrafficType result = _networkService.addTrafficTypeToPhysicalNetwork(getPhysicalNetworkId(), getTrafficType(), getIsolationMethod(), getXenLabel(), getKvmLabel(), getVmwareLabel(), getSimulatorLabel(), getVlan(), getHypervLabel(), getOvm3Label());
if (result != null) {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add traffic type to physical network");
}
}
use of com.cloud.network.PhysicalNetworkTrafficType in project cloudstack by apache.
the class OvsTunnelManagerImpl method getGreEndpointIP.
private String getGreEndpointIP(Host host, Network nw) throws AgentUnavailableException, OperationTimedoutException {
String endpointIp = null;
// Fetch fefault name for network label from configuration
String physNetLabel = _configDao.getValue(Config.OvsTunnelNetworkDefaultLabel.key());
Long physNetId = nw.getPhysicalNetworkId();
PhysicalNetworkTrafficType physNetTT = _physNetTTDao.findBy(physNetId, TrafficType.Guest);
HypervisorType hvType = host.getHypervisorType();
String label = null;
switch(hvType) {
case XenServer:
label = physNetTT.getXenNetworkLabel();
if ((label != null) && (!label.equals(""))) {
physNetLabel = label;
}
break;
case KVM:
label = physNetTT.getKvmNetworkLabel();
if ((label != null) && (!label.equals(""))) {
physNetLabel = label;
}
break;
default:
throw new CloudRuntimeException("Hypervisor " + hvType.toString() + " unsupported by OVS Tunnel Manager");
}
// Try to fetch GRE endpoint IP address for cloud db
// If not found, then find it on the hypervisor
OvsTunnelInterfaceVO tunnelIface = _tunnelInterfaceDao.getByHostAndLabel(host.getId(), physNetLabel);
if (tunnelIface == null) {
//Now find and fetch configuration for physical interface
//for network with label on target host
Commands fetchIfaceCmds = new Commands(new OvsFetchInterfaceCommand(physNetLabel));
s_logger.debug("Ask host " + host.getId() + " to retrieve interface for phy net with label:" + physNetLabel);
Answer[] fetchIfaceAnswers = _agentMgr.send(host.getId(), fetchIfaceCmds);
//And finally save it for future use
endpointIp = handleFetchInterfaceAnswer(fetchIfaceAnswers, host.getId());
} else {
endpointIp = tunnelIface.getIp();
}
return endpointIp;
}
use of com.cloud.network.PhysicalNetworkTrafficType in project cloudstack by apache.
the class ManagementServerMock method locatePhysicalNetwork.
private void locatePhysicalNetwork() {
// mandatory: name, zone-id
try {
long id = _networkService.findPhysicalNetworkId(_zone.getId(), "znet", TrafficType.Guest);
_znet = _networkService.getPhysicalNetwork(id);
List<PhysicalNetworkVO> nets = _physicalNetworkDao.listByZoneAndTrafficType(_zone.getId(), TrafficType.Public);
if (nets == null || nets.isEmpty()) {
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(), "vlan", null, null, null, null, null, null, null);
}
} catch (InvalidParameterValueException e) {
List<String> isolationMethods = new ArrayList<String>();
isolationMethods.add("L3VPN");
_znet = _networkService.createPhysicalNetwork(_zone.getId(), null, null, isolationMethods, BroadcastDomainRange.ZONE.toString(), _zone.getDomainId(), null, "znet");
List<PhysicalNetworkVO> nets = _physicalNetworkDao.listByZoneAndTrafficType(_zone.getId(), TrafficType.Public);
if (nets == null || nets.isEmpty()) {
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Public.toString(), "vlan", null, null, null, null, null, null, null);
}
}
if (_znet.getState() != PhysicalNetwork.State.Enabled) {
_znet = _networkService.updatePhysicalNetwork(_znet.getId(), null, null, null, PhysicalNetwork.State.Enabled.toString());
}
// Ensure that the physical network supports Guest traffic.
Pair<List<? extends PhysicalNetworkTrafficType>, Integer> trafficTypes = _networkService.listTrafficTypes(_znet.getId());
boolean found = false;
for (PhysicalNetworkTrafficType ttype : trafficTypes.first()) {
if (ttype.getTrafficType() == TrafficType.Guest) {
found = true;
}
}
if (!found) {
_networkService.addTrafficTypeToPhysicalNetwork(_znet.getId(), TrafficType.Guest.toString(), "vlan", null, null, null, null, null, null, null);
}
Pair<List<? extends PhysicalNetworkServiceProvider>, Integer> providers = _networkService.listNetworkServiceProviders(_znet.getId(), Provider.JuniperContrailRouter.getName(), null, null, null);
if (providers.second() == 0) {
s_logger.debug("Add " + Provider.JuniperContrailRouter.getName() + " to network " + _znet.getName());
PhysicalNetworkServiceProvider provider = _networkService.addProviderToPhysicalNetwork(_znet.getId(), Provider.JuniperContrailRouter.getName(), null, null);
_networkService.updateNetworkServiceProvider(provider.getId(), PhysicalNetworkServiceProvider.State.Enabled.toString(), null);
} else {
PhysicalNetworkServiceProvider provider = providers.first().get(0);
if (provider.getState() != PhysicalNetworkServiceProvider.State.Enabled) {
_networkService.updateNetworkServiceProvider(provider.getId(), PhysicalNetworkServiceProvider.State.Enabled.toString(), null);
}
}
providers = _networkService.listNetworkServiceProviders(_znet.getId(), null, PhysicalNetworkServiceProvider.State.Enabled.toString(), null, null);
s_logger.debug(_znet.getName() + " has " + providers.second().toString() + " Enabled providers");
for (PhysicalNetworkServiceProvider provider : providers.first()) {
if (provider.getProviderName().equals(Provider.JuniperContrailRouter.getName())) {
continue;
}
s_logger.debug("Disabling " + provider.getProviderName());
_networkService.updateNetworkServiceProvider(provider.getId(), PhysicalNetworkServiceProvider.State.Disabled.toString(), null);
}
}
Aggregations