Skip to content

Commit 9e962ad

Browse files
zoedtjmw51798dkirov-dd
authored andcommitted
[NDM] [Cisco ACI] Use actual int for interface index (#18414)
* Use actual int for interface index * Changelog * Update cisco_aci/datadog_checks/cisco_aci/models.py Co-authored-by: dkirov-dd <166512750+dkirov-dd@users.noreply.github.com> --------- Co-authored-by: Jim Wilson <86026167+jmw51798@users.noreply.github.com> Co-authored-by: dkirov-dd <166512750+dkirov-dd@users.noreply.github.com> (cherry picked from commit 6915c80)
1 parent 698c1eb commit 9e962ad

File tree

4 files changed

+243
-230
lines changed

4 files changed

+243
-230
lines changed

cisco_aci/changelog.d/18414.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[NDM] [Cisco ACI] Use actual int for interface index

cisco_aci/datadog_checks/cisco_aci/models.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# All rights reserved
33
# Licensed under a 3-clause BSD style license (see LICENSE)
44

5+
import re
6+
57
import six
68

79
if six.PY3:
@@ -123,7 +125,7 @@ class Status(StrEnum):
123125
class InterfaceMetadata(BaseModel):
124126
device_id: Optional[str] = Field(default=None)
125127
id_tags: list = Field(default_factory=list)
126-
index: Optional[str] = Field(default=None)
128+
index: Optional[int] = Field(default=None)
127129
name: Optional[str] = Field(default=None)
128130
description: Optional[str] = Field(default=None)
129131
mac_address: Optional[str] = Field(default=None)
@@ -151,6 +153,16 @@ def parse_oper_status(cls, oper_status: OperStatus | None) -> OperStatus | None:
151153
return OperStatus.UP
152154
return OperStatus.DOWN
153155

156+
@field_validator("index", mode="before")
157+
@classmethod
158+
def parse_index(cls, index: str | int | None) -> int | None:
159+
if type(index) == str:
160+
split = re.split('eth|/', index)
161+
return int(split[-1])
162+
if type(index) == int:
163+
return index
164+
return None
165+
154166
@computed_field
155167
@property
156168
def status(self) -> Status:

0 commit comments

Comments
 (0)