private DomainRouterVO deployLoadBalancerVM(final Long networkId, final IPAddressVO ipAddr) { final NetworkVO network = _networkDao.findById(networkId); final DataCenter dc = _dcDao.findById(network.getDataCenterId()); final Long podId = getPodIdForDirectIp(ipAddr); final Pod pod = podId == null ? null : _podDao.findById(podId); final Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1); params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true); final Account owner = _accountService.getActiveAccountByName("system", new Long(1)); final DeployDestination dest = new DeployDestination(dc, pod, null, null); s_logger.debug("About to deploy ELB vm "); try { final DomainRouterVO elbVm = deployELBVm(network, dest, owner, params); if (elbVm == null) { throw new InvalidParameterValueException("Could not deploy or find existing ELB VM"); } s_logger.debug("Deployed ELB vm = " + elbVm); return elbVm; } catch (final Throwable t) { s_logger.warn("Error while deploying ELB VM: ", t); return null; } }
boolean isNetworkImplemented(final NetworkVO network) { final Network.State state = network.getState(); if (state == Network.State.Implemented) { return true; } else if (state == Network.State.Setup) { final DataCenterVO zone = _dcDao.findById(network.getDataCenterId()); if (!isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) || zone.getNetworkType() == NetworkType.Basic) { return true; } } return false; }
@Override public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) { NetworkVO network = _networkDao.findById(nic.getNetworkId()); if (network != null && _networkModel.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) { return true; } else { return super.release(nic, vm, reservationId); } }
@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; } }
final NetworkVO guestNetwork = _networkDao.findById(guestNetworkId); String dhcpRange = null; final DataCenterVO dc = _dcDao.findById(guestNetwork.getDataCenterId());
private boolean implement(Long vpcId, long physicalNetworkId, VspNetwork vspNetwork, NetworkVO implemented, VspDhcpDomainOption vspDhcpDomainOption) { HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(physicalNetworkId); final boolean isVsdManaged = vspNetwork.getNetworkRelatedVsdIds() .getVsdSubnetId() .isPresent(); if (isVsdManaged) { //Implement cmd was already send in design step. _dcDetailsDao.persist(implemented.getDataCenterId(), vspNetwork.getNetworkRelatedVsdIds().getVsdSubnetId().orElseThrow(() -> new CloudRuntimeException("Managed but no subnetId. How can this happen?")), implemented.getUuid()); return true; } ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, vspDhcpDomainOption, false); Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); if (answer == null || !answer.getResult()) { s_logger.error("ImplementNetworkVspCommand for network " + vspNetwork.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname")); if ((null != answer) && (null != answer.getDetails())) { s_logger.error(answer.getDetails()); } return false; } ImplementNetworkVspAnswer implementAnswer = (ImplementNetworkVspAnswer) answer; saveNetworkAndVpcDetails(vspNetwork, implementAnswer.getNetworkRelatedVsdIds(), vpcId); return true; }
@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; } }
final DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId()); if (zone.getNetworkType() == NetworkType.Basic) { final List<VMInstanceVO> systemVms = _vmDao.listNonRemovedVmsByTypeAndNetwork(network.getId(), Type.ConsoleProxy, Type.SecondaryStorageVm);
if (_networkModel.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) { _externalDeviceUsageMgr.updateExternalLoadBalancerNetworkUsageStats(loadBalancerId);
final DataCenterVO zone = _dcDao.findById(networkFinal.getDataCenterId()); if (isSharedNetworkOfferingWithServices(networkFinal.getNetworkOfferingId()) && zone.getNetworkType() == NetworkType.Advanced) { networkFinal.setState(Network.State.Setup);
final DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId()); final Host host = _hostDao.findById(vm.getHostId()); final DeployDestination dest = new DeployDestination(dc, null, null, host);
sb.join("zoneSearch", zoneSearch, sb.entity().getDataCenterId(), zoneSearch.entity().getId(), JoinBuilder.JoinType.INNER); sb.and("removed", sb.entity().getRemoved(), Op.NULL);
long zoneId = netVO.getDataCenterId(); String vmwareVswitchLabel = _networkModel.getDefaultGuestTrafficLabel(zoneId, HypervisorType.VMware); String[] labelArray = null;
DataCenter dc = _dcDao.findById(network.getDataCenterId()); String networkCidr = network.getNetworkCidr(); DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null); s_logger.debug("Implementing the network " + network + " elements and resources as a part of network update"); try { if (network.getState() == Network.State.Allocated) { try { DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null); _networkMgr.implementNetwork(network.getId(), dest, context); } catch (Exception ex) {
if (network.getDataCenterId() != vmInstance.getDataCenterId()) { throw new CloudRuntimeException(vmInstance + " is in zone:" + vmInstance.getDataCenterId() + " but " + network + " is in zone:" + network.getDataCenterId());
network.setBroadcastUri(null); AccountVO networkAccount = _accountDao.findById(network.getAccountId()); DataCenterDeployment plan = new DataCenterDeployment(network.getDataCenterId(), null, null, null, null, newPhysicalNetworkId); for (final NetworkGuru guru : _networkMgr.getNetworkGurus()) {
boolean vpcNetwork = false; for (NetworkVO network : networkList) { if ((network.getDataCenterId() != zone.getId())) { if (!network.isStrechedL2Network()) { throw new InvalidParameterValueException("Network id=" + network.getId() +
AllFieldsSearch.and("broadcastType", AllFieldsSearch.entity().getBroadcastDomainType(), Op.EQ); AllFieldsSearch.and("offering", AllFieldsSearch.entity().getNetworkOfferingId(), Op.EQ); AllFieldsSearch.and("datacenter", AllFieldsSearch.entity().getDataCenterId(), Op.EQ); AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ); AllFieldsSearch.and("related", AllFieldsSearch.entity().getRelated(), Op.EQ); join.and("account", join.entity().getAccountId(), Op.EQ); AccountSearch.join("accounts", join, AccountSearch.entity().getId(), join.entity().getNetworkId(), JoinBuilder.JoinType.INNER); AccountSearch.and("datacenter", AccountSearch.entity().getDataCenterId(), Op.EQ); AccountSearch.and("cidr", AccountSearch.entity().getCidr(), Op.EQ); AccountSearch.and("vpcId", AccountSearch.entity().getVpcId(), Op.EQ); RelatedConfigSearch.and("datacenter", RelatedConfigSearch.entity().getDataCenterId(), Op.EQ); final SearchBuilder<NetworkAccountVO> join2 = _accountsDao.createSearchBuilder(); join2.and("account", join2.entity().getAccountId(), Op.EQ); ZoneBroadcastUriSearch.and("dataCenterId", ZoneBroadcastUriSearch.entity().getDataCenterId(), Op.EQ); ZoneBroadcastUriSearch.and("broadcastUri", ZoneBroadcastUriSearch.entity().getBroadcastUri(), Op.EQ); ZoneBroadcastUriSearch.and("guestType", ZoneBroadcastUriSearch.entity().getGuestType(), Op.EQ); ZoneSecurityGroupSearch.and("dataCenterId", ZoneSecurityGroupSearch.entity().getDataCenterId(), Op.EQ); final SearchBuilder<NetworkServiceMapVO> offJoin = _ntwkSvcMap.createSearchBuilder(); offJoin.and("service", offJoin.entity().getService(), Op.EQ); SourceNATSearch.and("datacenter", SourceNATSearch.entity().getDataCenterId(), Op.EQ); SourceNATSearch.and("guestType", SourceNATSearch.entity().getGuestType(), Op.EQ); final SearchBuilder<NetworkServiceMapVO> join6 = _ntwkSvcMap.createSearchBuilder(); OfferingAccountNetworkSearch.join("ntwkAccountSearch", ntwkAccountJoin, OfferingAccountNetworkSearch.entity().getId(), ntwkAccountJoin.entity().getNetworkId(),