Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5d1edfd
Support ubuntu24.04
yutongzhang-microsoft Apr 29, 2025
e02b539
Support ubuntu24
yutongzhang-microsoft May 6, 2025
4e4c2b0
Merge branch 'master' into yutongzhang/support_ubuntu24
yutongzhang-microsoft May 9, 2025
e9bf316
test
yutongzhang-microsoft May 12, 2025
b3deeab
Change path
yutongzhang-microsoft Jun 23, 2025
f68677a
Add traceback
yutongzhang-microsoft Jun 24, 2025
8577df9
Merge remote-tracking branch 'upstream/master'
yutongzhang-microsoft Jun 24, 2025
4895f2c
test
yutongzhang-microsoft Jun 24, 2025
7d5a720
test
yutongzhang-microsoft Jun 30, 2025
217241a
test
yutongzhang-microsoft Jun 30, 2025
8af9d85
test
yutongzhang-microsoft Jun 30, 2025
d0ca511
disable all sai validation
yutongzhang-microsoft Jul 1, 2025
85fed0a
modify
yutongzhang-microsoft Jul 1, 2025
3d49748
Fix pre-commit
yutongzhang-microsoft Jul 1, 2025
24f579b
Remove concurrent.futures
yutongzhang-microsoft Jul 2, 2025
76603a8
Fix collections.Iterable
yutongzhang-microsoft Jul 2, 2025
5a36eb8
Merge branch 'master' into yutongzhang/test_new_docker
yutongzhang-microsoft Jul 2, 2025
34306d9
Remove blank lines
yutongzhang-microsoft Jul 2, 2025
baa04bf
remove debug
yutongzhang-microsoft Jul 2, 2025
d6a2909
Change cmdgen
yutongzhang-microsoft Jul 2, 2025
f5c65e1
Merge branch 'master' into yutongzhang/test_new_docker
yutongzhang-microsoft Jul 3, 2025
8dc31dd
Fix format issue.
yutongzhang-microsoft Jul 3, 2025
5299e95
test snmp
yutongzhang-microsoft Jul 4, 2025
5d4ec58
Merge remote-tracking branch 'upstream/master'
yutongzhang-microsoft Jul 4, 2025
07413ee
test snmp
yutongzhang-microsoft Jul 4, 2025
a8c821b
fix pre-commit
yutongzhang-microsoft Jul 9, 2025
f6773ed
test
yutongzhang-microsoft Jul 9, 2025
f61bf82
test
yutongzhang-microsoft Jul 9, 2025
a58e656
test
yutongzhang-microsoft Jul 9, 2025
0a5996a
test
yutongzhang-microsoft Jul 10, 2025
88e369e
test
yutongzhang-microsoft Jul 10, 2025
de1ccb9
test
yutongzhang-microsoft Jul 10, 2025
a7d0f39
test
yutongzhang-microsoft Jul 10, 2025
884435d
test
yutongzhang-microsoft Jul 10, 2025
229e5ba
fix key error
yutongzhang-microsoft Jul 10, 2025
511c4df
modify
yutongzhang-microsoft Jul 11, 2025
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
4 changes: 2 additions & 2 deletions .azure-pipelines/pytest-collect-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ steps:
- script: |
set -x

sudo docker pull sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt:latest
sudo docker pull sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt:yutongtest
sudo docker rm -f sonic-mgmt-collect || true
sudo docker run --rm -dt --name sonic-mgmt-collect \
-v $(System.DefaultWorkingDirectory):/var/src/sonic-mgmt \
sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt:latest \
sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt:yutongtest \
/bin/bash
displayName: 'Prepare sonic-mgmt docker container'

Expand Down
71 changes: 40 additions & 31 deletions ansible/library/lldp_facts.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/python

import json
import asyncio
from collections import defaultdict
from ansible.module_utils.basic import AnsibleModule
try:
from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp.hlapi.v3arch.asyncio import cmdgen, UdpTransportTarget, next_cmd, SnmpEngine, ContextData
from pysnmp.smi.rfc1902 import ObjectType, ObjectIdentity
has_pysnmp = True
except Exception:
has_pysnmp = False
Expand Down Expand Up @@ -129,30 +131,12 @@ def get_iftable(snmp_data):
return (if_table, inverse_if_table)


def main():
module = AnsibleModule(
argument_spec=dict(
host=dict(required=True),
version=dict(required=True, choices=['v2', 'v2c', 'v3']),
community=dict(required=False, default=False),
username=dict(required=False),
level=dict(required=False, choices=['authNoPriv', 'authPriv']),
integrity=dict(required=False, choices=['md5', 'sha']),
privacy=dict(required=False, choices=['des', 'aes']),
authkey=dict(required=False),
privkey=dict(required=False),
removeplaceholder=dict(required=False)),
required_together=(['username', 'level', 'integrity', 'authkey'], [
'privacy', 'privkey'],),
supports_check_mode=False)

async def async_main(module):
m_args = module.params

if not has_pysnmp:
module.fail_json(msg='Missing required pysnmp module (check docs)')

cmd_gen = cmdgen.CommandGenerator()

# Verify that we receive a community when using snmp v2
if m_args['version'] == "v2" or m_args['version'] == "v2c":
if not m_args['community']:
Expand Down Expand Up @@ -202,25 +186,29 @@ def Tree(): return defaultdict(Tree)

host = m_args['host']

error_indication, error_status, error_index, var_binds = cmd_gen.nextCmd(
error_indication, error_status, error_index, var_binds = await next_cmd(
SnmpEngine(),
snmp_auth,
cmdgen.UdpTransportTarget((host, 161)),
cmdgen.MibVariable(p.if_descr,)
await UdpTransportTarget.create((host, 161)),
ContextData(),
ObjectType(ObjectIdentity(p.if_descr,))
)

if error_indication:
module.fail_json(msg=str(error_indication))

(if_table, inverse_if_table) = get_iftable(var_binds)

error_indication, error_status, error_index, var_table = cmd_gen.nextCmd(
error_indication, error_status, error_index, var_table = await next_cmd(
SnmpEngine(),
snmp_auth,
cmdgen.UdpTransportTarget((host, 161)),
cmdgen.MibVariable(p.lldp_rem_port_id,),
cmdgen.MibVariable(p.lldp_rem_port_desc,),
cmdgen.MibVariable(p.lldp_rem_sys_desc,),
cmdgen.MibVariable(p.lldp_rem_sys_name,),
cmdgen.MibVariable(p.lldp_rem_chassis_id,),
await UdpTransportTarget.create((host, 161)),
ContextData(),
ObjectType(ObjectIdentity(p.lldp_rem_port_id,)),
ObjectType(ObjectIdentity(p.lldp_rem_port_desc,)),
ObjectType(ObjectIdentity(p.lldp_rem_sys_desc,)),
ObjectType(ObjectIdentity(p.lldp_rem_sys_name,)),
ObjectType(ObjectIdentity(p.lldp_rem_chassis_id,)),
)

if error_indication:
Expand Down Expand Up @@ -278,4 +266,25 @@ def Tree(): return defaultdict(Tree)
module.exit_json(ansible_facts=results)


main()
def main():
module = AnsibleModule(
argument_spec=dict(
host=dict(required=True),
version=dict(required=True, choices=['v2', 'v2c', 'v3']),
community=dict(required=False, default=False),
username=dict(required=False),
level=dict(required=False, choices=['authNoPriv', 'authPriv']),
integrity=dict(required=False, choices=['md5', 'sha']),
privacy=dict(required=False, choices=['des', 'aes']),
authkey=dict(required=False),
privkey=dict(required=False),
removeplaceholder=dict(required=False)),
required_together=(['username', 'level', 'integrity', 'authkey'], [
'privacy', 'privkey'],),
supports_check_mode=False)

asyncio.run(async_main(module))


if __name__ == '__main__':
main()
Loading
Loading