Coverage for dcim/search.py: 100%

202 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-10 18:35 +0000

1from netbox.search import SearchIndex, register_search 

2 

3from . import models 

4 

5 

6@register_search 

7class CableBundleIndex(SearchIndex): 

8 model = models.CableBundle 

9 fields = ( 

10 ('name', 100), 

11 ('description', 500), 

12 ('comments', 5000), 

13 ) 

14 display_attrs = ('description',) 

15 

16 

17@register_search 

18class CableIndex(SearchIndex): 

19 model = models.Cable 

20 fields = ( 

21 ('label', 100), 

22 ('description', 500), 

23 ('comments', 5000), 

24 ) 

25 display_attrs = ('type', 'status', 'tenant', 'label', 'description') 

26 

27 

28@register_search 

29class ConsolePortIndex(SearchIndex): 

30 model = models.ConsolePort 

31 fields = ( 

32 ('name', 100), 

33 ('label', 200), 

34 ('description', 500), 

35 ('speed', 2000), 

36 ) 

37 display_attrs = ('device', 'label', 'type', 'description') 

38 

39 

40@register_search 

41class ConsoleServerPortIndex(SearchIndex): 

42 model = models.ConsoleServerPort 

43 fields = ( 

44 ('name', 100), 

45 ('label', 200), 

46 ('description', 500), 

47 ('speed', 2000), 

48 ) 

49 display_attrs = ('device', 'label', 'type', 'description') 

50 

51 

52@register_search 

53class CoolingFeedIndex(SearchIndex): 

54 model = models.CoolingFeed 

55 fields = ( 

56 ('name', 100), 

57 ('description', 500), 

58 ('comments', 5000), 

59 ) 

60 display_attrs = ('cooling_source', 'rack', 'status', 'description') 

61 

62 

63@register_search 

64class CoolingOutflowIndex(SearchIndex): 

65 model = models.CoolingOutflow 

66 fields = ( 

67 ('name', 100), 

68 ('label', 200), 

69 ('description', 500), 

70 ) 

71 display_attrs = ('device', 'label', 'type', 'description') 

72 

73 

74@register_search 

75class CoolingIntakeIndex(SearchIndex): 

76 model = models.CoolingIntake 

77 fields = ( 

78 ('name', 100), 

79 ('label', 200), 

80 ('description', 500), 

81 ) 

82 display_attrs = ('device', 'label', 'type', 'description') 

83 

84 

85@register_search 

86class CoolingSourceIndex(SearchIndex): 

87 model = models.CoolingSource 

88 fields = ( 

89 ('name', 100), 

90 ('description', 500), 

91 ('comments', 5000), 

92 ) 

93 display_attrs = ('site', 'location', 'type', 'status', 'description') 

94 

95 

96@register_search 

97class DeviceIndex(SearchIndex): 

98 model = models.Device 

99 fields = ( 

100 ('asset_tag', 50), 

101 ('serial', 60), 

102 ('name', 100), 

103 ('virtual_chassis', 200), 

104 ('description', 500), 

105 ('comments', 5000), 

106 ) 

107 display_attrs = ( 

108 'site', 'location', 'rack', 'status', 'device_type', 'role', 'tenant', 'platform', 'serial', 'asset_tag', 

109 'description', 

110 ) 

111 

112 

113@register_search 

114class DeviceBayIndex(SearchIndex): 

115 model = models.DeviceBay 

116 fields = ( 

117 ('name', 100), 

118 ('label', 200), 

119 ('description', 500), 

120 ) 

121 display_attrs = ('device', 'label', 'description') 

122 

123 

124@register_search 

125class DeviceRoleIndex(SearchIndex): 

126 model = models.DeviceRole 

127 fields = ( 

128 ('name', 100), 

129 ('slug', 110), 

130 ('description', 500), 

131 ('comments', 5000), 

132 ) 

133 display_attrs = ('description',) 

134 

135 

136@register_search 

137class DeviceTypeIndex(SearchIndex): 

138 model = models.DeviceType 

139 fields = ( 

140 ('model', 100), 

141 ('part_number', 200), 

142 ('description', 500), 

143 ('comments', 5000), 

144 ) 

145 display_attrs = ('manufacturer', 'part_number', 'description') 

146 

147 

148@register_search 

149class FrontPortIndex(SearchIndex): 

150 model = models.FrontPort 

151 fields = ( 

152 ('name', 100), 

153 ('label', 200), 

154 ('description', 500), 

155 ) 

156 display_attrs = ('device', 'label', 'type', 'description') 

157 

158 

159@register_search 

160class MACAddressIndex(SearchIndex): 

161 model = models.MACAddress 

162 fields = ( 

163 ('mac_address', 100), 

164 ('description', 500), 

165 ('comments', 5000), 

166 ) 

167 display_attrs = ('assigned_object', 'description') 

168 

169 

170@register_search 

171class InterfaceIndex(SearchIndex): 

172 model = models.Interface 

173 fields = ( 

174 ('name', 100), 

175 ('label', 200), 

176 ('wwn', 300), 

177 ('description', 500), 

178 ('mtu', 2000), 

179 ('speed', 2000), 

180 ) 

181 display_attrs = ('device', 'label', 'type', 'wwn', 'description') 

182 

183 

184@register_search 

185class InventoryItemIndex(SearchIndex): 

186 model = models.InventoryItem 

187 fields = ( 

188 ('asset_tag', 50), 

189 ('serial', 60), 

190 ('name', 100), 

191 ('label', 200), 

192 ('description', 500), 

193 ('part_id', 2000), 

194 ) 

195 display_attrs = ('device', 'manufacturer', 'parent', 'part_id', 'serial', 'asset_tag', 'description') 

196 

197 

198@register_search 

199class InventoryItemRoleIndex(SearchIndex): 

200 model = models.InventoryItemRole 

201 fields = ( 

202 ('name', 100), 

203 ('slug', 110), 

204 ('description', 500), 

205 ('comments', 5000), 

206 ) 

207 display_attrs = ('description',) 

208 

209 

210@register_search 

211class LocationIndex(SearchIndex): 

212 model = models.Location 

213 fields = ( 

214 ('name', 100), 

215 ('facility', 100), 

216 ('slug', 110), 

217 ('description', 500), 

218 ('comments', 5000), 

219 ) 

220 display_attrs = ('site', 'status', 'tenant', 'facility', 'description') 

221 

222 

223@register_search 

224class ManufacturerIndex(SearchIndex): 

225 model = models.Manufacturer 

226 fields = ( 

227 ('name', 100), 

228 ('slug', 110), 

229 ('description', 500), 

230 ('comments', 5000), 

231 ) 

232 display_attrs = ('description',) 

233 

234 

235@register_search 

236class ModuleIndex(SearchIndex): 

237 model = models.Module 

238 fields = ( 

239 ('asset_tag', 50), 

240 ('serial', 60), 

241 ('description', 500), 

242 ('comments', 5000), 

243 ) 

244 display_attrs = ('device', 'module_bay', 'module_type', 'status', 'serial', 'asset_tag', 'description') 

245 

246 

247@register_search 

248class ModuleBayIndex(SearchIndex): 

249 model = models.ModuleBay 

250 fields = ( 

251 ('name', 100), 

252 ('label', 200), 

253 ('description', 500), 

254 ) 

255 display_attrs = ('device', 'label', 'position', 'description') 

256 

257 

258@register_search 

259class ModuleBayTypeIndex(SearchIndex): 

260 model = models.ModuleBayType 

261 fields = ( 

262 ('name', 100), 

263 ('slug', 110), 

264 ('description', 500), 

265 ('comments', 5000), 

266 ) 

267 display_attrs = ('name', 'manufacturer', 'description') 

268 

269 

270@register_search 

271class ModuleTypeProfileIndex(SearchIndex): 

272 model = models.ModuleTypeProfile 

273 fields = ( 

274 ('name', 100), 

275 ('description', 500), 

276 ('comments', 5000), 

277 ) 

278 display_attrs = ('name', 'description') 

279 

280 

281@register_search 

282class ModuleTypeIndex(SearchIndex): 

283 model = models.ModuleType 

284 fields = ( 

285 ('model', 100), 

286 ('part_number', 200), 

287 ('description', 500), 

288 ('comments', 5000), 

289 ) 

290 display_attrs = ('manufacturer', 'model', 'part_number', 'description') 

291 

292 

293@register_search 

294class PlatformIndex(SearchIndex): 

295 model = models.Platform 

296 fields = ( 

297 ('name', 100), 

298 ('slug', 110), 

299 ('description', 500), 

300 ('comments', 5000), 

301 ) 

302 display_attrs = ('manufacturer', 'description') 

303 

304 

305@register_search 

306class PowerFeedIndex(SearchIndex): 

307 model = models.PowerFeed 

308 fields = ( 

309 ('name', 100), 

310 ('description', 500), 

311 ('comments', 5000), 

312 ) 

313 display_attrs = ('power_panel', 'rack', 'status', 'description') 

314 

315 

316@register_search 

317class PowerOutletIndex(SearchIndex): 

318 model = models.PowerOutlet 

319 fields = ( 

320 ('name', 100), 

321 ('label', 200), 

322 ('description', 500), 

323 ) 

324 display_attrs = ('device', 'label', 'type', 'status', 'description') 

325 

326 

327@register_search 

328class PowerPanelIndex(SearchIndex): 

329 model = models.PowerPanel 

330 fields = ( 

331 ('name', 100), 

332 ('description', 500), 

333 ('comments', 5000), 

334 ) 

335 display_attrs = ('site', 'location', 'description') 

336 

337 

338@register_search 

339class PowerPortIndex(SearchIndex): 

340 model = models.PowerPort 

341 fields = ( 

342 ('name', 100), 

343 ('label', 200), 

344 ('description', 500), 

345 ('maximum_draw', 2000), 

346 ('allocated_draw', 2000), 

347 ) 

348 display_attrs = ('device', 'label', 'type', 'description') 

349 

350 

351@register_search 

352class RackTypeIndex(SearchIndex): 

353 model = models.RackType 

354 fields = ( 

355 ('model', 100), 

356 ('description', 500), 

357 ('comments', 5000), 

358 ) 

359 display_attrs = ('model', 'description') 

360 

361 

362@register_search 

363class RackIndex(SearchIndex): 

364 model = models.Rack 

365 fields = ( 

366 ('asset_tag', 50), 

367 ('serial', 60), 

368 ('name', 100), 

369 ('facility_id', 200), 

370 ('description', 500), 

371 ('comments', 5000), 

372 ) 

373 display_attrs = ( 

374 'site', 'location', 'facility_id', 'tenant', 'status', 'role', 'serial', 'asset_tag', 'description', 

375 ) 

376 

377 

378@register_search 

379class RackReservationIndex(SearchIndex): 

380 model = models.RackReservation 

381 fields = ( 

382 ('description', 500), 

383 ('comments', 5000), 

384 ) 

385 display_attrs = ('rack', 'tenant', 'user', 'description') 

386 

387 

388@register_search 

389class RackGroupIndex(SearchIndex): 

390 model = models.RackGroup 

391 fields = ( 

392 ('name', 100), 

393 ('slug', 110), 

394 ('description', 500), 

395 ('comments', 5000), 

396 ) 

397 display_attrs = ('description',) 

398 

399 

400@register_search 

401class RackRoleIndex(SearchIndex): 

402 model = models.RackRole 

403 fields = ( 

404 ('name', 100), 

405 ('slug', 110), 

406 ('description', 500), 

407 ('comments', 5000), 

408 ) 

409 display_attrs = ('description',) 

410 

411 

412@register_search 

413class RearPortIndex(SearchIndex): 

414 model = models.RearPort 

415 fields = ( 

416 ('name', 100), 

417 ('label', 200), 

418 ('description', 500), 

419 ) 

420 display_attrs = ('device', 'label', 'type', 'description') 

421 

422 

423@register_search 

424class RegionIndex(SearchIndex): 

425 model = models.Region 

426 fields = ( 

427 ('name', 100), 

428 ('slug', 110), 

429 ('description', 500), 

430 ('comments', 5000), 

431 ) 

432 display_attrs = ('parent', 'description') 

433 

434 

435@register_search 

436class SiteIndex(SearchIndex): 

437 model = models.Site 

438 fields = ( 

439 ('name', 100), 

440 ('facility', 100), 

441 ('slug', 110), 

442 ('description', 500), 

443 ('physical_address', 2000), 

444 ('shipping_address', 2000), 

445 ('comments', 5000), 

446 ) 

447 display_attrs = ('region', 'group', 'status', 'tenant', 'facility', 'description') 

448 

449 

450@register_search 

451class SiteGroupIndex(SearchIndex): 

452 model = models.SiteGroup 

453 fields = ( 

454 ('name', 100), 

455 ('slug', 110), 

456 ('description', 500), 

457 ('comments', 5000), 

458 ) 

459 display_attrs = ('parent', 'description') 

460 

461 

462@register_search 

463class VirtualChassisIndex(SearchIndex): 

464 model = models.VirtualChassis 

465 fields = ( 

466 ('name', 100), 

467 ('domain', 300), 

468 ('description', 500), 

469 ('comments', 5000), 

470 ) 

471 display_attrs = ('master', 'domain', 'description') 

472 

473 

474@register_search 

475class VirtualDeviceContextIndex(SearchIndex): 

476 model = models.VirtualDeviceContext 

477 fields = ( 

478 ('name', 100), 

479 ('identifier', 300), 

480 ('description', 500), 

481 ('comments', 5000), 

482 ) 

483 display_attrs = ('device', 'status', 'identifier', 'tenant', 'description')