@Override public void findInfrastructureNetworks(PhysicalNetworkVO phys, List<NetworkVO> dbList) { final TrafficType[] ttypes = {TrafficType.Control, // maps to __link_local__ TrafficType.Management, // maps to ip-fabric TrafficType.Public, TrafficType.Storage // maps to ip-fabric }; for (int i = 0; i < ttypes.length; i++) { List<NetworkVO> phys_nets; phys_nets = _networksDao.listByZoneAndTrafficType(phys.getDataCenterId(), ttypes[i]); dbList.addAll(phys_nets); } }
@Override public IpAddress getPublicIpAddress(String ipAddress, long zoneId) { List<? extends Network> networks = _networksDao.listByZoneAndTrafficType(zoneId, TrafficType.Public); if (networks.isEmpty() || networks.size() > 1) { throw new CloudRuntimeException("Can't find public network in the zone specified"); } return _ipAddressDao.findByIpAndSourceNetworkId(networks.get(0).getId(), ipAddress); }
/** * 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); }
/** * 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); } }
|| (isolationMethod != null && isolationMethods.contains(isolationMethod) && isolationMethod.toLowerCase().equals("vxlan"))) { NetworkVO publicNetwork = _networksDao.listByZoneAndTrafficType(network.getDataCenterId(), TrafficType.Public).get(0); if (publicNetwork != null) { s_logger.debug("setting public network " + publicNetwork + " to broadcast type vxlan");
List<NetworkVO> nws = _networkDao.listByZoneAndTrafficType(zoneId, TrafficType.Storage); if (nws.size() == 0) { throw new CloudRuntimeException("Cannot find storage network in zone " + zoneId);
} else { TrafficType defaultTrafficType = TrafficType.Management; List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType); List<NetworkVO> publicNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, publicTrafficType);
final List<NetworkVO> guestNetworks = _networksDao.listByZoneAndTrafficType(zone.getId(), TrafficType.Guest); if (!guestNetworks.isEmpty()) { throw new InvalidParameterValueException("Can't have more than one Guest network in zone with network type " + NetworkType.Basic);