Skip to content

lfcli_base.py: add shared resolve_port_to_ipv4() to LFCliBase - #365

Merged
haricharan-candela merged 2 commits into
greearb:masterfrom
goyalsaurabh06:resolve_port_to_ipv4
Aug 25, 2026
Merged

lfcli_base.py: add shared resolve_port_to_ipv4() to LFCliBase#365
haricharan-candela merged 2 commits into
greearb:masterfrom
goyalsaurabh06:resolve_port_to_ipv4

Conversation

@Narayana-CT

Copy link
Copy Markdown
Contributor

Summary

Adds resolve_port_to_ipv4() to LFCliBase, a shared helper that resolves a
LANforge port to its IPv4 address.

The same port-to-IP logic is currently reimplemented in roughly 15 scripts
(lf_ftp.py, lf_webpage.py, DeviceConfig.py, test_l3.py, lf_multi_traffic.py,
lf_interop_*.py, and several under real_application_tests/), each with slightly
different behaviour and error handling. This puts a single implementation on the
base class so those copies can be retired incrementally.

Behaviour

The method accepts:

  • a bare port name — eth1 (shelf and resource default to 1.1)
  • a full port EID — 1.1.eth1.
  • an address that is already an IP — returned unchanged, with no query issued

It returns the resolved IPv4 address as a string, or None when the port cannot
be resolved — the port does not exist, is down, has no address assigned, or the
manager response is not in the expected shape. Every failure path logs the reason
before returning.

Error handling stays with the caller: the helper reports what went wrong and hands
control back, so the calling script decides whether to continue, clean up, record a
failure in its report, or stop. That keeps the decision — and the user-facing
messaging — in the script that owns the test.

Input that is empty or not a string is rejected up front and logged, so a bad
argument surfaces as a clear message rather than an attribute error deeper in.

Verification

Exercised against LANforge manager 192.168.245.117

Input Result
eth1, eth0, eth2 resolved to the port's address
1.1.eth1 resolved to the port's address
192.168.245.233, 8.8.8.8 returned unchanged, no query issued
0.0.0.0 returned unchanged, warning logged
eth3 (admin down) None, reason logged
eth99 (does not exist) None, reason logged
'', None, 0, [], {} None, reason logged
123, 1.5, ['eth1'], b'eth1' None, reason logged

Verified CLI:

python3 lf_interop_zoom.py --duration 1
--lanforge_ip 192.168.245.117
--signin_email <zoom_email> --signin_passwd <zoom_passwd> --participants 3 --audio --video
--upstream_port <upstream_ip>/<upstream_port>
--zoom_host 1.13
--resources 1.13,1.12,1.25
--api_stats_collection --env_file .env

python3 lf_interop_zoom.py --duration 1
--lanforge_ip 192.168.245.117
--signin_email <zoom_email> --signin_passwd <zoom_passwd>
--participants 3 --audio --video
--upstream_port <upstream_ip>/<upstream_port>
--zoom_host 1.13
--resources 1.13,1.12,1.25
--api_stats_collection --env_file .env

Signed-off-by: Narayana-CT <narayana.pinapatruni@candelatech.com>
Comment thread py-json/LANforge/lfcli_base.py Outdated
@haricharan-candela
haricharan-candela self-requested a review August 18, 2026 08:29
Comment thread py-json/LANforge/lfcli_base.py
Comment thread py-json/LANforge/lfcli_base.py
Comment thread py-json/LANforge/lfcli_base.py
Comment thread py-json/LANforge/lfcli_base.py
Comment thread py-json/LANforge/lfcli_base.py
Comment thread py-json/LANforge/lfcli_base.py
Comment thread py-json/LANforge/lfcli_base.py
@greearb

greearb commented Aug 19, 2026 via email

Copy link
Copy Markdown
Owner

@greearb

greearb commented Aug 19, 2026 via email

Copy link
Copy Markdown
Owner

@haricharan-candela
haricharan-candela self-requested a review August 19, 2026 19:34
Comment thread py-json/LANforge/lfcli_base.py Outdated

@tarun-candela tarun-candela left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Assuming you have done enough testing.

@goyalsaurabh06
goyalsaurabh06 self-requested a review August 24, 2026 05:59
…alid-port log message

Verified CLI:

 python3 lf_interop_zoom.py --duration 1
    --lanforge_ip 192.168.245.117
    --signin_email <zoom_email> --signin_passwd <zoom_passwd>
    --participants 3 --audio --video
    --upstream_port <upstream_ip>/<upstream_port>
    --zoom_host 1.13
    --resources 1.13,1.12,1.25
    --api_stats_collection --env_file .env

Signed-off-by: Narayana-CT <narayana.pinapatruni@candelatech.com>
@haricharan-candela
haricharan-candela merged commit 4d0f075 into greearb:master Aug 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants