From 7262b854a58e6f060a7f72ef2d2d17e3c0533ff1 Mon Sep 17 00:00:00 2001 From: abhishek Date: Mon, 8 Nov 2010 17:58:10 -0800 Subject: [PATCH] bug 7121: made the disk offering id optional, and added a check to ensure we never have both disk offering and snapshot ids to be null status 7121: resolved fixed --- server/src/com/cloud/api/commands/CreateVolumeCmd.java | 2 +- server/src/com/cloud/storage/StorageManagerImpl.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/api/commands/CreateVolumeCmd.java b/server/src/com/cloud/api/commands/CreateVolumeCmd.java index a06ed94ee78..0823b9c2f80 100644 --- a/server/src/com/cloud/api/commands/CreateVolumeCmd.java +++ b/server/src/com/cloud/api/commands/CreateVolumeCmd.java @@ -52,7 +52,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd { @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the disk volume. Must be used with the domainId parameter.") private String accountName; - @Parameter(name=ApiConstants.DISK_OFFERING_ID,required = true, type=CommandType.LONG, description="the ID of the disk offering. Either diskOfferingId or snapshotId must be passed in.") + @Parameter(name=ApiConstants.DISK_OFFERING_ID,required = false, type=CommandType.LONG, description="the ID of the disk offering. Either diskOfferingId or snapshotId must be passed in.") private Long diskOfferingId; @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the disk offering. If used with the account parameter returns the disk volume associated with the account for the specified domain.") diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 33a844540e4..c3aeb3b82b9 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -1669,11 +1669,16 @@ public class StorageManagerImpl implements StorageManager { rae.setResourceType("volume"); throw rae; } - + Long zoneId = null; Long diskOfferingId = null; Long size = null; + // validate input parameters before creating the volume + if(cmd.getSnapshotId() == null && cmd.getDiskOfferingId() == null){ + throw new InvalidParameterValueException("Either disk Offering Id or snapshot Id must be passed whilst creating volume"); + } + if (cmd.getSnapshotId() == null) { zoneId = cmd.getZoneId(); if ((zoneId == null)) {