Commit 884dc063 authored by Jose A. Lopes's avatar Jose A. Lopes

Move constants to the appropriate module

Move constants ALLOCATABLE_KEY and FAILED_KEY to the constants module.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 72cd5493
......@@ -36,7 +36,6 @@ from ganeti.masterd import iallocator
from ganeti import masterd
from ganeti import netutils
from ganeti import objects
from ganeti import opcodes
from ganeti import pathutils
from ganeti import rpc
from ganeti import utils
......@@ -1992,9 +1991,8 @@ class LUInstanceMultiAlloc(NoHooksLU):
"""
(allocatable, failed) = self.ia_result
return {
opcodes.OpInstanceMultiAlloc.ALLOCATABLE_KEY:
map(compat.fst, allocatable),
opcodes.OpInstanceMultiAlloc.FAILED_KEY: failed,
constants.ALLOCATABLE_KEY: map(compat.fst, allocatable),
constants.FAILED_KEY: failed,
}
def Exec(self, feedback_fn):
......
......@@ -2554,3 +2554,7 @@ MOND_TIME_INTERVAL = 5
# Do not re-export imported modules
del re, _vcsversion, _autoconf, socket, pathutils, compat
ALLOCATABLE_KEY = "allocatable"
FAILED_KEY = "failed"
......@@ -722,6 +722,6 @@ TJobIdListOnly = TStrictDict(True, True, {
TInstanceMultiAllocResponse = \
TStrictDict(True, True, {
constants.JOB_IDS_KEY: Comment("List of submitted jobs")(TJobIdList),
ALLOCATABLE_KEY: TListOf(TNonEmptyString),
FAILED_KEY: TListOf(TNonEmptyString)
constants.ALLOCATABLE_KEY: TListOf(TNonEmptyString),
constants.FAILED_KEY: TListOf(TNonEmptyString)
})
......@@ -1364,12 +1364,10 @@ class OpInstanceMultiAlloc(OpCode):
"List of instance create opcodes describing the instances to allocate"),
]
_JOB_LIST = ht.Comment("List of submitted jobs")(TJobIdList)
ALLOCATABLE_KEY = "allocatable"
FAILED_KEY = "allocatable"
OP_RESULT = ht.TStrictDict(True, True, {
constants.JOB_IDS_KEY: _JOB_LIST,
ALLOCATABLE_KEY: ht.TListOf(ht.TNonEmptyString),
FAILED_KEY: ht.TListOf(ht.TNonEmptyString),
constants.ALLOCATABLE_KEY: ht.TListOf(ht.TNonEmptyString),
constants.FAILED_KEY: ht.TListOf(ht.TNonEmptyString),
})
def __getstate__(self):
......
......@@ -503,8 +503,8 @@ class GanetiRapiClientTests(testutils.GanetiTestCase):
def testInstancesMultiAlloc(self):
response = {
constants.JOB_IDS_KEY: ["23423"],
opcodes.OpInstanceMultiAlloc.ALLOCATABLE_KEY: ["foobar"],
opcodes.OpInstanceMultiAlloc.FAILED_KEY: ["foobar2"],
constants.ALLOCATABLE_KEY: ["foobar"],
constants.FAILED_KEY: ["foobar2"],
}
self.rapi.AddResponse(serializer.DumpJson(response))
insts = [self.client.InstanceAllocation("create", "foobar",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment