Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion buildrpm/oci-utils.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: oci-utils
Version: 0.12.8
Release: 0%{?dist}
Release: 1%{?dist}
Url: http://cloud.oracle.com/iaas
Summary: Oracle Cloud Infrastructure utilities
License: UPL
Expand Down Expand Up @@ -36,6 +36,7 @@ Requires: python3-sdnotify
%if 0%{?rhel} == 8
Requires: network-scripts
Requires: python3-netaddr
Requires: python36-oci-sdk
Requires: python3-daemon
Requires: python3-sdnotify
%endif
Expand Down Expand Up @@ -205,6 +206,9 @@ rm -rf %{buildroot}
/opt/oci-utils/tests/__init__*

%changelog
* Thu Apr 14 2022 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.8-1
- fixed oci-public-ip all flag: removed

* Wed Mar 30 2022 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.7-3
- spec file fixed for ol9 builds of oci-kvm and oci-migrate
- tests for instance distribution and version
Expand Down
12 changes: 7 additions & 5 deletions lib/oci_utils/impl/oci-public-ip-main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def parse_args():
help="display details information")
parser.add_argument('-a', '--all',
action='store_true',
help='list all of the public IP addresses for the instance.')
# help='list all of the public IP addresses for the instance.')
help = argparse.SUPPRESS)
parser.add_argument('-s', '--sourceip',
action='store',
default="0.0.0.0",
Expand Down Expand Up @@ -92,10 +93,10 @@ def _display_ip_list(ip_list, displayALL, outputMode, displayDetails):
displayDetails : display detailed information ?
"""

_sorted_list_of_pubips = sorted(ip_list, key=lambda ip: ip['primary'], reverse=True)
if displayALL:
_ip_list_to_display = ip_list
else:
# We assume that primary is the first one and we want to display only it
_ip_list_to_display = ip_list[:1]

_collen = {'ipaddress': len('IP Address'),
Expand Down Expand Up @@ -136,7 +137,7 @@ def _display_ip_list(ip_list, displayALL, outputMode, displayDetails):

_printer = printerKlass(title=_title, columns=_columns)
_printer.printHeader()
_sorted_list_of_pubips = sorted(_ip_list_to_display, key=lambda ip: ip['primary'], reverse=True)
# _sorted_list_of_pubips = sorted(_ip_list_to_display, key=lambda ip: ip['primary'], reverse=True)
for _ip in _sorted_list_of_pubips:
_printer.printRow(_ip)
_printer.printFooter()
Expand Down Expand Up @@ -201,7 +202,7 @@ def main():
'vnic_ocid': v.get_ocid()} for v in _instance.all_vnics() if v.get_public_ip()]
stun_log.debug('%s ips retrieved from sdk information', len(_all_p_ips))
if len(_all_p_ips) == 0:
stun_log.info('No public ip addresses found from OCI, falling back to the stun servers.')
# stun_log.info('No public ip addresses found from OCI, falling back to the stun servers.')
_instance=None
except Exception as e:
stun_log.info('Instance is missing privileges to collect ip data from OCI, '
Expand Down Expand Up @@ -247,7 +248,8 @@ def main():
for ip in _all_p_ips:
print('%16s' % ip['ip'])
else:
_display_ip_list(_all_p_ips, args.all, args.output_mode, args.details)
# _display_ip_list(_all_p_ips, args.all, args.output_mode, args.details)
_display_ip_list(_all_p_ips, True, args.output_mode, args.details)

return 0

Expand Down
7 changes: 4 additions & 3 deletions man/man1/oci-public-ip.1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
.SH NAME
oci-public-ip \- display the public IP address of the system
.SH SYNOPSIS
.B oci-public-ip [-h|--human-readable] [-j|--json] [-g|--get] [-a|--all] [-s
.\" .B oci-public-ip [-h|--human-readable] [-j|--json] [-g|--get] [-a|--all] [-s
.B oci-public-ip [-h|--human-readable] [-j|--json] [-g|--get] [-s
.I SOURCEIP
.B | --sourceip
.I SOURCEIP
Expand All @@ -32,8 +33,8 @@ Print the public IP address(es) in JSON format, intended for scripting.
.IP -g,\ --get
Print the public IP address(es) (and nothing else) to the standard output.
Intended for scripting.
.IP -a,\ --all
Print all of the public IP addresses to the standard output.
.\" .IP -a,\ --all
.\" Print all of the public IP addresses to the standard output.
.IP "-s SOURCEIP, --sourceip SOURCEIP"
Determine the public IP address that belongs to the
.B SOURCEIP
Expand Down