@Override @DB public Network getNetwork(long id) { return _networksDao.findById(id); }
@Override @DB public Network getNetwork(long id) { return _networksDao.findById(id); }
private boolean isRollBackAllowedForProvider(LoadBalancerVO loadBalancer) { Network network = _networkDao.findById(loadBalancer.getNetworkId()); List<Provider> provider = _networkMgr.getProvidersForServiceInNetwork(network, Service.Lb); if (provider == null || provider.size() == 0) { return false; } if (provider.get(0) == Provider.Netscaler || provider.get(0) == Provider.F5BigIp || provider.get(0) == Provider.VirtualRouter) { return true; } return false; }
@Override public Network getDefaultNetworkForVm(long vmId) { Nic defaultNic = getDefaultNic(vmId); if (defaultNic == null) { return null; } else { return _networksDao.findById(defaultNic.getNetworkId()); } }
@Override public boolean isSharedNetworkWithoutServices (long networkId) { Network network = _networksDao.findById(networkId); if (network != null && network.getGuestType() != GuestType.Shared) { return false; } List<Service> services = listNetworkOfferingServices(network.getNetworkOfferingId()); if (services == null || services.isEmpty()) { return true; } return false; }
private void loadVmNetworks(VMEntityVO dbVO) { List<Long> networksIds = _vmNetworkMapDao.getNetworks(dbVO.getId()); List<String> networks = new ArrayList<String>(); for (Long networkId : networksIds) { NetworkVO network = _networkDao.findById(networkId); if (network != null) { networks.add(network.getUuid()); } } dbVO.setNetworkIds(networks); }
public Network retrievePrivateNetwork(final NetworkTopologyVisitor visitor) { // This network might be the same we have already as an instance in the // RuleApplier super class. // Just doing this here, but will double check is remove if it's not // needed. final NetworkDao networkDao = visitor.getVirtualNetworkApplianceFactory().getNetworkDao(); final Network network = networkDao.findById(_nicProfile.getNetworkId()); return network; }
private boolean getDefaultHasDns(Map<Long, Boolean> cache, Nic nic) { Long networkId = nic.isDefaultNic() ? Long.valueOf(nic.getNetworkId()) : getDefaultNetwork(nic.getInstanceId()); Boolean hasDns = cache.computeIfAbsent(networkId, k -> networkHasDns(_networkDao.findById(networkId))); return hasDns; }
@Override public String getNextAvailableMacAddressInNetwork(long networkId) throws InsufficientAddressCapacityException { NetworkVO network = _networksDao.findById(networkId); String mac = _networksDao.getNextAvailableMacAddress(networkId, MACIdentifier.value()); if (mac == null) { throw new InsufficientAddressCapacityException("Unable to create another mac address", Network.class, networkId); } return mac; }
@Override public void shutdown(NetworkProfile profile, NetworkOffering offering) { NetworkVO networkObject = _networkDao.findById(profile.getId()); if (networkObject.getBroadcastDomainType() != BroadcastDomainType.Vxlan || networkObject.getBroadcastUri() == null) { s_logger.warn("BroadcastUri is empty or incorrect for guestnetwork " + networkObject.getDisplayText()); return; } super.shutdown(profile, offering); }
@Override public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) { Network network = _networkDao.findById(nic.getNetworkId()); _sspMgr.deleteNicEnv(network, nic, new ReservationContextImpl(reservationId, null, null)); return super.release(nic, vm, reservationId); }
@Override public NetworkProfile convertNetworkToNetworkProfile(final long networkId) { final NetworkVO network = _networksDao.findById(networkId); final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName()); final NetworkProfile profile = new NetworkProfile(network); guru.updateNetworkProfile(profile); return profile; }
@Override public boolean getNetworkEgressDefaultPolicy(Long networkId) { NetworkVO network = _networksDao.findById(networkId); if (network != null) { NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId()); return offering.isEgressDefaultPolicy(); } else { InvalidParameterValueException ex = new InvalidParameterValueException("network with network id does not exist"); throw ex; } }
@Override public boolean applyACLToNetwork(final long networkId) throws ResourceUnavailableException { final Network network = _networkDao.findById(networkId); if (network.getNetworkACLId() == null) { return true; } final List<NetworkACLItemVO> rules = _networkACLItemDao.listByACL(network.getNetworkACLId()); return applyACLItemsToNetwork(networkId, rules); }
@Override public List<UserVmVO> listByNetworkIdAndStates(long networkId, State... states) { NetworkVO network = networkDao.findById(networkId); recreateUserVmSeach(network); SearchCriteria<UserVmVO> sc = UserVmSearch.create(); if (states != null && states.length != 0) { sc.setParameters("states", (Object[])states); } sc.setJoinParameters("nicSearch", "networkId", networkId); return listBy(sc); }
@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); } }
private void generateNetworkUsageForVm(VirtualMachine vm, boolean isDisplay, String eventType){ List<NicVO> nics = _nicDao.listByVmId(vm.getId()); for (NicVO nic : nics) { NetworkVO network = _networkDao.findById(nic.getNetworkId()); long isDefault = (nic.isDefaultNic()) ? 1 : 0; UsageEventUtils.publishUsageEvent(eventType, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), Long.toString(nic.getId()), network.getNetworkOfferingId(), null, isDefault, vm.getClass().getName(), vm.getUuid(), isDisplay); } }
@Override public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) { Network nw = _nwDao.findById(nic.getNetworkId()); if (!_sNwMgr.isStorageIpRangeAvailable(nw.getDataCenterId())) { return super.release(nic, vm, reservationId); } _sNwMgr.releaseIpAddress(nic.getIPv4Address()); s_logger.debug("Release an storage ip " + nic.getIPv4Address()); nic.deallocate(); return true; }
@Override public void doInTransactionWithoutResult(final TransactionStatus status) { _nicDao.update(nic.getId(), nic); if (nic.getVmType() == VirtualMachine.Type.User) { s_logger.debug("Changing active number of nics for network id=" + networkId + " on " + count); _networksDao.changeActiveNicsBy(networkId, count); } if (nic.getVmType() == VirtualMachine.Type.User || nic.getVmType() == VirtualMachine.Type.DomainRouter && _networksDao.findById(networkId).getTrafficType() == TrafficType.Guest) { _networksDao.setCheckForGc(networkId); } } });
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateAddVmToNetwork(final VmWorkAddVmToNetwork work) throws Exception { final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { s_logger.info("Unable to find vm " + work.getVmId()); } assert vm != null; final Network network = _networkDao.findById(work.getNetworkId()); final NicProfile nic = orchestrateAddVmToNetwork(vm, network, work.getRequestedNicProfile()); return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(nic)); }