Examples of AMException


Examples of com.abiquo.am.model.error.AMException

            OVFEnvelopeUtils.addVirtualSystem(envelope, vsystem);
            envelope.setReferences(references);
        }
        catch (Exception e)
        {
            throw new AMException(AMError.TEMPLATE_INSTALL,
                "Can not create the OVF from the DiskInfo", e);
        }

        return envelope;
    }
View Full Code Here

Examples of com.abiquo.am.model.error.AMException

            diskSection = OVFEnvelopeUtils.getSection(envelope, DiskSectionType.class);
        }
        catch (Exception e)
        {
            throw new AMException(AMError.TEMPLATE_BOUNDLE, String.format(
                "The bundle [%s] can not be created "
                    + "because the original envelope do not exist or do not have Disk Section",
                snapshot), e);
        }

        List<VirtualDiskDescType> disks = diskSection.getDisk();

        if (disks.isEmpty())
        {

            throw new AMException(AMError.TEMPLATE_BOUNDLE, String.format(
                "The bundle [%s] can not be created  because the "
                    + "original envelope do not contains any Disk", snapshot));
        }
        else
        {
            for (VirtualDiskDescType disk : disks)
            {
                diskFileIds.add(disk.getFileRef());
            }
        }

        // all the disk files should be marked with "snapshot + OVF_BUNDLE_PATH_IDENTIFIER" + hRef
        // (packagePath relative)
        for (String diskFileId : diskFileIds)
        {
            FileType file;
            try
            {
                file = OVFReferenceUtils.getReferencedFile(envelope, diskFileId);
            }
            catch (IdNotFoundException e)
            {
                throw new AMException(AMError.TEMPLATE_BOUNDLE, String.format(
                    "The bundle [%s] can not be created because the "
                        + "referenced file Id [%s] is not found on the Envelope", snapshot,
                    diskFileId), e);
            }

            // TODO check hRef is 'packagePath' relative
            final String relativeBundleFileRef = snapshot + file.getHref();
            final String absoluteBundleFileRef = packagePath + relativeBundleFileRef;

            File bundleFile = new File(absoluteBundleFileRef);
            Long bundleFileSize;

            if (!bundleFile.exists() || bundleFile.isDirectory())
            {

                throw new AMException(AMError.TEMPLATE_BOUNDLE, String.format(
                    "The bundle [%s] can not be created because the "
                        + "referenced file on [%s] is not found", snapshot, absoluteBundleFileRef));
            }
            else
            {
View Full Code Here

Examples of com.abiquo.am.model.error.AMException

            diskSection = OVFEnvelopeUtils.getSection(envelope, DiskSectionType.class);
        }
        catch (Exception e)
        {
            throw new AMException(AMError.PROMOTE_MASTER_OVF, String.format(
                "The promote [%s] can not be created "
                    + "because the original envelope do not exist or do not have Disk Section",
                relativeDiskPath), e);
        }

        List<VirtualDiskDescType> disks = diskSection.getDisk();

        if (disks.isEmpty())
        {

            throw new AMException(AMError.PROMOTE_MASTER_OVF, String.format(
                "The promote [%s] can not be created  because the "
                    + "original envelope do not contains any Disk", relativeDiskPath));
        }
        else
        {
            for (VirtualDiskDescType disk : disks)
            {
                diskFileIds.add(disk.getFileRef());
            }
        }

        // all the disk files should be marked with "snapshot + OVF_BUNDLE_PATH_IDENTIFIER" + hRef
        // (packagePath relative)
        for (String diskFileId : diskFileIds)
        {
            FileType file;
            try
            {
                file = OVFReferenceUtils.getReferencedFile(envelope, diskFileId);
            }
            catch (IdNotFoundException e)
            {
                throw new AMException(AMError.PROMOTE_MASTER_OVF, String.format(
                    "The promote [%s] can not be created because the "
                        + "referenced file Id [%s] is not found on the Envelope", relativeDiskPath,
                    diskFileId), e);
            }
View Full Code Here

Examples of com.abiquo.am.model.error.AMException

        {
            diskSection = OVFEnvelopeUtils.getSection(envelope, DiskSectionType.class);
        }
        catch (Exception e)// SectionNotPresentException InvalidSectionException
        {
            throw new AMException(AMError.TEMPLATE_INVALID, "missing DiskSection");
        }

        List<VirtualDiskDescType> disks = diskSection.getDisk();

        if (disks == null || disks.isEmpty() || disks.size() != 1)
        {
            throw new AMException(AMError.TEMPLATE_INVALID, "multiple Disk not supported");
        }

        return disks.get(0);

    }
View Full Code Here

Examples of com.abiquo.am.model.error.AMException

                        + "]"); // XXX warning ??
                }

                if (diskIdToVSs.size() != 1)
                {
                    throw new AMException(AMError.TEMPLATE_INVALID, String.format(
                        "There are more than one virtual system on the OVF Envelope [%s]", ovfId));
                }

                for (String vssName : diskIdToVSs.get(diskId))
                {
                    diskInfo = new TemplateDto();
                    diskInfo.setName(vssName);
                    diskInfo.setUrl(ovfId);
                    diskInfo.setLoginUser(getProductPropertyValue(product, "user"));
                    diskInfo.setLoginPassword(getProductPropertyValue(product, "password"));
                    diskInfo.setOsType(getOSType(ossection));
                    diskInfo.setOsVersion(getOSVersion(ossection));

                    DiskFormat diskFormat = DiskFormat.fromValue(format);
                    DiskFormatType ovfDiskFormat = DiskFormatType.valueOf(diskFormat.name());

                    diskInfo.setDiskFileFormat(ovfDiskFormat);
                    diskInfo.setDiskFileSize(fileSize);

                    // Note that getHRef() will now return the relative path
                    // of the file at the downloaded repository space

                    if (filePath.startsWith("http:"))
                    {
                        diskInfo.setDiskFilePath(FilenameUtils.getName(filePath));
                    }
                    else
                    {
                        diskInfo.setDiskFilePath(filePath);
                    }

                    diskInfo.setIconPath(iconPath);
                    diskInfo.setDescription(description);
                    diskInfo.setCategoryName(categoryName);
                    // XXX diskInfo.setSO(value);

                    if (!requiredByVSs.containsKey(vssName))
                    {
                        throw new IdNotFoundException("VirtualSystem id not found [" + vssName
                            + "]");
                    }

                    TemplateDto requirement = requiredByVSs.get(vssName);

                    // XXX disk format ::: diskInfo.setImageType(requirement.getImageType());

                    diskInfo.setCpu(requirement.getCpu());
                    diskInfo.setRam(requirement.getRam());
                    diskInfo.setHd(requirement.getHd());

                    diskInfo.setRamSizeUnit(requirement.getRamSizeUnit());
                    diskInfo.setHdSizeUnit(requirement.getHdSizeUnit());

                    diskInfo.setEthernetDriverType(requirement.getEthernetDriverType());
                    diskInfo.setDiskControllerType(requirement.getDiskControllerType());

                    // TODO diskInfo.setEnterpriseId(enterpriseId);
                    // diskInfo.setUserId(userId); TODO user ID
                    // diskInfo.getCategories().add(category); TODO category

                }// all vss
            }// all disks
        }
        catch (EmptyEnvelopeException e)
        {
            String msg = "No VirtualSystem or VirtualSystemCollection exists for this OVF package";
            throw new AMException(AMError.TEMPLATE_INVALID, msg, e);
        }
        catch (Exception e)
        {
            throw new AMException(AMError.TEMPLATE_INVALID, e);
        }

        if (diskInfo == null)
        {
            String msg = "No VirtualSystem or VirtualSystemCollection exists for this OVF package";
            throw new AMException(AMError.TEMPLATE_INVALID, msg);
        }

        return diskInfo;
    }
View Full Code Here

Examples of com.abiquo.am.model.error.AMException

            envelope = fixDiskFormtatUriAndFileSizes(envelope, ovfId);
            envelope = fixMissingProductSection(envelope);
        }
        catch (Exception e)
        {
            throw new AMException(AMError.TEMPLATE_INVALID, e);
        }

        return envelope;
    }
View Full Code Here

Examples of com.abiquo.am.model.error.AMException

                OVFEnvelopeUtils.getSection(envelope, DiskSectionType.class);

            if (diskSectionType.getDisk().size() != 1)
            {
                // more than one disk in disk section
                throw new AMException(AMError.TEMPLATE_INVALID_MULTIPLE_DISKS);
            }
            else
            {
                int references = 0;
                for (FileType fileType : envelope.getReferences().getFile())
                {
                    fileIdToFileType.put(fileType.getId(), fileType);
                    if (diskSectionType.getDisk().get(0).getFileRef().equals(fileType.getId()))
                    {
                        references++;
                    }
                }
                if (references != 1)
                {
                    // file referenced in diskSection isn't found in file references or found more
                    // than one
                    throw new AMException(AMError.TEMPLATE_INVALID_MULTIPLE_FILES);
                }
            }
            // Create a hash
            for (VirtualDiskDescType virtualDiskDescType : diskSectionType.getDisk())
            {
                diskIdToDiskFormat.put(virtualDiskDescType.getDiskId(), virtualDiskDescType);
            }

            // /

            ContentType content = OVFEnvelopeUtils.getTopLevelVirtualSystemContent(envelope);

            if (content instanceof VirtualSystemCollectionType)
            {
                throw new EmptyEnvelopeException(
                    "Current OVF description document includes a VirtualSystemCollection, "
                        + "abicloud only deal with single virtual system based OVFs");
            }

            VirtualSystemType vsystem = (VirtualSystemType) content;

            VirtualHardwareSectionType hardwareSectionType;
            Integer cpu = null;
            Long hd = null;
            Long ram = null;

            try
            {
                hardwareSectionType =
                    OVFEnvelopeUtils.getSection(vsystem, VirtualHardwareSectionType.class);
            }
            catch (InvalidSectionException e)
            {
                throw new SectionNotPresentException("VirtualHardware on a virtualSystem", e);
            }

            for (RASDType rasdType : hardwareSectionType.getItem())
            {

                ResourceType resourceType = rasdType.getResourceType();
                if (resourceType == null) // empty rasd element
                {
                    continue;
                }
                int resTnumeric = Integer.parseInt(resourceType.getValue());

                // Get the information on the ram
                if (CIMResourceTypeEnum.Processor.getNumericResourceType() == resTnumeric)
                {
                    try
                    {
                        String cpuVal = rasdType.getVirtualQuantity().getValue().toString();

                        cpu = Integer.parseInt(cpuVal);
                    }
                    catch (Exception e)
                    {
                        throw new AMException(AMError.TEMPLATE_INVALID,
                            "Invalid CPU virtualQuantity");
                    }
                }
                else if (CIMResourceTypeEnum.Memory.getNumericResourceType() == resTnumeric)
                {
                    try
                    {
                        BigInteger ramVal = rasdType.getVirtualQuantity().getValue();

                        ram = ramVal.longValue();
                    }
                    catch (Exception e)
                    {
                        throw new AMException(AMError.TEMPLATE_INVALID,
                            "Invalid RAM virtualQuantity");
                    }

                    if (rasdType.getAllocationUnits() != null
                        & rasdType.getAllocationUnits().getValue() != null)
                    {
                        final String allocationUnits = rasdType.getAllocationUnits().getValue();

                        final MemorySizeUnit ramSizeUnit = getMemoryUnitsFromOVF(allocationUnits);
                    }
                }
                else if (CIMResourceTypeEnum.Disk_Drive.getNumericResourceType() == resTnumeric)
                {
                    // HD requirements are extracted from the associated Disk on ''hostResource''
                    String diskId = getVirtualSystemDiskId(rasdType.getHostResource());

                    if (!diskIdToDiskFormat.containsKey(diskId))
                    {
                        throw new RequiredAttributeException(
                            "Virtual System makes reference to an undeclared disk " + diskId);
                    }

                    VirtualDiskDescType diskDescType = diskIdToDiskFormat.get(diskId);

                    String capacity = diskDescType.getCapacity();

                    hd = Long.parseLong(capacity);

                    final String allocationUnits = diskDescType.getCapacityAllocationUnits();
                    final MemorySizeUnit hdSizeUnit = getMemoryUnitsFromOVF(allocationUnits);
                }
            }// rasd

            if (cpu == null)
            {
                throw new RequiredAttributeException("Not CPU RASD element found on the envelope");
            }
            if (ram == null)
            {
                throw new RequiredAttributeException("Not RAM RASD element found on the envelope");
            }
            if (hd == null)
            {
                throw new RequiredAttributeException("Not HD RASD element found on the envelope");
            }

        }

        catch (AMException amException)
        {
            throw amException;
        }
        catch (Exception e)
        {
            throw new AMException(AMError.TEMPLATE_INVALID, e);
        }

        return envelope;
    }
View Full Code Here

Examples of com.abiquo.am.model.error.AMException

                    fileURL = new URL(packageURL + '/' + relativeFilePath);
                }
                catch (MalformedURLException e)
                {
                    final String msg = "Invalid file reference " + ovfId + '/' + relativeFilePath;
                    throw new AMException(AMError.TEMPLATE_INVALID, msg, e1);
                }
            }
            else
            {
                final String msg = "Invalid file reference " + relativeFilePath;
                throw new AMException(AMError.TEMPLATE_INVALID, msg, e1);
            }
        }
        return fileURL.toExternalForm();
    }
View Full Code Here

Examples of com.abiquo.am.model.error.AMException

                        + "]"); // XXX warning ??
                }

                if (diskIdToVSs.size() != 1)
                {
                    throw new AMException(AMError.TEMPLATE_INVALID, String.format(
                        "There are more than one virtual system on the OVF Envelope [%s]", ovfId));
                }

                for (String vssName : diskIdToVSs.get(diskId))
                {
                    diskInfo = new TemplateDto();
                    diskInfo.setName(vssName);
                    diskInfo.setUrl(ovfId);
                    diskInfo.setLoginUser(getProductPropertyValue(product, "user"));
                    diskInfo.setLoginPassword(getProductPropertyValue(product, "password"));
                    diskInfo.setOsType(getOSType(ossection));
                    diskInfo.setOsVersion(getOSVersion(ossection));

                    DiskFormatOVF diskFormat = DiskFormatOVF.fromValue(format);

                    diskInfo.setDiskFileFormat(diskFormat.name());
                    diskInfo.setDiskFileSize(fileSize);

                    // Note that getHRef() will now return the relative path
                    // of the file at the downloaded repository space

                    if (filePath.startsWith("http:"))
                    {
                        diskInfo.setDiskFilePath(FilenameUtils.getName(filePath));
                    }
                    else
                    {
                        diskInfo.setDiskFilePath(filePath);
                    }

                    diskInfo.setIconUrl(iconPath);
                    diskInfo.setDescription(description);
                    diskInfo.setCategoryName(categoryName);
                    // XXX diskInfo.setSO(value);

                    if (!requiredByVSs.containsKey(vssName))
                    {
                        throw new IdNotFoundException("VirtualSystem id not found [" + vssName
                            + "]");
                    }

                    TemplateDto requirement = requiredByVSs.get(vssName);

                    // XXX disk format ::: diskInfo.setImageType(requirement.getImageType());

                    diskInfo.setRequiredCpu(requirement.getRequiredCpu());
                    diskInfo.setRequiredRamInMB(requirement.getRequiredRamInMB());
                    diskInfo.setRequiredHDInMB(requirement.getRequiredHDInMB());

                    diskInfo.setEthernetDriverType(requirement.getEthernetDriverType());
                    diskInfo.setDiskControllerType(requirement.getDiskControllerType());

                    // TODO diskInfo.setEnterpriseId(enterpriseId);
                    // diskInfo.setUserId(userId); TODO user ID
                    // diskInfo.getCategories().add(category); TODO category

                }// all vss
            }// all disks
        }
        catch (EmptyEnvelopeException e)
        {
            String msg = "No VirtualSystem or VirtualSystemCollection exists for this OVF package";
            throw new AMException(AMError.TEMPLATE_INVALID, msg, e);
        }
        catch (Exception e)
        {
            throw new AMException(AMError.TEMPLATE_INVALID, e);
        }

        if (diskInfo == null)
        {
            String msg = "No VirtualSystem or VirtualSystemCollection exists for this OVF package";
            throw new AMException(AMError.TEMPLATE_INVALID, msg);
        }

        return diskInfo;
    }
View Full Code Here

Examples of com.abiquo.am.model.error.AMException

            envelope = fixDiskFormtatUriAndFileSizes(envelope);
            envelope = fixMissingProductSection(envelope);
        }
        catch (Exception e)
        {
            throw new AMException(AMError.TEMPLATE_INVALID, e);
        }

        return envelope;
    }
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.