use of com.cloud.model.enumeration.TrafficType in project cosmic by MissionCriticalCloud.
the class SystemVmManagerBase method getNetworkForBasicZone.
protected static NetworkVO getNetworkForBasicZone(final Zone zone, final NetworkDao _networkDao) {
if (zone.getNetworkType() != NetworkType.Basic) {
throw new CloudRuntimeException("Zone " + zone + " is not basic.");
}
final TrafficType defaultTrafficType = TrafficType.Guest;
final List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(zone.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.model.enumeration.TrafficType in project cosmic by MissionCriticalCloud.
the class DomainRouterJoinDaoImpl method newDomainRouterResponse.
@Override
public DomainRouterResponse newDomainRouterResponse(final DomainRouterJoinVO router, final Account caller) {
final DomainRouterResponse routerResponse = new DomainRouterResponse();
routerResponse.setId(router.getUuid());
routerResponse.setZoneId(router.getDataCenterUuid());
routerResponse.setName(router.getName());
routerResponse.setTemplateId(router.getTemplateUuid());
routerResponse.setCreated(router.getCreated());
routerResponse.setState(router.getState());
routerResponse.setIsRedundantRouter(router.isRedundantRouter());
routerResponse.setRedundantState(router.getRedundantState().toString());
if (router.getLastStartDateTime() != null) {
routerResponse.setLastStartDateTime(router.getLastStartDateTime());
}
if (router.getLastStartVersion() != null) {
routerResponse.setLastStartVersion(router.getLastStartVersion());
}
if (router.getRouterUnicastId() != null) {
routerResponse.setRouterUnicastId(router.getRouterUnicastId());
}
if (router.getTemplateVersion() != null) {
final String routerVersion = Version.trimRouterVersion(router.getTemplateVersion());
routerResponse.setVersion(routerVersion);
routerResponse.setRequiresUpgrade((Version.compare(routerVersion, NetworkOrchestrationService.MinVRVersion.valueIn(router.getDataCenterId())) < 0));
} else {
routerResponse.setVersion("UNKNOWN");
routerResponse.setRequiresUpgrade(true);
}
if (_accountMgr.isRootAdmin(caller.getId()) || (_accountMgr.isDomainAdmin(caller.getId()))) {
if (router.getHostId() != null) {
routerResponse.setHostId(router.getHostUuid());
routerResponse.setHostName(router.getHostName());
routerResponse.setHypervisor(router.getHypervisorType().toString());
}
routerResponse.setPodId(router.getPodUuid());
final long nic_id = router.getNicId();
if (nic_id > 0) {
final TrafficType ty = router.getTrafficType();
if (ty != null) {
// nics response object
if (ty == TrafficType.Public) {
routerResponse.setPublicIp(router.getIpAddress());
routerResponse.setPublicMacAddress(router.getMacAddress());
routerResponse.setPublicNetmask(router.getNetmask());
routerResponse.setGateway(router.getGateway());
routerResponse.setPublicNetworkId(router.getNetworkUuid());
} else if (ty == TrafficType.Control) {
routerResponse.setLinkLocalIp(router.getIpAddress());
routerResponse.setLinkLocalMacAddress(router.getMacAddress());
routerResponse.setLinkLocalNetmask(router.getNetmask());
routerResponse.setLinkLocalNetworkId(router.getNetworkUuid());
} else if (ty == TrafficType.Guest) {
routerResponse.setGuestIpAddress(router.getIpAddress());
routerResponse.setGuestMacAddress(router.getMacAddress());
routerResponse.setGuestNetmask(router.getNetmask());
routerResponse.setGuestNetworkId(router.getNetworkUuid());
routerResponse.setGuestNetworkName(router.getNetworkName());
routerResponse.setNetworkDomain(router.getNetworkDomain());
}
}
final NicResponse nicResponse = new NicResponse();
nicResponse.setId(router.getNicUuid());
nicResponse.setIpaddress(router.getIpAddress());
nicResponse.setGateway(router.getGateway());
nicResponse.setNetmask(router.getNetmask());
nicResponse.setNetworkid(router.getNetworkUuid());
nicResponse.setNetworkName(router.getNetworkName());
nicResponse.setMacAddress(router.getMacAddress());
nicResponse.setIp6Address(router.getIp6Address());
nicResponse.setIp6Gateway(router.getIp6Gateway());
nicResponse.setIp6Cidr(router.getIp6Cidr());
if (router.getBroadcastUri() != null) {
nicResponse.setBroadcastUri(router.getBroadcastUri().toString());
}
if (router.getIsolationUri() != null) {
nicResponse.setIsolationUri(router.getIsolationUri().toString());
}
if (router.getTrafficType() != null) {
nicResponse.setTrafficType(router.getTrafficType().toString());
}
if (router.getGuestType() != null) {
nicResponse.setType(router.getGuestType().toString());
}
nicResponse.setIsDefault(router.isDefaultNic());
nicResponse.setObjectName("nic");
routerResponse.addNic(nicResponse);
}
}
routerResponse.setServiceOfferingId(router.getServiceOfferingUuid());
routerResponse.setServiceOfferingName(router.getServiceOfferingName());
// populate owner.
ApiResponseHelper.populateOwner(routerResponse, router);
routerResponse.setDomainId(router.getDomainUuid());
routerResponse.setDomainName(router.getDomainName());
routerResponse.setZoneName(router.getDataCenterName());
routerResponse.setDns1(router.getDns1());
routerResponse.setDns2(router.getDns2());
routerResponse.setIp6Dns1(router.getIp6Dns1());
routerResponse.setIp6Dns2(router.getIp6Dns2());
routerResponse.setVpcId(router.getVpcUuid());
routerResponse.setVpcName(router.getVpcName());
routerResponse.setRole(router.getRole().toString());
// set async job
if (router.getJobId() != null) {
routerResponse.setJobId(router.getJobUuid());
routerResponse.setJobStatus(router.getJobStatus());
}
routerResponse.setObjectName("router");
return routerResponse;
}
use of com.cloud.model.enumeration.TrafficType in project cosmic by MissionCriticalCloud.
the class CommandSetupHelper method configureInterfacesAndIps.
private void configureInterfacesAndIps(final VirtualRouter router, final List<Nic> nicsToExclude, final List<Ip> ipsToExclude, final NetworkOverviewTO networkOverviewTO, final List<NetworkOverviewTO.InterfaceTO> interfacesTO, final List<NetworkOverviewTO.ServiceTO.ServiceSourceNatTO> serviceSourceNatsTO) {
final List<NicVO> nics = _nicDao.listByVmId(router.getId());
nics.stream().filter(nic -> !nicsToExclude.contains(nic)).forEach(nic -> {
final NetworkOverviewTO.InterfaceTO interfaceTO = new NetworkOverviewTO.InterfaceTO();
interfaceTO.setMacAddress(nic.getMacAddress());
final List<NetworkOverviewTO.InterfaceTO.IPv4AddressTO> ipv4Addresses = new ArrayList<>();
if (StringUtils.isNotBlank(nic.getIPv4Address()) && StringUtils.isNotBlank(nic.getIPv4Netmask())) {
ipv4Addresses.add(new NetworkOverviewTO.InterfaceTO.IPv4AddressTO(NetUtils.getIpv4AddressWithCidrSize(nic.getIPv4Address(), nic.getIPv4Netmask()), nic.getIPv4Gateway()));
}
final NetworkVO network = _networkDao.findById(nic.getNetworkId());
if (network != null) {
final TrafficType trafficType = network.getTrafficType();
if (TrafficType.Public.equals(trafficType)) {
ipv4Addresses.addAll(_ipAddressDao.listByVpc(router.getVpcId(), false).stream().filter(ipAddressVO -> !ipsToExclude.contains(ipAddressVO.getAddress()) && ipAddressVO.getAssociatedWithNetworkId() != null).map(ipAddressVO -> {
final Ip ip = ipAddressVO.getAddress();
final VlanVO vlanVO = _vlanDao.findById(ipAddressVO.getVlanId());
return new NetworkOverviewTO.InterfaceTO.IPv4AddressTO(NetUtils.getIpv4AddressWithCidrSize(ip.addr(), vlanVO.getVlanNetmask()), nic.getIPv4Gateway());
}).collect(Collectors.toList()));
serviceSourceNatsTO.addAll(_ipAddressDao.listByVpc(router.getVpcId(), true).stream().map(IPAddressVO::getAddress).filter(ip -> !ipsToExclude.contains(ip)).map(Ip::addr).map(ip -> new NetworkOverviewTO.ServiceTO.ServiceSourceNatTO(ip, nic.getIPv4Gateway())).collect(Collectors.toList()));
}
interfaceTO.setMetadata(new NetworkOverviewTO.InterfaceTO.MetadataTO(network));
}
interfaceTO.setIpv4Addresses(ipv4Addresses.toArray(new NetworkOverviewTO.InterfaceTO.IPv4AddressTO[ipv4Addresses.size()]));
interfacesTO.add(interfaceTO);
});
networkOverviewTO.setInterfaces(interfacesTO.toArray(new NetworkOverviewTO.InterfaceTO[interfacesTO.size()]));
}
use of com.cloud.model.enumeration.TrafficType in project cosmic by MissionCriticalCloud.
the class LibvirtVifDriverTest method testEmptyTrafficType.
@Test
public void testEmptyTrafficType() throws ConfigurationException {
final Map<String, Object> params = new HashMap<>();
params.put(this.LibVirtVifDriver + ".", this.FakeVifDriverClassName);
this.res.setBridgeType(BridgeType.NATIVE);
configure(params);
// Set all traffic types to use default, because bad traffic type should be ignored
for (final TrafficType trafficType : TrafficType.values()) {
this.assertions.put(trafficType, this.bridgeVifDriver);
}
checkAssertions();
}
use of com.cloud.model.enumeration.TrafficType in project cosmic by MissionCriticalCloud.
the class LibvirtVifDriverTest method testOverrideSomeTrafficTypes.
@Test
public void testOverrideSomeTrafficTypes() throws ConfigurationException {
final Map<String, Object> params = new HashMap<>();
params.put(this.LibVirtVifDriver + "." + "Public", this.FakeVifDriverClassName);
params.put(this.LibVirtVifDriver + "." + "Guest", LibvirtComputingResource.DEFAULT_OVS_VIF_DRIVER_CLASS);
this.res.setBridgeType(BridgeType.NATIVE);
configure(params);
// Initially, set all traffic types to use default
for (final TrafficType trafficType : TrafficType.values()) {
this.assertions.put(trafficType, this.bridgeVifDriver);
}
this.assertions.put(TrafficType.Public, this.fakeVifDriver);
this.assertions.put(TrafficType.Guest, this.ovsVifDriver);
checkAssertions();
}
Aggregations