Revision e5ff1a47
b/lib/rapi/rlib2.py | ||
---|---|---|
56 | 56 |
# C0103: Invalid name, since the R_* names are not conforming |
57 | 57 |
|
58 | 58 |
from ganeti import opcodes |
59 |
from ganeti import objects |
|
59 | 60 |
from ganeti import http |
60 | 61 |
from ganeti import constants |
61 | 62 |
from ganeti import cli |
... | ... | |
825 | 826 |
allocations |
826 | 827 |
|
827 | 828 |
""" |
828 |
return (self.request_body, { |
|
829 |
if "instances" not in self.request_body: |
|
830 |
raise http.HttpBadRequest("Request is missing required 'instances' field" |
|
831 |
" in body") |
|
832 |
|
|
833 |
op_id = { |
|
834 |
"OP_ID": self.POST_OPCODE.OP_ID, # pylint: disable=E1101 |
|
835 |
} |
|
836 |
body = objects.FillDict(self.request_body, { |
|
837 |
"instances": [objects.FillDict(inst, op_id) |
|
838 |
for inst in self.request_body["instances"]], |
|
839 |
}) |
|
840 |
|
|
841 |
return (body, { |
|
829 | 842 |
"dry_run": self.dryRun(), |
830 | 843 |
}) |
831 | 844 |
|
b/test/ganeti.rapi.rlib2_unittest.py | ||
---|---|---|
1734 | 1734 |
self.assertEqual(result, cl.cluster_info) |
1735 | 1735 |
|
1736 | 1736 |
|
1737 |
class TestInstancesMultiAlloc(unittest.TestCase): |
|
1738 |
def testInstanceUpdate(self): |
|
1739 |
clfactory = _FakeClientFactory(_FakeClient) |
|
1740 |
data = { |
|
1741 |
"instances": [{ |
|
1742 |
"instance_name": "bar", |
|
1743 |
"mode": "create", |
|
1744 |
}, { |
|
1745 |
"instance_name": "foo", |
|
1746 |
"mode": "create", |
|
1747 |
}], |
|
1748 |
} |
|
1749 |
handler = _CreateHandler(rlib2.R_2_instances_multi_alloc, [], {}, data, |
|
1750 |
clfactory) |
|
1751 |
(body, _) = handler.GetPostOpInput() |
|
1752 |
self.assertTrue(compat.all([inst["OP_ID"] == handler.POST_OPCODE.OP_ID |
|
1753 |
for inst in body["instances"]])) |
|
1754 |
|
|
1755 |
|
|
1737 | 1756 |
if __name__ == '__main__': |
1738 | 1757 |
testutils.GanetiTestProgram() |
Also available in: Unified diff