@@ -796,7 +796,7 @@ def do_detach_volume(oci_session, iscsiadm_session, iqn, mode):
796796 raise Exception ("Volume with IQN [%s] not found" % iqn )
797797 try :
798798 compat_info_message (compat_msg = "Detaching volume" ,
799- gen_msg = "Detaching volume %s (%s) " % (_volume .get_display_name (),
799+ gen_msg = "Detaching volume %s [%s] " % (_volume .get_display_name (),
800800 _volume .get_iqn ()), mode = mode )
801801 _volume .detach ()
802802 except Exception as e :
@@ -953,22 +953,22 @@ def _do_attach_oci_block_volume(sess, ocid, chap=False):
953953 Raise:
954954 Exception if attachment failed
955955 """
956- _logger .debug (" Attaching volume [%s]" , ocid )
956+ _logger .debug (' Attaching volume [%s]' , ocid )
957957 vol = sess .get_volume (ocid )
958958 if vol is None :
959- raise Exception (" Volume %s not found" % ocid )
959+ raise Exception (' Volume [%s] not found' % ocid )
960960
961961 if vol .is_attached ():
962962 if vol .get_instance ().get_ocid () == sess .this_instance ().get_ocid ():
963963 # attached to this instance already
964- _msg = " Volume %s already attached to this instance" % ocid
964+ _msg = ' Volume [%s] already attached to this instance' % ocid
965965 else :
966- _msg = " Volume %s already attached to instance %s (%s)" % (ocid ,
966+ _msg = ' Volume [%s] already attached to instance %s [%s]' % (ocid ,
967967 vol .get_instance ().get_ocid (),
968968 vol .get_instance ().get_display_name ())
969969 raise Exception (_msg )
970970
971- _logger .info (" Attaching OCI Volume to this instance." )
971+ _logger .info (' Attaching OCI Volume [%s] to this instance.' % ocid )
972972 # vol = vol.attach_to(instance_id=sess.this_instance().get_ocid(), wait=True)
973973 vol = vol .attach_to (instance_id = sess .this_instance ().get_ocid (), use_chap = chap , wait = True )
974974 _logger .debug ("Volume [%s] attached" , ocid )
@@ -1007,10 +1007,10 @@ def get_volume_by_iqn(sess, iqn):
10071007 _logger .debug ('Found %s' , str (volume ))
10081008 return volume
10091009 else :
1010- _logger .info ('Unable to get volume ocid and display name for iqn %s , ' , iqn )
1010+ _logger .info ('Unable to get volume ocid and display name for iqn [%s] , ' , iqn )
10111011 except Exception as e :
1012- _logger .debug ('Failed to get volume data for iqn %s : %s' , iqn , str (e ), stack_info = True , exc_info = True )
1013- _logger .error ('Failed to get volume data for iqn %s ' , iqn )
1012+ _logger .debug ('Failed to get volume data for iqn [%s] : %s' , iqn , str (e ), stack_info = True , exc_info = True )
1013+ _logger .error ('Failed to get volume data for iqn [%s] ' , iqn )
10141014 return None
10151015
10161016
@@ -1029,7 +1029,7 @@ def _get_iqn_from_ocid(sess, ocid):
10291029 -------
10301030 str: the iqn.
10311031 """
1032- _logger .debug ('Trying to find the iqn for volume %s ' , ocid )
1032+ _logger .debug ('Trying to find the iqn for volume [%s] ' , ocid )
10331033 this_compartment = sess .this_compartment ()
10341034 this_availability_domain = sess .this_availability_domain ()
10351035 all_volumes = this_compartment .all_volumes (this_availability_domain )
@@ -1057,7 +1057,7 @@ def _is_iqn_attached(sess, iqn):
10571057 -------
10581058 str: the ocid
10591059 """
1060- _logger .debug ('Verifying if %s is attached to this instance.' )
1060+ _logger .debug ('Verifying if [%s] is attached to this instance.' )
10611061 volume_data = get_volume_by_iqn (sess , iqn )
10621062 if volume_data is None :
10631063 return None
@@ -1084,7 +1084,7 @@ def do_umount(mountpoint):
10841084 subprocess .check_output (['/usr/bin/umount' , mountpoint ], stderr = subprocess .STDOUT )
10851085 return True
10861086 except subprocess .CalledProcessError as e :
1087- _logger .error ("Failed to unmount %s : %s" , mountpoint , e .output )
1087+ _logger .error ("Failed to unmount [%s] : %s" , mountpoint , e .output )
10881088 return False
10891089
10901090
@@ -1178,7 +1178,7 @@ def do_create_volume(sess, size, display_name, attach_it, chap_credentials, mode
11781178 _logger .debug ("Failed to create volume" , exc_info = True )
11791179 raise Exception ("Failed to create volume" ) from e
11801180
1181- _logger .info ("Volume %s created" , vol .get_display_name ())
1181+ _logger .info ("Volume [%s] created" , vol .get_display_name ())
11821182
11831183 if not attach_it :
11841184 return
@@ -1195,7 +1195,7 @@ def do_create_volume(sess, size, display_name, attach_it, chap_credentials, mode
11951195 raise Exception ('Cannot attach BV' ) from e
11961196 #
11971197 # attach using iscsiadm commands
1198- compat_info_message (gen_msg = "Attaching iSCSI device" , mode = mode )
1198+ compat_info_message (gen_msg = "Attaching iSCSI device. " , mode = mode )
11991199
12001200 vol_portal_ip = vol .get_portal_ip ()
12011201 vol_portal_port = vol .get_portal_port ()
@@ -1209,7 +1209,7 @@ def do_create_volume(sess, size, display_name, attach_it, chap_credentials, mode
12091209 password = vol_password ,
12101210 auto_startup = True )
12111211 compat_info_message (compat_msg = "iscsiadm attach Result: %s" % iscsiadm .error_message_from_code (retval ),
1212- gen_msg = "Volume %s is attached." % vol .get_display_name (), mode = mode )
1212+ gen_msg = "Volume [%s] is attached." % vol .get_display_name (), mode = mode )
12131213 if retval == 0 :
12141214 _logger .debug ('Creation successful' )
12151215 if chap_credentials :
@@ -1550,7 +1550,7 @@ def main():
15501550 retval = 0
15511551 if not args .yes :
15521552 for ocid in args .ocids :
1553- _logger .info ("Volume : %s " , ocid )
1553+ _logger .info ("Volume : [%s] " , ocid )
15541554 # if not ask_yes_no("WARNING: the volume(s) will be destroyed. This is irreversible. Continue?"):
15551555 if not _read_yn ('WARNING: the volume(s) will be destroyed. This is irreversible. Continue?' ,
15561556 yn = True ,
@@ -1589,11 +1589,11 @@ def main():
15891589 retval = 0
15901590 for iqn in args .iqns :
15911591 if iqn in detached_volume_iqns :
1592- _logger .error ("Target %s is already detached" , iqn )
1592+ _logger .error ("Target [%s] is already detached" , iqn )
15931593 retval = 1
15941594 continue
15951595 if iqn not in iscsiadm_session or 'device' not in iscsiadm_session [iqn ]:
1596- _logger .error ("Target %s not found" , iqn )
1596+ _logger .error ("Target [%s] not found" , iqn )
15971597 retval = 1
15981598 continue
15991599
@@ -1625,7 +1625,8 @@ def main():
16251625 retval = 1
16261626
16271627 if retval == 0 :
1628- compat_info_message (gen_msg = "Updating detached volume cache file: remove %s" % iqn , mode = compat_mode )
1628+ # compat_info_message(gen_msg="Updating detached volume cache file: remove %s" % iqn, mode=compat_mode)
1629+ # compat_info_message(gen_msg="Volume [%s] successfully detached." % iqn, mode=compat_mode)
16291630 write_cache (cache_content = detached_volume_iqns , cache_fname = __ignore_file )
16301631
16311632 _logger .debug ('Trigger ocid refresh' )
@@ -1652,7 +1653,7 @@ def main():
16521653 _iqn_to_use = iqn
16531654 _save_chap_cred = False
16541655 if iqn in iscsiadm_session :
1655- _logger .info ("Target %s is already attached." , iqn )
1656+ _logger .info ("Target [%s] is already attached." , iqn )
16561657 continue
16571658
16581659 if _iqn_to_use .startswith (oci_volume_tag ):
@@ -1703,7 +1704,7 @@ def main():
17031704 if not this_ocid :
17041705 #
17051706 # volume is not attached to oci, giving up for now instead of letting it timeout for 90 sec
1706- _logger .error ('A volume with iqn %s is not in this instance list\n '
1707+ _logger .error ('A volume with iqn [%s] is not in this instance list '
17071708 'of attached block volumes, attach it using the ocid.' , _iqn_to_use )
17081709 retval = 1
17091710 continue
@@ -1722,11 +1723,11 @@ def main():
17221723
17231724 if _iqn_to_use in iscsiadm_session :
17241725 _iscsi_portal_ip = iscsiadm_session [_iqn_to_use ]['current_portal_ip' ]
1725- _logger .debug ('Portal ip for %s is %s ' , _iqn_to_use , _iscsi_portal_ip )
1726+ _logger .debug ('Portal ip for [%s] is [%s] ' , _iqn_to_use , _iscsi_portal_ip )
17261727 elif pip_cand is not None :
17271728 _iscsi_portal_ip = pip_cand
17281729 else :
1729- _logger .info ('Invalid argument, iqn %s not found' , _iqn_to_use )
1730+ _logger .info ('Invalid argument, iqn [%s] not found' , _iqn_to_use )
17301731 retval = 1
17311732 continue
17321733 else :
@@ -1747,8 +1748,8 @@ def main():
17471748 if _iqn_to_use in detached_volume_iqns :
17481749 detached_volume_iqns .remove (_iqn_to_use )
17491750 except Exception as e :
1750- _logger .debug ("Failed to attach target %s : %s" , _iqn_to_use , str (e ), exc_info = True , stack_info = True )
1751- _logger .error ("Failed to attach target %s : %s" , _iqn_to_use , str (e ))
1751+ _logger .debug ("Failed to attach target [%s] : %s" , _iqn_to_use , str (e ), exc_info = True , stack_info = True )
1752+ _logger .error ("Failed to attach target [%s] : %s" , _iqn_to_use , str (e ))
17521753 _save_chap_cred = False
17531754 retval = 1
17541755 continue
@@ -1758,10 +1759,11 @@ def main():
17581759 add_chap_secret (_iqn_to_use , _attachment_username , _attachment_password )
17591760
17601761 if retval == 0 :
1762+ # compat_info_message(gen_msg="Volume [%s] successfully attached." % _iqn_to_use)
17611763 #
17621764 # update detached volume cache
1763- compat_info_message (gen_msg = "Updating detached volume cache file: remove %s if necessary."
1764- % _iqn_to_use , mode = compat_mode )
1765+ # compat_info_message(gen_msg="Updating detached volume cache file: remove %s if necessary."
1766+ # % _iqn_to_use, mode=compat_mode)
17651767 write_cache (cache_content = detached_volume_iqns , cache_fname = __ignore_file )
17661768 #
17671769 # run ocid.refresh
0 commit comments