Package com.cybozu.vmbkp.profile

Examples of com.cybozu.vmbkp.profile.ProfileVm


        if ((new File(backupDirPath)).isDirectory() &&
            (new File(profVmPath)).isFile()) {

            ret = 1;
            try {
                ProfileVm profVm = new ProfileVm(profVmPath);
                if (profVm.getLatestSucceededGenerationId() >= 0) {
                    /* Succeeded generation exists. */
                    ret = 2;
                }
            } catch (IOException e) {
                errMsg = String.format("load profile %s failed.\n", profVmPath);
View Full Code Here


                throw new Exception();
            }
        }

        /* Prepare vm profile. */
        ProfileVm profVm;
        if ((new File(profVmPath)).isFile()) {
            /* The file exists so we load and update it. */
            profVm = new ProfileVm(profVmPath);

            /* Check moref of both the profile and vmInfo is same. */
            String moref = profVm.getMoref();
            if (! moref.equals(vmInfo.getMoref())) {
                logger_.warning
                    (String.format
                     ("moref %s != %s.\n", moref, vmInfo.getMoref()));
                throw new Exception();
            }

            /* is_clean must be true to continue backup process. */
            if (profVm.isClean() == false) {
                throw new Exception("profVm is not clean.");
            }
           
            /* Overwrite the name of the virtula machine. */
            profVm.setName(vmInfo.getName());
           
        } else {
            /* Config file does not exist then we create it. */

            profVm = new ProfileVm();
            profVm.initializeMetadata(vmInfo);
            profVm.write(profVmPath);
        }
       
        /* Create backup */
        profVm.makeBackup();

        return profVm;
    }
View Full Code Here

    {
        String path = cfgGlobal_.getDefaultProfileVmPath(vmMoref);
        if (path == null) { return null; }
        if (! (new File(path)).isFile()) { return null; }

        ProfileVm profVm = null;
        try {
            profVm = new ProfileVm(path);
        } catch (Exception e) {
            logger_.warning(Utility.toString(e));
            return null;
        }
        return profVm;
View Full Code Here

        (VmInfo vmInfo, SnapInfo snapInfo,
         List<VmdkInfo> vmdkInfoList, Calendar calendar,
         boolean isGzip)
        throws Exception
    {
        ProfileVm profVm = profVm_;
       
        /*
         * Create new generation id.
         */
        int currGenId = profVm.getLatestSucceededGenerationId();
        String timestampMs = Long.toString(calendar.getTimeInMillis());
        int newGenId = profVm.createNewGenerationId(timestampMs);
        profVm.write();
       
        /*
         * Make generation directory if it does not exist.
         */
        String genDir = profVm.getDefaultGenerationDirectory(newGenId);
        if ((new File(genDir)).mkdir() == false) {
            logger_.warning(String.format("mkdir %s failed.", genDir));
            throw new Exception();
        }

View Full Code Here

    public ProfileGeneration loadProfileGeneration(int genId)
        throws IOException, ParseException, NotNormalFileException,
               BackupFailedException
    {
        assert profVm_ != null;
        ProfileVm profVm = profVm_;
       
        if (genId < 0) {
            genId = profVm.getLatestSucceededGenerationId();
            if (genId < 0) { return null; }
        }

        if (profVm.isGenerationSucceeded(genId) == false) {
            logger_.warning
                (String.format
                 ("status of the generation  %d is not succeeded.", genId));
            throw new BackupFailedException();
        }
        String path = profVm.getDefaultProfileGenerationPath(genId);
        if (path == null) { return null; }

        return new ProfileGeneration(path);
    }
View Full Code Here

    public void deleteOldGenerations()
        throws Exception
    {
        /* Used member variables. */
        ConfigGlobal cfgGlobal = cfgGlobal_;
        ProfileVm profVm = profVm_;
       
        /* get keep_generations value */
        int keep = cfgGlobal.getKeepGenerations();
       
        /* get set of id of old generations */
        Set<Integer> oldGenIdSet = profVm.getOldGenerationSet(keep);

        /* debug */
        if (oldGenIdSet.isEmpty()) {
            logger_.info("No generation was deleted.");
            return;
View Full Code Here

     * Delete backup directory of failed generations.
     */
    public void deleteFailedGenerations()
        throws Exception
    {
        ProfileVm profVm = profVm_;
        List<Integer> list = profVm.getFailedGenerationList();

        for (Integer genIdI : list) {
            assert genIdI != null;
            deleteGeneration(genIdI.intValue());
        }
View Full Code Here

     * @param genId
     * @return True if succeeded.
     */
    private boolean deleteGeneration(int genId)
    {
        ProfileVm profVm = profVm_;
       
        String tgtPath =
            profVm.getDefaultGenerationDirectory(genId);
           
        /* delete generation directory */
        boolean ret = Utility.deleteDirectoryRecursive(new File(tgtPath));
        logger_.info
            (String.format
             ("delete generation %d directory %s.\n",
              genId, (ret ? "succeeded" : "failed")));

        /* delete information of the generation from profile vm */
        profVm.delGenerationInfo(genId);

        return ret;
    }
View Full Code Here

     *
     * @return >=0 in success, or -1 in failure.
     */
    public int getPrevDiskId(int diskId)
    {
        ProfileVm profVm = profVm_;
        ProfileGeneration currGen = currGen_;
       
        String uuid = currGen.getUuid(diskId);

        /* get previous generation and check. */
 
View Full Code Here

TOP

Related Classes of com.cybozu.vmbkp.profile.ProfileVm

Copyright © 2018 www.massapicom. 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.