From 46c23f1a5b08b36ae9c426491a081edb0b5ba772 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Maharana Date: Tue, 22 Dec 2015 13:31:09 +0530 Subject: [PATCH] CLOUDSTACK-9132: API createVolume takes empty string for name parameter Added a condition to check in case of empty string. If the name is an empty string, it generates a random name for the volume. Made the name field as optional in UI as well as in API. --- .../cloudstack/api/command/user/volume/CreateVolumeCmd.java | 2 +- server/src/com/cloud/storage/VolumeApiServiceImpl.java | 2 +- ui/scripts/docs.js | 2 +- ui/scripts/storage.js | 5 +---- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java index 1e3c01cec9e0..54c376e22657 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java @@ -79,7 +79,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd { description = "the ID of the disk offering. Either diskOfferingId or snapshotId must be passed in.") private Long diskOfferingId; - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the disk volume") + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the disk volume") private String volumeName; @Parameter(name = ApiConstants.SIZE, type = CommandType.LONG, description = "Arbitrary volume size") diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 0874a6c2c53b..b60ecd38041f 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -672,7 +672,7 @@ public VolumeVO allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationExcept } String userSpecifiedName = cmd.getVolumeName(); - if (userSpecifiedName == null) { + if (userSpecifiedName == null || userSpecifiedName.isEmpty()) { userSpecifiedName = getRandomVolumeName(); } diff --git a/ui/scripts/docs.js b/ui/scripts/docs.js index ed6ab0c938c1..a2e333eeaed6 100755 --- a/ui/scripts/docs.js +++ b/ui/scripts/docs.js @@ -1008,7 +1008,7 @@ cloudStack.docs = { }, // Add volume helpVolumeName: { - desc: 'Give the volume a unique name so you can find it later.', + desc: 'Give the volume a unique name. If not, it will be generated randomly.', externalLink: '' }, helpVolumeAvailabilityZone: { diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 599802a45ab0..1e1f1a57d753 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -80,10 +80,7 @@ fields: { name: { docID: 'helpVolumeName', - label: 'label.name', - validation: { - required: true - } + label: 'label.name' }, availabilityZone: { label: 'label.availability.zone',