Skip to content

Commit 69bc5cb

Browse files
author
guido tijskens
committed
fix typos
1 parent 97faa21 commit 69bc5cb

File tree

5 files changed

+83
-38
lines changed

5 files changed

+83
-38
lines changed

lib/oci_utils/__init__.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,35 @@
2323
_configuration = read_configuration()
2424

2525
oci_regions = {
26-
'phx': 'phx - us-phoenix-1 (Phoenix, AZ, USA)',
27-
'iad': 'iad - us-ashburn-1 (Ashburn, VA, USA)',
28-
'fra': 'fra - eu-frankfurt-1 (Frankfurt, Germany)',
29-
'lhr': 'lhr - uk-london-1 (London, UK)',
3026
'ams': 'ams - eu-amsterdam-1 (Amsterdam, The Netherlands)',
27+
'arn': 'arn - eu-stockholm-1 (Stockholm, Norway)',
28+
'auh': 'auh - me-abu-dhabi-1 (Abu Dhabi, United Arab Emirates)',
3129
'bom': 'bom - ap-mumbai-1 (Mumbai, India)',
3230
'cwl': 'cwl - uk-cardiff-1 (Newport, UK)',
3331
'dxb': 'dxb - me-dubai-1 (Duabi, UAE)',
32+
'fra': 'fra - eu-frankfurt-1 (Frankfurt, Germany)',
3433
'gru': 'gru - sa-saopaulo-1 (Sao Paulo, Brazil)',
35-
'vcp': 'vcp - sa-vinhedo-1 (Vinhedo, Brazil)',
3634
'hyd': 'hyd - ap-hyderabad-1 (Hyderabad, India)',
35+
'iad': 'iad - us-ashburn-1 (Ashburn, VA, USA)',
3736
'icn': 'icn - ap-seoul-1 (Seoul, South Korea)',
38-
'jed': 'jed - me-jeddah-1 (Jeddah, Saoudi Arabia)',
37+
'jed': 'jed - me-jeddah-1 (Jeddah, Saudi Arabia)',
38+
'jnb': 'jnb - af-johannesburg-1 (Johannesburg, South Africa)',
3939
'kix': 'kix - ap-osaka-1 (Osaka, Japan)',
40+
'lhr': 'lhr - uk-london-1 (London, UK)',
41+
'lin': 'lin - eu-milan-1 (Milan, Italy)',
42+
'mct': 'mct - me-muscat-1 (Muscat, Oman)',
4043
'mel': 'mel - ap-melbourne-1 (Melbourne, Australia)',
44+
'mrs': 'mrs - eu-marseille-1 (Marseille, France)',
45+
'mtz': 'mtz - il-jerusalem-1 (Jerusalem, Israel)',
46+
'nri2': 'nri2 - ap-osaka-2 (Osaka, Japan)',
4147
'nrt': 'nrt - ap-tokyo-1 (Tokyo, Japan)',
48+
'phx': 'phx - us-phoenix-1 (Phoenix, AZ, USA)',
4249
'scl': 'scl - sa-santiago-1 (Santiago, Chile)',
50+
'sin': 'sin - ap-singapore-1 (Singapore, Singapore)',
4351
'sjc': 'sjc - us-sanjose-1 (San Jose, CA, USA)',
4452
'syd': 'syd - ap-sydney-1 (Sydney, Australia)',
53+
'vcp': 'vcp - sa-vinhedo-1 (Vinhedo, Brazil)',
54+
'wga': 'wga - ap-canberra-1 (Canberra, Australia)',
4555
'yny': 'yny - ap-chuncheon-1 (Chuncheon, South Korea)',
4656
'yul': 'yul - ca-montreal-1 (Montreal, Canada)',
4757
'yyz': 'yyz - ca-toronto-1 (Toronto, Canada)',

lib/oci_utils/impl/oci-iscsi-config-main.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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

lib/oci_utils/impl/oci_resources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,8 @@ def all_volumes(self):
595595
instance_id=self._ocid).data
596596
except oci_sdk.exceptions.ServiceError:
597597
# the user has no permission to list volumes
598-
OCIInstance._logger.debug('the user has no permission to list volumes', exc_info=True)
599-
# TODO : shouln't be an error ?
598+
OCIInstance._logger.debug('The user has no permission to list volumes', exc_info=True, stack_info=True)
599+
# TODO : shouldn't be an error ?
600600
return []
601601

602602
# multiple volume attachments may exist for the same

lib/oci_utils/impl/ocid-main.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,23 @@ def iscsi_func(context, func_logger):
300300

301301
all_iqns = {}
302302

303+
# -------------------------------------------------------------------------------------
304+
# possible change for LINUX-11440; comment out the in-between
305+
# verify if user has authorisation to list volumes; if not, scan for new volumes.
306+
# volumes = None
307+
# if context['oci_sess'] is not None:
308+
# try:
309+
# #
310+
# # get a list of volumes attached to the instance
311+
# instance = context['oci_sess'].this_instance()
312+
# if instance is None:
313+
# func_logger.debug('Cannot get current instance.')
314+
# else:
315+
# volumes = instance.all_volumes()
316+
# except Exception as e:
317+
# func_logger.debug('User is not authorized to list all volumes.')
318+
# -------------------------------------------------------------------------------------
319+
#
303320
# volumes connected to this instance
304321
inst_volumes = []
305322
if context['oci_sess'] is not None:
@@ -321,6 +338,23 @@ def iscsi_func(context, func_logger):
321338
else:
322339
all_iqns[v.get_portal_ip()] = [v.get_iqn()]
323340
func_logger.debug('All volumes: %s', all_iqns)
341+
# -------------------------------------------------------------------------------------
342+
#
343+
# possible change for LINUX-11440; comment out the above
344+
# if bool(volumes):
345+
# for v in volumes:
346+
# vol = {'iqn': v.get_iqn(),
347+
# 'ipaddr': v.get_portal_ip(),
348+
# 'user': v.get_user(),
349+
# 'password': v.get_password()}
350+
# inst_volumes.append(vol)
351+
# if v.get_portal_ip() in all_iqns:
352+
# all_iqns[v.get_portal_ip()].append(v.get_iqn())
353+
# else:
354+
# all_iqns[v.get_portal_ip()] = [v.get_iqn()]
355+
# func_logger.debug('All volumes: %s', all_iqns)
356+
#
357+
# -------------------------------------------------------------------------------------
324358
else:
325359
#
326360
# fall back to scanning
@@ -577,8 +611,7 @@ def start_thread(name, repeat):
577611
is_enabled = OCIUtilsConfiguration.get('public_ip', 'enabled')
578612
if is_enabled not in true_list:
579613
return None
580-
refresh_interval = \
581-
OCIUtilsConfiguration.get('public_ip', 'refresh_interval')
614+
refresh_interval = OCIUtilsConfiguration.get('public_ip', 'refresh_interval')
582615
th = OcidThread(name=name,
583616
ocidfunc=public_ip_func,
584617
context={},

lib/oci_utils/iscsiadm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def discovery(ipaddr):
106106
output = subprocess.check_output(_cmd, stderr=dev_null).decode('utf-8')
107107
iqns = []
108108
for line in output.splitlines():
109-
if b'iqn' not in line:
109+
if 'iqn' not in line:
110110
continue
111111
match = _DISCOVERY_PATTERN.match(line.strip())
112112
if match:

0 commit comments

Comments
 (0)