@Override public HostInventory getHostInventory(HostVO vo) { return HostInventory.valueOf(vo); }
protected HostInventory getSelfInventory() { return HostInventory.valueOf(self); }
public static List<HostInventory> valueOf(Collection<HostVO> vos) { List<HostInventory> invs = new ArrayList<HostInventory>(vos.size()); for (HostVO vo : vos) { invs.add(HostInventory.valueOf(vo)); } return invs; }
public void afterChange(HostVO vo, final HostStateEvent event, final HostState prevState) { final HostInventory hinv = HostInventory.valueOf(vo); CollectionUtils.safeForEach(changeStateExts, new ForEachFunction<HostChangeStateExtensionPoint>() { @Override public void run(HostChangeStateExtensionPoint extp) { extp.afterChangeHostState(hinv, event, prevState); } }); }
@Override public HostInventory getHostInventory(String uuid) { HostVO vo = dbf.findByUuid(uuid, HostVO.class); return HostInventory.valueOf(vo); }
public void beforeChange(HostVO vo, final HostStateEvent event) { final HostInventory hinv = HostInventory.valueOf(vo); final HostState next = vo.getState().nextState(event); CollectionUtils.safeForEach(changeStateExts, new ForEachFunction<HostChangeStateExtensionPoint>() { @Override public void run(HostChangeStateExtensionPoint extp) { extp.beforeChangeHostState(hinv, event, next); } }); }
public void preChange(HostVO vo, HostStateEvent event) throws HostException { HostState next = vo.getState().nextState(event); HostInventory hinv = HostInventory.valueOf(vo); for (HostChangeStateExtensionPoint extp : changeStateExts) { extp.preChangeHostState(hinv, event, next); } }
@Transactional public List<HostInventory> getConnectedHostForOperation(PrimaryStorageInventory pri, int startPage, int pageLimit) { if (pri.getAttachedClusterUuids().isEmpty()) { throw new OperationFailureException(operr("cannot find a Connected host to execute command for smp primary storage[uuid:%s]", pri.getUuid())); } String sql = "select h from HostVO h " + "where h.status = :connectionState and h.clusterUuid in (:clusterUuids) " + "and h.uuid not in (select ref.hostUuid from PrimaryStorageHostRefVO ref " + "where ref.primaryStorageUuid = :psUuid and ref.hostUuid = h.uuid and ref.status = :status)"; TypedQuery<HostVO> q = dbf.getEntityManager().createQuery(sql, HostVO.class); q.setParameter("connectionState", HostStatus.Connected); q.setParameter("clusterUuids", pri.getAttachedClusterUuids()); q.setParameter("psUuid", pri.getUuid()); q.setParameter("status", PrimaryStorageHostStatus.Disconnected); q.setFirstResult(startPage * pageLimit); if (pageLimit > 0){ q.setMaxResults(pageLimit); } List<HostVO> ret = q.getResultList(); if (ret.isEmpty() && startPage == 0) { //check is first page throw new OperationFailureException(operr( "cannot find a host which has Connected host-SMP connection to execute command for smp primary storage[uuid:%s]", pri.getUuid())); } else { Collections.shuffle(ret); return HostInventory.valueOf(ret); } }
@Transactional public List<HostInventory> getConnectedHostForOperation(PrimaryStorageInventory pri, int startPage, int pageLimit) { if (pri.getAttachedClusterUuids().isEmpty()) { throw new OperationFailureException(operr("cannot find a Connected host to execute command for nfs primary storage[uuid:%s]", pri.getUuid())); } String sql = "select h from HostVO h " + "where h.status = :connectionState and h.clusterUuid in (:clusterUuids) " + "and h.uuid not in (select ref.hostUuid from PrimaryStorageHostRefVO ref " + "where ref.primaryStorageUuid = :psUuid and ref.hostUuid = h.uuid and ref.status = :status)"; TypedQuery<HostVO> q = dbf.getEntityManager().createQuery(sql, HostVO.class); q.setParameter("connectionState", HostStatus.Connected); q.setParameter("clusterUuids", pri.getAttachedClusterUuids()); q.setParameter("psUuid", pri.getUuid()); q.setParameter("status", PrimaryStorageHostStatus.Disconnected); q.setFirstResult(startPage * pageLimit); if (pageLimit > 0){ q.setMaxResults(pageLimit); } List<HostVO> ret = q.getResultList(); if (ret.isEmpty() && startPage == 0) { //check is first page throw new OperationFailureException( operr("cannot find a host which has Connected host-NFS connection to execute command " + "for nfs primary storage[uuid:%s]", pri.getUuid())); } else { Collections.shuffle(ret); return HostInventory.valueOf(ret); } }
private List<HostInventory> hostFromAction(CascadeAction action) { List<HostInventory> ret = null; if (ClusterVO.class.getSimpleName().equals(action.getParentIssuer())) { List<ClusterInventory> clusters = action.getParentIssuerContext(); List<String> cuuids = CollectionUtils.transformToList(clusters, new Function<String, ClusterInventory>() { @Override public String call(ClusterInventory arg) { return arg.getUuid(); } }); SimpleQuery<HostVO> q = dbf.createQuery(HostVO.class); q.add(HostVO_.clusterUuid, SimpleQuery.Op.IN, cuuids); List<HostVO> hvos = q.list(); if (!hvos.isEmpty()) { ret = HostInventory.valueOf(hvos); } } else if (NAME.equals(action.getParentIssuer())) { ret = action.getParentIssuerContext(); } return ret; }
@Override public void run(MessageReply reply) { if (!reply.isSuccess()) { trigger.fail(reply.getError()); return; } spec.setDestHost(HostInventory.valueOf(dbf.findByUuid(hostUuid, HostVO.class))); AllocatePrimaryStorageReply ar = (AllocatePrimaryStorageReply) reply; data.put(VmInstanceConstant.Params.DestPrimaryStorageInventoryForAttachingVolume.toString(), ar.getPrimaryStorageInventory()); data.put(LocalStorageAllocateCapacityForAttachingVolumeFlow.class, ar.getSize()); trigger.next(); } });
private void done() { if (result == null) { if (isDryRun) { if (HostAllocatorError.NO_AVAILABLE_HOST.toString().equals(errorCode.getCode())) { dryRunCompletion.success(new ArrayList<HostInventory>()); } else { dryRunCompletion.fail(errorCode); } } else { completion.fail(errorCode); } return; } // in case a wrong flow returns an empty result set if (result.isEmpty()) { if (isDryRun) { dryRunCompletion.fail(err(HostAllocatorError.NO_AVAILABLE_HOST, "host allocation flow doesn't indicate any details")); } else { completion.fail(err(HostAllocatorError.NO_AVAILABLE_HOST, "host allocation flow doesn't indicate any details")); } return; } if (isDryRun) { dryRunCompletion.success(HostInventory.valueOf(result)); } else { completion.success(HostInventory.valueOf(result)); } }
@Override public void handle(ErrorCode errCode, Map data) { // delete host totally through the database, so other tables // refer to the host table will clean up themselves HostVO nvo = dbf.reload(vo); dbf.remove(nvo); dbf.eoCleanup(HostVO.class); HostInventory inv = HostInventory.valueOf(nvo); CollectionUtils.safeForEach(pluginRgty.getExtensionList(FailToAddHostExtensionPoint.class), new ForEachFunction<FailToAddHostExtensionPoint>() { @Override public void run(FailToAddHostExtensionPoint ext) { ext.failedToAddHost(inv, msg); } }); completion.fail(errCode); } }).start();
@Override public void handle(Map data) { casf.asyncCascadeFull(CascadeConstant.DELETION_CLEANUP_CODE, issuer, ctx, new NopeCompletion()); bus.publish(evt); HostDeletedData d = new HostDeletedData(); d.setInventory(HostInventory.valueOf(self)); d.setHostUuid(self.getUuid()); evtf.fire(HostCanonicalEvents.HOST_DELETED_PATH, d); } }).error(new FlowErrorHandler(msg) {
PrepareL2NetworkOnHostMsg msg = new PrepareL2NetworkOnHostMsg(); msg.setL2NetworkUuid(uuid); msg.setHost(HostInventory.valueOf((HostVO) Q.New(HostVO.class).eq(HostVO_.uuid, destHostUuid).find())); bus.makeTargetServiceIdByResourceUuid(msg, L2NetworkConstant.SERVICE_ID, uuid); bus.send(msg, new CloudBusCallBack(completion1) {
data.setNewStatus(next.toString()); data.setOldStatus(before.toString()); data.setInventory(HostInventory.valueOf(self)); evtf.fire(HostCanonicalEvents.HOST_STATUS_CHANGED_PATH, data);
@Override protected void handle(final InstantiateVolumeOnPrimaryStorageMsg msg) { if (msg.getDestHost() == null) { String hostUuid = getAvailableHostUuidForOperation(); if (hostUuid == null) { throw new OperationFailureException(operr("the shared mount point primary storage[uuid:%s, name:%s] cannot find any " + "available host in attached clusters for instantiating the volume", self.getUuid(), self.getName())); } msg.setDestHost(HostInventory.valueOf(dbf.findByUuid(hostUuid, HostVO.class))); } HypervisorFactory f = getHypervisorFactoryByHostUuid(msg.getDestHost().getUuid()); HypervisorBackend bkd = f.getHypervisorBackend(self); bkd.handle(msg, new ReturnValueCompletion<InstantiateVolumeOnPrimaryStorageReply>(msg) { @Override public void success(InstantiateVolumeOnPrimaryStorageReply reply) { bus.reply(msg, reply); } @Override public void fail(ErrorCode errorCode) { InstantiateVolumeOnPrimaryStorageReply reply = new InstantiateVolumeOnPrimaryStorageReply(); reply.setError(errorCode); bus.reply(msg, reply); } }); }
HostInventory hinv = HostInventory.valueOf(hvo); spec.setDestHost(hinv);
spec.setDestHost(HostInventory.valueOf(dbf.findByUuid(self.getHostUuid(), HostVO.class)));
throw new OperationFailureException(operr("The chosen host[uuid:%s] to perform storage migration is lost", msg.getHostUuid())); HostInventory host = HostInventory.valueOf(hostVO);