79 |
79 |
AssertCommand(["gnt-group", "remove", group1])
|
80 |
80 |
|
81 |
81 |
|
|
82 |
def _TestGroupModifyISpecs(groupname):
|
|
83 |
std_defaults = constants.IPOLICY_DEFAULTS[constants.ISPECS_STD]
|
|
84 |
min_v = std_defaults[constants.ISPEC_MEM_SIZE] * 10
|
|
85 |
max_v = min_v * 10
|
|
86 |
|
|
87 |
# Get the ipolicy command (from the cluster config)
|
|
88 |
mnode = qa_config.GetMasterNode()
|
|
89 |
addcmd = GetCommandOutput(mnode.primary, utils.ShellQuoteArgs([
|
|
90 |
"gnt-group", "show-ispecs-cmd", "--include-defaults", groupname,
|
|
91 |
]))
|
|
92 |
modcmd = ["gnt-group", "modify"]
|
|
93 |
opts = addcmd.split()
|
|
94 |
assert opts[0:2] == ["gnt-group", "add"]
|
|
95 |
for k in range(2, len(opts) - 1):
|
|
96 |
if opts[k].startswith("--ipolicy-"):
|
|
97 |
assert k + 2 <= len(opts)
|
|
98 |
modcmd.extend(opts[k:k + 2])
|
|
99 |
modcmd.append(groupname)
|
|
100 |
# Apply the ipolicy to the group and verify the result
|
|
101 |
AssertCommand(modcmd)
|
|
102 |
new_addcmd = GetCommandOutput(mnode.primary, utils.ShellQuoteArgs([
|
|
103 |
"gnt-group", "show-ispecs-cmd", groupname,
|
|
104 |
]))
|
|
105 |
AssertEqual(addcmd, new_addcmd)
|
|
106 |
|
|
107 |
AssertCommand(["gnt-group", "modify", "--specs-mem-size",
|
|
108 |
"min=%s,max=%s,std=0" % (min_v, max_v), groupname], fail=True)
|
|
109 |
AssertCommand(["gnt-group", "modify", "--specs-mem-size",
|
|
110 |
"min=%s,max=%s" % (min_v, max_v), groupname])
|
|
111 |
AssertCommand(["gnt-group", "modify", "--specs-mem-size",
|
|
112 |
"min=default,max=default", groupname])
|
|
113 |
|
|
114 |
|
|
115 |
def _TestGroupModifyIPolicy(groupname):
|
|
116 |
_TestGroupModifyISpecs(groupname)
|
|
117 |
AssertCommand(["gnt-group", "modify", "--ipolicy-vcpu-ratio",
|
|
118 |
"3.5", groupname])
|
|
119 |
AssertCommand(["gnt-group", "modify", "--ipolicy-vcpu-ratio",
|
|
120 |
"default", groupname])
|
|
121 |
|
|
122 |
|
82 |
123 |
def TestGroupModify():
|
83 |
124 |
"""gnt-group modify"""
|
84 |
125 |
(group1, ) = qa_utils.GetNonexistentGroups(1)
|
85 |
126 |
|
86 |
127 |
AssertCommand(["gnt-group", "add", group1])
|
87 |
128 |
|
88 |
|
std_defaults = constants.IPOLICY_DEFAULTS[constants.ISPECS_STD]
|
89 |
|
min_v = std_defaults[constants.ISPEC_MEM_SIZE] * 10
|
90 |
|
max_v = min_v * 10
|
91 |
|
|
92 |
129 |
try:
|
|
130 |
_TestGroupModifyIPolicy(group1)
|
93 |
131 |
AssertCommand(["gnt-group", "modify", "--alloc-policy", "unallocable",
|
94 |
132 |
"--node-parameters", "oob_program=/bin/false", group1])
|
95 |
133 |
AssertCommand(["gnt-group", "modify",
|
96 |
134 |
"--alloc-policy", "notvalid", group1], fail=True)
|
97 |
|
AssertCommand(["gnt-group", "modify", "--specs-mem-size",
|
98 |
|
"min=%s,max=%s,std=0" % (min_v, max_v), group1], fail=True)
|
99 |
|
AssertCommand(["gnt-group", "modify", "--specs-mem-size",
|
100 |
|
"min=%s,max=%s" % (min_v, max_v), group1])
|
101 |
|
AssertCommand(["gnt-group", "modify", "--specs-mem-size",
|
102 |
|
"min=default,max=default", group1])
|
103 |
|
AssertCommand(["gnt-group", "modify", "--ipolicy-vcpu-ratio",
|
104 |
|
"3.5", group1])
|
105 |
|
AssertCommand(["gnt-group", "modify", "--ipolicy-vcpu-ratio",
|
106 |
|
"default", group1])
|
107 |
135 |
AssertCommand(["gnt-group", "modify",
|
108 |
136 |
"--node-parameters", "spindle_count=10", group1])
|
109 |
137 |
if qa_config.TestEnabled("htools"):
|