Package com.cloud.hypervisor.vmware.mo

Examples of com.cloud.hypervisor.vmware.mo.DatastoreFile


        // we will honor vCenter's meta if it exists
      if(diskInfo != null) {
        // to deal with run-time upgrade to maintain the new datastore folder structure
        String disks[] = diskInfo.getDiskChain();
        for(int i = 0; i < disks.length; i++) {
          DatastoreFile file = new DatastoreFile(disks[i]);
          if(file.getDir() != null && file.getDir().isEmpty()) {
            s_logger.info("Perform run-time datastore folder upgrade. sync " + disks[i] + " to VM folder");
            disks[i] = VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(
                    dcMo, vmMo.getName(), dsMo, file.getFileBaseName());
          }
        }
        return disks;
      }
       
View Full Code Here


            VirtualMachineDiskInfo infoInChain = _gson.fromJson(chainInfo, VirtualMachineDiskInfo.class);
            if(infoInChain != null) {
              String[] disks = infoInChain.getDiskChain();
              if(disks.length > 0) {
                for(String diskPath : disks) {
                  DatastoreFile file = new DatastoreFile(diskPath);
                  diskInfo = diskInfoBuilder.getDiskInfoByBackingFileBaseName(file.getFileBaseName());
                  if(diskInfo != null) {
                    s_logger.info("Found existing disk from chain info: " + diskPath);
                    return diskInfo;
                  }
                }
View Full Code Here

        assert(diskInfo != null);
       
        String[] diskChain = diskInfo.getDiskChain();
        assert(diskChain.length > 0);
       
        DatastoreFile file = new DatastoreFile(diskChain[0]);
        if(!file.getFileBaseName().equalsIgnoreCase(volumeTO.getPath())) {
          if(s_logger.isInfoEnabled())
            s_logger.info("Detected disk-chain top file change on volume: " + volumeTO.getId() + " "
              + volumeTO.getPath() + " -> " + file.getFileBaseName());
        }
       
        VolumeObjectTO volInSpec = getVolumeInSpec(vmSpec, volumeTO);
        volInSpec.setPath(file.getFileBaseName());
        volInSpec.setChainInfo(_gson.toJson(diskInfo));
      }
    }
View Full Code Here

    public static void syncVolumeToRootFolder(DatacenterMO dcMo, DatastoreMO ds, String vmdkName) throws Exception {
      String fileDsFullPath = ds.searchFileInSubFolders(vmdkName + ".vmdk", false);
      if(fileDsFullPath == null)
        return;

      DatastoreFile srcDsFile = new DatastoreFile(fileDsFullPath);
      String companionFilePath = srcDsFile.getCompanionPath(vmdkName + "-flat.vmdk");
      if(ds.fileExists(companionFilePath)) {
        String targetPath = getLegacyDatastorePathFromVmdkFileName(ds, vmdkName + "-flat.vmdk");

        s_logger.info("Fixup folder-synchronization. move " + companionFilePath + " -> " + targetPath);
        ds.moveDatastoreFile(companionFilePath, dcMo.getMor(), ds.getMor(), targetPath, dcMo.getMor(), true);
      }
     
      companionFilePath = srcDsFile.getCompanionPath(vmdkName + "-delta.vmdk");
      if(ds.fileExists(companionFilePath)) {
        String targetPath = getLegacyDatastorePathFromVmdkFileName(ds, vmdkName + "-delta.vmdk");
       
        s_logger.info("Fixup folder-synchronization. move " + companionFilePath + " -> " + targetPath);
        ds.moveDatastoreFile(companionFilePath, dcMo.getMor(), ds.getMor(), targetPath, dcMo.getMor(), true);
View Full Code Here

    }
   
    public static void moveVolumeToRootFolder(DatacenterMO dcMo, List<String> detachedDisks) throws Exception {
      if(detachedDisks.size() > 0) {
        for(String fileFullDsPath : detachedDisks) {
          DatastoreFile file = new DatastoreFile(fileFullDsPath);
         
          s_logger.info("Check if we need to move " + fileFullDsPath + " to its root location");
          DatastoreMO dsMo = new DatastoreMO(dcMo.getContext(), dcMo.findDatastore(file.getDatastoreName()));
          if(dsMo.getMor() != null) {
            DatastoreFile targetFile = new DatastoreFile(file.getDatastoreName(), file.getFileName());
            if(!targetFile.getPath().equalsIgnoreCase(file.getPath())) {
              s_logger.info("Move " + file.getPath() + " -> " + targetFile.getPath());
              dsMo.moveDatastoreFile(file.getPath(), dcMo.getMor(), dsMo.getMor(), targetFile.getPath(), dcMo.getMor(), true);

              String pairSrcFilePath = file.getCompanionPath(file.getFileBaseName() + "-flat.vmdk");
                String pairTargetFilePath = targetFile.getCompanionPath(file.getFileBaseName() + "-flat.vmdk");
                if(dsMo.fileExists(pairSrcFilePath)) {
                  s_logger.info("Move " + pairSrcFilePath + " -> " + pairTargetFilePath);
                dsMo.moveDatastoreFile(pairSrcFilePath, dcMo.getMor(), dsMo.getMor(), pairTargetFilePath, dcMo.getMor(), true);
                }
               
              pairSrcFilePath = file.getCompanionPath(file.getFileBaseName() + "-delta.vmdk");
                pairTargetFilePath = targetFile.getCompanionPath(file.getFileBaseName() + "-delta.vmdk");
                if(dsMo.fileExists(pairSrcFilePath)) {
                  s_logger.info("Move " + pairSrcFilePath + " -> " + pairTargetFilePath);
                dsMo.moveDatastoreFile(pairSrcFilePath, dcMo.getMor(), dsMo.getMor(), pairTargetFilePath, dcMo.getMor(), true);
                }
            }
View Full Code Here

                              s_logger.error("Unexpected exception", e);
                            }
                           
                            s_logger.info("Disk has been consolidated, top VMDK is now: " + topVmdkFilePath);
                            if(topVmdkFilePath != null) {
                              DatastoreFile file = new DatastoreFile(topVmdkFilePath);
                             
                              SnapshotObjectTO snapshotInfo = (SnapshotObjectTO)answer.getNewData();
                              VolumeObjectTO vol = new VolumeObjectTO();
                              vol.setUuid(srcSnapshot.getVolume().getUuid());
                              vol.setPath(file.getFileBaseName());
                              snapshotInfo.setVolume(vol);
                            } else {
                              s_logger.error("Disk has been consolidated, but top VMDK is not found ?!");
                            }
                          }
View Full Code Here

        // we will honor vCenter's meta if it exists
        if(diskInfo != null) {
            // to deal with run-time upgrade to maintain the new datastore folder structure
            String disks[] = diskInfo.getDiskChain();
            for(int i = 0; i < disks.length; i++) {
                DatastoreFile file = new DatastoreFile(disks[i]);
                if (!isManaged && file.getDir() != null && file.getDir().isEmpty()) {
                    s_logger.info("Perform run-time datastore folder upgrade. sync " + disks[i] + " to VM folder");
                    disks[i] = VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(
                            dcMo, vmMo.getName(), dsMo, file.getFileBaseName());
                }
            }
            return disks;
        }
View Full Code Here

            VolumeObjectTO volume = (VolumeObjectTO)vol.getData();

            Map<String, String> details = vol.getDetails();
            boolean isManaged = details != null && Boolean.parseBoolean(details.get(DiskTO.MANAGED));

            VirtualMachineDiskInfo diskInfo = diskInfoBuilder.getDiskInfoByBackingFileBaseName(isManaged ? new DatastoreFile(volume.getPath()).getFileBaseName() : volume.getPath());
            if(diskInfo != null) {
                s_logger.info("Found existing disk info from volume path: " + volume.getPath());
                return diskInfo;
            } else {
                String chainInfo = volume.getChainInfo();
                if(chainInfo != null) {
                    VirtualMachineDiskInfo infoInChain = _gson.fromJson(chainInfo, VirtualMachineDiskInfo.class);
                    if(infoInChain != null) {
                        String[] disks = infoInChain.getDiskChain();
                        if(disks.length > 0) {
                            for(String diskPath : disks) {
                                DatastoreFile file = new DatastoreFile(diskPath);
                                diskInfo = diskInfoBuilder.getDiskInfoByBackingFileBaseName(file.getFileBaseName());
                                if(diskInfo != null) {
                                    s_logger.info("Found existing disk from chain info: " + diskPath);
                                    return diskInfo;
                                }
                            }
View Full Code Here

            assert(diskInfo != null);

            String[] diskChain = diskInfo.getDiskChain();
            assert(diskChain.length > 0);

            DatastoreFile file = new DatastoreFile(diskChain[0]);
            if(!file.getFileBaseName().equalsIgnoreCase(volumeTO.getPath())) {
                if(s_logger.isInfoEnabled())
                    s_logger.info("Detected disk-chain top file change on volume: " + volumeTO.getId() + " "
                            + volumeTO.getPath() + " -> " + file.getFileBaseName());
            }

            VolumeObjectTO volInSpec = getVolumeInSpec(vmSpec, volumeTO);
            volInSpec.setPath(file.getFileBaseName());
            volInSpec.setChainInfo(_gson.toJson(diskInfo));
        }
    }
View Full Code Here

      } while(parsePos > 0);
    return fileList.toArray(new String[0]);
  }

  public String composeDatastoreBrowseUrl(String dcName, String fullPath) {
    DatastoreFile dsFile = new DatastoreFile(fullPath);
    return composeDatastoreBrowseUrl(dcName, dsFile.getDatastoreName(), dsFile.getRelativePath());
  }
View Full Code Here

TOP

Related Classes of com.cloud.hypervisor.vmware.mo.DatastoreFile

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.