Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

op-mode: T6626: Fix for show dhcpv6 server leases #4065

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

natali-rs1985
Copy link
Contributor

Change Summary

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

Component(s) name

op-mode

Proposed changes

How to test

vyos@vyos# cat /config/dhcpdv6.leases
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.4.3-P1

# authoring-byte-order entry is generated, DO NOT DELETE
authoring-byte-order little-endian;

server-duid "\000\001\000\001.>X\261\014\337l\370\000\001";

ia-pd "\036\000\000\000\000\0048\202l\266\345\257IJ\236c\245\212\000\204D\014" {
  cltt 4 2024/09/13 14:38:45;
  iaprefix 2001:db8:1:ffe0::/60 {
    binding state active;
    preferred-life 4294967295;
    max-life 4294967295;
    ends never;
    set shared-networkname = "LAN";
  }
}

server-duid "\000\001\000\001.>X\261\014\337l\370\000\001";

ia-pd "\036\000\000\000\000\0048\202l\266\345\257IJ\236c\245\212\000\204D\014" {
  cltt 4 2024/09/13 14:55:43;
  iaprefix 2001:db8:1:ffe0::/60 {
    binding state released;
    preferred-life 4294967295;
    max-life 4294967295;
    ends never;
  }
}

ia-pd "\036\000\000\000\000\0048\202l\266\345\257IJ\236c\245\212\000\204D\014" {
  cltt 4 2024/09/13 14:56:08;
  iaprefix 2001:db8:1:fff0::/60 {
    binding state active;
    preferred-life 4294967295;
    max-life 4294967295;
    ends never;
    set shared-networkname = "LAN";
  }
}

ia-na "\334\005\2750\000\004\004\360.\224\341h\033#\243\261d\344'\275b6" {
  cltt 5 2024/09/13 14:22:18;
  iaaddr fd00::1:0:0:ffff:b1d9 {
    binding state active;
    preferred-life 7200;
    max-life 7500;
    ends 5 2024/09/13 16:27:18;
  }
}

Before the fix:

vyos@vyos:~$ show dhcpv6 server leases 
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/dhcp.py", line 438, in <module>
    res = vyos.opmode.run(sys.modules[__name__])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/opmode.py", line 263, in run
    res = func(**args)
          ^^^^^^^^^^^^
  File "/usr/libexec/vyos/op_mode/dhcp.py", line 265, in _wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/libexec/vyos/op_mode/dhcp.py", line 322, in show_server_leases
    return _get_formatted_server_leases(lease_data, family=family)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/libexec/vyos/op_mode/dhcp.py", line 175, in _get_formatted_server_leases
    end =  _utc_to_local(end).strftime('%Y/%m/%d %H:%M:%S')
           ^^^^^^^^^^^^^^^^^^
  File "/usr/libexec/vyos/op_mode/dhcp.py", line 47, in _utc_to_local
    return datetime.fromtimestamp((datetime.fromtimestamp(utc_dt) - datetime(1970, 1, 1)).total_seconds())
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object cannot be interpreted as an integer

After the fix:

vyos@vyos# run show dhcpv6 server leases
IPv6 address           State     Last communication    Lease expiration     Remaining    Type               Pool    DUID
---------------------  --------  --------------------  -------------------  -----------  -----------------  ------  -----------------------------------------------------
2001:db8:1:ffe0::/60   released  2024/09/13 14:55:43   -                    -            prefix delegation          00:04:38:82:6c:b6:e5:af:49:4a:9e:63:a5:8a:00:84:44:0c
2001:db8:1:fff0::/60   active    2024/09/13 14:56:08   -                    -            prefix delegation  LAN     00:04:38:82:6c:b6:e5:af:49:4a:9e:63:a5:8a:00:84:44:0c
fd00::1:0:0:ffff:b1d9  active    2024/09/13 14:22:18   2024/09/13 16:27:18  2:54:36      non-temporary              00:04:04:f0:2e:94:e1:68:1b:23:a3:b1:64:e4:27:bd:62:36
[edit]

Smoketest result

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

Copy link

👍
No issues in PR Title / Commit Title

@c-po c-po merged commit f25f0c1 into vyos:sagitta Sep 13, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sagitta VyOS 1.4 LTS
Development

Successfully merging this pull request may close these issues.

5 participants