public static NetworkOfferingVO findNetworkOfferingById(long networkOfferingId) { return s_networkOfferingDao.findByIdIncludingRemoved(networkOfferingId); }
@Override public boolean isNetworkSystem(Network network) { NetworkOffering no = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); if (no.isSystemOnly()) { return true; } else { return false; } }
protected boolean isNetworkSystem(Network network) { NetworkOffering no = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); if (no.isSystemOnly()) { return true; } else { return false; } }
@Override public boolean restartNetwork(final Long networkId, final Account callerAccount, final User callerUser, final boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { final NetworkVO network = _networksDao.findById(networkId); s_logger.debug("Restarting network " + networkId + "..."); final ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount); final NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); final DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null); if (cleanup) { if (!rollingRestartRouters(network, offering, dest, context)) { setRestartRequired(network, true); return false; } return true; } s_logger.debug("Implementing the network " + network + " elements and resources as a part of network restart without cleanup"); try { implementNetworkElementsAndResources(dest, context, network, offering); setRestartRequired(network, true); return true; } catch (final Exception ex) { s_logger.warn("Failed to implement network " + network + " elements and resources as a part of network restart due to ", ex); return false; } }
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); }
private void verifyNetworkCanBeMigrated(Account callerAccount, Network network) { // Don't allow to update system network NetworkOffering oldOffering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); if (oldOffering.isSystemOnly()) { throw new InvalidParameterValueException("Failed to migrate network as the specified network is a system network."); } // allow to upgrade only Guest networks if (network.getTrafficType() != TrafficType.Guest) { throw new InvalidParameterValueException("Can't allow networks which traffic type is not " + TrafficType.Guest); } _accountMgr.checkAccess(callerAccount, null, true, network); boolean validateNetworkReadyToMigrate = (network.getState() == Network.State.Implemented || network.getState() == Network.State.Setup || network.getState() == Network.State.Allocated); if (!validateNetworkReadyToMigrate) { s_logger.error("Failed to migrate network as it is in invalid state."); CloudRuntimeException ex = new CloudRuntimeException("Failed to migrate network as it is in invalid state."); ex.addProxyObject(network.getUuid(), "networkId"); throw ex; } }
@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; } }
private boolean canMoveToPhysicalNetwork(Network network, long oldNetworkOfferingId, long newNetworkOfferingId) { NetworkOffering oldNetworkOffering = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId); NetworkOffering newNetworkOffering = _networkOfferingDao.findById(newNetworkOfferingId);
private void vpcTiersCanBeMigrated(List<? extends Network> tiersInVpc, Account account, Map<String, String> networkToOffering, boolean resume) { for (Network network : tiersInVpc) { String networkOfferingUuid = networkToOffering.get(network.getUuid()); //offering uuid can be a tier where the uuid is previously already swapped in a previous migration if (resume && networkOfferingUuid == null) { NetworkVO oldVPCtier = _networksDao.findById(network.getRelated()); networkOfferingUuid = networkToOffering.get(oldVPCtier.getUuid()); } if (networkOfferingUuid == null) { throwInvalidIdException("Failed to migrate VPC as the specified tierNetworkOfferings is not complete", String.valueOf(network.getUuid()), "networkUuid"); } NetworkOfferingVO newNtwkOff = _networkOfferingDao.findByUuid(networkOfferingUuid); if (newNtwkOff == null) { throwInvalidIdException("Failed to migrate VPC as at least one network offering in tierNetworkOfferings does not exist", networkOfferingUuid, "networkOfferingUuid"); } if (!_configMgr.isOfferingForVpc(newNtwkOff)) { throw new InvalidParameterValueException( "Network offering " + newNtwkOff.getName() + " (" + newNtwkOff.getUuid() + ") can't be used for VPC networks for network " + network.getName() + "(" + network.getUuid() + ")"); } verifyNetworkCanBeMigrated(account, network); long newPhysicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), newNtwkOff.getTags(), newNtwkOff.getTrafficType()); final long oldNetworkOfferingId = network.getNetworkOfferingId(); NetworkOffering oldNtwkOff = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId); networkNeedsMigration(network, newPhysicalNetworkId, oldNtwkOff, newNtwkOff); } }
final NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); if (offering.isSystemOnly()) { throw new InvalidParameterValueException("Can't update system networks");
NetworkOffering oldNtwkOff = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId);
s_logger.debug("upgrading network to network with new offering."); NetworkVO network = _networksDao.findById(networkId); NetworkOffering newOffering = _networkOfferingDao.findByIdIncludingRemoved(networkOfferingId); long gurusImplementing = 0; network.setBroadcastUri(null);
NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); if (offering.isSystemOnly()) { throw new InvalidParameterValueException("Can't update system networks"); NetworkOffering oldNtwkOff = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId); NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId); if (networkOfferingId != null) {
NetworkOfferingVO offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId()); if (offering == null) { throw new InvalidParameterValueException("There is no network offering with the network");