Revision fdad8c4d
b/lib/cli.py | ||
---|---|---|
44 | 44 |
|
45 | 45 |
__all__ = [ |
46 | 46 |
# Command line options |
47 |
"ADD_UIDS_OPT", |
|
47 | 48 |
"ALLOCATABLE_OPT", |
48 | 49 |
"ALL_OPT", |
49 | 50 |
"AUTO_PROMOTE_OPT", |
... | ... | |
111 | 112 |
"RAPI_CERT_OPT", |
112 | 113 |
"READD_OPT", |
113 | 114 |
"REBOOT_TYPE_OPT", |
115 |
"REMOVE_UIDS_OPT", |
|
114 | 116 |
"SECONDARY_IP_OPT", |
115 | 117 |
"SELECT_OS_OPT", |
116 | 118 |
"SEP_OPT", |
... | ... | |
935 | 937 |
help=("A list of user-ids or user-id" |
936 | 938 |
" ranges separated by commas")) |
937 | 939 |
|
940 |
ADD_UIDS_OPT = cli_option("--add-uids", default=None, |
|
941 |
action="store", dest="add_uids", |
|
942 |
help=("A list of user-ids or user-id" |
|
943 |
" ranges separated by commas, to be" |
|
944 |
" added to the user-id pool")) |
|
945 |
|
|
946 |
REMOVE_UIDS_OPT = cli_option("--remove-uids", default=None, |
|
947 |
action="store", dest="remove_uids", |
|
948 |
help=("A list of user-ids or user-id" |
|
949 |
" ranges separated by commas, to be" |
|
950 |
" removed from the user-id pool")) |
|
951 |
|
|
938 | 952 |
|
939 | 953 |
def _ParseArgs(argv, commands, aliases): |
940 | 954 |
"""Parser for the command line arguments. |
b/lib/cmdlib.py | ||
---|---|---|
2272 | 2272 |
if self.op.uid_pool: |
2273 | 2273 |
uidpool.CheckUidPool(self.op.uid_pool) |
2274 | 2274 |
|
2275 |
if self.op.add_uids: |
|
2276 |
uidpool.CheckUidPool(self.op.add_uids) |
|
2277 |
|
|
2278 |
if self.op.remove_uids: |
|
2279 |
uidpool.CheckUidPool(self.op.remove_uids) |
|
2280 |
|
|
2275 | 2281 |
def ExpandNames(self): |
2276 | 2282 |
# FIXME: in the future maybe other cluster params won't require checking on |
2277 | 2283 |
# all nodes to be modified. |
... | ... | |
2466 | 2472 |
if self.op.maintain_node_health is not None: |
2467 | 2473 |
self.cluster.maintain_node_health = self.op.maintain_node_health |
2468 | 2474 |
|
2475 |
if self.op.add_uids is not None: |
|
2476 |
uidpool.AddToUidPool(self.cluster.uid_pool, self.op.add_uids) |
|
2477 |
|
|
2478 |
if self.op.remove_uids is not None: |
|
2479 |
uidpool.RemoveFromUidPool(self.cluster.uid_pool, self.op.remove_uids) |
|
2480 |
|
|
2469 | 2481 |
if self.op.uid_pool is not None: |
2470 | 2482 |
self.cluster.uid_pool = self.op.uid_pool |
2471 | 2483 |
|
b/lib/opcodes.py | ||
---|---|---|
307 | 307 |
"candidate_pool_size", |
308 | 308 |
"maintain_node_health", |
309 | 309 |
"uid_pool", |
310 |
"add_uids", |
|
311 |
"remove_uids", |
|
310 | 312 |
] |
311 | 313 |
|
312 | 314 |
|
b/lib/uidpool.py | ||
---|---|---|
78 | 78 |
return ranges |
79 | 79 |
|
80 | 80 |
|
81 |
def AddToUidPool(uid_pool, add_uids): |
|
82 |
"""Add a list of user-ids/user-id ranges to a user-id pool. |
|
83 |
|
|
84 |
@param uid_pool: a user-id pool (list of integer tuples) |
|
85 |
@param add_uids: user-id ranges to be added to the pool |
|
86 |
(list of integer tuples) |
|
87 |
|
|
88 |
""" |
|
89 |
for uid_range in add_uids: |
|
90 |
if uid_range not in uid_pool: |
|
91 |
uid_pool.append(uid_range) |
|
92 |
uid_pool.sort() |
|
93 |
|
|
94 |
|
|
95 |
def RemoveFromUidPool(uid_pool, remove_uids): |
|
96 |
"""Remove a list of user-ids/user-id ranges from a user-id pool. |
|
97 |
|
|
98 |
@param uid_pool: a user-id pool (list of integer tuples) |
|
99 |
@param remove_uids: user-id ranges to be removed from the pool |
|
100 |
(list of integer tuples) |
|
101 |
|
|
102 |
""" |
|
103 |
for uid_range in remove_uids: |
|
104 |
if uid_range not in uid_pool: |
|
105 |
raise errors.OpPrereqError( |
|
106 |
"User-id range to be removed is not found in the current" |
|
107 |
" user-id pool: %s" % uid_range, errors.ECODE_INVAL) |
|
108 |
uid_pool.remove(uid_range) |
|
109 |
|
|
110 |
|
|
81 | 111 |
def CheckUidPool(uid_pool): |
82 | 112 |
"""Sanity check user-id pool range definition values. |
83 | 113 |
|
b/scripts/gnt-cluster | ||
---|---|---|
603 | 603 |
opts.beparams or opts.nicparams or |
604 | 604 |
opts.candidate_pool_size is not None or |
605 | 605 |
opts.uid_pool is not None or |
606 |
opts.maintain_node_health is not None): |
|
606 |
opts.maintain_node_health is not None or |
|
607 |
opts.add_uids is not None or |
|
608 |
opts.remove_uids is not None): |
|
607 | 609 |
ToStderr("Please give at least one of the parameters.") |
608 | 610 |
return 1 |
609 | 611 |
|
... | ... | |
637 | 639 |
if uid_pool is not None: |
638 | 640 |
uid_pool = uidpool.ParseUidPool(uid_pool) |
639 | 641 |
|
642 |
add_uids = opts.add_uids |
|
643 |
if add_uids is not None: |
|
644 |
add_uids = uidpool.ParseUidPool(add_uids) |
|
645 |
|
|
646 |
remove_uids = opts.remove_uids |
|
647 |
if remove_uids is not None: |
|
648 |
remove_uids = uidpool.ParseUidPool(remove_uids) |
|
649 |
|
|
640 | 650 |
op = opcodes.OpSetClusterParams(vg_name=vg_name, |
641 | 651 |
enabled_hypervisors=hvlist, |
642 | 652 |
hvparams=hvparams, |
... | ... | |
645 | 655 |
nicparams=nicparams, |
646 | 656 |
candidate_pool_size=opts.candidate_pool_size, |
647 | 657 |
maintain_node_health=mnh, |
648 |
uid_pool=uid_pool) |
|
658 |
uid_pool=uid_pool, |
|
659 |
add_uids=add_uids, |
|
660 |
remove_uids=remove_uids) |
|
649 | 661 |
SubmitOpCode(op, opts=opts) |
650 | 662 |
return 0 |
651 | 663 |
|
... | ... | |
797 | 809 |
SetClusterParams, ARGS_NONE, |
798 | 810 |
[BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT, |
799 | 811 |
NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT, |
800 |
UIDPOOL_OPT], |
|
812 |
UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT],
|
|
801 | 813 |
"[opts...]", |
802 | 814 |
"Alters the parameters of the cluster"), |
803 | 815 |
"renew-crypto": ( |
Also available in: Unified diff