Revision 66e884e1 lib/client/gnt_group.py
b/lib/client/gnt_group.py | ||
---|---|---|
26 | 26 |
|
27 | 27 |
from ganeti.cli import * |
28 | 28 |
from ganeti import compat |
29 |
from ganeti import opcodes |
|
29 | 30 |
from ganeti import utils |
30 | 31 |
|
31 | 32 |
|
... | ... | |
42 | 43 |
} |
43 | 44 |
|
44 | 45 |
|
46 |
def AddGroup(opts, args): |
|
47 |
"""Add a node group to the cluster. |
|
48 |
|
|
49 |
@param opts: the command line options selected by the user |
|
50 |
@type args: list |
|
51 |
@param args: a list of length 1 with the name of the group to create |
|
52 |
@rtype: int |
|
53 |
@return: the desired exit code |
|
54 |
|
|
55 |
""" |
|
56 |
(group_name,) = args |
|
57 |
op = opcodes.OpAddGroup(group_name=group_name) |
|
58 |
SubmitOpCode(op, opts=opts) |
|
59 |
|
|
60 |
|
|
45 | 61 |
def ListGroups(opts, args): |
46 | 62 |
"""List node groups and their properties. |
47 | 63 |
|
... | ... | |
89 | 105 |
return 0 |
90 | 106 |
|
91 | 107 |
|
108 |
def RemoveGroup(opts, args): |
|
109 |
"""Remove a node group from the cluster. |
|
110 |
|
|
111 |
@param opts: the command line options selected by the user |
|
112 |
@type args: list |
|
113 |
@param args: a list of length 1 with the name of the group to remove |
|
114 |
@rtype: int |
|
115 |
@return: the desired exit code |
|
116 |
|
|
117 |
""" |
|
118 |
(group_name,) = args |
|
119 |
op = opcodes.OpRemoveGroup(group_name=group_name) |
|
120 |
SubmitOpCode(op, opts=opts) |
|
121 |
|
|
122 |
|
|
123 |
def RenameGroup(opts, args): |
|
124 |
"""Rename a node group. |
|
125 |
|
|
126 |
@param opts: the command line options selected by the user |
|
127 |
@type args: list |
|
128 |
@param args: a list of length 2, [old_name, new_name] |
|
129 |
@rtype: int |
|
130 |
@return: the desired exit code |
|
131 |
|
|
132 |
""" |
|
133 |
old_name, new_name = args |
|
134 |
op = opcodes.OpRenameGroup(old_name=old_name, new_name=new_name) |
|
135 |
SubmitOpCode(op, opts=opts) |
|
136 |
|
|
137 |
|
|
92 | 138 |
commands = { |
139 |
"add": ( |
|
140 |
AddGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT], |
|
141 |
"<group_name>", "Add a new node group to the cluster"), |
|
93 | 142 |
"list": ( |
94 | 143 |
ListGroups, ARGS_MANY_GROUPS, |
95 | 144 |
[NOHDR_OPT, SEP_OPT, FIELDS_OPT, SYNC_OPT, ROMAN_OPT], |
... | ... | |
97 | 146 |
"Lists the node groups in the cluster. The available fields are (see" |
98 | 147 |
" the man page for details): %s. The default list is (in order): %s." % |
99 | 148 |
(utils.CommaJoin(_LIST_HEADERS), utils.CommaJoin(_LIST_DEF_FIELDS))), |
149 |
"remove": ( |
|
150 |
RemoveGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT], |
|
151 |
"[--dry-run] <group_name>", |
|
152 |
"Remove an (empty) node group from the cluster"), |
|
153 |
"rename": ( |
|
154 |
RenameGroup, [ArgGroup(min=2, max=2)], [DRY_RUN_OPT], |
|
155 |
"[--dry-run] <old_name> <new_name>", "Rename a node group"), |
|
100 | 156 |
} |
101 | 157 |
|
102 | 158 |
|
Also available in: Unified diff