diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index ab0a76c5160..9ba34517319 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -1051,8 +1051,10 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati details.put(DiskTO.VOLUME_SIZE, String.valueOf(volumeInfo.getSize())); details.put(DiskTO.IQN, volumeInfo.get_iScsiName()); details.put(DiskTO.MOUNT_POINT, volumeInfo.get_iScsiName()); + VolumeVO volume = _volumeDao.findById(volumeInfo.getId()); - details.put(DiskTO.PROTOCOL_TYPE, (volume.getPoolType()!=null)?volume.getPoolType().toString():null); + + details.put(DiskTO.PROTOCOL_TYPE, (volume.getPoolType() != null) ? volume.getPoolType().toString() : null); ChapInfo chapInfo = volService.getChapInfo(volumeInfo, dataStore); diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java index 397e665b7f1..602de530555 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java @@ -1886,16 +1886,14 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe String mountpoint = details.get(DiskTO.MOUNT_POINT); String protocoltype=details.get(DiskTO.PROTOCOL_TYPE); - if(StoragePoolType.NetworkFilesystem.toString().equalsIgnoreCase(protocoltype)){ - String poolid = storageHost+":"+mountpoint; - String namelable = mountpoint; - String volumedesc = storageHost+":"+mountpoint; + if (StoragePoolType.NetworkFilesystem.toString().equalsIgnoreCase(protocoltype)) { + String poolid = storageHost + ":" + mountpoint; + String namelable = mountpoint; + String volumedesc = storageHost + ":" + mountpoint; - return getNfsSR(conn, poolid, namelable, storageHost, mountpoint, volumedesc); - - }else{ - - return getIscsiSR(conn, iScsiName, storageHost, iScsiName, chapInitiatorUsername, chapInitiatorSecret, true); + return getNfsSR(conn, poolid, namelable, storageHost, mountpoint, volumedesc); + } else { + return getIscsiSR(conn, iScsiName, storageHost, iScsiName, chapInitiatorUsername, chapInitiatorSecret, true); } } @@ -1908,20 +1906,21 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe if (vdi == null) { vdi = createVdi(sr, vdiNameLabel, volumeSize); - }else { + } else { + // if VDI is not null, it must have already been created, so check whether a resize of the volume was performed + // if true, resize the VDI to the volume size - // if vdi is not null, it must have been already created, check whether a resize of volume was done - // if true , resize the vdi to the volume size s_logger.info("checking for the resize of the datadisk"); - long vdiVirtualsize = vdi.getVirtualSize(conn); - if(vdiVirtualsize != volumeSize){ - s_logger.info("resizing the datadisk(vdi) from vdiVirtualsize :"+ vdiVirtualsize + "to volumeSize :" + volumeSize); + long vdiVirtualSize = vdi.getVirtualSize(conn); + + if (vdiVirtualSize != volumeSize) { + s_logger.info("resizing the datadisk(vdi) from vdiVirtualsize :"+ vdiVirtualSize + "to volumeSize :" + volumeSize); try { vdi.resize(conn, volumeSize); } catch (Exception e) { - s_logger.warn("Unable to resize volume",e); + s_logger.warn("Unable to resize volume", e); } } } @@ -5086,7 +5085,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe StorageFilerTO pool = cmd.getPool(); try { if (pool.getType() == StoragePoolType.NetworkFilesystem) { - getNfsSR(conn, Long.toString(pool.getId()),pool.getUuid(),pool.getHost(),pool.getPath(),pool.toString()); + getNfsSR(conn, Long.toString(pool.getId()), pool.getUuid(), pool.getHost(), pool.getPath(), pool.toString()); } else if (pool.getType() == StoragePoolType.IscsiLUN) { getIscsiSR(conn, pool.getUuid(), pool.getHost(), pool.getPath(), null, null, false); } else if (pool.getType() == StoragePoolType.PreSetup) { @@ -6096,7 +6095,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe } } - protected SR getNfsSR(Connection conn,String poolid,String uuid, String server,String serverpath,String pooldesc) { + protected SR getNfsSR(Connection conn, String poolid, String uuid, String server, String serverpath, String pooldesc) { Map deviceConfig = new HashMap(); try { serverpath = serverpath.replace("//", "/"); @@ -6129,7 +6128,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe if (server.equals(dc.get("server")) && serverpath.equals(dc.get("serverpath"))) { throw new CloudRuntimeException("There is a SR using the same configuration server:" + dc.get("server") + ", serverpath:" + dc.get("serverpath") + - " for pool " + uuid + "on host:" + _host.uuid); + " for pool " + uuid + " on host:" + _host.uuid); } } diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 76bc50ced5d..7af404e9728 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -2094,7 +2094,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic details.put(DiskTO.VOLUME_SIZE, String.valueOf(volumeToAttach.getSize())); details.put(DiskTO.IQN, volumeToAttach.get_iScsiName()); details.put(DiskTO.MOUNT_POINT, volumeToAttach.get_iScsiName()); - details.put(DiskTO.PROTOCOL_TYPE, (volumeToAttach.getPoolType()!=null) ? volumeToAttach.getPoolType().toString() : null); + details.put(DiskTO.PROTOCOL_TYPE, (volumeToAttach.getPoolType() != null) ? volumeToAttach.getPoolType().toString() : null); if (chapInfo != null) { details.put(DiskTO.CHAP_INITIATOR_USERNAME, chapInfo.getInitiatorUsername());