private Response attachDiskToVm(Disk disk) {
    boolean isDiskActive = BooleanUtils.toBooleanDefaultIfNull(disk.isActive(), false);
    boolean isDiskReadOnly = BooleanUtils.toBooleanDefaultIfNull(disk.isReadOnly(), false);
    AttachDetachVmDiskParameters params =
        new AttachDetachVmDiskParameters(
            parentId,
            Guid.createGuidFromStringDefaultEmpty(disk.getId()),
            isDiskActive,
            isDiskReadOnly);

    if (disk.isSetSnapshot()) {
      validateParameters(disk, "snapshot.id");
      params.setSnapshotId(asGuid(disk.getSnapshot().getId()));
    }

    return performAction(VdcActionType.AttachDiskToVm, params);
  }
 /**
  * Constructor called from Jelly with parameters.
  *
  * @param name name
  * @param description description
  * @param script script
  * @param choiceType choice type
  * @param referencedParameters referenced parameters
  * @param omitValueField used in the UI to decide whether to include a hidden empty <input
  *     name=value&gt;. <code>false</code> by default.
  */
 @DataBoundConstructor
 public DynamicReferenceParameter(
     String name,
     String description,
     Script script,
     String choiceType,
     String referencedParameters,
     Boolean omitValueField) {
   super(name, description, script, referencedParameters);
   this.choiceType = StringUtils.defaultIfBlank(choiceType, PARAMETER_TYPE_SINGLE_SELECT);
   this.omitValueField = BooleanUtils.toBooleanDefaultIfNull(omitValueField, Boolean.FALSE);
 }