mirror of https://github.com/apache/cloudstack.git
bug 10743: default local storage is ext in XenServer 6.0, add ext local storage support
This commit is contained in:
parent
95b48ba222
commit
e666cf5e77
|
|
@ -96,7 +96,8 @@ public class Storage {
|
|||
LVM(false), // XenServer local LVM SR
|
||||
SharedMountPoint(true),
|
||||
VMFS(true), // VMware VMFS storage
|
||||
PreSetup(true); // for XenServer, Storage Pool is set up by customers.
|
||||
PreSetup(true), // for XenServer, Storage Pool is set up by customers.
|
||||
EXT(false); // XenServer local EXT SR
|
||||
|
||||
|
||||
boolean shared;
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
protected String _localGateway;
|
||||
|
||||
public enum SRType {
|
||||
NFS, LVM, ISCSI, ISO, LVMOISCSI, LVMOHBA;
|
||||
NFS, LVM, ISCSI, ISO, LVMOISCSI, LVMOHBA, EXT;
|
||||
|
||||
String _str;
|
||||
|
||||
|
|
@ -3612,43 +3612,100 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
s_logger.warn(msg);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
protected StartupStorageCommand initializeLocalSR(Connection conn) {
|
||||
|
||||
SR lvmsr = getLocalLVMSR(conn);
|
||||
if (lvmsr == null) {
|
||||
return null;
|
||||
}
|
||||
protected SR getLocalEXTSR(Connection conn) {
|
||||
try {
|
||||
String lvmuuid = lvmsr.getUuid(conn);
|
||||
long cap = lvmsr.getPhysicalSize(conn);
|
||||
if (cap < 0) {
|
||||
return null;
|
||||
Map<SR, SR.Record> map = SR.getAllRecords(conn);
|
||||
for (Map.Entry<SR, SR.Record> entry : map.entrySet()) {
|
||||
SR.Record srRec = entry.getValue();
|
||||
if (SRType.EXT.equals(srRec.type)) {
|
||||
Set<PBD> pbds = srRec.PBDs;
|
||||
if (pbds == null) {
|
||||
continue;
|
||||
}
|
||||
for (PBD pbd : pbds) {
|
||||
Host host = pbd.getHost(conn);
|
||||
if (!isRefNull(host) && host.getUuid(conn).equals(_host.uuid)) {
|
||||
if (!pbd.getCurrentlyAttached(conn)) {
|
||||
pbd.plug(conn);
|
||||
}
|
||||
SR sr = entry.getKey();
|
||||
sr.scan(conn);
|
||||
return sr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long avail = cap - lvmsr.getPhysicalUtilisation(conn);
|
||||
lvmsr.setNameLabel(conn, lvmuuid);
|
||||
String name = "Cloud Stack Local Storage Pool for " + _host.uuid;
|
||||
lvmsr.setNameDescription(conn, name);
|
||||
Host host = Host.getByUuid(conn, _host.uuid);
|
||||
String address = host.getAddress(conn);
|
||||
StoragePoolInfo pInfo = new StoragePoolInfo(lvmuuid, address, SRType.LVM.toString(), SRType.LVM.toString(), StoragePoolType.LVM, cap, avail);
|
||||
StartupStorageCommand cmd = new StartupStorageCommand();
|
||||
cmd.setPoolInfo(pInfo);
|
||||
cmd.setGuid(_host.uuid);
|
||||
cmd.setDataCenter(Long.toString(_dcId));
|
||||
cmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
|
||||
return cmd;
|
||||
} catch (XenAPIException e) {
|
||||
String msg = "build startupstoragecommand err in host:" + _host.uuid + e.toString();
|
||||
String msg = "Unable to get local EXTSR in host:" + _host.uuid + e.toString();
|
||||
s_logger.warn(msg);
|
||||
} catch (XmlRpcException e) {
|
||||
String msg = "build startupstoragecommand err in host:" + _host.uuid + e.getMessage();
|
||||
String msg = "Unable to get local EXTSR in host:" + _host.uuid + e.getCause();
|
||||
s_logger.warn(msg);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected StartupStorageCommand initializeLocalSR(Connection conn) {
|
||||
SR lvmsr = getLocalLVMSR(conn);
|
||||
if (lvmsr != null) {
|
||||
try {
|
||||
String lvmuuid = lvmsr.getUuid(conn);
|
||||
long cap = lvmsr.getPhysicalSize(conn);
|
||||
if (cap > 0) {
|
||||
long avail = cap - lvmsr.getPhysicalUtilisation(conn);
|
||||
lvmsr.setNameLabel(conn, lvmuuid);
|
||||
String name = "Cloud Stack Local LVM Storage Pool for " + _host.uuid;
|
||||
lvmsr.setNameDescription(conn, name);
|
||||
Host host = Host.getByUuid(conn, _host.uuid);
|
||||
String address = host.getAddress(conn);
|
||||
StoragePoolInfo pInfo = new StoragePoolInfo(lvmuuid, address, SRType.LVM.toString(), SRType.LVM.toString(), StoragePoolType.LVM, cap, avail);
|
||||
StartupStorageCommand cmd = new StartupStorageCommand();
|
||||
cmd.setPoolInfo(pInfo);
|
||||
cmd.setGuid(_host.uuid);
|
||||
cmd.setDataCenter(Long.toString(_dcId));
|
||||
cmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
|
||||
return cmd;
|
||||
}
|
||||
} catch (XenAPIException e) {
|
||||
String msg = "build local LVM info err in host:" + _host.uuid + e.toString();
|
||||
s_logger.warn(msg);
|
||||
} catch (XmlRpcException e) {
|
||||
String msg = "build local LVM info err in host:" + _host.uuid + e.getMessage();
|
||||
s_logger.warn(msg);
|
||||
}
|
||||
}
|
||||
|
||||
SR extsr = getLocalEXTSR(conn);
|
||||
if (extsr != null) {
|
||||
try {
|
||||
String extuuid = extsr.getUuid(conn);
|
||||
long cap = extsr.getPhysicalSize(conn);
|
||||
if (cap > 0) {
|
||||
long avail = cap - extsr.getPhysicalUtilisation(conn);
|
||||
extsr.setNameLabel(conn, extuuid);
|
||||
String name = "Cloud Stack Local EXT Storage Pool for " + _host.uuid;
|
||||
extsr.setNameDescription(conn, name);
|
||||
Host host = Host.getByUuid(conn, _host.uuid);
|
||||
String address = host.getAddress(conn);
|
||||
StoragePoolInfo pInfo = new StoragePoolInfo(extuuid, address, SRType.EXT.toString(), SRType.EXT.toString(), StoragePoolType.EXT, cap, avail);
|
||||
StartupStorageCommand cmd = new StartupStorageCommand();
|
||||
cmd.setPoolInfo(pInfo);
|
||||
cmd.setGuid(_host.uuid);
|
||||
cmd.setDataCenter(Long.toString(_dcId));
|
||||
cmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
|
||||
return cmd;
|
||||
}
|
||||
} catch (XenAPIException e) {
|
||||
String msg = "build local EXT info err in host:" + _host.uuid + e.toString();
|
||||
s_logger.warn(msg);
|
||||
} catch (XmlRpcException e) {
|
||||
String msg = "build local EXT info err in host:" + _host.uuid + e.getMessage();
|
||||
s_logger.warn(msg);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ copyvhd()
|
|||
cleanup
|
||||
exit 0
|
||||
fi
|
||||
if [ $type != "nfs" ]; then
|
||||
if [ $type != "nfs" -a $type != "ext" ]; then
|
||||
dd if=$srcvhd of=$desvhd bs=512 seek=$(($(($vsize/512))-1)) count=1
|
||||
$VHDUTIL modify -s $vsize -n $desvhd
|
||||
if [ $? -ne 0 ]; then
|
||||
|
|
@ -107,7 +107,7 @@ copyvhd()
|
|||
fi
|
||||
}
|
||||
|
||||
if [ $type == "nfs" ]; then
|
||||
if [ $type == "nfs" -o $type == "ext" ]; then
|
||||
uuid=$(uuidgen -r)
|
||||
desvhd=/var/run/sr-mount/$sruuid/$uuid
|
||||
copyvhd $desvhd $vhdfile 0 $type
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ fi
|
|||
|
||||
vhdfile=$localmp/${vdiuuid}.vhd
|
||||
|
||||
if [ $type == "nfs" ]; then
|
||||
if [ $type == "nfs" -o $type == "ext" ]; then
|
||||
dd if=/var/run/sr-mount/$sruuid/${vdiuuid}.vhd of=$vhdfile bs=2M
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "8#failed to copy /var/run/sr-mount/$sruuid/${vdiuuid}.vhd to secondarystorage"
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
List<StoragePoolHostVO> storagePoolHostRefs = _storagePoolHostDao.listByHostId(host.getId());
|
||||
for (StoragePoolHostVO storagePoolHostRef : storagePoolHostRefs) {
|
||||
StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolHostRef.getPoolId());
|
||||
if (storagePool.getPoolType() == StoragePoolType.LVM) {
|
||||
if (storagePool.getPoolType() == StoragePoolType.LVM || storagePool.getPoolType() == StoragePoolType.EXT) {
|
||||
SearchBuilder<VolumeVO> volumeSB = _volsDao.createSearchBuilder();
|
||||
volumeSB.and("poolId", volumeSB.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||
volumeSB.and("removed", volumeSB.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||
|
|
@ -1311,7 +1311,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
throw new InvalidParameterValueException("Unable to find pool by id " + id);
|
||||
}
|
||||
|
||||
if (sPool.getPoolType().equals(StoragePoolType.LVM)) {
|
||||
if (sPool.getPoolType().equals(StoragePoolType.LVM) || sPool.getPoolType().equals(StoragePoolType.EXT)) {
|
||||
s_logger.warn("Unable to delete local storage id:" + id);
|
||||
throw new InvalidParameterValueException("Unable to delete local storage id: " + id);
|
||||
}
|
||||
|
|
@ -3030,7 +3030,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
@DB
|
||||
public StoragePoolVO findLocalStorageOnHost(long hostId) {
|
||||
SearchCriteria<StoragePoolVO> sc = LocalStorageSearch.create();
|
||||
sc.setParameters("type", new Object[]{StoragePoolType.Filesystem, StoragePoolType.LVM});
|
||||
sc.setParameters("type", new Object[]{StoragePoolType.Filesystem, StoragePoolType.LVM, StoragePoolType.EXT});
|
||||
sc.setJoinParameters("poolHost", "hostId", hostId);
|
||||
List<StoragePoolVO> storagePools = _storagePoolDao.search(sc, null);
|
||||
if (!storagePools.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -93,8 +93,6 @@ public interface StoragePoolDao extends GenericDao<StoragePoolVO, Long> {
|
|||
|
||||
List<StoragePoolVO> listPoolByHostPath(String host, String path);
|
||||
|
||||
void deleteStoragePoolRecords(ArrayList<Long> ids);
|
||||
|
||||
void updateDetails(long poolId, Map<String, String> details);
|
||||
|
||||
Map<String, String> getDetails(long poolId);
|
||||
|
|
|
|||
|
|
@ -256,17 +256,6 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
|||
return pool;
|
||||
}
|
||||
|
||||
@DB
|
||||
@Override
|
||||
public void deleteStoragePoolRecords(ArrayList<Long> ids)
|
||||
{
|
||||
SearchCriteria<StoragePoolVO> sc = DeleteLvmSearch.create();
|
||||
sc.setParameters("ids", ids.toArray());
|
||||
sc.setParameters("LVM", StoragePoolType.LVM);
|
||||
sc.setParameters("Filesystem", StoragePoolType.Filesystem);
|
||||
remove(sc);
|
||||
}
|
||||
|
||||
@DB
|
||||
@Override
|
||||
public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue