From bf377735c4c061a478addbe9078c9dce1661226e Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 22 Oct 2010 14:31:47 -0700 Subject: [PATCH 1/5] new UI - instance page - hide routers tab for non-admin user. --- ui/new/jsp/instance.jsp | 4 ++-- ui/new/scripts/cloud.core2.instance.js | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ui/new/jsp/instance.jsp b/ui/new/jsp/instance.jsp index 12338d81ac1..e826901cb2f 100644 --- a/ui/new/jsp/instance.jsp +++ b/ui/new/jsp/instance.jsp @@ -26,7 +26,7 @@ <%=t.t("Volume")%>
<%=t.t("Statistics")%>
-
+
@@ -183,7 +183,7 @@ -
+ + + +

Start VM

+

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

+ + +

Stop VM

+

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

+ +

Destroy VM

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

From e5461835488aa5356a592c6fdcc1ef29982ea3b7 Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Fri, 22 Oct 2010 15:03:08 -0700 Subject: [PATCH 3/5] Fix deployVM problem currently in master branch --- server/src/com/cloud/api/commands/DeployVMCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/com/cloud/api/commands/DeployVMCmd.java b/server/src/com/cloud/api/commands/DeployVMCmd.java index 565dfa693b4..818748f0ad2 100644 --- a/server/src/com/cloud/api/commands/DeployVMCmd.java +++ b/server/src/com/cloud/api/commands/DeployVMCmd.java @@ -40,7 +40,7 @@ import com.cloud.user.UserContext; import com.cloud.uservm.UserVm; import com.cloud.vm.InstanceGroupVO; -@Implementation(createMethod="createVirtualMachine", method="startVirtualMachine", manager=Manager.UserVmManager, description="Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.") +@Implementation(method="deployVirtualMachine", description="Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.") public class DeployVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeployVMCmd.class.getName()); From ecbb1030163dfc5f2ce16bcb01dc60f1141f6f18 Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Fri, 22 Oct 2010 14:07:19 -0700 Subject: [PATCH 4/5] bug 6675: return snapshotId as part of the createVolume response if a non-null snapshotId was passed in. This will represent the snapshot from which the volume was created. status 6675: resolved fixed --- .../src/com/cloud/api/commands/CreateVolumeCmd.java | 3 +++ server/src/com/cloud/api/response/VolumeResponse.java | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/server/src/com/cloud/api/commands/CreateVolumeCmd.java b/server/src/com/cloud/api/commands/CreateVolumeCmd.java index 31ec30f5c70..4cfb29a6139 100644 --- a/server/src/com/cloud/api/commands/CreateVolumeCmd.java +++ b/server/src/com/cloud/api/commands/CreateVolumeCmd.java @@ -163,6 +163,9 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd { if (volume.getPoolId() != null) { response.setStoragePoolName(ApiDBUtils.findStoragePoolById(volume.getPoolId()).getName()); } + + // if the volume was created from a snapshot, snapshotId will be set so we pass it back in the response + response.setSnapshotId(getSnapshotId()); response.setZoneId(volume.getDataCenterId()); response.setZoneName(ApiDBUtils.findZoneById(volume.getDataCenterId()).getName()); diff --git a/server/src/com/cloud/api/response/VolumeResponse.java b/server/src/com/cloud/api/response/VolumeResponse.java index 8a2099d380f..8d5b643da63 100644 --- a/server/src/com/cloud/api/response/VolumeResponse.java +++ b/server/src/com/cloud/api/response/VolumeResponse.java @@ -101,6 +101,9 @@ public class VolumeResponse extends BaseResponse { @SerializedName("storage") @Param(description="name of the primary storage hosting the disk volume") private String storagePoolName; + @SerializedName("snapshotid") @Param(description="ID of the snapshot from which this volume was created") + private Long snapshotId; + public Long getId() { return id; } @@ -308,4 +311,12 @@ public class VolumeResponse extends BaseResponse { public void setStoragePoolName(String storagePoolName) { this.storagePoolName = storagePoolName; } + + public Long getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(Long snapshotId) { + this.snapshotId = snapshotId; + } } From 109bdb18fe3e77ced4d3f0cbc837c23a6d0baf70 Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Fri, 22 Oct 2010 16:12:36 -0700 Subject: [PATCH 5/5] bug 6675: some fixes for creating volumes from snapshots - make sure size is set on the volume being created, either from the disk offering if a stand-along volume, or from the original volume size if from a snapshot - in createVolumeFromSnapshot, create a DiskProfile object that will set the size from the volume size rather than using the constructor that takes size from the disk offering - get zone for new volume from either the command properties or from the original vol (snapshot case) status 6675: resolved fixed --- .../com/cloud/storage/StorageManagerImpl.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 8e4b680ab54..842e0330602 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -73,7 +73,6 @@ import com.cloud.api.commands.PreparePrimaryStorageForMaintenanceCmd; import com.cloud.api.commands.UpdateStoragePoolCmd; import com.cloud.async.AsyncInstanceCreateStatus; import com.cloud.async.AsyncJobManager; -import com.cloud.async.executor.VolumeOperationParam.VolumeOp; import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; import com.cloud.configuration.Config; @@ -507,7 +506,7 @@ public class StorageManagerImpl implements StorageManager { @DB protected Pair createVolumeFromSnapshot(VolumeVO volume, SnapshotVO snapshot, VMTemplateVO template, long virtualsize) { VolumeVO createdVolume = null; - Long volumeId = null; + Long volumeId = volume.getId(); String volumeFolder = null; @@ -524,7 +523,7 @@ public class StorageManagerImpl implements StorageManager { DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId()); DataCenterVO dc = _dcDao.findById(volume.getDataCenterId()); - DiskProfile dskCh = createDiskCharacteristics(volume, template, dc, diskOffering); + DiskProfile dskCh = new DiskProfile(volume, diskOffering, template.getHypervisorType()); int retry = 0; // Determine what pod to store the volume in @@ -624,7 +623,7 @@ public class StorageManagerImpl implements StorageManager { VolumeVO originalVolume = _volsDao.findById(origVolumeId); // NOTE: Original volume could be destroyed and removed. VMTemplateVO template = null; if (originalVolume != null) { - template = _templateDao.findById(originalVolume.getTemplateId()); + template = _templateDao.findById(originalVolume.getTemplateId()); } // everything went well till now @@ -1669,15 +1668,18 @@ public class StorageManagerImpl implements StorageManager { throw rae; } + Long zoneId = null; + Long diskOfferingId = null; + Long size = null; // validate input parameters before creating the volume if (cmd.getSnapshotId() == null) { - Long zoneId = cmd.getZoneId(); + zoneId = cmd.getZoneId(); if ((zoneId == null)) { throw new InvalidParameterValueException("Missing parameter, zoneid must be specified."); } - Long diskOfferingId = cmd.getDiskOfferingId(); - Long size = cmd.getSize(); + diskOfferingId = cmd.getDiskOfferingId(); + size = cmd.getSize(); if ((diskOfferingId == null) && (size == null)) { throw new InvalidParameterValueException("Missing parameter(s),either a positive volume size or a valid disk offering id must be specified."); } else if ((diskOfferingId == null) && (size != null)) { @@ -1696,6 +1698,7 @@ public class StorageManagerImpl implements StorageManager { if ((diskOffering == null) || !DiskOfferingVO.Type.Disk.equals(diskOffering.getType())) { throw new InvalidParameterValueException("Please specify a valid disk offering."); } + size = diskOffering.getDiskSize(); } } else { Long snapshotId = cmd.getSnapshotId(); @@ -1703,7 +1706,12 @@ public class StorageManagerImpl implements StorageManager { if (snapshotCheck == null) { throw new ServerApiException (BaseCmd.SNAPSHOT_INVALID_PARAM_ERROR, "unable to find a snapshot with id " + snapshotId); } - + + VolumeVO vol = _volsDao.findById(snapshotCheck.getVolumeId()); + zoneId = vol.getDataCenterId(); + diskOfferingId = vol.getDiskOfferingId(); + size = vol.getSize(); + if (account != null) { if (isAdmin(account.getType())) { Account snapshotOwner = _accountDao.findById(snapshotCheck.getAccountId()); @@ -1715,13 +1723,6 @@ public class StorageManagerImpl implements StorageManager { } } } - - Long zoneId = cmd.getZoneId(); - // Check that the zone is valid - DataCenterVO zone = _dcDao.findById(zoneId); - if (zone == null) { - throw new InvalidParameterValueException("Please specify a valid zone."); - } // Check that there is a shared primary storage pool in the specified zone List storagePools = _storagePoolDao.listByDataCenterId(zoneId); @@ -1754,7 +1755,8 @@ public class StorageManagerImpl implements StorageManager { volume.setAccountId(targetAccount.getId()); volume.setDomainId(((account == null) ? Domain.ROOT_DOMAIN : account.getDomainId())); volume.setMirrorState(MirrorState.NOT_MIRRORED); - volume.setDiskOfferingId(cmd.getDiskOfferingId()); + volume.setDiskOfferingId(diskOfferingId); + volume.setSize(size); volume.setStorageResourceType(StorageResourceType.STORAGE_POOL); volume.setInstanceId(null); volume.setUpdated(new Date());