Ejemplo n.º 1
0
  public static boolean setDiskAlias(BaseDisk disk, VM vm, int count) {
    if (disk == null) {
      log.error("Disk object is null");
      return false;
    }

    String vmName = nullSafeGetVmName(vm);
    disk.setDiskAlias(getSuggestedDiskAlias(disk, vmName, count));
    return true;
  }
Ejemplo n.º 2
0
 /**
  * Returns an alias for the given disk. If the disk already has an alias, it is returned. If not,
  * {@link #aliasIfNull} is returned.
  *
  * @param disk The disk
  * @param aliasIfNull The alias to return if the disk does not have an alias
  * @return The alias in question
  */
 public static String getDiskAliasWithDefault(BaseDisk disk, String aliasIfNull) {
   String diskAlias = disk.getDiskAlias();
   if (StringUtils.isEmpty(diskAlias)) {
     log.info(
         "Disk alias retrieved from the client is null or empty, the suggested default disk alias to be"
             + " used is '{}'",
         aliasIfNull);
     return aliasIfNull;
   }
   return diskAlias;
 }
Ejemplo n.º 3
0
 /**
  * Adds disk to vm
  *
  * @param disk the disk to add
  * @param vmId the ID of the VM to add to
  */
 public static void addDiskToVm(BaseDisk disk, Guid vmId) {
   DbFacade.getInstance().getBaseDiskDao().save(disk);
   VmDeviceUtils.addDiskDevice(vmId, disk.getId());
 }
Ejemplo n.º 4
0
 /**
  * Add disk if it does not exist to a given vm
  *
  * @param disk the disk to add
  * @param vmId the ID of the vm to add to if the disk does not exist for this VM
  */
 public static void addDiskToVmIfNotExists(BaseDisk disk, Guid vmId) {
   if (!DbFacade.getInstance().getBaseDiskDao().exists(disk.getId())) {
     addDiskToVm(disk, vmId);
   }
 }
Ejemplo n.º 5
0
 /**
  * Adds disk to a VM without creating a VmDevice entry
  *
  * @param disk disk to add
  */
 public static void addDisk(BaseDisk disk) {
   if (!DbFacade.getInstance().getBaseDiskDao().exists(disk.getId())) {
     DbFacade.getInstance().getBaseDiskDao().save(disk);
   }
 }