mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Changes related to Review Board comments
This commit is contained in:
parent
120b8d409f
commit
06f73092fb
@ -27,6 +27,12 @@ public class AttachVolumeAnswer extends Answer {
|
||||
this.deviceId = null;
|
||||
}
|
||||
|
||||
public AttachVolumeAnswer(AttachVolumeCommand cmd, Long deviceId) {
|
||||
super(cmd);
|
||||
this.deviceId = deviceId;
|
||||
this.vdiUuid = "";
|
||||
}
|
||||
|
||||
public AttachVolumeAnswer(AttachVolumeCommand cmd, Long deviceId, String vdiUuid) {
|
||||
super(cmd);
|
||||
this.deviceId = deviceId;
|
||||
|
||||
@ -19,57 +19,57 @@ package com.cloud.agent.api;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
|
||||
public class AttachVolumeCommand extends Command {
|
||||
private boolean attach;
|
||||
private boolean _managed;
|
||||
private String vmName;
|
||||
private StoragePoolType pooltype;
|
||||
private String volumePath;
|
||||
private String volumeName;
|
||||
private Long deviceId;
|
||||
private String chainInfo;
|
||||
private String poolUuid;
|
||||
private String _storageHost;
|
||||
private int _storagePort;
|
||||
private String _iScsiName;
|
||||
private String _chapInitiatorUsername;
|
||||
private String _chapInitiatorPassword;
|
||||
private String _chapTargetUsername;
|
||||
private String _chapTargetPassword;
|
||||
private Long bytesReadRate;
|
||||
private Long bytesWriteRate;
|
||||
private Long iopsReadRate;
|
||||
private Long iopsWriteRate;
|
||||
private boolean attach;
|
||||
private boolean _managed;
|
||||
private String vmName;
|
||||
private StoragePoolType pooltype;
|
||||
private String volumePath;
|
||||
private String volumeName;
|
||||
private Long deviceId;
|
||||
private String chainInfo;
|
||||
private String poolUuid;
|
||||
private String _storageHost;
|
||||
private int _storagePort;
|
||||
private String _iScsiName;
|
||||
private String _chapInitiatorUsername;
|
||||
private String _chapInitiatorPassword;
|
||||
private String _chapTargetUsername;
|
||||
private String _chapTargetPassword;
|
||||
private Long bytesReadRate;
|
||||
private Long bytesWriteRate;
|
||||
private Long iopsReadRate;
|
||||
private Long iopsWriteRate;
|
||||
|
||||
protected AttachVolumeCommand() {
|
||||
}
|
||||
protected AttachVolumeCommand() {
|
||||
}
|
||||
|
||||
public AttachVolumeCommand(boolean attach, boolean managed, String vmName,
|
||||
StoragePoolType pooltype, String volumePath, String volumeName,
|
||||
Long deviceId, String chainInfo) {
|
||||
this.attach = attach;
|
||||
this._managed = managed;
|
||||
this.vmName = vmName;
|
||||
this.pooltype = pooltype;
|
||||
this.volumePath = volumePath;
|
||||
this.volumeName = volumeName;
|
||||
this.deviceId = deviceId;
|
||||
this.chainInfo = chainInfo;
|
||||
}
|
||||
this.attach = attach;
|
||||
this._managed = managed;
|
||||
this.vmName = vmName;
|
||||
this.pooltype = pooltype;
|
||||
this.volumePath = volumePath;
|
||||
this.volumeName = volumeName;
|
||||
this.deviceId = deviceId;
|
||||
this.chainInfo = chainInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean getAttach() {
|
||||
return attach;
|
||||
}
|
||||
public boolean getAttach() {
|
||||
return attach;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public StoragePoolType getPooltype() {
|
||||
public StoragePoolType getPooltype() {
|
||||
return pooltype;
|
||||
}
|
||||
|
||||
@ -77,13 +77,13 @@ public class AttachVolumeCommand extends Command {
|
||||
this.pooltype = pooltype;
|
||||
}
|
||||
|
||||
public String getVolumePath() {
|
||||
return volumePath;
|
||||
}
|
||||
public String getVolumePath() {
|
||||
return volumePath;
|
||||
}
|
||||
|
||||
public String getVolumeName() {
|
||||
public String getVolumeName() {
|
||||
return volumeName;
|
||||
}
|
||||
}
|
||||
|
||||
public Long getDeviceId() {
|
||||
return deviceId;
|
||||
@ -109,61 +109,61 @@ public class AttachVolumeCommand extends Command {
|
||||
_storageHost = storageHost;
|
||||
}
|
||||
|
||||
public String getStorageHost() {
|
||||
return _storageHost;
|
||||
}
|
||||
public String getStorageHost() {
|
||||
return _storageHost;
|
||||
}
|
||||
|
||||
public void setStoragePort(int storagePort) {
|
||||
_storagePort = storagePort;
|
||||
}
|
||||
public void setStoragePort(int storagePort) {
|
||||
_storagePort = storagePort;
|
||||
}
|
||||
|
||||
public int getStoragePort() {
|
||||
return _storagePort;
|
||||
}
|
||||
public int getStoragePort() {
|
||||
return _storagePort;
|
||||
}
|
||||
|
||||
public boolean isManaged() {
|
||||
public boolean isManaged() {
|
||||
return _managed;
|
||||
}
|
||||
|
||||
public void set_iScsiName(String iScsiName) {
|
||||
this._iScsiName = iScsiName;
|
||||
}
|
||||
public void set_iScsiName(String iScsiName) {
|
||||
this._iScsiName = iScsiName;
|
||||
}
|
||||
|
||||
public String get_iScsiName() {
|
||||
return _iScsiName;
|
||||
}
|
||||
public String get_iScsiName() {
|
||||
return _iScsiName;
|
||||
}
|
||||
|
||||
public void setChapInitiatorUsername(String chapInitiatorUsername) {
|
||||
_chapInitiatorUsername = chapInitiatorUsername;
|
||||
}
|
||||
public void setChapInitiatorUsername(String chapInitiatorUsername) {
|
||||
_chapInitiatorUsername = chapInitiatorUsername;
|
||||
}
|
||||
|
||||
public String getChapInitiatorUsername() {
|
||||
return _chapInitiatorUsername;
|
||||
}
|
||||
public String getChapInitiatorUsername() {
|
||||
return _chapInitiatorUsername;
|
||||
}
|
||||
|
||||
public void setChapInitiatorPassword(String chapInitiatorPassword) {
|
||||
_chapInitiatorPassword = chapInitiatorPassword;
|
||||
}
|
||||
public void setChapInitiatorPassword(String chapInitiatorPassword) {
|
||||
_chapInitiatorPassword = chapInitiatorPassword;
|
||||
}
|
||||
|
||||
public String getChapInitiatorPassword() {
|
||||
return _chapInitiatorPassword;
|
||||
}
|
||||
public String getChapInitiatorPassword() {
|
||||
return _chapInitiatorPassword;
|
||||
}
|
||||
|
||||
public void setChapTargetUsername(String chapTargetUsername) {
|
||||
_chapTargetUsername = chapTargetUsername;
|
||||
}
|
||||
public void setChapTargetUsername(String chapTargetUsername) {
|
||||
_chapTargetUsername = chapTargetUsername;
|
||||
}
|
||||
|
||||
public String getChapTargetUsername() {
|
||||
return _chapTargetUsername;
|
||||
}
|
||||
public String getChapTargetUsername() {
|
||||
return _chapTargetUsername;
|
||||
}
|
||||
|
||||
public void setChapTargetPassword(String chapTargetPassword) {
|
||||
_chapTargetPassword = chapTargetPassword;
|
||||
}
|
||||
public void setChapTargetPassword(String chapTargetPassword) {
|
||||
_chapTargetPassword = chapTargetPassword;
|
||||
}
|
||||
|
||||
public String getChapTargetPassword() {
|
||||
return _chapTargetPassword;
|
||||
}
|
||||
public String getChapTargetPassword() {
|
||||
return _chapTargetPassword;
|
||||
}
|
||||
|
||||
public void setBytesReadRate(Long bytesReadRate) {
|
||||
this.bytesReadRate = bytesReadRate;
|
||||
|
||||
@ -33,7 +33,7 @@ public class AttachVolumeAnswerTest {
|
||||
String results = "";
|
||||
AttachVolumeAnswer ava2 = new AttachVolumeAnswer(avc, results);
|
||||
Long deviceId = 10L;
|
||||
AttachVolumeAnswer ava3 = new AttachVolumeAnswer(avc, deviceId, "");
|
||||
AttachVolumeAnswer ava3 = new AttachVolumeAnswer(avc, deviceId);
|
||||
|
||||
@Test
|
||||
public void testGetDeviceId() {
|
||||
|
||||
@ -98,10 +98,10 @@ public class DiskOfferingVO implements DiskOffering {
|
||||
private Boolean customizedIops;
|
||||
|
||||
@Column(name="min_iops")
|
||||
Long minIops;
|
||||
private Long minIops;
|
||||
|
||||
@Column(name="max_iops")
|
||||
Long maxIops;
|
||||
private Long maxIops;
|
||||
|
||||
@Column(name = "sort_key")
|
||||
int sortKey;
|
||||
|
||||
@ -71,10 +71,10 @@ public class VolumeVO implements Volume {
|
||||
Long size;
|
||||
|
||||
@Column(name = "min_iops")
|
||||
Long minIops;
|
||||
private Long minIops;
|
||||
|
||||
@Column(name = "max_iops")
|
||||
Long maxIops;
|
||||
private Long maxIops;
|
||||
|
||||
@Column(name = "folder")
|
||||
String folder;
|
||||
@ -155,8 +155,9 @@ public class VolumeVO implements Volume {
|
||||
String reservationId;
|
||||
|
||||
// Real Constructor
|
||||
public VolumeVO(Type type, String name, long dcId, long domainId, long accountId, long diskOfferingId, long size,
|
||||
Long minIops, Long maxIops, String iScsiName) {
|
||||
public VolumeVO(Type type, String name, long dcId, long domainId,
|
||||
long accountId, long diskOfferingId, long size,
|
||||
Long minIops, Long maxIops, String iScsiName) {
|
||||
this.volumeType = type;
|
||||
this.name = name;
|
||||
this.dataCenterId = dcId;
|
||||
@ -171,8 +172,10 @@ public class VolumeVO implements Volume {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public VolumeVO(String name, long dcId, long podId, long accountId, long domainId, Long instanceId, String folder, String path,
|
||||
long size, Long minIops, Long maxIops, String iScsiName, Volume.Type vType) {
|
||||
public VolumeVO(String name, long dcId, long podId, long accountId,
|
||||
long domainId, Long instanceId, String folder, String path,
|
||||
long size, Long minIops, Long maxIops, String iScsiName,
|
||||
Volume.Type vType) {
|
||||
this.name = name;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
@ -191,6 +194,27 @@ public class VolumeVO implements Volume {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public VolumeVO(String name, long dcId, long podId, long accountId,
|
||||
long domainId, Long instanceId, String folder, String path,
|
||||
long size, Volume.Type vType) {
|
||||
this.name = name;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.instanceId = instanceId;
|
||||
this.folder = folder;
|
||||
this.path = path;
|
||||
this.size = size;
|
||||
this.minIops = null;
|
||||
this.maxIops = null;
|
||||
this._iScsiName = null;
|
||||
this.podId = podId;
|
||||
this.dataCenterId = dcId;
|
||||
this.volumeType = vType;
|
||||
this.state = Volume.State.Allocated;
|
||||
this.recreatable = false;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
// Copy Constructor
|
||||
public VolumeVO(Volume that) {
|
||||
this(that.getName(), that.getDataCenterId(), that.getPodId(), that.getAccountId(), that.getDomainId(), that.getInstanceId(),
|
||||
|
||||
@ -3972,7 +3972,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
throw new Exception("Unable to create a dummy VM for volume creation");
|
||||
}
|
||||
|
||||
vmMo.createDisk(volumeDatastorePath, (int)(dsMo.getSummary().getFreeSpace() / (1024L * 1024L)),
|
||||
vmMo.createDisk(volumeDatastorePath, getMBsFromBytes(dsMo.getSummary().getFreeSpace()),
|
||||
morDs, vmMo.getScsiDeviceControllerKey());
|
||||
vmMo.detachDisk(volumeDatastorePath, false);
|
||||
}
|
||||
@ -5054,7 +5054,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
synchronized (this) {
|
||||
s_logger.info("Delete file if exists in datastore to clear the way for creating the volume. file: " + volumeDatastorePath);
|
||||
VmwareHelper.deleteVolumeVmdkFiles(dsMo, vmdkName, dcMo);
|
||||
vmMo.createDisk(volumeDatastorePath, (int) (dskch.getSize() / (1024L * 1024L)), morDatastore, -1);
|
||||
vmMo.createDisk(volumeDatastorePath, getMBsFromBytes(dskch.getSize()), morDatastore, -1);
|
||||
vmMo.detachDisk(volumeDatastorePath, false);
|
||||
}
|
||||
|
||||
@ -5113,7 +5113,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
// s_logger.info("Delete file if exists in datastore to clear the way for creating the volume. file: " + volumeDatastorePath);
|
||||
VmwareHelper.deleteVolumeVmdkFiles(dsMo, volumeUuid.toString(), dcMo);
|
||||
|
||||
vmMo.createDisk(volumeDatastorePath, (int) (dskch.getSize() / (1024L * 1024L)), morDatastore, vmMo.getScsiDeviceControllerKey());
|
||||
vmMo.createDisk(volumeDatastorePath, getMBsFromBytes(dskch.getSize()), morDatastore, vmMo.getScsiDeviceControllerKey());
|
||||
vmMo.detachDisk(volumeDatastorePath, false);
|
||||
}
|
||||
|
||||
@ -5137,6 +5137,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
}
|
||||
}
|
||||
|
||||
private static int getMBsFromBytes(long bytes) {
|
||||
return (int)(bytes / (1024L * 1024L));
|
||||
}
|
||||
|
||||
protected VirtualMachineMO prepareVolumeHostDummyVm(VmwareHypervisorHost hyperHost, DatastoreMO dsMo, String vmName) throws Exception {
|
||||
assert (hyperHost != null);
|
||||
|
||||
|
||||
@ -6591,7 +6591,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
}
|
||||
|
||||
protected VDI handleSrAndVdiAttach(String iqn, String storageHostName,
|
||||
String chapInitiatorName, String chapInitiatorPassword) throws Exception {
|
||||
String chapInitiatorName, String chapInitiatorPassword) throws Types.XenAPIException, XmlRpcException {
|
||||
VDI vdi = null;
|
||||
|
||||
Connection conn = getConnection();
|
||||
@ -6612,7 +6612,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
vdir.virtualSize = sr.getPhysicalSize(conn) - sr.getPhysicalUtilisation(conn) - getMetadata(sr.getPhysicalSize(conn));
|
||||
|
||||
if (vdir.virtualSize < 0) {
|
||||
throw new Exception("VDI virtual size cannot be less than 0.");
|
||||
throw new CloudRuntimeException("VDI virtual size cannot be less than 0.");
|
||||
}
|
||||
|
||||
vdi = VDI.create(conn, vdir);
|
||||
|
||||
@ -36,6 +36,7 @@ import com.cloud.agent.api.to.DataObjectType;
|
||||
import com.cloud.agent.api.to.DataStoreTO;
|
||||
import com.cloud.agent.api.to.DataTO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
@ -120,21 +121,16 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
|
||||
private SolidFireUtil.SolidFireAccount createSolidFireAccount(String sfAccountName,
|
||||
SolidFireConnection sfConnection) {
|
||||
try {
|
||||
String mVip = sfConnection.getManagementVip();
|
||||
int mPort = sfConnection.getManagementPort();
|
||||
String clusterAdminUsername = sfConnection.getClusterAdminUsername();
|
||||
String clusterAdminPassword = sfConnection.getClusterAdminPassword();
|
||||
String mVip = sfConnection.getManagementVip();
|
||||
int mPort = sfConnection.getManagementPort();
|
||||
String clusterAdminUsername = sfConnection.getClusterAdminUsername();
|
||||
String clusterAdminPassword = sfConnection.getClusterAdminPassword();
|
||||
|
||||
long accountNumber = SolidFireUtil.createSolidFireAccount(mVip, mPort,
|
||||
clusterAdminUsername, clusterAdminPassword, sfAccountName);
|
||||
long accountNumber = SolidFireUtil.createSolidFireAccount(mVip, mPort,
|
||||
clusterAdminUsername, clusterAdminPassword, sfAccountName);
|
||||
|
||||
return SolidFireUtil.getSolidFireAccountById(mVip, mPort,
|
||||
clusterAdminUsername, clusterAdminPassword, accountNumber);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalArgumentException(ex.getMessage());
|
||||
}
|
||||
return SolidFireUtil.getSolidFireAccountById(mVip, mPort,
|
||||
clusterAdminUsername, clusterAdminPassword, accountNumber);
|
||||
}
|
||||
|
||||
private void updateCsDbWithAccountInfo(long csAccountId, SolidFireUtil.SolidFireAccount sfAccount) {
|
||||
@ -225,7 +221,6 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
}
|
||||
|
||||
private SolidFireUtil.SolidFireVolume createSolidFireVolume(VolumeInfo volumeInfo, SolidFireConnection sfConnection)
|
||||
throws StorageUnavailableException, Exception
|
||||
{
|
||||
String mVip = sfConnection.getManagementVip();
|
||||
int mPort = sfConnection.getManagementPort();
|
||||
@ -248,11 +243,11 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
iops = new Iops(volumeInfo.getMinIops(), volumeInfo.getMaxIops());
|
||||
}
|
||||
|
||||
long sfVolumeId = SolidFireUtil.createSolidFireVolume(mVip, mPort, clusterAdminUsername, clusterAdminPassword,
|
||||
volumeInfo.getName(), sfAccountId, volumeInfo.getSize(), true,
|
||||
iops.getMinIops(), iops.getMaxIops(), iops.getBurstIops());
|
||||
long sfVolumeId = SolidFireUtil.createSolidFireVolume(mVip, mPort, clusterAdminUsername, clusterAdminPassword,
|
||||
volumeInfo.getName(), sfAccountId, volumeInfo.getSize(), true,
|
||||
iops.getMinIops(), iops.getMaxIops(), iops.getBurstIops());
|
||||
|
||||
return SolidFireUtil.getSolidFireVolume(mVip, mPort, clusterAdminUsername, clusterAdminPassword, sfVolumeId);
|
||||
return SolidFireUtil.getSolidFireVolume(mVip, mPort, clusterAdminUsername, clusterAdminPassword, sfVolumeId);
|
||||
}
|
||||
|
||||
private static class Iops
|
||||
@ -261,14 +256,14 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
private final long _maxIops;
|
||||
private final long _burstIops;
|
||||
|
||||
public Iops(long minIops, long maxIops) throws Exception
|
||||
public Iops(long minIops, long maxIops) throws IllegalArgumentException
|
||||
{
|
||||
if (minIops <= 0 || maxIops <= 0) {
|
||||
throw new Exception("The 'Min IOPS' and 'Max IOPS' values must be greater than 0.");
|
||||
throw new IllegalArgumentException("The 'Min IOPS' and 'Max IOPS' values must be greater than 0.");
|
||||
}
|
||||
|
||||
if (minIops > maxIops) {
|
||||
throw new Exception("The 'Min IOPS' value cannot exceed the 'Max IOPS' value.");
|
||||
throw new IllegalArgumentException("The 'Min IOPS' value cannot exceed the 'Max IOPS' value.");
|
||||
}
|
||||
|
||||
_minIops = minIops;
|
||||
@ -299,7 +294,6 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
}
|
||||
|
||||
private void deleteSolidFireVolume(VolumeInfo volumeInfo, SolidFireConnection sfConnection)
|
||||
throws StorageUnavailableException, Exception
|
||||
{
|
||||
Long storagePoolId = volumeInfo.getPoolId();
|
||||
|
||||
@ -318,15 +312,10 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
}
|
||||
|
||||
private String getSfAccountName(String csAccountUuid, long csAccountId) {
|
||||
return "CloudStack_" + csAccountUuid + "_" + getRandomNumber() + "_" + csAccountId;
|
||||
return "CloudStack_" + csAccountUuid + "_" + csAccountId;
|
||||
}
|
||||
|
||||
private static long getRandomNumber()
|
||||
{
|
||||
return Math.round(Math.random() * 1000000000);
|
||||
}
|
||||
|
||||
private boolean sfAccountExists(String sfAccountName, SolidFireConnection sfConnection) throws Exception {
|
||||
private boolean sfAccountExists(String sfAccountName, SolidFireConnection sfConnection) {
|
||||
String mVip = sfConnection.getManagementVip();
|
||||
int mPort = sfConnection.getManagementPort();
|
||||
String clusterAdminUsername = sfConnection.getClusterAdminUsername();
|
||||
@ -349,55 +338,43 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
String errMsg = null;
|
||||
|
||||
if (dataObject.getType() == DataObjectType.VOLUME) {
|
||||
try {
|
||||
VolumeInfo volumeInfo = (VolumeInfo)dataObject;
|
||||
AccountVO account = _accountDao.findById(volumeInfo.getAccountId());
|
||||
String sfAccountName = getSfAccountName(account.getUuid(), account.getAccountId());
|
||||
VolumeInfo volumeInfo = (VolumeInfo)dataObject;
|
||||
AccountVO account = _accountDao.findById(volumeInfo.getAccountId());
|
||||
String sfAccountName = getSfAccountName(account.getUuid(), account.getAccountId());
|
||||
|
||||
long storagePoolId = dataStore.getId();
|
||||
SolidFireConnection sfConnection = getSolidFireConnection(storagePoolId);
|
||||
long storagePoolId = dataStore.getId();
|
||||
SolidFireConnection sfConnection = getSolidFireConnection(storagePoolId);
|
||||
|
||||
if (!sfAccountExists(sfAccountName, sfConnection)) {
|
||||
SolidFireUtil.SolidFireAccount sfAccount = createSolidFireAccount(sfAccountName,
|
||||
sfConnection);
|
||||
if (!sfAccountExists(sfAccountName, sfConnection)) {
|
||||
SolidFireUtil.SolidFireAccount sfAccount = createSolidFireAccount(sfAccountName,
|
||||
sfConnection);
|
||||
|
||||
updateCsDbWithAccountInfo(account.getId(), sfAccount);
|
||||
}
|
||||
|
||||
SolidFireUtil.SolidFireVolume sfVolume = createSolidFireVolume(volumeInfo, sfConnection);
|
||||
|
||||
iqn = sfVolume.getIqn();
|
||||
|
||||
VolumeVO volume = this._volumeDao.findById(volumeInfo.getId());
|
||||
|
||||
volume.set_iScsiName(iqn);
|
||||
volume.setFolder(String.valueOf(sfVolume.getId()));
|
||||
volume.setPoolType(StoragePoolType.IscsiLUN);
|
||||
volume.setPoolId(storagePoolId);
|
||||
|
||||
_volumeDao.update(volume.getId(), volume);
|
||||
|
||||
StoragePoolVO storagePool = _storagePoolDao.findById(dataStore.getId());
|
||||
|
||||
long capacityBytes = storagePool.getCapacityBytes();
|
||||
long usedBytes = storagePool.getUsedBytes();
|
||||
|
||||
usedBytes += volumeInfo.getSize();
|
||||
|
||||
if (usedBytes > capacityBytes) {
|
||||
usedBytes = capacityBytes;
|
||||
}
|
||||
|
||||
storagePool.setUsedBytes(usedBytes);
|
||||
|
||||
_storagePoolDao.update(storagePoolId, storagePool);
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.error("Failed to create volume (StorageUnavailableException)", e);
|
||||
errMsg = e.toString();
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Failed to create volume (Exception)", e);
|
||||
errMsg = e.toString();
|
||||
updateCsDbWithAccountInfo(account.getId(), sfAccount);
|
||||
}
|
||||
|
||||
SolidFireUtil.SolidFireVolume sfVolume = createSolidFireVolume(volumeInfo, sfConnection);
|
||||
|
||||
iqn = sfVolume.getIqn();
|
||||
|
||||
VolumeVO volume = this._volumeDao.findById(volumeInfo.getId());
|
||||
|
||||
volume.set_iScsiName(iqn);
|
||||
volume.setFolder(String.valueOf(sfVolume.getId()));
|
||||
volume.setPoolType(StoragePoolType.IscsiLUN);
|
||||
volume.setPoolId(storagePoolId);
|
||||
|
||||
_volumeDao.update(volume.getId(), volume);
|
||||
|
||||
StoragePoolVO storagePool = _storagePoolDao.findById(dataStore.getId());
|
||||
|
||||
long capacityBytes = storagePool.getCapacityBytes();
|
||||
long usedBytes = storagePool.getUsedBytes();
|
||||
|
||||
usedBytes += volumeInfo.getSize();
|
||||
|
||||
storagePool.setUsedBytes(usedBytes > capacityBytes ? capacityBytes : usedBytes);
|
||||
|
||||
_storagePoolDao.update(storagePoolId, storagePool);
|
||||
}
|
||||
else {
|
||||
errMsg = "Invalid DataObjectType (" + dataObject.getType() + ") passed to createAsync";
|
||||
@ -412,7 +389,7 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
callback.complete(result);
|
||||
}
|
||||
|
||||
private void deleteSolidFireAccount(long sfAccountId, SolidFireConnection sfConnection) throws Exception {
|
||||
private void deleteSolidFireAccount(long sfAccountId, SolidFireConnection sfConnection) {
|
||||
String mVip = sfConnection.getManagementVip();
|
||||
int mPort = sfConnection.getManagementPort();
|
||||
String clusterAdminUsername = sfConnection.getClusterAdminUsername();
|
||||
@ -433,7 +410,7 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
SolidFireUtil.deleteSolidFireAccount(mVip, mPort, clusterAdminUsername, clusterAdminPassword, sfAccountId);
|
||||
}
|
||||
|
||||
private boolean sfAccountHasVolume(long sfAccountId, SolidFireConnection sfConnection) throws Exception {
|
||||
private boolean sfAccountHasVolume(long sfAccountId, SolidFireConnection sfConnection) {
|
||||
String mVip = sfConnection.getManagementVip();
|
||||
int mPort = sfConnection.getManagementPort();
|
||||
String clusterAdminUsername = sfConnection.getClusterAdminUsername();
|
||||
@ -459,48 +436,36 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
String errMsg = null;
|
||||
|
||||
if (dataObject.getType() == DataObjectType.VOLUME) {
|
||||
try {
|
||||
VolumeInfo volumeInfo = (VolumeInfo)dataObject;
|
||||
AccountVO account = _accountDao.findById(volumeInfo.getAccountId());
|
||||
AccountDetailVO accountDetails = _accountDetailsDao.findDetail(account.getAccountId(), SolidFireUtil.ACCOUNT_ID);
|
||||
long sfAccountId = Long.parseLong(accountDetails.getValue());
|
||||
VolumeInfo volumeInfo = (VolumeInfo)dataObject;
|
||||
AccountVO account = _accountDao.findById(volumeInfo.getAccountId());
|
||||
AccountDetailVO accountDetails = _accountDetailsDao.findDetail(account.getAccountId(), SolidFireUtil.ACCOUNT_ID);
|
||||
long sfAccountId = Long.parseLong(accountDetails.getValue());
|
||||
|
||||
long storagePoolId = dataStore.getId();
|
||||
SolidFireConnection sfConnection = getSolidFireConnection(storagePoolId);
|
||||
long storagePoolId = dataStore.getId();
|
||||
SolidFireConnection sfConnection = getSolidFireConnection(storagePoolId);
|
||||
|
||||
deleteSolidFireVolume(volumeInfo, sfConnection);
|
||||
deleteSolidFireVolume(volumeInfo, sfConnection);
|
||||
|
||||
_volumeDao.deleteVolumesByInstance(volumeInfo.getId());
|
||||
_volumeDao.deleteVolumesByInstance(volumeInfo.getId());
|
||||
|
||||
if (!sfAccountHasVolume(sfAccountId, sfConnection)) {
|
||||
// delete the account from the SolidFire SAN
|
||||
deleteSolidFireAccount(sfAccountId, sfConnection);
|
||||
if (!sfAccountHasVolume(sfAccountId, sfConnection)) {
|
||||
// delete the account from the SolidFire SAN
|
||||
deleteSolidFireAccount(sfAccountId, sfConnection);
|
||||
|
||||
// delete the info in the account_details table
|
||||
// that's related to the SolidFire account
|
||||
_accountDetailsDao.deleteDetails(account.getAccountId());
|
||||
}
|
||||
|
||||
StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId);
|
||||
|
||||
long usedBytes = storagePool.getUsedBytes();
|
||||
|
||||
usedBytes -= volumeInfo.getSize();
|
||||
|
||||
if (usedBytes < 0) {
|
||||
usedBytes = 0;
|
||||
}
|
||||
|
||||
storagePool.setUsedBytes(usedBytes);
|
||||
|
||||
_storagePoolDao.update(storagePoolId, storagePool);
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.error("Failed to create volume (StorageUnavailableException)", e);
|
||||
errMsg = e.toString();
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Failed to create volume (Exception)", e);
|
||||
errMsg = e.toString();
|
||||
// delete the info in the account_details table
|
||||
// that's related to the SolidFire account
|
||||
_accountDetailsDao.deleteDetails(account.getAccountId());
|
||||
}
|
||||
|
||||
StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId);
|
||||
|
||||
long usedBytes = storagePool.getUsedBytes();
|
||||
|
||||
usedBytes -= volumeInfo.getSize();
|
||||
|
||||
storagePool.setUsedBytes(usedBytes < 0 ? 0 : usedBytes);
|
||||
|
||||
_storagePoolDao.update(storagePoolId, storagePool);
|
||||
}
|
||||
else {
|
||||
errMsg = "Invalid DataObjectType (" + dataObject.getType() + ") passed to deleteAsync";
|
||||
@ -515,6 +480,7 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
|
||||
@Override
|
||||
public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -524,13 +490,16 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
||||
|
||||
@Override
|
||||
public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,12 +35,11 @@ import com.cloud.utils.component.ComponentContext;
|
||||
|
||||
@Component
|
||||
public class SolidfirePrimaryDataStoreProvider implements PrimaryDataStoreProvider {
|
||||
protected DataStoreLifeCycle lifecycle;
|
||||
protected PrimaryDataStoreDriver driver;
|
||||
protected HypervisorHostListener listener;
|
||||
private DataStoreLifeCycle lifecycle;
|
||||
private PrimaryDataStoreDriver driver;
|
||||
private HypervisorHostListener listener;
|
||||
|
||||
SolidfirePrimaryDataStoreProvider() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -740,7 +740,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
txn.start();
|
||||
|
||||
VolumeVO volume = new VolumeVO(volumeName, zoneId, -1, -1, -1,
|
||||
new Long(-1), null, null, 0, null, null, null, Volume.Type.DATADISK);
|
||||
new Long(-1), null, null, 0, Volume.Type.DATADISK);
|
||||
volume.setPoolId(null);
|
||||
volume.setDataCenterId(zoneId);
|
||||
volume.setPodId(null);
|
||||
@ -1012,7 +1012,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
txn.start();
|
||||
|
||||
VolumeVO volume = new VolumeVO(userSpecifiedName, -1, -1, -1, -1,
|
||||
new Long(-1), null, null, 0, null, null, null, Volume.Type.DATADISK);
|
||||
new Long(-1), null, null, 0, Volume.Type.DATADISK);
|
||||
volume.setPoolId(null);
|
||||
volume.setDataCenterId(zoneId);
|
||||
volume.setPodId(null);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user