Revision cb178a1e
b/qa/ganeti-qa.py | ||
---|---|---|
528 | 528 |
|
529 | 529 |
def TestIPolicyPlainInstance(): |
530 | 530 |
"""Test instance policy interaction with instances""" |
531 |
params = ["mem-size", "cpu-count", "disk-count", "disk-size", "nic-count"] |
|
531 |
params = ["memory-size", "cpu-count", "disk-count", "disk-size", "nic-count"]
|
|
532 | 532 |
if not qa_config.IsTemplateSupported(constants.DT_PLAIN): |
533 | 533 |
print "Template %s not supported" % constants.DT_PLAIN |
534 | 534 |
return |
b/qa/qa_cluster.py | ||
---|---|---|
544 | 544 |
for (key, val) in policy.items(): |
545 | 545 |
if key in ispec_keys: |
546 | 546 |
for (par, pval) in val.items(): |
547 |
if par == "memory-size": |
|
548 |
par = "mem-size" |
|
549 | 547 |
d = ret_specs.setdefault(par, {}) |
550 | 548 |
d[key] = pval |
551 | 549 |
else: |
... | ... | |
617 | 615 |
AssertEqual(eff_policy[p], old_policy[p]) |
618 | 616 |
|
619 | 617 |
|
618 |
def _GetParameterOptions(key, specs, old_specs): |
|
619 |
values = ["%s=%s" % (par, keyvals[key]) |
|
620 |
for (par, keyvals) in specs.items() |
|
621 |
if key in keyvals] |
|
622 |
if old_specs: |
|
623 |
present_pars = frozenset(par |
|
624 |
for (par, keyvals) in specs.items() |
|
625 |
if key in keyvals) |
|
626 |
values.extend("%s=%s" % (par, keyvals[key]) |
|
627 |
for (par, keyvals) in old_specs.items() |
|
628 |
if key in keyvals and par not in present_pars) |
|
629 |
return ",".join(values) |
|
630 |
|
|
631 |
|
|
620 | 632 |
def TestClusterSetISpecs(new_specs, fail=False, old_values=None): |
621 | 633 |
"""Change instance specs. |
622 | 634 |
|
... | ... | |
637 | 649 |
(old_policy, old_specs) = _GetClusterIPolicy() |
638 | 650 |
if new_specs: |
639 | 651 |
cmd = ["gnt-cluster", "modify"] |
640 |
for (par, keyvals) in new_specs.items(): |
|
641 |
if par == "spindle-use": |
|
642 |
# ignore spindle-use, which is not settable |
|
643 |
continue |
|
644 |
cmd += [ |
|
645 |
"--specs-%s" % par, |
|
646 |
",".join(["%s=%s" % (k, v) for (k, v) in keyvals.items()]), |
|
647 |
] |
|
652 |
if any(("min" in val or "max" in val) for val in new_specs.values()): |
|
653 |
minmax_opt_items = [] |
|
654 |
for key in ["min", "max"]: |
|
655 |
keyopt = _GetParameterOptions(key, new_specs, old_specs) |
|
656 |
minmax_opt_items.append("%s:%s" % (key, keyopt)) |
|
657 |
cmd.extend([ |
|
658 |
"--ipolicy-bounds-specs", |
|
659 |
"/".join(minmax_opt_items) |
|
660 |
]) |
|
661 |
std_opt = _GetParameterOptions("std", new_specs, {}) |
|
662 |
if std_opt: |
|
663 |
cmd.extend(["--ipolicy-std-specs", std_opt]) |
|
648 | 664 |
AssertCommand(cmd, fail=fail) |
665 |
|
|
649 | 666 |
# Check the new state |
650 | 667 |
(eff_policy, eff_specs) = _GetClusterIPolicy() |
651 | 668 |
AssertEqual(eff_policy, old_policy) |
... | ... | |
663 | 680 |
|
664 | 681 |
def TestClusterModifyISpecs(): |
665 | 682 |
"""gnt-cluster modify --specs-*""" |
666 |
params = ["mem-size", "disk-size", "disk-count", "cpu-count", "nic-count"] |
|
683 |
params = ["memory-size", "disk-size", "disk-count", "cpu-count", "nic-count"]
|
|
667 | 684 |
(cur_policy, cur_specs) = _GetClusterIPolicy() |
668 | 685 |
for par in params: |
669 | 686 |
test_values = [ |
b/qa/qa_group.py | ||
---|---|---|
80 | 80 |
|
81 | 81 |
|
82 | 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 | 83 |
# Get the ipolicy command (from the cluster config) |
88 | 84 |
mnode = qa_config.GetMasterNode() |
89 | 85 |
addcmd = GetCommandOutput(mnode.primary, utils.ShellQuoteArgs([ |
... | ... | |
104 | 100 |
])) |
105 | 101 |
AssertEqual(addcmd, new_addcmd) |
106 | 102 |
|
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 | 103 |
|
115 | 104 |
def _TestGroupModifyIPolicy(groupname): |
116 | 105 |
_TestGroupModifyISpecs(groupname) |
b/qa/qa_instance.py | ||
---|---|---|
338 | 338 |
@type instance: string |
339 | 339 |
@param instance: Instance name |
340 | 340 |
@type spec: string |
341 |
@param spec: one of the supported parameters: "mem-size", "cpu-count", |
|
341 |
@param spec: one of the supported parameters: "memory-size", "cpu-count",
|
|
342 | 342 |
"disk-count", "disk-size", "nic-count" |
343 | 343 |
@rtype: tuple |
344 | 344 |
@return: (minspec, maxspec); minspec and maxspec can be different only for |
... | ... | |
346 | 346 |
|
347 | 347 |
""" |
348 | 348 |
specmap = { |
349 |
"mem-size": ["be/minmem", "be/maxmem"], |
|
349 |
"memory-size": ["be/minmem", "be/maxmem"],
|
|
350 | 350 |
"cpu-count": ["vcpus"], |
351 | 351 |
"disk-count": ["disk.count"], |
352 | 352 |
"disk-size": ["disk.size/ "], |
Also available in: Unified diff