Examples of TemplateObjectTO


Examples of org.apache.cloudstack.storage.to.TemplateObjectTO

            if (srcSnapshot.getParent() != null) {
                newSnapshot.setParentSnapshotPath(srcSnapshot.getParent().getPath());
            }
            data = newSnapshot;
        } else if (destData.getType() == DataObjectType.TEMPLATE) {
            TemplateObjectTO newTemplate = new TemplateObjectTO();
            newTemplate.setPath(UUID.randomUUID().toString());
            newTemplate.setFormat(Storage.ImageFormat.QCOW2);
            newTemplate.setSize(10L);
            newTemplate.setPhysicalSize(10L);
            data = newTemplate;
        }
        answer = new CopyCmdAnswer(data);
        CopyCommandResult result = new CopyCommandResult("something", answer);
        callback.complete(result);
View Full Code Here

Examples of org.apache.cloudstack.storage.to.TemplateObjectTO

         */

        DataStore store = this.dataStoreMgr.getDataStore(imageStore.getId(), DataStoreRole.Image);
        TemplateInfo template = templateFactory.getTemplate(image.getId(), DataStoreRole.Image);
        DataObject templateOnStore = store.create(template);
        TemplateObjectTO to = new TemplateObjectTO();
        to.setPath(this.getImageInstallPath());
        to.setFormat(ImageFormat.VHD);
        to.setSize(100L);
        CopyCmdAnswer answer = new CopyCmdAnswer(to);
        templateOnStore.processEvent(Event.CreateOnlyRequested);
        templateOnStore.processEvent(Event.OperationSuccessed, answer);

    }
View Full Code Here

Examples of org.apache.cloudstack.storage.to.TemplateObjectTO

        long size = this._storage.getSize(downloadPath + File.separator + templateFilename);

        DataTO newDestTO = null;

        if (destData.getObjectType() == DataObjectType.TEMPLATE) {
            TemplateObjectTO newTemplTO = new TemplateObjectTO();
            newTemplTO.setPath(finalDownloadPath);
            newTemplTO.setName(finalFileName);
            newTemplTO.setSize(size);
            newTemplTO.setPhysicalSize(size);
            newDestTO = newTemplTO;
        } else {
            VolumeObjectTO newVolTO = new VolumeObjectTO();
            newVolTO.setPath(finalDownloadPath);
            newVolTO.setName(finalFileName);
View Full Code Here

Examples of org.apache.cloudstack.storage.to.TemplateObjectTO

            TemplateLocation loc = new TemplateLocation(_storage, destPath);
            loc.create(1, true, templateUuid);
            loc.addFormat(info);
            loc.save();
            TemplateProp prop = loc.getTemplateInfo();
            TemplateObjectTO newTemplate = new TemplateObjectTO();
            newTemplate.setPath(destData.getPath() + File.separator + templateName);
            newTemplate.setFormat(ImageFormat.VHD);
            newTemplate.setSize(prop.getSize());
            newTemplate.setPhysicalSize(prop.getPhysicalSize());
            newTemplate.setName(templateUuid);
            return new CopyCmdAnswer(newTemplate);
        } catch (ConfigurationException e) {
            s_logger.debug("Failed to create template from snapshot: " + e.toString());
            errMsg = e.toString();
        } catch (InternalErrorException e) {
View Full Code Here

Examples of org.apache.cloudstack.storage.to.TemplateObjectTO

                loc.create(1, true, destData.getName());
                loc.addFormat(info);
                loc.save();

                TemplateProp prop = loc.getTemplateInfo();
                TemplateObjectTO newTemplate = new TemplateObjectTO();
                newTemplate.setPath(destData.getPath() + File.separator + fileName);
                newTemplate.setFormat(srcFormat);
                newTemplate.setSize(prop.getSize());
                newTemplate.setPhysicalSize(prop.getPhysicalSize());
                return new CopyCmdAnswer(newTemplate);
            } catch (ConfigurationException e) {
                s_logger.debug("Failed to create template:" + e.toString());
                return new CopyCmdAnswer(e.toString());
            } catch (IOException e) {
View Full Code Here

Examples of org.apache.cloudstack.storage.to.TemplateObjectTO

                File properties = new File(templateFile.getParent() + File.separator + _tmpltpp);
                if (properties.exists()) {
                    SwiftUtil.putObject(swift, properties, containterName, _tmpltpp);
                }

                TemplateObjectTO template = new TemplateObjectTO();
                template.setPath(swiftPath);
                template.setSize(templateFile.length());
                template.setPhysicalSize(template.getSize());
                SnapshotObjectTO snapshot = (SnapshotObjectTO)srcData;
                template.setFormat(snapshot.getVolume().getFormat());
                return new CopyCmdAnswer(template);
            } else if (destDataStore instanceof S3TO) {
                //create template on the same data store
                CopyCmdAnswer answer = (CopyCmdAnswer)copySnapshotToTemplateFromNfsToNfs(cmd, (SnapshotObjectTO) srcData, (NfsTO) srcDataStore,
                        (TemplateObjectTO) destData, (NfsTO) srcDataStore);
                if (!answer.getResult()) {
                    return answer;
                }
                TemplateObjectTO newTemplate = (TemplateObjectTO)answer.getNewData();
                newTemplate.setDataStore(srcDataStore);
                CopyCommand newCpyCmd = new CopyCommand(newTemplate, destData, cmd.getWait(), cmd.executeInSequence());
                return copyFromNfsToS3(newCpyCmd);
            }
        }
        s_logger.debug("Failed to create templat from snapshot");
View Full Code Here

Examples of org.apache.cloudstack.storage.to.TemplateObjectTO

            String key = destData.getPath() + S3Utils.SEPARATOR + srcFile.getName();
            putFile(s3, srcFile, bucket, key);

            DataTO retObj = null;
            if (destData.getObjectType() == DataObjectType.TEMPLATE) {
                TemplateObjectTO newTemplate = new TemplateObjectTO();
                newTemplate.setPath(key);
                newTemplate.setSize(getVirtualSize(srcFile, format));
                newTemplate.setPhysicalSize(srcFile.length());
                newTemplate.setFormat(format);
                retObj = newTemplate;
            } else if (destData.getObjectType() == DataObjectType.VOLUME) {
                VolumeObjectTO newVol = new VolumeObjectTO();
                newVol.setPath(key);
                newVol.setSize(srcFile.length());
View Full Code Here

Examples of org.apache.cloudstack.storage.to.TemplateObjectTO

        root.isIso = false;
        vm.rootDisk = root;
      } else if (volume.getType() == Volume.Type.ISO) {
        DataTO isoTO = volume.getData();
        if (isoTO.getPath() != null) {
          TemplateObjectTO template = (TemplateObjectTO)isoTO;
          DataStoreTO store = template.getDataStore();
          if (!(store instanceof NfsTO)) {
            throw new CloudRuntimeException("unsupported protocol");
          }
          NfsTO nfsStore = (NfsTO)store;
          String isoPath = nfsStore.getUrl() + File.separator + template.getPath();
          OvmDisk.Details iso = new OvmDisk.Details();
          URI path = new URI(isoPath);
          iso.path = path.getHost() + ":" + path.getPath();
          iso.type = OvmDisk.READ;
          iso.isIso = true;
View Full Code Here

Examples of org.apache.cloudstack.storage.to.TemplateObjectTO

         */

        DataStore store = this.dataStoreMgr.getDataStore(imageStore.getId(), DataStoreRole.Image);
        TemplateInfo template = templateFactory.getTemplate(image.getId(), DataStoreRole.Image);
        DataObject templateOnStore = store.create(template);
        TemplateObjectTO to = new TemplateObjectTO();
        to.setPath(this.getImageInstallPath());
        to.setFormat(ImageFormat.VHD);
        to.setSize(1000L);
        CopyCmdAnswer answer = new CopyCmdAnswer(to);
        templateOnStore.processEvent(Event.CreateOnlyRequested);
        templateOnStore.processEvent(Event.OperationSuccessed, answer);

    }
View Full Code Here

Examples of org.apache.cloudstack.storage.to.TemplateObjectTO

    protected VDI mount(Connection conn, String vmName, DiskTO volume) throws XmlRpcException, XenAPIException {
        DataTO data = volume.getData();
        Volume.Type type = volume.getType();
        if (type == Volume.Type.ISO) {
            TemplateObjectTO iso = (TemplateObjectTO)data;
            DataStoreTO store = iso.getDataStore();
           
            if (store == null) {
                //It's a fake iso
                return null;
            }
           
            //corer case, xenserver pv driver iso
            String templateName = iso.getName();
            if (templateName.startsWith("xs-tools")) {
                try {
                    Set<VDI> vdis = VDI.getByNameLabel(conn, templateName);
                    if (vdis.isEmpty()) {
                        throw new CloudRuntimeException("Could not find ISO with URL: " + templateName);
                    }
                    return vdis.iterator().next();
                } catch (XenAPIException e) {
                    throw new CloudRuntimeException("Unable to get pv iso: " + templateName + " due to " + e.toString());
                } catch (Exception e) {
                    throw new CloudRuntimeException("Unable to get pv iso: " + templateName + " due to " + e.toString());
                }
            }
           
            if (!(store instanceof NfsTO)) {
                throw new CloudRuntimeException("only support mount iso on nfs");
            }
            NfsTO nfsStore = (NfsTO)store;
            String isoPath = nfsStore.getUrl() + File.separator + iso.getPath();
            int index = isoPath.lastIndexOf("/");

            String mountpoint = isoPath.substring(0, index);
            URI uri;
            try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.