Skip to content

Commit 07abca7

Browse files
committed
oci-network-config: show-os subcommand
Add a new subcommand to just show the os network information, which is sometimes included with the `show` subcommand. Signed-off-by: Ben Formosa <ben.formosa@gmail.com>
1 parent 2bb92cf commit 07abca7

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

lib/oci_utils/impl/oci_network_config_main.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,28 @@ def def_show_parser(s_parser):
124124
return show_parser
125125

126126

127+
def def_show_os_parser(s_parser):
128+
"""
129+
Define the show_os subparser.
130+
131+
Parameters
132+
----------
133+
s_parser: subparsers.
134+
135+
Returns
136+
-------
137+
ArgumentParser: the show subcommand parser.
138+
"""
139+
show_os_parser = s_parser.add_parser('show-os',
140+
description='Display the current network interface configuration as well as the VNIC configuration from OCI.',
141+
help='Display the current network interface configuration as well as the VNIC configuration from OCI.')
142+
show_os_parser.add_argument('--output-mode',
143+
choices=('parsable', 'table', 'json', 'text'),
144+
help='Set output mode.',
145+
default='table')
146+
return show_os_parser
147+
148+
127149
def def_show_vnics_parser(s_parser):
128150
"""
129151
Define the show_vnics subparser
@@ -533,6 +555,9 @@ def get_arg_parser():
533555
# show
534556
_ = def_show_parser(subparser)
535557
#
558+
# show-os
559+
_ = def_show_os_parser(subparser)
560+
#
536561
# show-vnics
537562
_ = def_show_vnics_parser(subparser)
538563
#
@@ -1002,6 +1027,25 @@ def _display_subnet(interface):
10021027
return nw_conf
10031028

10041029

1030+
def do_show_os_network_config(show_args):
1031+
"""
1032+
Display the current network interface configuration as well as the VNIC configuration from OCI.
1033+
1034+
Parameters
1035+
----------
1036+
show_args: namespace
1037+
The command line arguments.
1038+
1039+
Returns
1040+
-------
1041+
int: 0 on success, 1 otherwise.
1042+
"""
1043+
_logger.debug('%s', where_am_i())
1044+
vnic_utils = get_vnic_utils(show_args)
1045+
show_os_network_config(vnic_utils, show_args.output_mode)
1046+
return 0
1047+
1048+
10051049
def show_os_network_config(vnic_utils, mode):
10061050
"""
10071051
Display the current network interface configuration as well as the VNIC configuration from OCI.
@@ -1011,7 +1055,7 @@ def show_os_network_config(vnic_utils, mode):
10111055
vnic_utils :
10121056
The VNIC configuration instance.
10131057
1014-
mode :
1058+
mode : str
10151059
The output mode
10161060
10171061
Returns
@@ -2041,6 +2085,7 @@ def main():
20412085
"""
20422086
sub_commands = {'usage': show_usage,
20432087
'show': show_network,
2088+
'show-os': do_show_os_network_config,
20442089
'show-vnics': show_vnics,
20452090
'show-vnics-all': show_vnics_all,
20462091
'show-vcns': show_vcns,

man/man1/oci-network-config.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ usage
1616
.B oci-network-config
1717
show [-h|--help] [-I ITEM|--include ITEM] [-X ITEM|--exclude ITEM] [--output-mode MODE] [--details]
1818

19+
.B oci-network-config
20+
show-os [-h|--help] [--output-mode MODE]
21+
1922
.B oci-network-config
2023
show-vcns [-h|--help] [--output-mode MODE] [--details] [--ocid VCN_OCID] [--name VCN_NAME] [--no-truncate]
2124

0 commit comments

Comments
 (0)