protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromVolumeCommand cmd) { String secondaryStorageUrl = cmd.getSecondaryStorageUrl(); String volumePath = cmd.getVolumePath(); Long accountId = cmd.getAccountId(); Long templateId = cmd.getTemplateId(); int wait = cmd.getWait(); if (wait == 0) { /* Defaut timeout 2 hours */ wait = 7200; } try { URI uri; uri = new URI(secondaryStorageUrl); String secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath(); String installPath = "template/tmpl/" + accountId + "/" + templateId; Map<String, String> res = OvmStoragePool.createTemplateFromVolume(_conn, secondaryStorageMountPath, installPath, volumePath, wait); return new CreatePrivateTemplateAnswer(cmd, true, null, res.get("installPath"), Long.parseLong(res.get("virtualSize")), Long.parseLong(res.get("physicalSize")), res.get("templateFileName"), ImageFormat.RAW); } catch (Exception e) { s_logger.debug("Create template failed", e); return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); } }
public CreatePrivateTemplateAnswer execute( final CreatePrivateTemplateFromVolumeCommand cmd) { LOGGER.debug("execute: "+ cmd.getClass()); String volumePath = cmd.getVolumePath(); Long accountId = cmd.getAccountId(); Long templateId = cmd.getTemplateId(); int wait = cmd.getWait(); if (wait == 0) { /* Defaut timeout 2 hours */ wait = 7200; } try { /* missing uuid */ String installPath = config.getAgentOvmRepoPath() + "/" + config.getTemplateDir() + "/" + accountId + "/" + templateId; Linux host = new Linux(c); host.copyFile(volumePath, installPath); return new CreatePrivateTemplateAnswer(cmd, true, installPath); } catch (Exception e) { LOGGER.debug("Create template failed", e); return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage()); } }
command.getPool().getUserInfo(), command.getPool().getType()); } else { return new CreatePrivateTemplateAnswer(command, false, e.getMessage()); return new CreatePrivateTemplateAnswer(command, false, result); loc.save(); return new CreatePrivateTemplateAnswer(command, true, null, templateInstallFolder + command.getUniqueName() + ".qcow2", info.virtualSize, info.size, command.getUniqueName(), ImageFormat.QCOW2); } catch (final InternalErrorException e) { return new CreatePrivateTemplateAnswer(command, false, e.toString()); } catch (final IOException e) { return new CreatePrivateTemplateAnswer(command, false, e.toString()); } catch (final ConfigurationException e) { return new CreatePrivateTemplateAnswer(command, false, e.toString()); } catch (final CloudRuntimeException e) { return new CreatePrivateTemplateAnswer(command, false, e.toString()); } finally { if (secondaryStorage != null) {
loc.save(); return new CreatePrivateTemplateAnswer(command, true, "", tmplPath, info.virtualSize, info.size, tmplName, info.format); } catch (final ConfigurationException e) { return new CreatePrivateTemplateAnswer(command, false, e.getMessage()); } catch (final InternalErrorException e) { return new CreatePrivateTemplateAnswer(command, false, e.getMessage()); } catch (final IOException e) { return new CreatePrivateTemplateAnswer(command, false, e.getMessage()); } catch (final CloudRuntimeException e) { return new CreatePrivateTemplateAnswer(command, false, e.getMessage()); } finally { if (secondaryPool != null) {