Revision d3d7a7ae lib/query.py
b/lib/query.py | ||
---|---|---|
2468 | 2468 |
"gateway6": ("IPv6Gateway", QFT_OTHER, 0, "The ipv6 gateway"), |
2469 | 2469 |
"mac_prefix": ("MacPrefix", QFT_OTHER, 0, "The mac prefix"), |
2470 | 2470 |
"network_type": ("NetworkType", QFT_OTHER, 0, "The network type"), |
2471 |
"serial_no": ("SerialNo", QFT_NUMBER, 0, _SERIAL_NO_DOC % "Network"), |
|
2472 |
"uuid": ("UUID", QFT_TEXT, 0, "Network UUID"), |
|
2471 | 2473 |
} |
2472 | 2474 |
|
2473 | 2475 |
|
2474 | 2476 |
_NETWORK_STATS_FIELDS = { |
2475 | 2477 |
"free_count": ("FreeCount", QFT_NUMBER, 0, "How many addresses are free"), |
2476 |
"reserved_count": ("ReservedCount", QFT_NUMBER, 0, "How many addresses are reserved"), |
|
2478 |
"reserved_count": ("ReservedCount", QFT_NUMBER, 0, |
|
2479 |
"How many addresses are reserved"), |
|
2477 | 2480 |
"map": ("Map", QFT_TEXT, 0, "The actual mapping"), |
2478 |
"external_reservations": ("ExternalReservations", QFT_TEXT, 0, "The external reservations"), |
|
2481 |
"external_reservations": ("ExternalReservations", QFT_TEXT, 0, |
|
2482 |
"The external reservations"), |
|
2479 | 2483 |
} |
2480 | 2484 |
|
2481 |
|
|
2482 |
def _GetNetworkStatsField(field, kind, ctx, net): |
|
2485 |
def _GetNetworkStatsField(field, kind, ctx): |
|
2483 | 2486 |
"""Gets the value of a "stats" field from L{NetworkQueryData}. |
2484 | 2487 |
|
2485 | 2488 |
@param field: Field name |
... | ... | |
2503 | 2506 |
return int(value) |
2504 | 2507 |
except (ValueError, TypeError): |
2505 | 2508 |
logging.exception("Failed to convert network field '%s' (value %r) to int", |
2506 |
value, field)
|
|
2509 |
field, value)
|
|
2507 | 2510 |
return _FS_UNAVAIL |
2508 | 2511 |
|
2509 | 2512 |
|
... | ... | |
2515 | 2518 |
fields = [ |
2516 | 2519 |
(_MakeField(name, title, kind, doc), |
2517 | 2520 |
NETQ_CONFIG, 0, _GetItemAttr(name)) |
2518 |
for (name, (title, kind, flags, doc)) in _NETWORK_SIMPLE_FIELDS.items()] |
|
2521 |
for (name, (title, kind, _, doc)) in _NETWORK_SIMPLE_FIELDS.items() |
|
2522 |
]) |
|
2519 | 2523 |
|
2520 | 2524 |
def _GetLength(getter): |
2521 | 2525 |
return lambda ctx, network: len(getter(ctx)[network.uuid]) |
... | ... | |
2546 | 2550 |
fields.extend([ |
2547 | 2551 |
(_MakeField(name, title, kind, doc), NETQ_STATS, 0, |
2548 | 2552 |
compat.partial(_GetNetworkStatsField, name, kind)) |
2549 |
for (name, (title, kind, flags, doc)) in _NETWORK_STATS_FIELDS.items()
|
|
2553 |
for (name, (title, kind, _, doc)) in _NETWORK_STATS_FIELDS.items()
|
|
2550 | 2554 |
]) |
2551 | 2555 |
|
2552 | 2556 |
return _PrepareFieldList(fields, []) |
Also available in: Unified diff