protected PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadCommand cmd) { try { URI uri = new URI(cmd.getUrl()); String secondaryStoragePath = uri.getHost() + ":" + uri.getPath(); Pair<String, Long> res = OvmStoragePool.downloadTemplate(_conn, cmd.getPoolUuid(), secondaryStoragePath); return new PrimaryStorageDownloadAnswer(res.first(), res.second()); } catch (Exception e) { s_logger.debug("PrimaryStorageDownloadCommand failed", e); return new PrimaryStorageDownloadAnswer(e.getMessage()); } }
private void corePrimaryStorageDownloadCommandTestCycle(final PrimaryStorageDownloadCommand cmd) { PrimaryStorageDownloadAnswer ans = (PrimaryStorageDownloadAnswer)s_hypervresource.executeRequest(cmd); if (!ans.getResult()) { s_logger.error(ans.getDetails()); } else { s_logger.debug(ans.getDetails()); } Assert.assertTrue(ans.getDetails(), ans.getResult()); // Test that returned URL works. // CreateCommand createCmd = CreateCommandSample(); // CreateCommand testCreateCmd = new // CreateCommand(createCmd.getDiskCharacteristics(), // ans.getInstallPath(), createCmd.getPool()); // CreateAnswer ans2 = // (CreateAnswer)s_hypervresource.executeRequest(testCreateCmd); // Assert.assertTrue(ans2.getDetails(), ans2.getResult()); }
/** * Download from template url into primary storage ?.. is this relevant ? * * @param cmd * @return */ public PrimaryStorageDownloadAnswer execute( final PrimaryStorageDownloadCommand cmd) { try { Repository repo = new Repository(c); String tmplturl = cmd.getUrl(); String poolName = cmd.getPoolUuid(); String image = repo.deDash(repo.newUuid()) + ".raw"; /* url to download from, image name, and repo to copy it to */ repo.importVirtualDisk(tmplturl, image, poolName); return new PrimaryStorageDownloadAnswer(image); } catch (Exception e) { LOGGER.debug("PrimaryStorageDownloadCommand failed", e); return new PrimaryStorageDownloadAnswer(e.getMessage()); } } }
final String msg = "There are " + srs.size() + " SRs with same name: " + poolName; s_logger.warn(msg); return new PrimaryStorageDownloadAnswer(msg); } else { poolsr = srs.iterator().next(); } catch (final Exception e) { return new PrimaryStorageDownloadAnswer(snapshotvdi.getUuid(conn), phySize); } catch (final Exception e) { final String msg = "Catch Exception " + e.getClass().getName() + " on host:" + citrixResourceBase.getHost().getUuid() + " for template: " + tmplturl + " due to " + e.toString(); s_logger.warn(msg, e); return new PrimaryStorageDownloadAnswer(msg);
final List<KVMPhysicalDisk> disks = secondaryPool.listPhysicalDisks(); if (disks == null || disks.isEmpty()) { return new PrimaryStorageDownloadAnswer("Failed to get volumes from pool: " + secondaryPool.getUuid()); return new PrimaryStorageDownloadAnswer("Failed to get template from pool: " + secondaryPool.getUuid()); return new PrimaryStorageDownloadAnswer(primaryVol.getName(), primaryVol.getSize()); } catch (final CloudRuntimeException e) { return new PrimaryStorageDownloadAnswer(e.toString()); } finally { if (secondaryPool != null) {
final List<KVMPhysicalDisk> disks = secondaryPool.listPhysicalDisks(); if (disks == null || disks.isEmpty()) { return new PrimaryStorageDownloadAnswer("Failed to get volumes from pool: " + secondaryPool.getUuid()); return new PrimaryStorageDownloadAnswer("Failed to get template from pool: " + secondaryPool.getUuid());