protected boolean canUpgrade(Network network, long oldNetworkOfferingId, long newNetworkOfferingId) { NetworkOffering oldNetworkOffering = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId); NetworkOffering newNetworkOffering = _networkOfferingDao.findById(newNetworkOfferingId); // security group service should be the same if (areServicesSupportedByNetworkOffering(oldNetworkOfferingId, Service.SecurityGroup) != areServicesSupportedByNetworkOffering(newNetworkOfferingId, Service.SecurityGroup)) { s_logger.debug("Offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different securityGroupProperty, can't upgrade"); return false; } // tags should be the same if (newNetworkOffering.getTags() != null) { if (oldNetworkOffering.getTags() == null) { s_logger.debug("New network offering id=" + newNetworkOfferingId + " has tags and old network offering id=" + oldNetworkOfferingId + " doesn't, can't upgrade"); return false; } if (!StringUtils.areTagsEqual(oldNetworkOffering.getTags(), newNetworkOffering.getTags())) { s_logger.debug("Network offerings " + newNetworkOffering.getUuid() + " and " + oldNetworkOffering.getUuid() + " have different tags, can't upgrade"); return false; } } // specify vlan should be the same if (oldNetworkOffering.isSpecifyVlan() != newNetworkOffering.isSpecifyVlan()) { s_logger.debug("Network offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different values for specifyVlan, can't upgrade"); return false; } return canMoveToPhysicalNetwork(network, oldNetworkOfferingId, newNetworkOfferingId); }
@Override public boolean areServicesEnabledInZone(long zoneId, NetworkOffering offering, List<Service> services) { long physicalNtwkId = findPhysicalNetworkId(zoneId, offering.getTags(), offering.getTrafficType()); boolean result = true; List<String> checkedProvider = new ArrayList<String>(); for (Service service : services) { // get all the providers, and check if each provider is enabled List<String> providerNames = _ntwkOfferingSrvcDao.listProvidersForServiceForNetworkOffering(offering.getId(), service); for (String providerName : providerNames) { if (!checkedProvider.contains(providerName)) { result = result && isProviderEnabledInPhysicalNetwork(physicalNtwkId, providerName); } } } return result; }
@Override public Long getPhysicalNetworkId(Network network) { if (network.getTrafficType() != TrafficType.Guest) { return getNonGuestNetworkPhysicalNetworkId(network); } Long physicalNetworkId = network.getPhysicalNetworkId(); NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId()); if (physicalNetworkId == null) { physicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), offering.getTags(), offering.getTrafficType()); } return physicalNetworkId; }
public Long getPhysicalNetworkId() { NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, networkOfferingId); if (offering == null) { throw new InvalidParameterValueException("Unable to find network offering by ID " + networkOfferingId); } if (physicalNetworkId != null) { if (offering.getGuestType() == GuestType.Shared) { return physicalNetworkId; } else { throw new InvalidParameterValueException("Physical network OD can be specified for networks of guest IP type " + GuestType.Shared + " only."); } } else { if (zoneId == null) { throw new InvalidParameterValueException("ZoneId is required as physicalNetworkId is null"); } return _networkService.findPhysicalNetworkId(zoneId, offering.getTags(), offering.getTrafficType()); } }
@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); }
@Override @ActionEvent(eventType = EventTypes.EVENT_NETWORK_MIGRATE, eventDescription = "migrating network", async = true) public Network migrateGuestNetwork(long networkId, long networkOfferingId, Account callerAccount, User callerUser, boolean resume) { NetworkVO network = _networksDao.findById(networkId); NetworkOffering newNtwkOff = _networkOfferingDao.findById(networkOfferingId); //perform below validation if the network is vpc network if (network.getVpcId() != null) { s_logger.warn("Failed to migrate network as the specified network is a vpc tier. Use migrateVpc."); throw new InvalidParameterValueException("Failed to migrate network as the specified network is a vpc tier. Use migrateVpc."); } if (_configMgr.isOfferingForVpc(newNtwkOff)) { s_logger.warn("Failed to migrate network as the specified network offering is a VPC offering"); throw new InvalidParameterValueException("Failed to migrate network as the specified network offering is a VPC offering"); } verifyNetworkCanBeMigrated(callerAccount, network); //Retrieve new Physical NetworkId long newPhysicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), newNtwkOff.getTags(), newNtwkOff.getTrafficType()); final long oldNetworkOfferingId = network.getNetworkOfferingId(); NetworkOffering oldNtwkOff = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId); if (!resume && network.getRelated() != network.getId()) { s_logger.warn("Related network is not equal to network id. You might want to re-run migration with resume = true command."); throw new CloudRuntimeException("Failed to migrate network as previous migration left this network in transient condition. Specify resume as true."); } if (networkNeedsMigration(network, newPhysicalNetworkId, oldNtwkOff, newNtwkOff)) { return migrateNetworkToPhysicalNetwork(network, oldNtwkOff, newNtwkOff, null, null, newPhysicalNetworkId, callerAccount, callerUser); } else { s_logger.info("Network does not need migration."); return network; } }
physicalNetworkId = networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
physicalNetworkId = networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
offering.getTags(), offering.getTrafficType());
response.setName(offering.getName()); response.setDisplayText(offering.getDisplayText()); response.setTags(offering.getTags()); response.setTrafficType(offering.getTrafficType().toString()); response.setIsDefault(offering.isDefault());
@Override public Network implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context) throws InsufficientVirtualNetworkCapacityException { assert network.getState() == State.Implementing : "Why are we implementing " + network; final long dcId = dest.getDataCenter().getId(); //get physical network id Long physicalNetworkId = network.getPhysicalNetworkId(); // physical network id can be null in Guest Network in Basic zone, so locate the physical network if (physicalNetworkId == null) { physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType()); } final NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated, network.getDataCenterId(), physicalNetworkId, offering.isRedundantRouter()); allocateVnet(network, implemented, dcId, physicalNetworkId, context.getReservationId()); if (network.getGateway() != null) { implemented.setGateway(network.getGateway()); } if (network.getCidr() != null) { implemented.setCidr(network.getCidr()); } return implemented; }
@Override public Network implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException { assert (network.getState() == State.Implementing) : "Why are we implementing " + network; long dcId = dest.getDataCenter().getId(); //get physical network id Long physicalNetworkId = network.getPhysicalNetworkId(); // physical network id can be null in Guest Network in Basic zone, so locate the physical network if (physicalNetworkId == null) { physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType()); } NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated, network.getDataCenterId(), physicalNetworkId, offering.isRedundantRouter()); allocateVnet(network, implemented, dcId, physicalNetworkId, context.getReservationId()); if (network.getGateway() != null) { implemented.setGateway(network.getGateway()); } if (network.getCidr() != null) { implemented.setCidr(network.getCidr()); } return implemented; }
long physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
Long physicalNetworkId = _networkModel.findPhysicalNetworkId(zone.getId(), ntwkOffering.getTags(), ntwkOffering.getTrafficType());
public Long getPhysicalNetworkId() { final NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, networkOfferingId); if (offering == null) { throw new InvalidParameterValueException("Unable to find network offering by ID " + networkOfferingId); } if (physicalNetworkId != null) { if (offering.getGuestType() == GuestType.Shared) { return physicalNetworkId; } else { throw new InvalidParameterValueException("Physical network OD can be specified for networks of guest IP type " + GuestType.Shared + " only."); } } else { if (zoneId == null) { throw new InvalidParameterValueException("ZoneId is required as physicalNetworkId is null"); } return _networkService.findPhysicalNetworkId(zoneId, offering.getTags(), offering.getTrafficType()); } }