@Override public void deleteEntityExtractUrl(DataStore store, String installPath, String downloadUrl, Upload.Type entityType) { // find an endpoint to send command based on the ssvm on which the url was created. EndPoint ep = _epSelector.select(store, downloadUrl); // Delete Symlink at ssvm. In case of volume also delete the volume. DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(installPath, entityType, downloadUrl, ((ImageStoreEntity) store).getMountPoint()); Answer ans = null; if (ep == null) { String errMsg = "No remote endpoint to send command, check if host or ssvm is down?"; s_logger.error(errMsg); ans = new Answer(cmd, false, errMsg); } else { ans = ep.sendMessage(cmd); } if (ans == null || !ans.getResult()) { String errorString = "Unable to delete the url " + downloadUrl + " for path " + installPath + " on ssvm, " + ans.getDetails(); s_logger.error(errorString); throw new CloudRuntimeException(errorString); } }
private String generateCopyUrl(TemplateInfo srcTemplate) { DataStore srcStore = srcTemplate.getDataStore(); EndPoint ep = _epSelector.select(srcTemplate); if (ep != null) { if (ep.getPublicAddr() == null) { s_logger.warn("A running secondary storage vm has a null public ip?"); return null; } return generateCopyUrl(ep.getPublicAddr(), ((ImageStoreEntity)srcStore).getMountPoint(), srcTemplate.getInstallPath()); } VMTemplateVO tmplt = _templateDao.findById(srcTemplate.getId()); HypervisorType hyperType = tmplt.getHypervisorType(); /*No secondary storage vm yet*/ if (hyperType != null && hyperType == HypervisorType.KVM) { return "file://" + ((ImageStoreEntity)srcStore).getMountPoint() + "/" + srcTemplate.getInstallPath(); } return null; }
@Override public String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format, DataObject dataObject) { // find an endpoint to send command EndPoint ep = _epSelector.select(store); // Create Symlink at ssvm String path = installPath; String uuid = UUID.randomUUID().toString() + "." + format.getFileExtension(); CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(((ImageStoreEntity)store).getMountPoint(), path, uuid, dataObject.getTO()); Answer ans = null; if (ep == null) { String errMsg = "No remote endpoint to send command, check if host or ssvm is down?"; s_logger.error(errMsg); ans = new Answer(cmd, false, errMsg); } else { ans = ep.sendMessage(cmd); } if (ans == null || !ans.getResult()) { String errorString = "Unable to create a link for entity at " + installPath + " on ssvm," + ans.getDetails(); s_logger.error(errorString); throw new CloudRuntimeException(errorString); } // Construct actual URL locally now that the symlink exists at SSVM return generateCopyUrl(ep.getPublicAddr(), uuid); }
CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(((ImageStoreEntity)store).getMountPoint(), path, uuid, null); Answer ans = ep.sendMessage(cmd); if (ans == null || !ans.getResult()) {
CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(((ImageStoreEntity)secStore).getMountPoint(), path, uuid, null); Answer ans = ep.sendMessage(cmd); if (ans == null || !ans.getResult()) {