mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
UI changes and accept any type of datastore as presetup in vmware
This commit is contained in:
parent
4bbb747b23
commit
6df819028e
@ -27,6 +27,7 @@ public class ModifyStoragePoolAnswer extends Answer {
|
||||
private StoragePoolInfo poolInfo;
|
||||
private Map<String, TemplateProp> templateInfo;
|
||||
private String localDatastoreName;
|
||||
private String poolType;
|
||||
|
||||
public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, long capacityBytes, long availableBytes, Map<String, TemplateProp> tInfo) {
|
||||
super(cmd);
|
||||
@ -61,4 +62,13 @@ public class ModifyStoragePoolAnswer extends Answer {
|
||||
public String getLocalDatastoreName() {
|
||||
return localDatastoreName;
|
||||
}
|
||||
|
||||
|
||||
public String getPoolType() {
|
||||
return poolType;
|
||||
}
|
||||
|
||||
public void setPoolType(String poolType) {
|
||||
this.poolType = poolType;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,9 @@ import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
@ -53,6 +56,8 @@ public class DefaultHostListener implements HypervisorHostListener {
|
||||
StoragePoolHostDao storagePoolHostDao;
|
||||
@Inject
|
||||
PrimaryDataStoreDao primaryStoreDao;
|
||||
@Inject
|
||||
StoragePoolDetailsDao storagePoolDetailsDao;
|
||||
|
||||
@Override
|
||||
public boolean hostAdded(long hostId) {
|
||||
@ -102,6 +107,10 @@ public class DefaultHostListener implements HypervisorHostListener {
|
||||
StoragePoolVO poolVO = this.primaryStoreDao.findById(poolId);
|
||||
poolVO.setUsedBytes(mspAnswer.getPoolInfo().getCapacityBytes() - mspAnswer.getPoolInfo().getAvailableBytes());
|
||||
poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes());
|
||||
if(StringUtils.isNotEmpty(mspAnswer.getPoolType())) {
|
||||
StoragePoolDetailVO storagePoolDetailVO = new StoragePoolDetailVO(poolId, "pool_type", mspAnswer.getPoolType(), false);
|
||||
storagePoolDetailsDao.persist(storagePoolDetailVO);
|
||||
}
|
||||
primaryStoreDao.update(pool.getId(), poolVO);
|
||||
|
||||
s_logger.info("Connection established between storage pool " + pool + " and host " + hostId);
|
||||
|
||||
@ -4908,7 +4908,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
|
||||
|
||||
if (morDatastore == null) {
|
||||
morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(), pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""));
|
||||
morDatastore = hyperHost.mountDatastore((pool.getType() == StoragePoolType.VMFS || pool.getType() == StoragePoolType.PreSetup), pool.getHost(), pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""));
|
||||
}
|
||||
|
||||
assert (morDatastore != null);
|
||||
@ -4924,6 +4924,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, capacity, available, tInfo);
|
||||
|
||||
if (cmd.getAdd() && (pool.getType() == StoragePoolType.VMFS || pool.getType() == StoragePoolType.PreSetup)) {
|
||||
answer.setPoolType(dsMo.getDatastoreType());
|
||||
answer.setLocalDatastoreName(morDatastore.getValue());
|
||||
}
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
|
||||
@ -133,6 +134,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
|
||||
Long zoneId = (Long)dsInfos.get("zoneId");
|
||||
String url = (String)dsInfos.get("url");
|
||||
String providerName = (String)dsInfos.get("providerName");
|
||||
String hypervisorType = (String)dsInfos.get("hypervisorType");
|
||||
if (clusterId != null && podId == null) {
|
||||
throw new InvalidParameterValueException("Cluster id requires pod id");
|
||||
}
|
||||
@ -327,7 +329,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
|
||||
uuid = (String)existingUuid;
|
||||
} else if (scheme.equalsIgnoreCase("sharedmountpoint") || scheme.equalsIgnoreCase("clvm")) {
|
||||
uuid = UUID.randomUUID().toString();
|
||||
} else if (scheme.equalsIgnoreCase("PreSetup")) {
|
||||
} else if (scheme.equalsIgnoreCase("PreSetup") && !(StringUtils.isNotBlank(hypervisorType) && HypervisorType.getType(hypervisorType).equals(HypervisorType.VMware))) {
|
||||
uuid = hostPath.replace("/", "");
|
||||
} else {
|
||||
uuid = UUID.nameUUIDFromBytes((storageHost + hostPath).getBytes()).toString();
|
||||
|
||||
@ -32,6 +32,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -52,6 +54,9 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
|
||||
@Inject
|
||||
protected PrimaryDataStoreDao storagePoolDao;
|
||||
|
||||
@Inject
|
||||
private StoragePoolDetailsDao storagePoolDetailsDao;
|
||||
|
||||
private final SearchBuilder<StoragePoolJoinVO> spSearch;
|
||||
|
||||
private final SearchBuilder<StoragePoolJoinVO> spIdSearch;
|
||||
@ -94,6 +99,10 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Lo
|
||||
poolResponse.setHypervisor(pool.getHypervisor().toString());
|
||||
}
|
||||
|
||||
StoragePoolDetailVO poolType = storagePoolDetailsDao.findDetail(pool.getId(), "pool_type");
|
||||
if (poolType != null) {
|
||||
poolResponse.setType(poolType.getValue());
|
||||
}
|
||||
long allocatedSize = pool.getUsedCapacity() + pool.getReservedCapacity();
|
||||
poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
|
||||
poolResponse.setDiskSizeAllocated(allocatedSize);
|
||||
|
||||
@ -614,6 +614,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
params.put("zoneId", host.getDataCenterId());
|
||||
params.put("clusterId", host.getClusterId());
|
||||
params.put("podId", host.getPodId());
|
||||
params.put("hypervisorType", host.getHypervisorType());
|
||||
params.put("url", pInfo.getPoolType().toString() + "://" + pInfo.getHost() + "/" + pInfo.getHostPath());
|
||||
params.put("name", name);
|
||||
params.put("localStorage", true);
|
||||
@ -699,6 +700,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
&& hypervisorType != HypervisorType.Any) {
|
||||
throw new InvalidParameterValueException("zone wide storage pool is not supported for hypervisor type " + hypervisor);
|
||||
}
|
||||
} else {
|
||||
ClusterVO clusterVO = _clusterDao.findById(clusterId);
|
||||
hypervisorType = clusterVO.getHypervisorType();
|
||||
}
|
||||
|
||||
Map<String, String> details = extractApiParamAsMap(cmd.getDetails());
|
||||
@ -716,6 +720,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
params.put("zoneId", zone.getId());
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("podId", podId);
|
||||
params.put("hypervisorType", hypervisorType.toString());
|
||||
params.put("url", cmd.getUrl());
|
||||
params.put("tags", cmd.getTags());
|
||||
params.put("name", cmd.getStoragePoolName());
|
||||
|
||||
@ -491,7 +491,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
||||
final String dsPath = disk.getDatastorePath();
|
||||
final String dsType = disk.getDatastoreType();
|
||||
final String dsName = disk.getDatastoreName();
|
||||
if (dsType.equals("VMFS")) {
|
||||
if (dsType.equals(Storage.StoragePoolType.VMFS.toString())) {
|
||||
List<StoragePoolVO> pools = primaryDataStoreDao.listPoolsByCluster(cluster.getId());
|
||||
pools.addAll(primaryDataStoreDao.listByDataCenterId(zone.getId()));
|
||||
for (StoragePool pool : pools) {
|
||||
|
||||
@ -711,7 +711,7 @@ cloudStack.docs = {
|
||||
externalLink: ''
|
||||
},
|
||||
helpPrimaryStorageProtocol: {
|
||||
desc: 'For XenServer, choose NFS, iSCSI, or PreSetup. For KVM, choose NFS, SharedMountPoint, RDB, CLVM or Gluster. For vSphere, choose VMFS (iSCSI or FiberChannel) or NFS. For Hyper-V, choose SMB/CIFS. For LXC, choose NFS or SharedMountPoint. For OVM, choose NFS or ocfs2.',
|
||||
desc: 'For XenServer, choose NFS, iSCSI, or PreSetup. For KVM, choose NFS, SharedMountPoint, RDB, CLVM or Gluster. For vSphere, choose PreSetup (VMFS or iSCSI or FiberChannel or vSAN or vVols) or NFS. For Hyper-V, choose SMB/CIFS. For LXC, choose NFS or SharedMountPoint. For OVM, choose NFS or ocfs2.',
|
||||
externalLink: ''
|
||||
},
|
||||
helpPrimaryStorageServer: {
|
||||
|
||||
@ -18735,8 +18735,8 @@
|
||||
description: "nfs"
|
||||
});
|
||||
items.push({
|
||||
id: "vmfs",
|
||||
description: "vmfs"
|
||||
id: "presetup",
|
||||
description: "presetup"
|
||||
});
|
||||
items.push({
|
||||
id: "custom",
|
||||
@ -18885,7 +18885,7 @@
|
||||
$form.find('.form-item[rel=rbdsecret]').hide();
|
||||
|
||||
$form.find('.form-item[rel=glustervolume]').hide();
|
||||
} else if (protocol == "PreSetup") {
|
||||
} else if (protocol == "PreSetup" && selectedClusterObj.hypervisortype != "VMware") {
|
||||
$form.find('.form-item[rel=server]').hide();
|
||||
$form.find('.form-item[rel=server]').find(".value").find("input").val("localhost");
|
||||
|
||||
@ -18983,7 +18983,7 @@
|
||||
$form.find('.form-item[rel=rbdsecret]').hide();
|
||||
|
||||
$form.find('.form-item[rel=glustervolume]').hide();
|
||||
} else if (protocol == "vmfs") {
|
||||
} else if (protocol == "presetup" && selectedClusterObj.hypervisortype == "VMware") {
|
||||
$form.find('.form-item[rel=server]').css('display', 'inline-block');
|
||||
$form.find('.form-item[rel=server]').find(".value").find("input").val("");
|
||||
|
||||
@ -19408,7 +19408,7 @@
|
||||
array1.push("&details[0].user=" + args.data.smbUsername);
|
||||
array1.push("&details[1].password=" + encodeURIComponent(args.data.smbPassword));
|
||||
array1.push("&details[2].domain=" + args.data.smbDomain);
|
||||
} else if (args.data.protocol == "PreSetup") {
|
||||
} else if (args.data.protocol == "PreSetup" && selectedClusterObj.hypervisortype != "VMware") {
|
||||
var path = args.data.path;
|
||||
if (path.substring(0, 1) != "/")
|
||||
path = "/" + path;
|
||||
@ -19434,12 +19434,12 @@
|
||||
var rbdid = args.data.rbdid;
|
||||
var rbdsecret = args.data.rbdsecret;
|
||||
url = rbdURL(rbdmonitor, rbdpool, rbdid, rbdsecret);
|
||||
} else if (args.data.protocol == "vmfs") {
|
||||
} else if (args.data.protocol == "presetup" && selectedClusterObj.hypervisortype == "VMware") {
|
||||
var path = args.data.vCenterDataCenter;
|
||||
if (path.substring(0, 1) != "/")
|
||||
path = "/" + path;
|
||||
path += "/" + args.data.vCenterDataStore;
|
||||
url = vmfsURL("dummy", path);
|
||||
url = presetupURL("dummy", path);
|
||||
} else if (args.data.protocol == "gluster") {
|
||||
var glustervolume = args.data.glustervolume;
|
||||
|
||||
|
||||
@ -1434,8 +1434,8 @@
|
||||
description: "nfs"
|
||||
});
|
||||
items.push({
|
||||
id: "vmfs",
|
||||
description: "vmfs"
|
||||
id: "presetup",
|
||||
description: "presetup"
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
@ -1576,7 +1576,7 @@
|
||||
$form.find('[rel=rbdsecret]').hide();
|
||||
|
||||
$form.find('[rel=glustervolume]').hide();
|
||||
} else if (protocol == "PreSetup") {
|
||||
} else if (protocol == "PreSetup" && selectedClusterObj.hypervisortype != "VMware") {
|
||||
$form.find('[rel=server]').hide();
|
||||
$form.find('[rel=server]').find(".value").find("input").val("localhost");
|
||||
|
||||
@ -1649,7 +1649,7 @@
|
||||
$form.find('[rel=rbdsecret]').hide();
|
||||
|
||||
$form.find('[rel=glustervolume]').hide();
|
||||
} else if (protocol == "vmfs") {
|
||||
} else if (protocol == "presetup" && selectedClusterObj.hypervisortype == "VMware") {
|
||||
$form.find('[rel=server]').css('display', 'block');
|
||||
$form.find('[rel=server]').find(".value").find("input").val("");
|
||||
|
||||
@ -4529,7 +4529,7 @@
|
||||
array1.push("&details[0].user=" + args.data.primaryStorage.smbUsername);
|
||||
array1.push("&details[1].password=" + encodeURIComponent(args.data.primaryStorage.smbPassword));
|
||||
array1.push("&details[2].domain=" + args.data.primaryStorage.smbDomain);
|
||||
} else if (args.data.primaryStorage.protocol == "PreSetup") {
|
||||
} else if (args.data.primaryStorage.protocol == "PreSetup" && selectedClusterObj.hypervisortype != "VMware") {
|
||||
var path = args.data.primaryStorage.path;
|
||||
if (path.substring(0, 1) != "/")
|
||||
path = "/" + path;
|
||||
@ -4555,12 +4555,12 @@
|
||||
var rbdid = args.data.primaryStorage.rbdid;
|
||||
var rbdsecret = args.data.primaryStorage.rbdsecret;
|
||||
url = rbdURL(rbdmonitor, rbdpool, rbdid, rbdsecret);
|
||||
} else if (args.data.primaryStorage.protocol == "vmfs") {
|
||||
} else if (args.data.primaryStorage.protocol == "presetup" && selectedClusterObj.hypervisortype == "VMware") {
|
||||
var path = args.data.primaryStorage.vCenterDataCenter;
|
||||
if (path.substring(0, 1) != "/")
|
||||
path = "/" + path;
|
||||
path += "/" + args.data.primaryStorage.vCenterDataStore;
|
||||
url = vmfsURL("dummy", path);
|
||||
url = presetupURL("dummy", path);
|
||||
} else {
|
||||
var iqn = args.data.primaryStorage.iqn;
|
||||
if (iqn.substring(0, 1) != "/")
|
||||
|
||||
@ -441,4 +441,9 @@ public class DatastoreMO extends BaseMO {
|
||||
|
||||
return isDatastoreCompatible;
|
||||
}
|
||||
|
||||
public String getDatastoreType() throws Exception {
|
||||
DatastoreSummary summary = _context.getVimClient().getDynamicProperty(getMor(), "summary");
|
||||
return summary.getType();
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +36,6 @@ import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
|
||||
import com.vmware.vim25.VirtualDiskType;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user