@@ -4480,13 +4480,27 @@ private boolean datastoreFileExists(DatastoreMO dsMo, String volumeDatastorePath
44804480 return false ;
44814481 }
44824482
4483+ private String trimIqn (String iqn ) {
4484+ String [] tmp = iqn .split ("/" );
4485+
4486+ if (tmp .length != 3 ) {
4487+ String msg = "Wrong format for iScsi path: " + iqn + ". It should be formatted as '/targetIQN/LUN'." ;
4488+
4489+ s_logger .warn (msg );
4490+
4491+ throw new CloudRuntimeException (msg );
4492+ }
4493+
4494+ return tmp [1 ].trim ();
4495+ }
4496+
44834497 public ManagedObjectReference handleDatastoreAndVmdkAttach (Command cmd , String iqn , String storageHost , int storagePort ,
44844498 String initiatorUsername , String initiatorPassword , String targetUsername , String targetPassword ) throws Exception {
44854499 VmwareContext context = getServiceContext ();
44864500 VmwareHypervisorHost hyperHost = getHyperHost (context );
44874501
44884502 ManagedObjectReference morDs = createVmfsDatastore (hyperHost , getDatastoreName (iqn ),
4489- storageHost , storagePort , iqn ,
4503+ storageHost , storagePort , trimIqn ( iqn ) ,
44904504 initiatorUsername , initiatorPassword ,
44914505 targetUsername , targetPassword );
44924506
@@ -4516,7 +4530,7 @@ public void handleDatastoreAndVmdkDetach(String iqn, String storageHost, int sto
45164530 VmwareContext context = getServiceContext ();
45174531 VmwareHypervisorHost hyperHost = getHyperHost (context );
45184532
4519- deleteVmfsDatastore (hyperHost , getDatastoreName (iqn ), storageHost , storagePort , iqn );
4533+ deleteVmfsDatastore (hyperHost , getDatastoreName (iqn ), storageHost , storagePort , trimIqn ( iqn ) );
45204534 }
45214535
45224536 protected Answer execute (AttachVolumeCommand cmd ) {
0 commit comments