Skip to content

Commit

Permalink
[NDM] [Cisco ACI] Utilize raw ID for interface metadata (#18842)
Browse files Browse the repository at this point in the history
* Utilize raw ID for interface metadata

* Add changelog

* Interface ID tags to utilize the interface name not ID
  • Loading branch information
zoedt authored Oct 18, 2024
1 parent 267b6af commit 8f4378c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions cisco_aci/changelog.d/18842.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[NDM] [Cisco ACI] Utilize raw ID for interface metadata
3 changes: 3 additions & 0 deletions cisco_aci/datadog_checks/cisco_aci/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ class Status(StrEnum):
class InterfaceMetadata(BaseModel):
device_id: Optional[str] = Field(default=None)
id_tags: list = Field(default_factory=list)
raw_id: Optional[str] = Field(default=None)
raw_id_type: Optional[str] = Field(default='cisco_aci')
index: Optional[int] = Field(default=None)
name: Optional[str] = Field(default=None)
alias: Optional[str] = Field(default=None)
description: Optional[str] = Field(default=None)
mac_address: Optional[str] = Field(default=None)
admin_status: Optional[AdminStatus] = Field(default=None)
Expand Down
2 changes: 2 additions & 0 deletions cisco_aci/datadog_checks/cisco_aci/ndm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ def create_interface_metadata(phys_if, address, namespace):
eth = PhysIf(**phys_if.get('l1PhysIf', {}))
interface = InterfaceMetadata(
device_id='{}:{}'.format(namespace, address),
raw_id=eth.attributes.id,
id_tags=['interface:{}'.format(eth.attributes.name)],
index=eth.attributes.id,
name=eth.attributes.name,
alias=eth.attributes.id,
description=eth.attributes.desc,
mac_address=eth.attributes.router_mac,
admin_status=eth.attributes.admin_st,
Expand Down
18 changes: 18 additions & 0 deletions cisco_aci/tests/fixtures/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
INTERFACE_METADATA = [
{
'admin_status': 1,
'alias': 'eth1/1',
'raw_id': 'eth1/1',
'device_id': 'default:10.0.200.0',
'id_tags': [
'interface:eth1/1',
Expand All @@ -150,6 +152,8 @@
},
{
'admin_status': 1,
'alias': 'eth1/2',
'raw_id': 'eth1/2',
'device_id': 'default:10.0.200.0',
'id_tags': [
'interface:eth1/2',
Expand All @@ -163,6 +167,8 @@
},
{
'admin_status': 1,
'alias': 'eth1/3',
'raw_id': 'eth1/3',
'device_id': 'default:10.0.200.0',
'id_tags': [
'interface:eth1/3',
Expand All @@ -176,6 +182,8 @@
},
{
'admin_status': 1,
'alias': 'eth1/1',
'raw_id': 'eth1/1',
'device_id': 'default:10.0.200.1',
'id_tags': [
'interface:eth1/1',
Expand All @@ -189,6 +197,8 @@
},
{
'admin_status': 1,
'alias': 'eth1/2',
'raw_id': 'eth1/2',
'device_id': 'default:10.0.200.1',
'id_tags': [
'interface:eth1/2',
Expand All @@ -202,6 +212,8 @@
},
{
'admin_status': 1,
'alias': 'eth1/3',
'raw_id': 'eth1/3',
'device_id': 'default:10.0.200.1',
'id_tags': [
'interface:eth1/3',
Expand All @@ -215,6 +227,8 @@
},
{
'admin_status': 1,
'alias': 'eth5/1',
'raw_id': 'eth5/1',
'device_id': 'default:10.0.200.5',
'id_tags': [
'interface:eth5/1',
Expand All @@ -228,6 +242,8 @@
},
{
'admin_status': 1,
'alias': 'eth5/2',
'raw_id': 'eth5/2',
'device_id': 'default:10.0.200.5',
'id_tags': [
'interface:eth5/2',
Expand All @@ -241,6 +257,8 @@
},
{
'admin_status': 1,
'alias': 'eth7/1',
'raw_id': 'eth7/1',
'device_id': 'default:10.0.200.5',
'id_tags': [
'interface:eth7/1',
Expand Down

0 comments on commit 8f4378c

Please sign in to comment.