Revision ee93aa8a lib/client/gnt_network.py
b/lib/client/gnt_network.py | ||
---|---|---|
83 | 83 |
SubmitOrSend(op, opts) |
84 | 84 |
|
85 | 85 |
|
86 |
def MapNetwork(opts, args):
|
|
86 |
def ConnectNetwork(opts, args):
|
|
87 | 87 |
"""Map a network to a node group. |
88 | 88 |
|
89 | 89 |
@param opts: the command line options selected by the user |
90 | 90 |
@type args: list |
91 |
@param args: a list of length 3 with network, nodegroup, mode, physlink
|
|
91 |
@param args: Network, mode, physlink and node groups
|
|
92 | 92 |
@rtype: int |
93 | 93 |
@return: the desired exit code |
94 | 94 |
|
95 | 95 |
""" |
96 |
(network, groups, mode, link) = args |
|
96 |
(network, mode, link) = args[:3] |
|
97 |
groups = args[3:] |
|
97 | 98 |
|
98 | 99 |
cl = GetClient() |
99 | 100 |
|
100 |
# FIXME: This doesn't work with a group named "all" |
|
101 |
if groups == "all": |
|
102 |
(groups, ) = cl.QueryGroups([], ["name"], False) |
|
103 |
else: |
|
104 |
groups = [groups] |
|
101 |
if not groups: |
|
102 |
(groups, ) = cl.QueryGroups([], ["uuid"], False) |
|
105 | 103 |
|
106 | 104 |
# TODO: Change logic to support "--submit" |
107 | 105 |
for group in groups: |
... | ... | |
113 | 111 |
SubmitOpCode(op, opts=opts, cl=cl) |
114 | 112 |
|
115 | 113 |
|
116 |
def UnmapNetwork(opts, args):
|
|
114 |
def DisconnectNetwork(opts, args):
|
|
117 | 115 |
"""Unmap a network from a node group. |
118 | 116 |
|
119 | 117 |
@param opts: the command line options selected by the user |
120 | 118 |
@type args: list |
121 |
@param args: a list of length 3 with network, nodegroup
|
|
119 |
@param args: Network and node groups
|
|
122 | 120 |
@rtype: int |
123 | 121 |
@return: the desired exit code |
124 | 122 |
|
125 | 123 |
""" |
126 |
(network, groups) = args |
|
124 |
(network, ) = args[:1] |
|
125 |
groups = args[1:] |
|
127 | 126 |
|
128 | 127 |
cl = GetClient() |
129 | 128 |
|
130 |
# FIXME: This doesn't work with a group named "all" |
|
131 |
if groups == "all": |
|
132 |
(groups, ) = cl.QueryGroups([], ["name"], False) |
|
133 |
else: |
|
134 |
groups = [groups] |
|
129 |
if not groups: |
|
130 |
(groups, ) = cl.QueryGroups([], ["uuid"], False) |
|
135 | 131 |
|
136 | 132 |
# TODO: Change logic to support "--submit" |
137 | 133 |
for group in groups: |
... | ... | |
327 | 323 |
PRIORITY_OPT], |
328 | 324 |
"<network_name>", "Alters the parameters of a network"), |
329 | 325 |
"connect": ( |
330 |
MapNetwork,
|
|
331 |
[ArgNetwork(min=1, max=1), ArgGroup(min=1, max=1),
|
|
326 |
ConnectNetwork,
|
|
327 |
[ArgNetwork(min=1, max=1), |
|
332 | 328 |
ArgChoice(min=1, max=1, choices=constants.NIC_VALID_MODES), |
333 |
ArgUnknown(min=1, max=1)], |
|
329 |
ArgUnknown(min=1, max=1), |
|
330 |
ArgGroup()], |
|
334 | 331 |
[NOCONFLICTSCHECK_OPT, PRIORITY_OPT], |
335 |
"<network_name> <node_group> <mode> <link>",
|
|
332 |
"<network_name> <mode> <link> [<node_group>...]",
|
|
336 | 333 |
"Map a given network to the specified node group" |
337 | 334 |
" with given mode and link (netparams)"), |
338 | 335 |
"disconnect": ( |
339 |
UnmapNetwork,
|
|
340 |
[ArgNetwork(min=1, max=1), ArgGroup(min=1, max=1)],
|
|
336 |
DisconnectNetwork,
|
|
337 |
[ArgNetwork(min=1, max=1), ArgGroup()], |
|
341 | 338 |
[NOCONFLICTSCHECK_OPT, PRIORITY_OPT], |
342 |
"<network_name> <node_group>",
|
|
339 |
"<network_name> [<node_group>...]",
|
|
343 | 340 |
"Unmap a given network from a specified node group"), |
344 | 341 |
"remove": ( |
345 | 342 |
RemoveNetwork, ARGS_ONE_NETWORK, |
Also available in: Unified diff