Skip to content

Commit 77c75e9

Browse files
Merge pull request #140 from guidotijskens/version01250
kvm tests
2 parents 65d78a9 + 69bc5cb commit 77c75e9

38 files changed

+2983
-145
lines changed

buildrpm/oci-utils.spec

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,20 @@ rm -rf %{buildroot}
182182
/opt/oci-utils/tests/__init__*
183183

184184
%changelog
185+
* Tue Sep 07 2021 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.5.10
186+
- LINUX-11499: oci-metadata --value-only returning null
187+
188+
* Fri Aug 27 2021 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.5.9
189+
- LINUX-11457: public API oci_api missing get_object_storage_client
190+
191+
* Tue Aug 24 2021 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.5-8
192+
- LINUX-11441: add --yes flag to delete-network in oci-kvm
193+
- LINUX-11442: oci-kvm create network fails with 'numerical result out of range when name > 14 characters
194+
- LINUX-11443: oci-kvm create-pool on nfs fails with python3 string error
195+
196+
* Thu Aug 12 2021 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.5-7
197+
- LINUX-7304: KVM image script alignment
198+
185199
* Wed Aug 11 2021 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.5-6
186200
- LINUX-1742: oci-public-ip reports errors when python-oci-sdk is installed but not set up
187201
- LINUX-9425: oci-iscsi-config attach -I fails on iqn's

lib/oci_utils/__init__.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +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)',
3534
'hyd': 'hyd - ap-hyderabad-1 (Hyderabad, India)',
35+
'iad': 'iad - us-ashburn-1 (Ashburn, VA, USA)',
3636
'icn': 'icn - ap-seoul-1 (Seoul, South Korea)',
37-
'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)',
3839
'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)',
3943
'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)',
4047
'nrt': 'nrt - ap-tokyo-1 (Tokyo, Japan)',
48+
'phx': 'phx - us-phoenix-1 (Phoenix, AZ, USA)',
4149
'scl': 'scl - sa-santiago-1 (Santiago, Chile)',
50+
'sin': 'sin - ap-singapore-1 (Singapore, Singapore)',
4251
'sjc': 'sjc - us-sanjose-1 (San Jose, CA, USA)',
4352
'syd': 'syd - ap-sydney-1 (Sydney, Australia)',
53+
'vcp': 'vcp - sa-vinhedo-1 (Vinhedo, Brazil)',
54+
'wga': 'wga - ap-canberra-1 (Canberra, Australia)',
4455
'yny': 'yny - ap-chuncheon-1 (Chuncheon, South Korea)',
4556
'yul': 'yul - ca-montreal-1 (Montreal, Canada)',
4657
'yyz': 'yyz - ca-toronto-1 (Toronto, Canada)',

lib/oci_utils/impl/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ def setup_logging(forceDebug=False):
161161
else:
162162
if forceDebug:
163163
try:
164-
handler = logging.handlers.RotatingFileHandler(
165-
'/var/tmp/oci-utils.log', mode='a', maxBytes=1024 * 1024, backupCount=3)
164+
handler = logging.handlers.RotatingFileHandler('/var/tmp/oci-utils.log',
165+
mode='a',
166+
maxBytes=1024 * 1024,
167+
backupCount=3)
166168
handler.setFormatter(formatter)
167169
handler.setLevel(logging.NOTSET)
168170
except Exception as _:

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

Lines changed: 34 additions & 32 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:
@@ -866,7 +866,7 @@ def api_display_available_block_volumes(sess, compartments, show_all, output_mod
866866
compartement ocid(s)
867867
show_all: bool
868868
display all volumes. By default display only not-attached ones
869-
output_mode : informtion display mode
869+
output_mode : information display mode
870870
details : display detailed information ?
871871
truncate: truncate text?
872872
@@ -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)
@@ -1002,15 +1002,15 @@ def get_volume_by_iqn(sess, iqn):
10021002
try:
10031003
if bool(sess):
10041004
get_volume_by_iqn.all_this_instance_volume = sess.this_instance().all_volumes()
1005-
for v in get_volume_by_iqn.all_this_instance_volume:
1006-
if v.get_iqn() == iqn:
1007-
_logger.debug('Found %s', str(v))
1008-
return v
1005+
for volume in get_volume_by_iqn.all_this_instance_volume:
1006+
if volume.get_iqn() == iqn:
1007+
_logger.debug('Found %s', str(volume))
1008+
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

Comments
 (0)