Skip to content

Commit 2d857d3

Browse files
authored
[NDM] [Cisco ACI] Fix APIC device status (#19204)
* Fix APIC status check * Add changelog
1 parent 53dc9f7 commit 2d857d3

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

cisco_aci/changelog.d/19204.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[NDM] [Cisco ACI] Fix APIC device status

cisco_aci/datadog_checks/cisco_aci/models.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
class NodeAttributes(BaseModel):
1919
address: Optional[str] = None
20+
ad_st: Optional[str] = Field(default=None, alias="adSt")
2021
fabric_st: Optional[str] = Field(default=None, alias="fabricSt")
2122
role: Optional[str] = None
2223
dn: Optional[str] = None
@@ -34,6 +35,22 @@ def device_type(self) -> str:
3435
return 'switch'
3536
return 'other'
3637

38+
@computed_field
39+
@property
40+
def status(self) -> int:
41+
if self.role == 'controller':
42+
return 1 if self.ad_st == 'on' else 2
43+
mapping = {
44+
'active': 1,
45+
'inactive': 2,
46+
'disabled': 2,
47+
'discovering': 2,
48+
'undiscovered': 2,
49+
'unsupported': 2,
50+
'unknown': 2,
51+
}
52+
return mapping.get(self.fabric_st, 2)
53+
3754

3855
class Node(BaseModel):
3956
attributes: NodeAttributes
@@ -161,8 +178,8 @@ class DeviceMetadata(BaseModel):
161178
tags: list = Field(default_factory=list)
162179
name: Optional[str] = Field(default=None)
163180
ip_address: Optional[str] = Field(default=None)
181+
status: Optional[int] = Field(default=None)
164182
model: Optional[str] = Field(default=None)
165-
fabric_st: Optional[str] = Field(default=None, exclude=True)
166183
vendor: Optional[str] = Field(default=None)
167184
version: Optional[str] = Field(default=None)
168185
serial_number: Optional[str] = Field(default=None)
@@ -172,20 +189,6 @@ class DeviceMetadata(BaseModel):
172189
# non-exported fields
173190
pod_node_id: Optional[str] = Field(default=None, exclude=True)
174191

175-
@computed_field
176-
@property
177-
def status(self) -> int:
178-
mapping = {
179-
'active': 1,
180-
'inactive': 2,
181-
'disabled': 2,
182-
'discovering': 2,
183-
'undiscovered': 2,
184-
'unsupported': 2,
185-
'unknown': 2,
186-
}
187-
return mapping.get(self.fabric_st, 2)
188-
189192

190193
class DeviceMetadataList(BaseModel):
191194
device_metadata: list = Field(default_factory=list)

cisco_aci/datadog_checks/cisco_aci/ndm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def create_node_metadata(node_attrs, tags, namespace):
3939
tags=device_tags + tags,
4040
name=hostname,
4141
ip_address=node.attributes.address,
42+
status=node.attributes.status,
4243
model=node.attributes.model,
43-
fabric_st=node.attributes.fabric_st,
4444
vendor=VENDOR_CISCO,
4545
version=node.attributes.version,
4646
serial_number=node.attributes.serial,

cisco_aci/tests/fixtures/metadata.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
],
3131
'ip_address': '10.0.200.0',
3232
'model': 'N9K-C93180YC-FX',
33-
'fabric_st': 'active',
3433
'name': 'leaf101',
3534
'serial_number': 'FDO20440TS1',
3635
'status': 1,
@@ -62,7 +61,6 @@
6261
],
6362
'ip_address': '10.0.200.1',
6463
'model': 'N9K-C93180YC-FX',
65-
'fabric_st': 'active',
6664
'name': 'leaf102',
6765
'serial_number': 'FDO20510HCA',
6866
'status': 1,
@@ -93,10 +91,9 @@
9391
],
9492
'ip_address': '10.0.200.4',
9593
'model': 'APIC-SERVER-M1',
96-
'fabric_st': 'unknown',
9794
'name': 'apic1',
9895
'serial_number': 'FCH1928V0SL',
99-
'status': 2,
96+
'status': 1,
10097
'vendor': 'cisco',
10198
'version': 'A',
10299
},
@@ -125,7 +122,6 @@
125122
],
126123
'ip_address': '10.0.200.5',
127124
'model': 'N9K-C9336PQ',
128-
'fabric_st': 'active',
129125
'name': 'spine201',
130126
'serial_number': 'SAL2014N5U4',
131127
'status': 1,

0 commit comments

Comments
 (0)