@Override public List<String> getEdgeNames() { return Arrays.asList( HostVO.class.getSimpleName(), L3NetworkVO.class.getSimpleName(), IpRangeVO.class.getSimpleName(), PrimaryStorageVO.class.getSimpleName(), L2NetworkVO.class.getSimpleName(), InstanceOfferingVO.class.getSimpleName(), AccountVO.class.getSimpleName()); }
@Transactional(readOnly = true) private List<String> getVmUuidFromL2NetworkDetached(List<L2NetworkDetachStruct> structs) { List<String> vmUuids = new ArrayList<String>(); for (L2NetworkDetachStruct s : structs) { String sql = "select vm.uuid from VmInstanceVO vm, L2NetworkVO l2, L3NetworkVO l3, VmNicVO nic where vm.type = :vmType and vm.clusterUuid = :clusterUuid and vm.state not in (:vmStates) and vm.uuid = nic.vmInstanceUuid and nic.l3NetworkUuid = l3.uuid and l3.l2NetworkUuid = l2.uuid and l2.uuid = :l2Uuid"; TypedQuery<String> q = dbf.getEntityManager().createQuery(sql, String.class); q.setParameter("vmType", VmInstanceConstant.USER_VM_TYPE); q.setParameter( "vmStates", Arrays.asList( VmInstanceState.Stopped, VmInstanceState.Migrating, VmInstanceState.Stopping)); q.setParameter("clusterUuid", s.getClusterUuid()); q.setParameter("l2Uuid", s.getL2NetworkUuid()); vmUuids.addAll(q.getResultList()); } return vmUuids; }
@Transactional(readOnly = true) private List<String> getVmUuidForPrimaryStorageDetached( List<PrimaryStorageDetachStruct> structs) { List<String> vmUuids = new ArrayList<String>(); for (PrimaryStorageDetachStruct s : structs) { String sql = "select vm.uuid from VmInstanceVO vm, PrimaryStorageVO ps, VolumeVO vol where vm.type = :vmType and vm.state not in (:vmStates) and vm.clusterUuid = :clusterUuid and vm.uuid = vol.vmInstanceUuid and vol.primaryStorageUuid = :psUuid"; TypedQuery<String> q = dbf.getEntityManager().createQuery(sql, String.class); q.setParameter("vmType", VmInstanceConstant.USER_VM_TYPE); q.setParameter( "vmStates", Arrays.asList( VmInstanceState.Stopped, VmInstanceState.Migrating, VmInstanceState.Stopping)); q.setParameter("clusterUuid", s.getClusterUuid()); q.setParameter("psUuid", s.getPrimaryStorageUuid()); vmUuids.addAll(q.getResultList()); } return vmUuids; }