File tree 4 files changed +9
-30
lines changed 4 files changed +9
-30
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ fn main() -> Result<(), Error> {
129
129
log:: debug!( "Building netshot devices simplified inventory" ) ;
130
130
let netshot_simplified_inventory: HashMap < & String , & String > = netshot_devices
131
131
. iter ( )
132
- . map ( |dev| ( & dev. management_address . ip , & dev. name ) )
132
+ . map ( |dev| ( & dev. management_address , & dev. name ) )
133
133
. collect ( ) ;
134
134
135
135
log:: info!( "Getting devices list from Netbox" ) ;
@@ -192,14 +192,14 @@ fn main() -> Result<(), Error> {
192
192
193
193
let mut devices_to_enable: Vec < String > = Vec :: new ( ) ;
194
194
for device in & netshot_disabled_devices {
195
- match netbox_simplified_devices. get ( device. management_address . ip . as_str ( ) ) {
195
+ match netbox_simplified_devices. get ( & device. management_address ) {
196
196
Some ( _x) => {
197
197
log:: debug!(
198
198
"{}({}) to be enabled (present on Netbox)" ,
199
199
device. name,
200
- device. management_address. ip
200
+ device. management_address
201
201
) ;
202
- devices_to_enable. push ( device. management_address . ip . clone ( ) ) ;
202
+ devices_to_enable. push ( device. management_address . clone ( ) ) ;
203
203
}
204
204
None => { }
205
205
}
Original file line number Diff line number Diff line change @@ -17,21 +17,12 @@ pub struct NetshotClient {
17
17
pub client : reqwest:: blocking:: Client ,
18
18
}
19
19
20
- #[ derive( Debug , Serialize , Deserialize ) ]
21
- pub struct ManagementAddress {
22
- #[ serde( rename = "prefixLength" ) ]
23
- pub prefix_length : u8 ,
24
- #[ serde( rename = "addressUsage" ) ]
25
- pub address_usage : String ,
26
- pub ip : String ,
27
- }
28
-
29
20
#[ derive( Debug , Serialize , Deserialize ) ]
30
21
pub struct Device {
31
22
pub id : u32 ,
32
23
pub name : String ,
33
24
#[ serde( rename = "mgmtAddress" ) ]
34
- pub management_address : ManagementAddress ,
25
+ pub management_address : String ,
35
26
pub status : String ,
36
27
}
37
28
@@ -301,7 +292,7 @@ mod tests {
301
292
302
293
assert_eq ! ( device. name, "test-device" ) ;
303
294
assert_eq ! ( device. id, 1 as u32 ) ;
304
- assert_eq ! ( device. management_address. ip , "1.2.3.4" ) ;
295
+ assert_eq ! ( device. management_address, "1.2.3.4" ) ;
305
296
}
306
297
307
298
#[ test]
Original file line number Diff line number Diff line change 5
5
"id" : 2318 ,
6
6
"name" : " test-device.dc" ,
7
7
"family" : " Cisco Catalyst 2900" ,
8
- "mgmtAddress" : {
9
- "prefixLength" : 0 ,
10
- "addressUsage" : " PRIMARY" ,
11
- "ip" : " 1.2.3.4"
12
- },
8
+ "mgmtAddress" : " 1.2.3.4" ,
13
9
"status" : " INPRODUCTION"
14
10
},
15
11
{
16
12
"id" : 2318 ,
17
13
"name" : " test-device.dc" ,
18
14
"family" : " Cisco Catalyst 2900" ,
19
- "mgmtAddress" : {
20
- "prefixLength" : 0 ,
21
- "addressUsage" : " PRIMARY" ,
22
- "ip" : " 1.2.3.4"
23
- },
15
+ "mgmtAddress" : " 1.2.3.4" ,
24
16
"status" : " INPRODUCTION"
25
17
}
26
18
]
Original file line number Diff line number Diff line change 3
3
"id" : 1 ,
4
4
"name" : " test-device" ,
5
5
"family" : " Nexus 9000 C93108TC-EX" ,
6
- "mgmtAddress" : {
7
- "prefixLength" : 0 ,
8
- "addressUsage" : " PRIMARY" ,
9
- "ip" : " 1.2.3.4"
10
- },
6
+ "mgmtAddress" : " 1.2.3.4" ,
11
7
"status" : " INPRODUCTION"
12
8
}
13
9
]
You can’t perform that action at this time.
0 commit comments