def testDictOf(self): fn = ht.TDictOf(ht.TNonEmptyString, ht.TInt) self.assertTrue(fn({})) self.assertTrue(fn({"x": 123, "y": 999})) self.assertFalse(fn(None)) self.assertFalse(fn({1: "x"})) self.assertFalse(fn({"x": ""})) self.assertFalse(fn({"x": None})) self.assertFalse(fn({"": 8234}))
from ganeti import utils from ganeti import ht from ganeti import ssh from ganeti import pathutils from ganeti.tools import common _DATA_CHECK = ht.TStrictDict( False, True, { constants.SSHS_CLUSTER_NAME: ht.TNonEmptyString, constants.SSHS_NODE_DAEMON_CERTIFICATE: ht.TNonEmptyString, constants.SSHS_SSH_PUBLIC_KEYS: ht.TItems([ ht.TElemOf(constants.SSHS_ACTIONS), ht.TDictOf(ht.TNonEmptyString, ht.TListOf(ht.TNonEmptyString)) ]), constants.SSHS_SSH_AUTHORIZED_KEYS: ht.TItems([ ht.TElemOf(constants.SSHS_ACTIONS), ht.TDictOf(ht.TNonEmptyString, ht.TListOf(ht.TNonEmptyString)) ]), constants.SSHS_GENERATE: ht.TDictOf(ht.TNonEmptyString, ht.TString), }) class SshUpdateError(errors.GenericError): """Local class for reporting errors. """
from ganeti import cli from ganeti import constants from ganeti import errors from ganeti import pathutils from ganeti import utils from ganeti import serializer from ganeti import runtime from ganeti import ht from ganeti import ssconf _DATA_CHECK = ht.TStrictDict( False, True, { constants.NDS_CLUSTER_NAME: ht.TNonEmptyString, constants.NDS_NODE_DAEMON_CERTIFICATE: ht.TNonEmptyString, constants.NDS_SSCONF: ht.TDictOf(ht.TNonEmptyString, ht.TString), constants.NDS_START_NODE_DAEMON: ht.TBool, }) class SetupError(errors.GenericError): """Local class for reporting errors. """ def ParseOptions(): """Parses the options passed to the program. @return: Options and arguments