This commit is contained in:
John Burwell 2013-07-23 18:38:43 -04:00
commit f508bcaae9
16 changed files with 149 additions and 68 deletions

View File

@ -22,6 +22,7 @@ label.disk.iops.min=Min IOPS
label.disk.iops.max=Max IOPS
label.disk.iops.total=IOPS Total
label.view.secondary.ips=View secondary IPs
message.validate.invalid.characters=Invalid characters found; please correct.
message.acquire.ip.nic=Please confirm that you would like to acquire a new secondary IP for this NIC.<br/>NOTE: You need to manually configure the newly-acquired secondary IP inside the virtual machine.
message.select.affinity.groups=Please select any affinity groups you want this VM to belong to:
message.no.affinity.groups=You do not have any affinity groups. Please continue to the next step.

View File

@ -18,10 +18,14 @@
*/
package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.storage.DataStoreRole;
public interface VolumeDataFactory {
VolumeInfo getVolume(long volumeId, DataStore store);
VolumeInfo getVolume(DataObject volume, DataStore store);
VolumeInfo getVolume(long volumeId, DataStoreRole storeRole);
VolumeInfo getVolume(long volumeId);
}

View File

@ -51,6 +51,26 @@ public class VolumeDataFactoryImpl implements VolumeDataFactory {
return vol;
}
@Override
public VolumeInfo getVolume(long volumeId, DataStoreRole storeRole) {
VolumeVO volumeVO = volumeDao.findById(volumeId);
VolumeObject vol = null;
if (storeRole == DataStoreRole.Image) {
VolumeDataStoreVO volumeStore = volumeStoreDao.findByVolume(volumeId);
if (volumeStore != null) {
DataStore store = this.storeMgr.getDataStore(volumeStore.getDataStoreId(), DataStoreRole.Image);
vol = VolumeObject.getVolumeObject(store, volumeVO);
}
} else {
// Primary data store
if (volumeVO.getPoolId() != null) {
DataStore store = this.storeMgr.getDataStore(volumeVO.getPoolId(), DataStoreRole.Primary);
vol = VolumeObject.getVolumeObject(store, volumeVO);
}
}
return vol;
}
@Override
public VolumeInfo getVolume(long volumeId) {
VolumeVO volumeVO = volumeDao.findById(volumeId);

View File

@ -109,7 +109,7 @@ public class VolumeObject implements VolumeInfo {
@Override
public String get_iScsiName() {
return volumeVO.get_iScsiName();
return volumeVO.get_iScsiName();
}
public void setSize(Long size) {
@ -254,9 +254,8 @@ public class VolumeObject implements VolumeInfo {
}
if (this.dataStore.getRole() == DataStoreRole.Image) {
objectInStoreMgr.update(this, event);
if (this.volumeVO.getState() == Volume.State.Migrating
|| this.volumeVO.getState() == Volume.State.Copying
|| this.volumeVO.getState() == Volume.State.Uploaded) {
if (this.volumeVO.getState() == Volume.State.Migrating || this.volumeVO.getState() == Volume.State.Copying || this.volumeVO.getState() == Volume.State.Uploaded
|| this.volumeVO.getState() == Volume.State.Expunged) {
return;
}
if (event == ObjectInDataStoreStateMachine.Event.CreateOnlyRequested) {
@ -513,6 +512,7 @@ public class VolumeObject implements VolumeInfo {
}
@Override
public void incRefCount() {
if (this.dataStore == null) {
return;

View File

@ -75,6 +75,7 @@ import com.cloud.storage.StoragePool;
import com.cloud.storage.VMTemplateStoragePoolVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.Volume.State;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.VMTemplatePoolDao;
@ -210,13 +211,34 @@ public class VolumeServiceImpl implements VolumeService {
}
}
// check if a volume is expunged on both primary and secondary
private boolean canVolumeBeRemoved(long volumeId) {
VolumeVO vol = volDao.findById(volumeId);
if (vol == null) {
// already removed from volumes table
return false;
}
VolumeDataStoreVO volumeStore = _volumeStoreDao.findByVolume(volumeId);
if (vol.getState() == State.Expunged && volumeStore == null) {
// volume is expunged from primary, as well as on secondary
return true;
} else {
return false;
}
}
@DB
@Override
public AsyncCallFuture<VolumeApiResult> expungeVolumeAsync(VolumeInfo volume) {
AsyncCallFuture<VolumeApiResult> future = new AsyncCallFuture<VolumeApiResult>();
VolumeApiResult result = new VolumeApiResult(volume);
if (volume.getDataStore() == null) {
volDao.remove(volume.getId());
s_logger.info("Expunge volume with no data store specified");
if (canVolumeBeRemoved(volume.getId())) {
s_logger.info("Volume " + volume.getId() + " is not referred anywhere, remove it from volumes table");
volDao.remove(volume.getId());
}
future.complete(result);
return future;
}
@ -245,7 +267,11 @@ public class VolumeServiceImpl implements VolumeService {
}
VolumeObject vo = (VolumeObject) volume;
volume.processEvent(Event.ExpungeRequested);
if (volume.getDataStore().getRole() == DataStoreRole.Image) {
volume.processEvent(Event.DestroyRequested);
} else if (volume.getDataStore().getRole() == DataStoreRole.Primary) {
volume.processEvent(Event.ExpungeRequested);
}
DeleteVolumeContext<VolumeApiResult> context = new DeleteVolumeContext<VolumeApiResult>(null, vo, future);
AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this);
@ -255,6 +281,7 @@ public class VolumeServiceImpl implements VolumeService {
return future;
}
public Void deleteVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> callback,
DeleteVolumeContext<VolumeApiResult> context) {
CommandResult result = callback.getResult();
@ -262,7 +289,10 @@ public class VolumeServiceImpl implements VolumeService {
VolumeApiResult apiResult = new VolumeApiResult(vo);
if (result.isSuccess()) {
vo.processEvent(Event.OperationSuccessed);
volDao.remove(vo.getId());
if (canVolumeBeRemoved(vo.getId())) {
s_logger.info("Volume " + vo.getId() + " is not referred anywhere, remove it from volumes table");
volDao.remove(vo.getId());
}
} else {
vo.processEvent(Event.OperationFailed);
apiResult.setResult(result.getResult());

View File

@ -4885,8 +4885,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
} catch (XenAPIException e) {
s_logger.warn("Unable to create local link network", e);
throw new CloudRuntimeException("Unable to create local link network due to " + e.toString(), e);
} catch (XmlRpcException e) {
s_logger.warn("Unable to create local link network", e);
throw new CloudRuntimeException("Unable to create local link network due to " + e.toString(), e);
}
}

View File

@ -44,6 +44,7 @@ import com.cloud.agent.api.Command;
import com.cloud.agent.api.MaintainCommand;
import com.cloud.agent.api.MigrateCommand;
import com.cloud.agent.api.PingTestCommand;
import com.cloud.agent.api.PvlanSetupCommand;
import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.SetupCommand;
import com.cloud.agent.api.ShutdownCommand;
@ -109,7 +110,9 @@ public abstract class AgentAttache {
protected AgentManagerImpl _agentMgr;
public final static String[] s_commandsAllowedInMaintenanceMode =
new String[] { MaintainCommand.class.toString(), MigrateCommand.class.toString(), StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(), ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), ClusterSyncCommand.class.toString(), CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString() };
new String[] { MaintainCommand.class.toString(), MigrateCommand.class.toString(), StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(),
CheckHealthCommand.class.toString(), ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), ClusterSyncCommand.class.toString(),
CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString() };
protected final static String[] s_commandsNotAllowedInConnectingMode =
new String[] { StartCommand.class.toString(), CreateCommand.class.toString() };
static {

View File

@ -31,6 +31,10 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
@ -69,9 +73,7 @@ import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.storage.CreateVolumeOVAAnswer;
@ -349,7 +351,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
public VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId,
Long destPoolPodId, Long destPoolClusterId,
HypervisorType dataDiskHyperType)
throws ConcurrentOperationException {
throws ConcurrentOperationException {
// Find a destination storage pool with the specified criteria
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume
@ -411,7 +413,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
private boolean validateVolume(Account caller, long ownerId, Long zoneId,
String volumeName, String url, String format)
throws ResourceAllocationException {
throws ResourceAllocationException {
// permission check
_accountMgr.checkAccess(caller, null, true,
@ -480,17 +482,17 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
&& !url.toLowerCase().endsWith("qcow2.zip")
&& !url.toLowerCase().endsWith("qcow2.bz2") && !url
.toLowerCase().endsWith("qcow2.gz")))
|| (format.equalsIgnoreCase("ova") && (!url.toLowerCase()
.endsWith(".ova")
&& !url.toLowerCase().endsWith("ova.zip")
&& !url.toLowerCase().endsWith("ova.bz2") && !url
.toLowerCase().endsWith("ova.gz")))
|| (format.equalsIgnoreCase("raw") && (!url.toLowerCase()
.endsWith(".img") && !url.toLowerCase().endsWith("raw")))) {
|| (format.equalsIgnoreCase("ova") && (!url.toLowerCase()
.endsWith(".ova")
&& !url.toLowerCase().endsWith("ova.zip")
&& !url.toLowerCase().endsWith("ova.bz2") && !url
.toLowerCase().endsWith("ova.gz")))
|| (format.equalsIgnoreCase("raw") && (!url.toLowerCase()
.endsWith(".img") && !url.toLowerCase().endsWith("raw")))) {
throw new InvalidParameterValueException(
"Please specify a valid URL. URL:" + url
+ " is an invalid for the format "
+ format.toLowerCase());
+ " is an invalid for the format "
+ format.toLowerCase());
}
UriUtils.validateUrl(url);
@ -905,26 +907,26 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
if (isCustomizedIops != null) {
if (isCustomizedIops) {
minIops = cmd.getMinIops();
maxIops = cmd.getMaxIops();
minIops = cmd.getMinIops();
maxIops = cmd.getMaxIops();
if (minIops == null && maxIops == null) {
minIops = 0L;
maxIops = 0L;
}
else {
if (minIops == null && maxIops == null) {
minIops = 0L;
maxIops = 0L;
}
else {
if (minIops == null || minIops <= 0) {
throw new InvalidParameterValueException("The min IOPS must be greater than 0.");
}
if (maxIops == null) {
maxIops = 0L;
}
if (maxIops == null) {
maxIops = 0L;
}
if (minIops > maxIops) {
throw new InvalidParameterValueException("The min IOPS must be less than or equal to the max IOPS.");
}
}
if (minIops > maxIops) {
throw new InvalidParameterValueException("The min IOPS must be less than or equal to the max IOPS.");
}
}
}
else {
minIops = diskOffering.getMinIops();
@ -933,10 +935,10 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
}
if (!validateVolumeSizeRange(size)) {// convert size from mb to gb
// for validation
// for validation
throw new InvalidParameterValueException(
"Invalid size for custom volume creation: " + size
+ " ,max volume size is:" + _maxVolumeSizeInGb);
+ " ,max volume size is:" + _maxVolumeSizeInGb);
}
} else { // create volume from snapshot
Long snapshotId = cmd.getSnapshotId();
@ -957,7 +959,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
diskOffering = _diskOfferingDao.findById(diskOfferingId);
zoneId = snapshotCheck.getDataCenterId();
size = snapshotCheck.getSize(); // ; disk offering is used for tags
// purposes
// purposes
// check snapshot permissions
_accountMgr.checkAccess(caller, null, true, snapshotCheck);
@ -1311,7 +1313,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
_accountMgr.checkAccess(caller, null, true, volume);
if (volume.getInstanceId() != null) {
if (volume.getInstanceId() != null) {
throw new InvalidParameterValueException(
"Please specify a volume that is not attached to any VM.");
}
@ -1355,9 +1357,20 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
_usageEventDao.persist(usageEvent);
}
}
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volFactory.getVolume(volume.getId()));
future.get();
// expunge volume from primary if volume is on primary
VolumeInfo volOnPrimary = volFactory.getVolume(volume.getId(), DataStoreRole.Primary);
if (volOnPrimary != null) {
s_logger.info("Expunging volume " + volume.getId() + " from primary data store");
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volOnPrimary);
future.get();
}
// expunge volume from secondary if volume is on image store
VolumeInfo volOnSecondary = volFactory.getVolume(volume.getId(), DataStoreRole.Image);
if (volOnSecondary != null) {
s_logger.info("Expunging volume " + volume.getId() + " from secondary data store");
AsyncCallFuture<VolumeApiResult> future2 = volService.expungeVolumeAsync(volOnSecondary);
future2.get();
}
} catch (Exception e) {
s_logger.warn("Failed to expunge volume:", e);
return false;
@ -1644,7 +1657,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
volumeToAttach = _volsDao.findById(volumeToAttach.getId());
if (volumeToAttachStoragePool.isManaged() &&
volumeToAttach.getPath() == null) {
volumeToAttach.getPath() == null) {
volumeToAttach.setPath(answer.getDisk().getVdiUuid());
_volsDao.update(volumeToAttach.getId(), volumeToAttach);
@ -1656,8 +1669,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
// insert record for disk I/O statistics
VmDiskStatisticsVO diskstats = _vmDiskStatsDao.findBy(vm.getAccountId(), vm.getDataCenterId(),vm.getId(), volumeToAttach.getId());
if (diskstats == null) {
diskstats = new VmDiskStatisticsVO(vm.getAccountId(), vm.getDataCenterId(),vm.getId(), volumeToAttach.getId());
_vmDiskStatsDao.persist(diskstats);
diskstats = new VmDiskStatisticsVO(vm.getAccountId(), vm.getDataCenterId(),vm.getId(), volumeToAttach.getId());
_vmDiskStatsDao.persist(diskstats);
}
return _volsDao.findById(volumeToAttach.getId());
@ -2030,7 +2043,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
@DB
protected VolumeVO switchVolume(VolumeVO existingVolume,
VirtualMachineProfile vm)
throws StorageUnavailableException {
throws StorageUnavailableException {
Transaction txn = Transaction.currentTxn();
Long templateIdToUse = null;
@ -2086,7 +2099,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
for (VolumeVO vol : volumesForVm) {
if (vol.getVolumeType().equals(Type.ROOT)) {
// Destroy volume if not already destroyed
boolean volumeAlreadyDestroyed = (vol.getState() == Volume.State.Destroy ||
boolean volumeAlreadyDestroyed = (vol.getState() == Volume.State.Destroy ||
vol.getState() == Volume.State.Expunged ||
vol.getState() == Volume.State.Expunging);
if (!volumeAlreadyDestroyed) {
@ -2337,14 +2350,14 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
MIGRATE
}
private static class VolumeTask {
final VolumeTaskType type;
final StoragePoolVO pool;
final VolumeVO volume;
VolumeTask(VolumeTaskType type, VolumeVO volume, StoragePoolVO pool) {
this.type = type;
this.pool = pool;
this.volume = volume;
}
final VolumeTaskType type;
final StoragePoolVO pool;
final VolumeVO volume;
VolumeTask(VolumeTaskType type, VolumeVO volume, StoragePoolVO pool) {
this.type = type;
this.pool = pool;
this.volume = volume;
}
}
private List<VolumeTask> getTasks(List<VolumeVO> vols, Map<Volume, StoragePool> destVols) throws StorageUnavailableException {
@ -2445,7 +2458,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
DataStore destPool = null;
if (recreate
&& (dest.getStorageForDisks() == null || dest
.getStorageForDisks().get(vol) == null)) {
.getStorageForDisks().get(vol) == null)) {
destPool = dataStoreMgr.getDataStore(vol.getPoolId(), DataStoreRole.Primary);
s_logger.debug("existing pool: " + destPool.getId());
} else {
@ -2602,8 +2615,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
.getValue(Config.CustomDiskOfferingMinSize.toString());
_customDiskOfferingMinSize = NumbersUtil.parseInt(
_customDiskOfferingMinSizeStr, Integer
.parseInt(Config.CustomDiskOfferingMinSize
.getDefaultValue()));
.parseInt(Config.CustomDiskOfferingMinSize
.getDefaultValue()));
String maxVolumeSizeInGbString = _configDao
.getValue("storage.max.volume.size");

View File

@ -25,6 +25,7 @@ under the License.
<% long now = System.currentTimeMillis(); %>
<script language="javascript">
dictionary = {
'message.validate.invalid.characters': '<fmt:message key="message.validate.invalid.characters" />',
'label.about': '<fmt:message key="label.about" />',
'label.about.app': '<fmt:message key="label.about.app" />',
'label.app.name': '<fmt:message key="label.app.name" />',

View File

@ -298,7 +298,7 @@ under the License.
<div class="field name hide-if-unselected">
<div class="name"> <span class="field-required">*</span> <fmt:message key="label.name"/></div>
<div class="value">
<input type="text" class="required" name="new-network-name" />
<input type="text" class="required disallowSpecialCharacters" name="new-network-name" />
</div>
</div>
@ -348,7 +348,7 @@ under the License.
<span><fmt:message key="label.name"/> (<fmt:message key="label.optional"/>)</span>
</div>
<div class="value">
<input type="text" name="displayname" />
<input type="text" name="displayname" class="disallowSpecialCharacters" />
</div>
</div>
<!-- Add to group -->
@ -357,7 +357,7 @@ under the License.
<span><fmt:message key="label.add.to.group"/> (<fmt:message key="label.optional"/>)</span>
</div>
<div class="value">
<input type="text" name="groupname" />
<input type="text" name="groupname" class="disallowSpecialCharacters" />
</div>
</div>
<!-- Zone -->

View File

@ -55,7 +55,7 @@
nspHardcodingArray.push({
id: id,
name: name,
state: selectedProviderObj? selectedProviderObj.state : 'Disabled'
state: selectedProviderObj? selectedProviderObj.state : 'Absent'
});
}
});

View File

@ -568,7 +568,7 @@
args.response.success({
data: {
name: 'CiscoVnmc',
state: 'Disabled'
state: 'Absent'
},
actionFilter: vnmcActionFilter
});

View File

@ -588,7 +588,7 @@
$('<div>').addClass('value').append(
$('<input>').attr({
type: 'text'
}).addClass('required')
}).addClass('required disallowSpecialCharacters')
)
);

View File

@ -588,7 +588,7 @@
type: 'text',
value: data
})
.data('original-value', data)
.addClass('disallowSpecialCharacters').data('original-value', data)
);
// Make option values from given array
@ -617,7 +617,7 @@
name: name,
type: 'text',
value: data
}).data('original-value', data)
}).addClass('disallowSpecialCharacters').data('original-value', data)
);
}

View File

@ -533,6 +533,11 @@
if (!$editInput.is(':visible') || !(typeof(args.action) == 'undefined')) { //click Edit button
showEditField();
} else if ($editInput.val() != $label.html()) { //click Save button with changed value
if ($editInput.val().match(/<|>/)) {
cloudStack.dialog.notice({ message: 'message.validate.invalid.characters' });
return false;
}
$edit.animate({
opacity: 0.5
});

View File

@ -918,6 +918,7 @@
$(field.range).each(function() { //e.g. field.range = ['privateport', 'privateendport'];
var $input = $('<input>')
.addClass('disallowSpecialCharacters')
.attr({
name: this,
type: 'text'
@ -941,7 +942,8 @@
name: fieldName,
type: field.isPassword ? 'password' : 'text'
})
.addClass(!field.isOptional ? 'required' : null)
.addClass(!field.isOptional ? 'required' : null)
.addClass('disallowSpecialCharacters')
.attr('disabled', field.isDisabled ? 'disabled' : false)
.appendTo($td);