@Override public void done() { if(ret.firstAccessHostUuids.size() > 1){ ret.huuids.addAll(ret.firstAccessHostUuids); ret.errorCodes.add(operr( "hosts[uuid:%s] have the same mount path, but actually mount different storage.", ret.firstAccessHostUuids )); } if (!ret.errorCodes.isEmpty()) { cleanInvalidIdFile(ret.firstAccessHostUuids); String mountPathErrorInfo = "Can't access mount path on "; for(String hostUuid : ret.huuids) { mountPathErrorInfo += String.format("host[uuid:%s] ", hostUuid); } completion.fail(errf.stringToOperationError( String.format("unable to connect the shared mount point storage[uuid:%s, name:%s] to the cluster[uuid:%s], %s", self.getUuid(), self.getName(), clusterUuid, mountPathErrorInfo), new ArrayList<>(ret.errorCodes) )); } else { completion.success(ClusterConnectionStatus.FullyConnected); } } });
@Override protected void done() { if (success) { self = dbf.reload(self); completion.success(); } else { completion.fail(errf.stringToOperationError(String.format("unable to connect the" + "NFS primary storage[uuid:%s, name:%s]", self.getUuid(), self.getName()), errors)); } } }.start();
@Override public void run(SyncTaskChain chain) { NfsPrimaryStorageBackend backend = getUsableBackend(); if (backend == null) { throw new OperationFailureException(operr("the NFS primary storage[uuid:%s, name:%s] cannot find hosts in attached clusters to perform the operation", self.getUuid(), self.getName())); } backend.handle(getSelfInventory(), msg, new ReturnValueCompletion<NfsToNfsMigrateBitsReply>(msg) { @Override public void success(NfsToNfsMigrateBitsReply reply) { bus.reply(msg, reply); chain.next(); } @Override public void fail(ErrorCode errorCode) { NfsToNfsMigrateBitsReply reply = new NfsToNfsMigrateBitsReply(); reply.setError(errorCode); bus.reply(msg, reply); chain.next(); } }); }
@Override protected void pingHook(Completion completion) { NfsPrimaryStorageBackend bkd = getUsableBackend(); if (bkd == null) { // the nfs primary storage has not been attached to any clusters, or no connected hosts completion.fail(operr("the NFS primary storage[uuid:%s, name:%s] has not attached to any clusters, or no hosts in the" + " attached clusters are connected", self.getUuid(), self.getName())); } else { bkd.ping(getSelfInventory(), completion); } }
@Override public void run(MessageReply reply) { if (!reply.isSuccess() && !reply.getError().isError(PrimaryStorageErrors.DISCONNECTED)) { evt.setError(reply.getError()); logger.warn(String.format("failed to connect primary storage[uuid:%s, name:%s, url:%s]", finalVo.getUuid(), finalVo.getName(), finalVo.getUrl())); dbf.remove(finalVo); } else { PrimaryStorageInventory pinv = factory.getInventory(finalVo.getUuid()); logger.debug(String.format("successfully add primary storage[uuid:%s, name:%s, url: %s]", finalVo.getUuid(), finalVo.getName(), finalVo.getUrl())); evt.setInventory(pinv); } bus.publish(evt); } });
"or no hosts in the attached clusters are connected", self.getUuid(), self.getName() )); return;
private void handle(NfsRebaseVolumeBackingFileMsg msg) { NfsPrimaryStorageBackend backend = getUsableBackend(); if (backend == null) { throw new OperationFailureException(operr("the NFS primary storage[uuid:%s, name:%s] cannot find hosts in attached clusters to perform the operation", self.getUuid(), self.getName())); } backend.handle(getSelfInventory(), msg, new ReturnValueCompletion<NfsRebaseVolumeBackingFileReply>(msg) { @Override public void success(NfsRebaseVolumeBackingFileReply reply) { bus.reply(msg, reply); } @Override public void fail(ErrorCode errorCode) { NfsRebaseVolumeBackingFileReply reply = new NfsRebaseVolumeBackingFileReply(); reply.setError(errorCode); bus.reply(msg, reply); } }); }
@Override protected void handle(final SyncVolumeSizeOnPrimaryStorageMsg msg) { NfsPrimaryStorageBackend backend = getUsableBackend(); if (backend == null) { throw new OperationFailureException(operr("the NFS primary storage[uuid:%s, name:%s] cannot find hosts in attached clusters to perform the operation", self.getUuid(), self.getName())); } backend.handle(getSelfInventory(), msg, new ReturnValueCompletion<SyncVolumeSizeOnPrimaryStorageReply>(msg) { @Override public void success(SyncVolumeSizeOnPrimaryStorageReply reply) { bus.reply(msg, reply); } @Override public void fail(ErrorCode errorCode) { SyncVolumeSizeOnPrimaryStorageReply reply = new SyncVolumeSizeOnPrimaryStorageReply(); reply.setError(errorCode); bus.reply(msg, reply); } }); }
" the local storage[name:%s, uuid:%s]", snapshotUuids, hostUuid, self.getName(), self.getUuid())); .param("uuids", volumesUuids).execute(); logger.debug(String.format("delete volumes%s because the host[uuid:%s] is removed from" + " the local storage[name:%s, uuid:%s]", volumesUuids, hostUuid, self.getName(), self.getUuid())); " the local storage[name:%s, uuid:%s]", vmUuidsToDelete, hostUuid, self.getName(), self.getUuid()));
self.getUuid(), self.getName(), future.getErrorCode()); } else { changeStatus(PrimaryStorageStatus.Connected);
protected void checkParam() { super.checkParam(); SimpleQuery<FusionstorBackupStorageVO> q = dbf.createQuery(FusionstorBackupStorageVO.class); q.select(FusionstorBackupStorageVO_.fsid); q.add(FusionstorBackupStorageVO_.uuid, Op.EQ, backupStorage.getUuid()); String bsFsid = q.findValue(); if (!getSelf().getFsid().equals(bsFsid)) { throw new OperationFailureException(operr( "the backup storage[uuid:%s, name:%s, fsid:%s] is not in the same fusionstor cluster" + " with the primary storage[uuid:%s, name:%s, fsid:%s]", backupStorage.getUuid(), backupStorage.getName(), bsFsid, self.getUuid(), self.getName(), getSelf().getFsid() )); } }
public void checkParam() { super.checkParam(); SimpleQuery<CephBackupStorageVO> q = dbf.createQuery(CephBackupStorageVO.class); q.select(CephBackupStorageVO_.fsid); q.add(CephBackupStorageVO_.uuid, Op.EQ, backupStorage.getUuid()); String bsFsid = q.findValue(); if (!getSelf().getFsid().equals(bsFsid)) { throw new OperationFailureException(operr( "the backup storage[uuid:%s, name:%s, fsid:%s] is not in the same ceph cluster" + " with the primary storage[uuid:%s, name:%s, fsid:%s]", backupStorage.getUuid(), backupStorage.getName(), bsFsid, self.getUuid(), self.getName(), getSelf().getFsid()) ); } }
protected boolean changeStatus(PrimaryStorageStatus status) { if (status == self.getStatus()) { return false; } PrimaryStorageStatus oldStatus = self.getStatus(); self.setStatus(status); self = dbf.updateAndRefresh(self); PrimaryStorageStatusChangedData d = new PrimaryStorageStatusChangedData(); d.setInventory(PrimaryStorageInventory.valueOf(self)); d.setPrimaryStorageUuid(self.getUuid()); d.setOldStatus(oldStatus.toString()); d.setNewStatus(status.toString()); evtf.fire(PrimaryStorageCanonicalEvent.PRIMARY_STORAGE_STATUS_CHANGED_PATH, d); logger.debug(String.format("the primary storage[uuid:%s, name:%s] changed status from %s to %s", self.getUuid(), self.getName(), oldStatus, status)); return true; }
" attached clusters are connected", self.getUuid(), self.getName() ));
protected void handle(final ReInitRootVolumeFromTemplateOnPrimaryStorageMsg msg) { final ReInitRootVolumeFromTemplateOnPrimaryStorageReply reply = new ReInitRootVolumeFromTemplateOnPrimaryStorageReply(); HostInventory destHost = factory.getConnectedHostForOperation(PrimaryStorageInventory.valueOf(self)).get(0); if (destHost == null) { reply.setError(operr("no host in Connected status to which nfs primary storage[uuid:%s, name:%s] attached" + " found to revert volume[uuid:%s] to image[uuid:%s]", self.getUuid(), self.getName(), msg.getVolume().getUuid(), msg.getVolume().getRootImageUuid())); bus.reply(msg, reply); return; } NfsPrimaryStorageBackend bkd = getBackend(nfsMgr.findHypervisorTypeByImageFormatAndPrimaryStorageUuid( VolumeConstant.VOLUME_FORMAT_QCOW2, self.getUuid()) ); bkd.resetRootVolumeFromImage(msg.getVolume(), destHost, new ReturnValueCompletion<String>(msg) { @Override public void success(String returnValue) { reply.setNewVolumeInstallPath(returnValue); bus.reply(msg, reply); } @Override public void fail(ErrorCode errorCode) { reply.setError(errorCode); bus.reply(msg, reply); } }); }
logger.debug(String.format("volume[uuid:%s] is not on the local storage[uuid:%s, name:%s]," + "the host the volume is on may have been deleted", msg.getVolume().getUuid(), self.getUuid(), self.getName()));
@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); } }); }
protected void handle(final RevertVolumeFromSnapshotOnPrimaryStorageMsg msg) { final RevertVolumeFromSnapshotOnPrimaryStorageReply reply = new RevertVolumeFromSnapshotOnPrimaryStorageReply(); HostInventory destHost; try { destHost = factory.getConnectedHostForOperation(PrimaryStorageInventory.valueOf(self)).get(0); }catch (OperationFailureException e){ reply.setError(operr("no host in Connected status to which nfs primary storage[uuid:%s, name:%s] attached" + " found to revert volume[uuid:%s] to snapshot[uuid:%s, name:%s]", self.getUuid(), self.getName(), msg.getVolume().getUuid(), msg.getSnapshot().getUuid(), msg.getSnapshot().getName())); bus.reply(msg, reply); return; } NfsPrimaryStorageBackend bkd = getBackend(nfsMgr.findHypervisorTypeByImageFormatAndPrimaryStorageUuid(msg.getSnapshot().getFormat(), self.getUuid())); bkd.revertVolumeFromSnapshot(msg.getSnapshot(), msg.getVolume(), destHost, new ReturnValueCompletion<RevertVolumeFromSnapshotOnPrimaryStorageReply>(msg) { @Override public void success(RevertVolumeFromSnapshotOnPrimaryStorageReply returnValue) { reply.setNewVolumeInstallPath(returnValue.getNewVolumeInstallPath()); reply.setSize(returnValue.getSize()); bus.reply(msg, reply); } @Override public void fail(ErrorCode errorCode) { reply.setError(errorCode); bus.reply(msg, reply); } }); }
protected PrimaryStorageInventory(PrimaryStorageVO vo) { setZoneUuid(vo.getZoneUuid()); setCreateDate(vo.getCreateDate()); setDescription(vo.getDescription()); setLastOpDate(vo.getLastOpDate()); setName(vo.getName()); setState(vo.getState().toString()); setType(vo.getType()); setUrl(vo.getUrl()); setUuid(vo.getUuid()); setMountPath(vo.getMountPath()); setStatus(vo.getStatus().toString()); attachedClusterUuids = new ArrayList<String>(vo.getAttachedClusterRefs().size()); for (PrimaryStorageClusterRefVO ref : vo.getAttachedClusterRefs()) { attachedClusterUuids.add(ref.getClusterUuid()); } if (vo.getCapacity() != null) { setTotalCapacity(vo.getCapacity().getTotalCapacity()); setAvailableCapacity(vo.getCapacity().getAvailableCapacity()); setTotalPhysicalCapacity(vo.getCapacity().getTotalPhysicalCapacity()); setAvailablePhysicalCapacity(vo.getCapacity().getAvailablePhysicalCapacity()); setSystemUsedCapacity(vo.getCapacity().getSystemUsedCapacity()); } }
private void createEmptyVolume(final InstantiateVolumeOnPrimaryStorageMsg msg) { NfsPrimaryStorageBackend backend; if (msg.getDestHost() != null) { backend = getBackend(HypervisorType.valueOf(msg.getDestHost().getHypervisorType())); } else { backend = getUsableBackend(); if (backend == null) { throw new OperationFailureException(operr("the NFS primary storage[uuid:%s, name:%s] cannot find any usable host to" + " create the data volume[uuid:%s, name:%s]", self.getUuid(), self.getName(), msg.getVolume().getUuid(), msg.getVolume().getName())); } } VolumeInventory vol = msg.getVolume(); final InstantiateVolumeOnPrimaryStorageReply reply = new InstantiateVolumeOnPrimaryStorageReply(); backend.instantiateVolume(PrimaryStorageInventory.valueOf(self), vol, new ReturnValueCompletion<VolumeInventory>(msg) { @Override public void success(VolumeInventory returnValue) { reply.setVolume(returnValue); bus.reply(msg, reply); } @Override public void fail(ErrorCode errorCode) { reply.setError(errorCode); reply.setSuccess(false); bus.reply(msg, reply); } }); }