public List<String> getGuestL3Networks() { return CollectionUtils.transformToList(getVmNics(), new Function<String, VmNicInventory>() { @Override public String call(VmNicInventory arg) { return VirtualRouterNicMetaData.isGuestNic(arg) ? arg.getL3NetworkUuid() : null; } }); }
public List<String> getHypervisorTypesSupportingThisVolumeFormatInString() { return CollectionUtils.transformToList(getHypervisorTypesSupportingThisVolumeFormat(), new Function<String, HypervisorType>() { @Override public String call(HypervisorType arg) { return arg.toString(); } }); }
public static List<String> getVolumeFormatSupportedByHypervisorTypeInString(HypervisorType hvType) { return CollectionUtils.transformToList(getVolumeFormatSupportedByHypervisorType(hvType), new Function<String, VolumeFormat>() { @Override public String call(VolumeFormat arg) { return arg.toString(); } }); }
public Boolean getDeleteAll() { if (backupStorageUuids == null) { return true; } if (deleteAll == null) { List<String> bsUuids = CollectionUtils.transformToList(image.getBackupStorageRefs(), new Function<String, ImageBackupStorageRefInventory>() { @Override public String call(ImageBackupStorageRefInventory arg) { return arg.getBackupStorageUuid(); } }); deleteAll = backupStorageUuids.containsAll(bsUuids); } return deleteAll; }
private void prepareStatistics() { List<Class> needReplyMsgs = new ArrayList<>(BeanUtils.reflections.getSubTypesOf(NeedReplyMessage.class)); needReplyMsgs = CollectionUtils.transformToList(needReplyMsgs, (Function<Class, Class>) arg -> !APIMessage.class.isAssignableFrom(arg) || APISyncCallMessage.class.isAssignableFrom(arg) ? arg : null); for (Class clz : needReplyMsgs) { MessageStatistic stat = new MessageStatistic(); stat.setMessageClassName(clz.getName()); statistics.put(stat.getMessageClassName(), stat); } }
@Transactional(readOnly = true) private List<Tuple> getLbTuple(VmInstanceSpec servedVm) { String sql = "select l.uuid, l.loadBalancerUuid, ref.vmNicUuid from LoadBalancerListenerVmNicRefVO ref, LoadBalancerListenerVO l where ref.listenerUuid = l.uuid" + " and ref.vmNicUuid in (:nicUuids)"; TypedQuery<Tuple> q = dbf.getEntityManager().createQuery(sql, Tuple.class); q.setParameter("nicUuids", CollectionUtils.transformToList(servedVm.getDestNics(), new Function<String, VmNicInventory>() { @Override public String call(VmNicInventory arg) { return arg.getUuid(); } })); return q.getResultList(); }
@Transactional(readOnly = true) private List<DiskOfferingInventory> getForTheAccount(List<AccountInventory> invs) { List<String> accountUuids = CollectionUtils.transformToList(invs, new Function<String, AccountInventory>() { @Override public String call(AccountInventory arg) { return arg.getUuid(); } }); String sql = "select d from DiskOfferingVO d, AccountResourceRefVO r where d.uuid = r.resourceUuid and" + " r.resourceType = :rtype and r.accountUuid in (:auuids)"; TypedQuery<DiskOfferingVO> q = dbf.getEntityManager().createQuery(sql, DiskOfferingVO.class); q.setParameter("rtype", DiskOfferingVO.class.getSimpleName()); q.setParameter("auuids", accountUuids); List<DiskOfferingVO> vos = q.getResultList(); return DiskOfferingInventory.valueOf(vos); }
@Transactional(readOnly = true) private List<InstanceOfferingInventory> getForAccount(List<AccountInventory> invs) { List<String> accountUuids = CollectionUtils.transformToList(invs, new Function<String, AccountInventory>() { @Override public String call(AccountInventory arg) { return arg.getUuid(); } }); String sql = "select d from InstanceOfferingVO d, AccountResourceRefVO r where d.uuid = r.resourceUuid and" + " r.resourceType = :rtype and r.accountUuid in (:auuids)"; TypedQuery<InstanceOfferingVO> q = dbf.getEntityManager().createQuery(sql, InstanceOfferingVO.class); q.setParameter("rtype", InstanceOfferingVO.class.getSimpleName()); q.setParameter("auuids", accountUuids); List<InstanceOfferingVO> vos = q.getResultList(); return InstanceOfferingInventory.valueOf(vos); }
private List<T> listObject() { done(); List<KeyValueBinaryVO> vos = listBinaryVO(); if (vos.isEmpty()) { return new ArrayList<T>(); } return CollectionUtils.transformToList(vos, new Function<T, KeyValueBinaryVO>() { @Override public T call(KeyValueBinaryVO arg) { try { return SerializableHelper.readObject(arg.getContents()); } catch (Exception e) { throw new CloudRuntimeException(e); } } }); }
private void checkIfNicIsAdded(List<String> nicUuids) { List<String> allNicUuids = new ArrayList<String>(); for (LoadBalancerListenerVO l : self.getListeners()) { allNicUuids.addAll(CollectionUtils.transformToList(l.getVmNicRefs(), new Function<String, LoadBalancerListenerVmNicRefVO>() { @Override public String call(LoadBalancerListenerVmNicRefVO arg) { return arg.getVmNicUuid(); } })); } for (String nicUuid : nicUuids) { if (!allNicUuids.contains(nicUuid)) { throw new CloudRuntimeException(String.format("the load balancer[uuid: %s] doesn't have a vm nic[uuid: %s] added", self.getUuid(), nicUuid)); } } }
private void loadPrimaryStorage(boolean skipConnected) { List<String> uuids = getPrimaryStorageManagedByUs(skipConnected); if (uuids.isEmpty()) { return; } List<ConnectPrimaryStorageMsg> msgs = CollectionUtils.transformToList(uuids, new Function<ConnectPrimaryStorageMsg, String>() { @Override public ConnectPrimaryStorageMsg call(String arg) { ConnectPrimaryStorageMsg msg = new ConnectPrimaryStorageMsg(); msg.setPrimaryStorageUuid(arg); bus.makeTargetServiceIdByResourceUuid(msg, PrimaryStorageConstant.SERVICE_ID, arg); return msg; } }); bus.send(msgs); }
@Override public List<HostVO> filter(List<HostVO> candidates) { List<String> toRemoveHuuids = Q.New(HostVO.class).notEq(KVMHostVO_.username, "root").select(KVMHostVO_.uuid).listValues(); if (!toRemoveHuuids.isEmpty()){ candidates = CollectionUtils.transformToList(candidates, new Function<HostVO, HostVO>() { @Override public HostVO call(HostVO arg) { return toRemoveHuuids.contains(arg.getUuid()) ? null : arg; } }); } return candidates; } }
private void handleL2NetworkDetach(CascadeAction action, final Completion completion) { List<L2NetworkDetachStruct> structs = action.getParentIssuerContext(); final List<VmInstanceVO> apvms = getVmFromL2NetworkDetached(structs); if (apvms.isEmpty()) { completion.success(); return; } List<String> clusterUuids = CollectionUtils.transformToList(structs, new Function<String, L2NetworkDetachStruct>() { @Override public String call(L2NetworkDetachStruct arg) { return arg.getClusterUuid(); } }); migrateOrStopVmOnClusterDetach(apvms, clusterUuids, completion); }
private void handlePrimaryStorageDetach(CascadeAction action, final Completion completion) { List<PrimaryStorageDetachStruct> structs = action.getParentIssuerContext(); final List<VmInstanceVO> vmInstanceVOs = getVmForPrimaryStorageDetached(structs); if (vmInstanceVOs.isEmpty()) { completion.success(); return; } List<String> clusterUuids = CollectionUtils.transformToList(structs, new Function<String, PrimaryStorageDetachStruct>() { @Override public String call(PrimaryStorageDetachStruct arg) { return arg.getClusterUuid(); } }); migrateOrStopVmOnClusterDetach(vmInstanceVOs, clusterUuids, completion); }
private void checkExistingBackupStorage(List<String> monUrls) { List<String> hostnames = CollectionUtils.transformToList(monUrls, new Function<String, String>() { @Override public String call(String url) { MonUri uri = new MonUri(url); return uri.getHostname(); } }); SimpleQuery<CephBackupStorageMonVO> q = dbf.createQuery(CephBackupStorageMonVO.class); q.select(CephBackupStorageMonVO_.hostname); q.add(CephBackupStorageMonVO_.hostname, Op.IN, hostnames); List<String> existing = q.listValue(); if (!existing.isEmpty()) { throw new ApiMessageInterceptionException(argerr("cannot add ceph backup storage, there has been some ceph backup storage using mon[hostnames:%s]", existing)); } }
private void checkExistingPrimaryStorage(List<String> monUrls) { List<String> hostnames = CollectionUtils.transformToList(monUrls, new Function<String, String>() { @Override public String call(String url) { MonUri uri = new MonUri(url); return uri.getHostname(); } }); SimpleQuery<CephPrimaryStorageMonVO> q = dbf.createQuery(CephPrimaryStorageMonVO.class); q.select(CephPrimaryStorageMonVO_.hostname); q.add(CephPrimaryStorageMonVO_.hostname, Op.IN, hostnames); List<String> existing = q.listValue(); if (!existing.isEmpty()) { throw new ApiMessageInterceptionException(argerr("cannot add ceph primary storage, there has been some ceph primary storage using mon[hostnames:%s]", existing)); } }
@Override public void failedToMigrateVm(final VmInstanceInventory inv, final String destHostUuid, ErrorCode reason) { RuleCalculator cal = new RuleCalculator(); cal.vmNicUuids = CollectionUtils.transformToList(inv.getVmNics(), new Function<String, VmNicInventory>() { @Override public String call(VmNicInventory arg) { return arg.getUuid(); } }); cal.vmStates = asList(VmInstanceState.Unknown); List<HostRuleTO> htos = cal.calculate(); logger.debug(String.format("vm[uuid:%s, name:%s] failed to migrate to host[uuid:%s], recover its rules on previous host[uuid:%s]", inv.getUuid(), inv.getName(), destHostUuid, inv.getHostUuid())); applyRules(htos); }
private void trackOurs() { SimpleQuery<VirtualRouterVmVO> q = dbf.createQuery(VirtualRouterVmVO.class); q.select(VirtualRouterVmVO_.uuid); List<String> vrUuids = q.listValue(); List<String> toTrack = CollectionUtils.transformToList(vrUuids, new Function<String, String>() { @Override public String call(String arg) { return destinationMaker.isManagedByUs(arg) ? arg : null; } }); untrackAll(); track(toTrack); }
private void checkExistingPrimaryStorage(List<String> monUrls) { List<String> hostnames = CollectionUtils.transformToList(monUrls, new Function<String, String>() { @Override public String call(String url) { MonUri uri = new MonUri(url); return uri.getHostname(); } }); SimpleQuery<FusionstorPrimaryStorageMonVO> q = dbf.createQuery(FusionstorPrimaryStorageMonVO.class); q.select(FusionstorPrimaryStorageMonVO_.hostname); q.add(FusionstorPrimaryStorageMonVO_.hostname, Op.IN, hostnames); List<String> existing = q.listValue(); if (!existing.isEmpty()) { throw new ApiMessageInterceptionException(argerr( "cannot add fusionstor primary storage, there has been some fusionstor primary storage using mon[hostnames:%s]", existing )); } }
private void checkExistingBackupStorage(List<String> monUrls) { List<String> hostnames = CollectionUtils.transformToList(monUrls, new Function<String, String>() { @Override public String call(String url) { MonUri uri = new MonUri(url); return uri.getHostname(); } }); SimpleQuery<FusionstorBackupStorageMonVO> q = dbf.createQuery(FusionstorBackupStorageMonVO.class); q.select(FusionstorBackupStorageMonVO_.hostname); q.add(FusionstorBackupStorageMonVO_.hostname, Op.IN, hostnames); List<String> existing = q.listValue(); if (!existing.isEmpty()) { throw new ApiMessageInterceptionException(argerr( "cannot add fusionstor backup storage, there has been some fusionstor backup storage using mon[hostnames:%s]", existing )); } }