Revision 8140e24f lib/client/gnt_network.py
b/lib/client/gnt_network.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
#: default list of fields for L{ListNetworks} |
35 | 35 |
_LIST_DEF_FIELDS = ["name", "network", "gateway", |
36 |
"network_type", "mac_prefix", "group_list"] |
|
36 |
"network_type", "mac_prefix", "group_list", "tags"]
|
|
37 | 37 |
|
38 | 38 |
|
39 | 39 |
def _HandleReservedIPs(ips): |
... | ... | |
56 | 56 |
""" |
57 | 57 |
(network_name, ) = args |
58 | 58 |
|
59 |
if opts.tags is not None: |
|
60 |
tags = opts.tags.split(",") |
|
61 |
else: |
|
62 |
tags = [] |
|
63 |
|
|
59 | 64 |
op = opcodes.OpNetworkAdd(network_name=network_name, |
60 | 65 |
gateway=opts.gateway, |
61 | 66 |
network=opts.network, |
... | ... | |
63 | 68 |
network6=opts.network6, |
64 | 69 |
mac_prefix=opts.mac_prefix, |
65 | 70 |
network_type=opts.network_type, |
66 |
add_reserved_ips=_HandleReservedIPs(opts.add_reserved_ips)) |
|
71 |
add_reserved_ips=_HandleReservedIPs(opts.add_reserved_ips), |
|
72 |
tags=tags) |
|
67 | 73 |
SubmitOpCode(op, opts=opts) |
68 | 74 |
|
69 | 75 |
|
... | ... | |
139 | 145 |
fmtoverride = { |
140 | 146 |
"group_list": (",".join, False), |
141 | 147 |
"inst_list": (",".join, False), |
148 |
"tags": (",".join, False), |
|
142 | 149 |
} |
143 | 150 |
|
144 | 151 |
return GenericList(constants.QR_NETWORK, desired_fields, args, None, |
... | ... | |
283 | 290 |
commands = { |
284 | 291 |
"add": ( |
285 | 292 |
AddNetwork, ARGS_ONE_NETWORK, |
286 |
[DRY_RUN_OPT, NETWORK_OPT, GATEWAY_OPT, ADD_RESERVED_IPS_OPT, |
|
293 |
[DRY_RUN_OPT, NETWORK_OPT, GATEWAY_OPT, ADD_RESERVED_IPS_OPT, TAG_ADD_OPT,
|
|
287 | 294 |
MAC_PREFIX_OPT, NETWORK_TYPE_OPT, NETWORK6_OPT, GATEWAY6_OPT], |
288 | 295 |
"<network_name>", "Add a new IP network to the cluster"), |
289 | 296 |
"list": ( |
... | ... | |
322 | 329 |
RemoveNetwork, ARGS_ONE_NETWORK, [FORCE_OPT, DRY_RUN_OPT], |
323 | 330 |
"[--dry-run] <network_id>", |
324 | 331 |
"Remove an (empty) network from the cluster"), |
332 |
"list-tags": ( |
|
333 |
ListTags, ARGS_ONE_NETWORK, [], |
|
334 |
"<network_name>", "List the tags of the given network"), |
|
335 |
"add-tags": ( |
|
336 |
AddTags, [ArgNetwork(min=1, max=1), ArgUnknown()], |
|
337 |
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT], |
|
338 |
"<network_name> tag...", "Add tags to the given network"), |
|
339 |
"remove-tags": ( |
|
340 |
RemoveTags, [ArgNetwork(min=1, max=1), ArgUnknown()], |
|
341 |
[TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT], |
|
342 |
"<network_name> tag...", "Remove tags from given network"), |
|
325 | 343 |
} |
326 | 344 |
|
327 | 345 |
|
328 | 346 |
def Main(): |
329 |
return GenericMain(commands) |
|
347 |
return GenericMain(commands, override={"tag_type": constants.TAG_NETWORK}) |
Also available in: Unified diff