From a7940300e87e1071283b2d20678b45d83f642f7c Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Mon, 4 Aug 2014 18:58:22 -0600 Subject: [PATCH 01/20] Added support for mutable and auto vis a vis raet changes --- salt/daemons/flo/core.py | 9 ++- salt/daemons/salting.py | 31 ++++++-- salt/daemons/test/minion.flo | 3 +- salt/daemons/test/test_saltkeep.py | 124 +++++++++++++++++------------ 4 files changed, 104 insertions(+), 63 deletions(-) diff --git a/salt/daemons/flo/core.py b/salt/daemons/flo/core.py index c4b0d2bdff..429cc4f572 100644 --- a/salt/daemons/flo/core.py +++ b/salt/daemons/flo/core.py @@ -110,7 +110,7 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): 'local': {'ipath': 'local', 'ival': {'name': 'master', 'main': False, - 'auto': None, + 'mutable': False, 'eid': 0, 'sigkey': None, 'prikey': None}}, @@ -134,8 +134,8 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): name = self.opts.value.get('id', self.local.data.name) sigkey = self.local.data.sigkey prikey = self.local.data.prikey - auto = self.local.data.auto main = self.local.data.main + mutable = self.opts.value.get('open_mode', self.local.data.mutable) eid = self.local.data.eid ha = (self.opts.value['interface'], self.opts.value['raet_port']) @@ -146,6 +146,7 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): eid=eid, name=name, main=main, + mutable=mutable, ha=ha, sigkey=sigkey, prikey=prikey) @@ -154,14 +155,14 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): keep = salting.SaltKeep(opts=self.opts.value, basedirpath=basedirpath, - stackname=name, - auto=auto) + stackname=name) self.stack.value = RoadStack( local=local, store=self.store, name=name, main=main, + mutable=mutable, keep=keep, txMsgs=txMsgs, rxMsgs=rxMsgs, diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index b2d57be3f4..e8e322d13b 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -35,9 +35,12 @@ class SaltKeep(Keep): estate.name.ext estate.name.ext ''' - LocalFields = ['uid', 'name', 'ha', 'main', 'sid', 'neid', 'sighex', 'prihex', 'auto', 'role'] - LocalDumpFields = ['uid', 'name', 'ha', 'main', 'sid', 'neid', 'role'] - RemoteFields = ['uid', 'name', 'ha', 'sid', 'joined', 'acceptance', 'verhex', 'pubhex', 'role'] + LocalFields = ['uid', 'name', 'ha', 'main', 'sid', 'neid', 'sighex', + 'prihex', 'auto', 'role', 'mutable'] + LocalDumpFields = ['uid', 'name', 'ha', 'main', 'sid', 'neid', 'role', + 'mutable'] + RemoteFields = ['uid', 'name', 'ha', 'sid', 'joined', 'acceptance', + 'verhex', 'pubhex', 'role'] RemoteDumpFields = ['uid', 'name', 'ha', 'sid', 'joined', 'role'] Auto = False #auto accept @@ -48,7 +51,10 @@ class SaltKeep(Keep): ''' basedirpath = basedirpath or os.path.join(opts['cache_dir'], 'raet') super(SaltKeep, self).__init__(prefix=prefix, basedirpath=basedirpath, **kwa) - self.auto = auto if auto is not None else opts['auto_accept'] + self.auto = (auto if auto is not None else + (raeting.autoModes.always if opts['open_mode'] else + (raeting.autoModes.once if opts['auto_accept'] else + raeting.autoModes.never))) self.saltRaetKey = RaetKey(opts) def loadLocalData(self): @@ -81,9 +87,11 @@ class SaltKeep(Keep): break if not keydata: - return None - - data.update(acceptance=raeting.ACCEPTANCES[status], + data.update(acceptance=None, + verhex=None, + pubhex=None) + else: + data.update(acceptance=raeting.ACCEPTANCES[status], verhex=keydata['verify'], pubhex=keydata['pub']) @@ -94,6 +102,10 @@ class SaltKeep(Keep): Load and Return the data from the all the remote estate files ''' keeps = super(SaltKeep, self).loadAllRemoteData() + for name, data in keeps.items(): + keeps[name].update(acceptance=None, + verhex=None, + pubhex=None) for status, mids in self.saltRaetKey.list_keys().items(): for mid in mids: @@ -122,6 +134,7 @@ class SaltKeep(Keep): ('name', local.name), ('ha', local.ha), ('main', local.main), + ('mutable', local.mutable), ('sid', local.sid), ('neid', local.neid), ('role', local.role), @@ -146,7 +159,9 @@ class SaltKeep(Keep): if self.verifyRemoteData(data, remoteFields=self.RemoteDumpFields): self.dumpRemoteData(data, remote.name) - self.saltRaetKey.status(remote.role, + if remote.pubber.keyhex and remote.verfer.keyhex: + # kludge to persist the keys since no way to write + self.saltRaetKey.status(remote.role, remote.pubber.keyhex, remote.verfer.keyhex) diff --git a/salt/daemons/test/minion.flo b/salt/daemons/test/minion.flo index 8ffafd9a9f..6b1fe9efc2 100644 --- a/salt/daemons/test/minion.flo +++ b/salt/daemons/test/minion.flo @@ -12,7 +12,8 @@ init .raet.udp.stack.local to eid 0 name "minion" host "" port 7531 main false framer minionudpstack be active first start frame start - do salt raet road stack per inode ".raet.udp.stack" + enter + do salt raet road stack setup per inode ".raet.udp.stack" exit do salt raet road stack closer per inode ".raet.udp.stack." diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index adc74a9b40..13dae51c16 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -115,11 +115,12 @@ class BasicTestCase(unittest.TestCase): return data - def createRoadStack(self, data, keep, eid=0, main=None, ha=None): + def createRoadStack(self, data, keep, eid=0, main=None, ha=None, mutable=None): ''' Creates stack and local estate from data with local estate.eid = eid stack.main = main + stack.mutable = mutable stack.auto = auto stack.name = data['name'] local estate.name = data['name'] @@ -138,6 +139,7 @@ class BasicTestCase(unittest.TestCase): stack = stacking.RoadStack(name=data['name'], local=local, main=main, + mutable=mutable, store=self.store, keep=keep) @@ -211,16 +213,17 @@ class BasicTestCase(unittest.TestCase): main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertFalse(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.never) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': False, + 'auto': raeting.autoModes.never, 'role': mainData['role'], }) @@ -309,7 +312,7 @@ class BasicTestCase(unittest.TestCase): other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) - self.assertFalse(other.keep.auto) + self.assertIs(other.keep.auto, raeting.autoModes.never) self.assertDictEqual(other.keep.loadLocalData(), { @@ -317,11 +320,12 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': False, + 'auto': raeting.autoModes.never, 'role': otherData['role'], }) @@ -405,16 +409,17 @@ class BasicTestCase(unittest.TestCase): main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertTrue(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.always) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.always, 'role': mainData['role'], }) @@ -501,7 +506,7 @@ class BasicTestCase(unittest.TestCase): other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) - self.assertTrue(other.keep.auto) + self.assertIs(other.keep.auto,raeting.autoModes.always) self.assertDictEqual(other.keep.loadLocalData(), { @@ -509,11 +514,12 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.always, 'role': otherData['role'], }) @@ -597,16 +603,17 @@ class BasicTestCase(unittest.TestCase): main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertTrue(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.once) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.once, 'role': mainData['role'], }) @@ -693,7 +700,7 @@ class BasicTestCase(unittest.TestCase): other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) - self.assertTrue(other.keep.auto) + self.assertIs(other.keep.auto, raeting.autoModes.once) self.assertDictEqual(other.keep.loadLocalData(), { @@ -701,11 +708,12 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.once, 'role': otherData['role'], }) @@ -791,16 +799,17 @@ class BasicTestCase(unittest.TestCase): main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertFalse(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.never) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': False, + 'auto': raeting.autoModes.never, 'role': mainData['role'], }) @@ -872,7 +881,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(main.local.uid, 1) self.assertEqual(main.local.main, True) self.assertEqual(main.local.role, mainData['role']) - self.assertFalse(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.never) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertEqual(main.local.priver.keyhex, mainData['prihex']) self.assertEqual(main.local.signer.keyhex, mainData['sighex']) @@ -917,16 +926,17 @@ class BasicTestCase(unittest.TestCase): main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertTrue(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.always) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.always, 'role': mainData['role'], }) @@ -996,7 +1006,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(main.local.uid, 1) self.assertEqual(main.local.main, True) self.assertEqual(main.local.role, mainData['role']) - self.assertTrue(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.always) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertEqual(main.local.priver.keyhex, mainData['prihex']) self.assertEqual(main.local.signer.keyhex, mainData['sighex']) @@ -1042,16 +1052,17 @@ class BasicTestCase(unittest.TestCase): main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertTrue(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.once) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.once, 'role': mainData['role'], }) @@ -1124,7 +1135,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(main.local.uid, 1) self.assertEqual(main.local.main, True) self.assertEqual(main.local.role, mainData['role']) - self.assertTrue(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.once) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertEqual(main.local.priver.keyhex, mainData['prihex']) self.assertEqual(main.local.signer.keyhex, mainData['sighex']) @@ -1169,16 +1180,17 @@ class BasicTestCase(unittest.TestCase): main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertFalse(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.never) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': False, + 'auto': raeting.autoModes.never, 'role': mainData['role'], }) @@ -1204,18 +1216,19 @@ class BasicTestCase(unittest.TestCase): other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) - self.assertFalse(other.keep.auto) + self.assertIs(other.keep.auto, raeting.autoModes.never) self.assertDictEqual(other.keep.loadLocalData(), { 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': False, + 'auto': raeting.autoModes.never, 'role': otherData['role'], }) @@ -1283,16 +1296,17 @@ class BasicTestCase(unittest.TestCase): main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertTrue(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.always) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.always, 'role': mainData['role'], }) @@ -1318,18 +1332,19 @@ class BasicTestCase(unittest.TestCase): other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) - self.assertTrue(other.keep.auto) + self.assertIs(other.keep.auto, raeting.autoModes.always) self.assertDictEqual(other.keep.loadLocalData(), { 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.always, 'role': otherData['role'], }) @@ -1392,17 +1407,18 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertTrue(main.keep.auto) + self.assertEqual(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertIs(main.keep.auto, raeting.autoModes.once) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.once, 'role': mainData['role'], }) @@ -1434,11 +1450,12 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.once, 'role': otherData['role'], }) @@ -1502,16 +1519,17 @@ class BasicTestCase(unittest.TestCase): main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertFalse(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.never) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': False, + 'auto': raeting.autoModes.never, 'role': mainData['role'], }) @@ -1539,18 +1557,19 @@ class BasicTestCase(unittest.TestCase): other1.name, other1.keep.dirpath)) self.assertTrue(other1.keep.dirpath.endswith('other1/raet/other1')) self.assertEqual(other1.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) - self.assertFalse(other1.keep.auto) + self.assertIs(other1.keep.auto, raeting.autoModes.never) self.assertDictEqual(other1.keep.loadLocalData(), { 'uid': 0, 'name': other1Data['name'], 'ha': ['0.0.0.0', 7531], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], - 'auto': False, + 'auto': raeting.autoModes.never, 'role': other1Data['role'], }) @@ -1604,18 +1623,19 @@ class BasicTestCase(unittest.TestCase): other2.name, other2.keep.dirpath)) self.assertTrue(other2.keep.dirpath.endswith('other2/raet/other2')) self.assertEqual(other2.local.ha, ("0.0.0.0", 7532)) - self.assertFalse(other2.keep.auto) + self.assertIs(other2.keep.auto, raeting.autoModes.never) self.assertDictEqual(other2.keep.loadLocalData(), { 'uid': 0, 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], - 'auto': False, + 'auto': raeting.autoModes.never, 'role': other2Data['role'], }) @@ -1623,8 +1643,8 @@ class BasicTestCase(unittest.TestCase): self.join(other2, main) self.assertEqual(len(main.transactions), 0) # rejected since not same keys self.assertEqual(other2.remotes.values()[0].joined, False) - self.assertEqual(len(main.remotes), 2) - main.removeRemote(main.nameRemotes[other2.local.name], clear=True) + self.assertEqual(len(main.remotes), 1) + #main.removeRemote(main.nameRemotes[other2.local.name], clear=True) other2.server.close() other2.keep.clearAllDir() path = os.path.join(main.keep.remotedirpath, @@ -1661,18 +1681,19 @@ class BasicTestCase(unittest.TestCase): other2.name, other2.keep.dirpath)) self.assertTrue(other2.keep.dirpath.endswith('other2/raet/other2')) self.assertEqual(other2.local.ha, ("0.0.0.0", 7532)) - self.assertFalse(other2.keep.auto) + self.assertIs(other2.keep.auto, raeting.autoModes.never) self.assertDictEqual(other2.keep.loadLocalData(), { 'uid': 0, 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], - 'auto': False, + 'auto': raeting.autoModes.never, 'role': other2Data['role'], }) @@ -1743,16 +1764,17 @@ class BasicTestCase(unittest.TestCase): main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) - self.assertTrue(main.keep.auto) + self.assertIs(main.keep.auto, raeting.autoModes.once) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'main': True, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': True, + 'auto': raeting.autoModes.once, 'role': mainData['role'], }) @@ -1780,18 +1802,19 @@ class BasicTestCase(unittest.TestCase): other1.name, other1.keep.dirpath)) self.assertTrue(other1.keep.dirpath.endswith('other1/raet/other1')) self.assertEqual(other1.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) - self.assertTrue(other1.keep.auto) + self.assertIs(other1.keep.auto, raeting.autoModes.once) self.assertDictEqual(other1.keep.loadLocalData(), { 'uid': 0, 'name': other1Data['name'], 'ha': ['0.0.0.0', 7531], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], - 'auto': True, + 'auto': raeting.autoModes.once, 'role': other1Data['role'], }) @@ -1844,18 +1867,19 @@ class BasicTestCase(unittest.TestCase): other2.name, other2.keep.dirpath)) self.assertTrue(other2.keep.dirpath.endswith('other2/raet/other2')) self.assertEqual(other2.local.ha, ("0.0.0.0", 7532)) - self.assertFalse(other2.keep.auto) + self.assertIs(other2.keep.auto, raeting.autoModes.never) self.assertDictEqual(other2.keep.loadLocalData(), { 'uid': 0, 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], 'main': None, + 'mutable': None, 'sid': 0, 'neid': 1, 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], - 'auto': False, + 'auto': raeting.autoModes.never, 'role': other2Data['role'], }) From 9b7342d3cafd09f8be16e76b2ed703946bf530be Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Tue, 19 Aug 2014 10:24:49 -0600 Subject: [PATCH 02/20] Refactor to normalize use uid instead of eid and yid in preparation for raetpeer --- salt/cli/caller.py | 4 +- salt/client/raet/__init__.py | 8 +-- salt/daemons/flo/core.py | 20 +++---- salt/daemons/flo/worker.py | 4 +- salt/daemons/test/test_saltkeep.py | 86 +++++++++++++++--------------- salt/transport/__init__.py | 4 +- salt/utils/raetevent.py | 4 +- 7 files changed, 65 insertions(+), 65 deletions(-) diff --git a/salt/cli/caller.py b/salt/cli/caller.py index 928577ebfa..1e146bedd3 100644 --- a/salt/cli/caller.py +++ b/salt/cli/caller.py @@ -274,8 +274,8 @@ class RAETCaller(ZeroMQCaller): ''' mid = opts['id'] sockdirpath = opts['sock_dir'] - yid = nacling.uuid(size=18) - name = 'caller' + yid + uid = nacling.uuid(size=18) + name = 'caller' + uid stack = LaneStack(name=name, lanename=mid, sockdirpath=sockdirpath) diff --git a/salt/client/raet/__init__.py b/salt/client/raet/__init__.py index 818f76cc07..6c4fa61a80 100644 --- a/salt/client/raet/__init__.py +++ b/salt/client/raet/__init__.py @@ -51,17 +51,17 @@ class LocalClient(salt.client.LocalClient): jid=jid, timeout=timeout, **kwargs) - yid = nacling.uuid(size=18) + uid = nacling.uuid(size=18) stack = LaneStack( - name=('client' + yid), - yid=yid, + name=('client' + uid), + uid=uid, lanename='master', sockdirpath=self.opts['sock_dir']) stack.Pk = raeting.packKinds.pack router_yard = RemoteYard( stack=stack, lanename='master', - yid=0, + uid=0, name='manor', dirpath=self.opts['sock_dir']) stack.addRemote(router_yard) diff --git a/salt/daemons/flo/core.py b/salt/daemons/flo/core.py index 429cc4f572..3e16210f27 100644 --- a/salt/daemons/flo/core.py +++ b/salt/daemons/flo/core.py @@ -143,7 +143,7 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): basedirpath = os.path.abspath(os.path.join(self.opts.value['cachedir'], 'raet')) local = LocalEstate( - eid=eid, + uid=eid, name=name, main=main, mutable=mutable, @@ -581,11 +581,11 @@ class SaltManorLaneSetup(ioflo.base.deeding.Deed): #name = "{0}{1}".format(self.opts.value.get('id', self.local.data.name), 'lane') name = 'manor' lanename = self.opts.value.get('id', self.local.data.lanename) - yid = self.local.data.yid + #yid = self.local.data.yid self.stack.value = LaneStack( name=name, lanename=lanename, - yid=0, + uid=0, sockdirpath=self.opts.value['sock_dir']) self.stack.value.Pk = raeting.packKinds.pack self.event_yards.value = set() @@ -771,8 +771,8 @@ class Router(ioflo.base.deeding.Deed): pass elif d_estate != self.udp_stack.value.local: # Forward to the correct estate - eid = self.udp_stack.value.fetchUidByName(d_estate) - self.udp_stack.value.message(msg, eid) + uid = self.udp_stack.value.fetchUidByName(d_estate) + self.udp_stack.value.message(msg, uid) return if d_share == 'pub_ret': if msg.get('__worker_verify') == self.worker_verify.value: @@ -892,13 +892,13 @@ class SaltPublisher(ioflo.base.deeding.Deed): # only publish to available minions by intersecting sets minions = self.availables.value & set(self.stack.value.nameRemotes.keys()) for minion in minions: - eid = self.stack.value.fetchUidByName(minion) - if eid: + uid = self.stack.value.fetchUidByName(minion) + if uid: route = { 'dst': (minion, None, 'fun'), 'src': (self.stack.value.local.name, None, None)} msg = {'route': route, 'pub': pub_data['pub']} - self.stack.value.message(msg, eid) + self.stack.value.message(msg, uid) def action(self): ''' @@ -944,8 +944,8 @@ class NixExecutor(ioflo.base.deeding.Deed): ''' mid = self.opts['id'] - yid = nacling.uuid(size=18) - name = 'jobber' + yid + uid = nacling.uuid(size=18) + name = 'jobber' + uid stack = LaneStack( name=name, lanename=mid, diff --git a/salt/daemons/flo/worker.py b/salt/daemons/flo/worker.py index 4ce5ac851c..784e984246 100644 --- a/salt/daemons/flo/worker.py +++ b/salt/daemons/flo/worker.py @@ -118,12 +118,12 @@ class WorkerSetup(ioflo.base.deeding.Deed): self.stack.value = LaneStack( name=name, lanename=lanename, - yid=self.yid.value, + uid=self.yid.value, sockdirpath=self.opts.value['sock_dir']) self.stack.value.Pk = raeting.packKinds.pack manor_yard = RemoteYard( stack=self.stack.value, - yid=0, + uid=0, name='manor', lanename=lanename, dirpath=self.opts.value['sock_dir']) diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index 13dae51c16..664f07ca0a 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -115,10 +115,10 @@ class BasicTestCase(unittest.TestCase): return data - def createRoadStack(self, data, keep, eid=0, main=None, ha=None, mutable=None): + def createRoadStack(self, data, keep, uid=0, main=None, ha=None, mutable=None): ''' Creates stack and local estate from data with - local estate.eid = eid + local estate.uid = uid stack.main = main stack.mutable = mutable stack.auto = auto @@ -129,7 +129,7 @@ class BasicTestCase(unittest.TestCase): returns stack ''' - local = estating.LocalEstate(eid=eid, + local = estating.LocalEstate(uid=uid, name=data['name'], ha=ha, sigkey=data['sighex'], @@ -204,7 +204,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -229,7 +229,7 @@ class BasicTestCase(unittest.TestCase): data1 = self.createRoadData(name='remote1', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - eid=3, + uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -239,7 +239,7 @@ class BasicTestCase(unittest.TestCase): data2 = self.createRoadData(name='remote2', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - eid=4, + uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -303,7 +303,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - eid=0, + uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -331,7 +331,7 @@ class BasicTestCase(unittest.TestCase): data3 = self.createRoadData(name='remote3', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - eid=3, + uid=3, name=data3['name'], ha=('127.0.0.1', 7534), verkey=data3['verhex'], @@ -341,7 +341,7 @@ class BasicTestCase(unittest.TestCase): data4 = self.createRoadData(name='remote4', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - eid=4, + uid=4, name=data4['name'], ha=('127.0.0.1', 7535), verkey=data4['verhex'], @@ -400,7 +400,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -425,7 +425,7 @@ class BasicTestCase(unittest.TestCase): data1 = self.createRoadData(name='remote1', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - eid=3, + uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -435,7 +435,7 @@ class BasicTestCase(unittest.TestCase): data2 = self.createRoadData(name='remote2', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - eid=4, + uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -497,7 +497,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - eid=0, + uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -525,7 +525,7 @@ class BasicTestCase(unittest.TestCase): data3 = self.createRoadData(name='remote3', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - eid=3, + uid=3, name=data3['name'], ha=('127.0.0.1', 7534), verkey=data3['verhex'], @@ -535,7 +535,7 @@ class BasicTestCase(unittest.TestCase): data4 = self.createRoadData(name='remote4', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - eid=4, + uid=4, name=data4['name'], ha=('127.0.0.1', 7535), verkey=data4['verhex'], @@ -594,7 +594,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -619,7 +619,7 @@ class BasicTestCase(unittest.TestCase): data1 = self.createRoadData(name='remote1', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - eid=3, + uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -629,7 +629,7 @@ class BasicTestCase(unittest.TestCase): data2 = self.createRoadData(name='remote2', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - eid=4, + uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -691,7 +691,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - eid=0, + uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -719,7 +719,7 @@ class BasicTestCase(unittest.TestCase): data3 = self.createRoadData(name='remote3', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - eid=3, + uid=3, name=data3['name'], ha=('127.0.0.1', 7534), verkey=data3['verhex'], @@ -729,7 +729,7 @@ class BasicTestCase(unittest.TestCase): data4 = self.createRoadData(name='remote4', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - eid=4, + uid=4, name=data4['name'], ha=('127.0.0.1', 7535), verkey=data4['verhex'], @@ -790,7 +790,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -818,7 +818,7 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - eid=3, + uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -831,7 +831,7 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - eid=4, + uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -917,7 +917,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -945,7 +945,7 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - eid=3, + uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -958,7 +958,7 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - eid=4, + uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -1043,7 +1043,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1071,7 +1071,7 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - eid=3, + uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -1084,7 +1084,7 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - eid=4, + uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -1171,7 +1171,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1207,7 +1207,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - eid=0, + uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -1287,7 +1287,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1323,7 +1323,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - eid=0, + uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -1399,7 +1399,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1435,7 +1435,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - eid=0, + uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -1510,7 +1510,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1548,7 +1548,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(other1Keep.loadAllRemoteData(), {}) other1 = self.createRoadStack(data=other1Data, - eid=0, + uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=other1Keep) @@ -1614,7 +1614,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(other2Keep.loadAllRemoteData(), {}) other2 = self.createRoadStack(data=other2Data, - eid=0, + uid=0, main=None, ha=("", 7532), keep=other2Keep) @@ -1672,7 +1672,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(other2Keep.loadAllRemoteData(), {}) other2 = self.createRoadStack(data=other2Data, - eid=0, + uid=0, main=None, ha=("", 7532), keep=other2Keep) @@ -1755,7 +1755,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - eid=1, + uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1793,7 +1793,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(other1Keep.loadAllRemoteData(), {}) other1 = self.createRoadStack(data=other1Data, - eid=0, + uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=other1Keep) @@ -1858,7 +1858,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(other2Keep.loadAllRemoteData(), {}) other2 = self.createRoadStack(data=other2Data, - eid=0, + uid=0, main=None, ha=("", 7532), keep=other2Keep) diff --git a/salt/transport/__init__.py b/salt/transport/__init__.py index 22faf2edcc..29b0d76d4d 100644 --- a/salt/transport/__init__.py +++ b/salt/transport/__init__.py @@ -73,8 +73,8 @@ class RAETChannel(Channel): ''' import wingdbstub mid = self.opts['id'] - yid = nacling.uuid(size=18) - name = 'channel' + yid + uid = nacling.uuid(size=18) + name = 'channel' + uid stack = LaneStack(name=name, lanename=mid, sockdirpath=self.opts['sock_dir']) diff --git a/salt/utils/raetevent.py b/salt/utils/raetevent.py index 9ef6d089b6..87268d4415 100644 --- a/salt/utils/raetevent.py +++ b/salt/utils/raetevent.py @@ -47,14 +47,14 @@ class SaltEvent(object): self.connected = False self.stack = LaneStack( name=name, - yid=self.yid, + uid=self.yid, lanename=self.node, sockdirpath=self.sock_dir) self.stack.Pk = raeting.packKinds.pack self.router_yard = RemoteYard( stack=self.stack, lanename=self.node, - yid=0, + uid=0, name='manor', dirpath=self.sock_dir) self.stack.addRemote(self.router_yard) From eb83c27d25c58f05d9a4f1c4fc0d442a5c75b0b0 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Tue, 19 Aug 2014 10:52:59 -0600 Subject: [PATCH 03/20] updated neid to nuid --- salt/daemons/salting.py | 6 ++-- salt/daemons/test/test_saltkeep.py | 44 +++++++++++++++--------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index e8e322d13b..936267f4a6 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -35,9 +35,9 @@ class SaltKeep(Keep): estate.name.ext estate.name.ext ''' - LocalFields = ['uid', 'name', 'ha', 'main', 'sid', 'neid', 'sighex', + LocalFields = ['uid', 'name', 'ha', 'main', 'sid', 'nuid', 'sighex', 'prihex', 'auto', 'role', 'mutable'] - LocalDumpFields = ['uid', 'name', 'ha', 'main', 'sid', 'neid', 'role', + LocalDumpFields = ['uid', 'name', 'ha', 'main', 'sid', 'nuid', 'role', 'mutable'] RemoteFields = ['uid', 'name', 'ha', 'sid', 'joined', 'acceptance', 'verhex', 'pubhex', 'role'] @@ -136,7 +136,7 @@ class SaltKeep(Keep): ('main', local.main), ('mutable', local.mutable), ('sid', local.sid), - ('neid', local.neid), + ('nuid', local.nuid), ('role', local.role), ]) if self.verifyLocalData(data, localFields = self.LocalDumpFields): diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index 664f07ca0a..69b6c21f60 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -220,7 +220,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -322,7 +322,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.never, @@ -416,7 +416,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.always, @@ -516,7 +516,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.always, @@ -610,7 +610,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -710,7 +710,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.once, @@ -806,7 +806,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -933,7 +933,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.always, @@ -1059,7 +1059,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -1187,7 +1187,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -1225,7 +1225,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.never, @@ -1303,7 +1303,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.always, @@ -1341,7 +1341,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.always, @@ -1415,7 +1415,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -1452,7 +1452,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.once, @@ -1526,7 +1526,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -1566,7 +1566,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'auto': raeting.autoModes.never, @@ -1632,7 +1632,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], 'auto': raeting.autoModes.never, @@ -1690,7 +1690,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'auto': raeting.autoModes.never, @@ -1771,7 +1771,7 @@ class BasicTestCase(unittest.TestCase): 'main': True, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -1811,7 +1811,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'auto': raeting.autoModes.once, @@ -1876,7 +1876,7 @@ class BasicTestCase(unittest.TestCase): 'main': None, 'mutable': None, 'sid': 0, - 'neid': 1, + 'nuid': 1, 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], 'auto': raeting.autoModes.never, From 1fc13fd32c0086a090362f3b8aa92406c4d11983 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Tue, 19 Aug 2014 15:20:13 -0600 Subject: [PATCH 04/20] Updated to latest Raet with stachname in keep and change in how to create stacks --- salt/daemons/flo/core.py | 16 ++--- salt/daemons/salting.py | 5 +- salt/daemons/test/test_saltkeep.py | 101 ++++++++++++----------------- 3 files changed, 52 insertions(+), 70 deletions(-) diff --git a/salt/daemons/flo/core.py b/salt/daemons/flo/core.py index bda459876e..e3d477affc 100644 --- a/salt/daemons/flo/core.py +++ b/salt/daemons/flo/core.py @@ -142,14 +142,6 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): basedirpath = os.path.abspath(os.path.join(self.opts.value['cachedir'], 'raet')) - local = LocalEstate( - uid=eid, - name=name, - main=main, - mutable=mutable, - ha=ha, - sigkey=sigkey, - prikey=prikey) txMsgs = self.txmsgs.value rxMsgs = self.rxmsgs.value @@ -158,12 +150,16 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): stackname=name) self.stack.value = RoadStack( - local=local, store=self.store, name=name, + keep=keep, + localname=name, + uid=eid, + ha=ha, + sigkey=sigkey, + prikey=prikey, main=main, mutable=mutable, - keep=keep, txMsgs=txMsgs, rxMsgs=rxMsgs, period=3.0, diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index 936267f4a6..e2bef31658 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -36,9 +36,9 @@ class SaltKeep(Keep): estate.name.ext ''' LocalFields = ['uid', 'name', 'ha', 'main', 'sid', 'nuid', 'sighex', - 'prihex', 'auto', 'role', 'mutable'] + 'prihex', 'auto', 'role', 'mutable', 'stackname'] LocalDumpFields = ['uid', 'name', 'ha', 'main', 'sid', 'nuid', 'role', - 'mutable'] + 'mutable', 'stackname'] RemoteFields = ['uid', 'name', 'ha', 'sid', 'joined', 'acceptance', 'verhex', 'pubhex', 'role'] RemoteDumpFields = ['uid', 'name', 'ha', 'sid', 'joined', 'role'] @@ -137,6 +137,7 @@ class SaltKeep(Keep): ('mutable', local.mutable), ('sid', local.sid), ('nuid', local.nuid), + ('stackname', local.stack.name), ('role', local.role), ]) if self.verifyLocalData(data, localFields = self.LocalDumpFields): diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index 69b6c21f60..0d3897a7db 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -129,19 +129,18 @@ class BasicTestCase(unittest.TestCase): returns stack ''' - local = estating.LocalEstate(uid=uid, - name=data['name'], - ha=ha, - sigkey=data['sighex'], - prikey=data['prihex'], - role=data['role']) - stack = stacking.RoadStack(name=data['name'], - local=local, + stack = stacking.RoadStack(store=self.store, + name=data['name'], + keep=keep, + localname=data['name'], + uid=uid, + ha=ha, main=main, mutable=mutable, - store=self.store, - keep=keep) + role=data['role'], + sigkey=data['sighex'], + prikey=data['prihex'],) return stack @@ -221,6 +220,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -233,9 +233,7 @@ class BasicTestCase(unittest.TestCase): name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], - pubkey=data1['pubhex'], - period=main.period, - offset=main.offset, )) + pubkey=data1['pubhex'],)) data2 = self.createRoadData(name='remote2', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, @@ -243,9 +241,7 @@ class BasicTestCase(unittest.TestCase): name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], - pubkey=data2['pubhex'], - period=main.period, - offset=main.offset,)) + pubkey=data2['pubhex'],)) main.dumpRemotes() @@ -323,6 +319,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.never, @@ -335,9 +332,7 @@ class BasicTestCase(unittest.TestCase): name=data3['name'], ha=('127.0.0.1', 7534), verkey=data3['verhex'], - pubkey=data3['pubhex'], - period=main.period, - offset=main.offset,)) + pubkey=data3['pubhex'],)) data4 = self.createRoadData(name='remote4', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, @@ -345,9 +340,7 @@ class BasicTestCase(unittest.TestCase): name=data4['name'], ha=('127.0.0.1', 7535), verkey=data4['verhex'], - pubkey=data4['pubhex'], - period=main.period, - offset=main.offset,)) + pubkey=data4['pubhex'],)) other.dumpRemotes() self.assertDictEqual(other.keep.loadAllRemoteData(), @@ -417,6 +410,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.always, @@ -429,9 +423,7 @@ class BasicTestCase(unittest.TestCase): name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], - pubkey=data1['pubhex'], - period=main.period, - offset=main.offset, )) + pubkey=data1['pubhex'],)) data2 = self.createRoadData(name='remote2', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, @@ -439,9 +431,7 @@ class BasicTestCase(unittest.TestCase): name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], - pubkey=data2['pubhex'], - period=main.period, - offset=main.offset,)) + pubkey=data2['pubhex'],)) main.dumpRemotes() @@ -517,6 +507,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.always, @@ -529,9 +520,7 @@ class BasicTestCase(unittest.TestCase): name=data3['name'], ha=('127.0.0.1', 7534), verkey=data3['verhex'], - pubkey=data3['pubhex'], - period=main.period, - offset=main.offset,)) + pubkey=data3['pubhex'],)) data4 = self.createRoadData(name='remote4', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, @@ -539,9 +528,7 @@ class BasicTestCase(unittest.TestCase): name=data4['name'], ha=('127.0.0.1', 7535), verkey=data4['verhex'], - pubkey=data4['pubhex'], - period=main.period, - offset=main.offset,)) + pubkey=data4['pubhex'],)) other.dumpRemotes() self.assertDictEqual(other.keep.loadAllRemoteData(), @@ -611,6 +598,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -623,9 +611,7 @@ class BasicTestCase(unittest.TestCase): name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], - pubkey=data1['pubhex'], - period=main.period, - offset=main.offset, )) + pubkey=data1['pubhex'],)) data2 = self.createRoadData(name='remote2', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, @@ -633,9 +619,7 @@ class BasicTestCase(unittest.TestCase): name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], - pubkey=data2['pubhex'], - period=main.period, - offset=main.offset,)) + pubkey=data2['pubhex'],)) main.dumpRemotes() @@ -711,6 +695,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.once, @@ -723,9 +708,7 @@ class BasicTestCase(unittest.TestCase): name=data3['name'], ha=('127.0.0.1', 7534), verkey=data3['verhex'], - pubkey=data3['pubhex'], - period=main.period, - offset=main.offset,)) + pubkey=data3['pubhex'],)) data4 = self.createRoadData(name='remote4', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, @@ -733,9 +716,7 @@ class BasicTestCase(unittest.TestCase): name=data4['name'], ha=('127.0.0.1', 7535), verkey=data4['verhex'], - pubkey=data4['pubhex'], - period=main.period, - offset=main.offset,)) + pubkey=data4['pubhex'],)) other.dumpRemotes() self.assertDictEqual(other.keep.loadAllRemoteData(), @@ -807,6 +788,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -823,8 +805,6 @@ class BasicTestCase(unittest.TestCase): ha=('127.0.0.1', 7532), verkey=data1['verhex'], pubkey=data1['pubhex'], - period=main.period, - offset=main.offset, role=data1['role']) ) data2 = self.createRoadData(name='remote2', @@ -836,8 +816,6 @@ class BasicTestCase(unittest.TestCase): ha=('127.0.0.1', 7533), verkey=data2['verhex'], pubkey=data2['pubhex'], - period=main.period, - offset=main.offset, role=data2['role']) ) main.dumpRemotes() @@ -934,6 +912,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.always, @@ -950,8 +929,6 @@ class BasicTestCase(unittest.TestCase): ha=('127.0.0.1', 7532), verkey=data1['verhex'], pubkey=data1['pubhex'], - period=main.period, - offset=main.offset, role=data1['role']) ) data2 = self.createRoadData(name='remote2', @@ -963,8 +940,6 @@ class BasicTestCase(unittest.TestCase): ha=('127.0.0.1', 7533), verkey=data2['verhex'], pubkey=data2['pubhex'], - period=main.period, - offset=main.offset, role=data2['role']) ) main.dumpRemotes() @@ -1060,6 +1035,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -1076,8 +1052,6 @@ class BasicTestCase(unittest.TestCase): ha=('127.0.0.1', 7532), verkey=data1['verhex'], pubkey=data1['pubhex'], - period=main.period, - offset=main.offset, role=data1['role']) ) data2 = self.createRoadData(name='remote2', @@ -1089,8 +1063,6 @@ class BasicTestCase(unittest.TestCase): ha=('127.0.0.1', 7533), verkey=data2['verhex'], pubkey=data2['pubhex'], - period=main.period, - offset=main.offset, role=data2['role']) ) main.dumpRemotes() @@ -1188,6 +1160,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -1226,6 +1199,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.never, @@ -1304,6 +1278,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.always, @@ -1342,6 +1317,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.always, @@ -1416,6 +1392,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -1453,6 +1430,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.once, @@ -1527,6 +1505,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -1567,6 +1546,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': other1Data['name'], 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'auto': raeting.autoModes.never, @@ -1633,6 +1613,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': other2Data['name'], 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], 'auto': raeting.autoModes.never, @@ -1691,6 +1672,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': other2Data['name'], 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'auto': raeting.autoModes.never, @@ -1772,6 +1754,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -1812,6 +1795,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': other1Data['name'], 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'auto': raeting.autoModes.once, @@ -1877,6 +1861,7 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, + 'stackname': other2Data['name'], 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], 'auto': raeting.autoModes.never, From 45d5ff6b767d44412e3f1c11726423da48e19b74 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Tue, 19 Aug 2014 16:35:15 -0600 Subject: [PATCH 05/20] updated SaltKeep nuid now stack attribute --- salt/daemons/salting.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index e2bef31658..801313d35a 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -35,10 +35,10 @@ class SaltKeep(Keep): estate.name.ext estate.name.ext ''' - LocalFields = ['uid', 'name', 'ha', 'main', 'sid', 'nuid', 'sighex', - 'prihex', 'auto', 'role', 'mutable', 'stackname'] - LocalDumpFields = ['uid', 'name', 'ha', 'main', 'sid', 'nuid', 'role', - 'mutable', 'stackname'] + LocalFields = ['uid', 'name', 'ha', 'main', 'sid', 'mutable', + 'nuid', 'stackname', 'auto', 'role', 'sighex', 'prihex'] + LocalDumpFields = ['uid', 'name', 'ha', 'main', 'sid', 'mutable', + 'nuid', 'stackname', 'role'] RemoteFields = ['uid', 'name', 'ha', 'sid', 'joined', 'acceptance', 'verhex', 'pubhex', 'role'] RemoteDumpFields = ['uid', 'name', 'ha', 'sid', 'joined', 'role'] @@ -136,7 +136,7 @@ class SaltKeep(Keep): ('main', local.main), ('mutable', local.mutable), ('sid', local.sid), - ('nuid', local.nuid), + ('nuid', local.stack.nuid), ('stackname', local.stack.name), ('role', local.role), ]) From 20a0dca6c745155ceb7a0f02027fa3ed358e8e3b Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Tue, 19 Aug 2014 20:37:34 -0600 Subject: [PATCH 06/20] Revert no stackname persisted use local.name --- salt/daemons/flo/core.py | 28 +++++++++++++--------------- salt/daemons/salting.py | 5 ++--- salt/daemons/test/test_saltkeep.py | 23 ----------------------- 3 files changed, 15 insertions(+), 41 deletions(-) diff --git a/salt/daemons/flo/core.py b/salt/daemons/flo/core.py index e3d477affc..a7bc5e1726 100644 --- a/salt/daemons/flo/core.py +++ b/salt/daemons/flo/core.py @@ -149,21 +149,19 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): basedirpath=basedirpath, stackname=name) - self.stack.value = RoadStack( - store=self.store, - name=name, - keep=keep, - localname=name, - uid=eid, - ha=ha, - sigkey=sigkey, - prikey=prikey, - main=main, - mutable=mutable, - txMsgs=txMsgs, - rxMsgs=rxMsgs, - period=3.0, - offset=0.5) + self.stack.value = RoadStack(store=self.store, + keep=keep, + name=name, + uid=eid, + ha=ha, + sigkey=sigkey, + prikey=prikey, + main=main, + mutable=mutable, + txMsgs=txMsgs, + rxMsgs=rxMsgs, + period=3.0, + offset=0.5) class SaltRaetRoadStackCloser(ioflo.base.deeding.Deed): diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index 801313d35a..0e54e95a8d 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -36,9 +36,9 @@ class SaltKeep(Keep): estate.name.ext ''' LocalFields = ['uid', 'name', 'ha', 'main', 'sid', 'mutable', - 'nuid', 'stackname', 'auto', 'role', 'sighex', 'prihex'] + 'nuid', 'auto', 'role', 'sighex', 'prihex'] LocalDumpFields = ['uid', 'name', 'ha', 'main', 'sid', 'mutable', - 'nuid', 'stackname', 'role'] + 'nuid', 'role'] RemoteFields = ['uid', 'name', 'ha', 'sid', 'joined', 'acceptance', 'verhex', 'pubhex', 'role'] RemoteDumpFields = ['uid', 'name', 'ha', 'sid', 'joined', 'role'] @@ -137,7 +137,6 @@ class SaltKeep(Keep): ('mutable', local.mutable), ('sid', local.sid), ('nuid', local.stack.nuid), - ('stackname', local.stack.name), ('role', local.role), ]) if self.verifyLocalData(data, localFields = self.LocalDumpFields): diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index 0d3897a7db..c788c9587e 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -133,7 +133,6 @@ class BasicTestCase(unittest.TestCase): stack = stacking.RoadStack(store=self.store, name=data['name'], keep=keep, - localname=data['name'], uid=uid, ha=ha, main=main, @@ -220,7 +219,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -319,7 +317,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.never, @@ -410,7 +407,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.always, @@ -507,7 +503,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.always, @@ -598,7 +593,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -695,7 +689,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.once, @@ -788,7 +781,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -912,7 +904,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.always, @@ -1035,7 +1026,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -1160,7 +1150,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -1199,7 +1188,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.never, @@ -1278,7 +1266,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.always, @@ -1317,7 +1304,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.always, @@ -1392,7 +1378,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -1430,7 +1415,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': otherData['name'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'auto': raeting.autoModes.once, @@ -1505,7 +1489,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.never, @@ -1546,7 +1529,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': other1Data['name'], 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'auto': raeting.autoModes.never, @@ -1613,7 +1595,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': other2Data['name'], 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], 'auto': raeting.autoModes.never, @@ -1672,7 +1653,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': other2Data['name'], 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'auto': raeting.autoModes.never, @@ -1754,7 +1734,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': mainData['name'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'auto': raeting.autoModes.once, @@ -1795,7 +1774,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': other1Data['name'], 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'auto': raeting.autoModes.once, @@ -1861,7 +1839,6 @@ class BasicTestCase(unittest.TestCase): 'mutable': None, 'sid': 0, 'nuid': 1, - 'stackname': other2Data['name'], 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], 'auto': raeting.autoModes.never, From 4be6aa4797edf55282ea4870f7e35c9dfe1fac1f Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Tue, 19 Aug 2014 21:13:25 -0600 Subject: [PATCH 07/20] main is not stack attribute not local --- salt/daemons/salting.py | 2 +- salt/daemons/test/test_saltkeep.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index 0e54e95a8d..3c5bc4eff1 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -133,10 +133,10 @@ class SaltKeep(Keep): ('uid', local.uid), ('name', local.name), ('ha', local.ha), - ('main', local.main), ('mutable', local.mutable), ('sid', local.sid), ('nuid', local.stack.nuid), + ('main', local.stack.main), ('role', local.role), ]) if self.verifyLocalData(data, localFields = self.LocalDumpFields): diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index c788c9587e..43a79948cf 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -849,7 +849,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(main.local.name, mainData['name']) self.assertEqual(main.local.uid, 1) - self.assertEqual(main.local.main, True) + self.assertEqual(main.main, True) self.assertEqual(main.local.role, mainData['role']) self.assertIs(main.keep.auto, raeting.autoModes.never) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) @@ -970,7 +970,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(main.local.name, mainData['name']) self.assertEqual(main.local.uid, 1) - self.assertEqual(main.local.main, True) + self.assertEqual(main.main, True) self.assertEqual(main.local.role, mainData['role']) self.assertIs(main.keep.auto, raeting.autoModes.always) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) @@ -1095,7 +1095,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(main.local.name, mainData['name']) self.assertEqual(main.local.uid, 1) - self.assertEqual(main.local.main, True) + self.assertEqual(main.main, True) self.assertEqual(main.local.role, mainData['role']) self.assertIs(main.keep.auto, raeting.autoModes.once) self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) From 827c907853188a7aefbff0007d034fe41a0c5a4a Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Tue, 19 Aug 2014 21:30:00 -0600 Subject: [PATCH 08/20] mutable is now stack attribute not local --- salt/daemons/salting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index 3c5bc4eff1..89496f610d 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -133,10 +133,10 @@ class SaltKeep(Keep): ('uid', local.uid), ('name', local.name), ('ha', local.ha), - ('mutable', local.mutable), ('sid', local.sid), ('nuid', local.stack.nuid), ('main', local.stack.main), + ('mutable', local.stack.mutable), ('role', local.role), ]) if self.verifyLocalData(data, localFields = self.LocalDumpFields): From 6dca7a4e9754420464ac97779a2e1b2142575741 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Tue, 19 Aug 2014 21:57:25 -0600 Subject: [PATCH 09/20] no longer persisting main and mutable attributes --- salt/daemons/salting.py | 7 +--- salt/daemons/test/test_saltkeep.py | 62 ++++++------------------------ 2 files changed, 14 insertions(+), 55 deletions(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index 89496f610d..4849dcd268 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -35,10 +35,9 @@ class SaltKeep(Keep): estate.name.ext estate.name.ext ''' - LocalFields = ['uid', 'name', 'ha', 'main', 'sid', 'mutable', + LocalFields = ['uid', 'name', 'ha', 'sid', 'nuid', 'auto', 'role', 'sighex', 'prihex'] - LocalDumpFields = ['uid', 'name', 'ha', 'main', 'sid', 'mutable', - 'nuid', 'role'] + LocalDumpFields = ['uid', 'name', 'ha', 'sid', 'nuid', 'role'] RemoteFields = ['uid', 'name', 'ha', 'sid', 'joined', 'acceptance', 'verhex', 'pubhex', 'role'] RemoteDumpFields = ['uid', 'name', 'ha', 'sid', 'joined', 'role'] @@ -135,8 +134,6 @@ class SaltKeep(Keep): ('ha', local.ha), ('sid', local.sid), ('nuid', local.stack.nuid), - ('main', local.stack.main), - ('mutable', local.stack.mutable), ('role', local.role), ]) if self.verifyLocalData(data, localFields = self.LocalDumpFields): diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index 43a79948cf..efbd3ec5ad 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -215,8 +215,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -276,7 +274,8 @@ class BasicTestCase(unittest.TestCase): stackname=mainData['name']) main = stacking.RoadStack(name=mainData['name'], store=self.store, - keep=mainKeep) + keep=mainKeep, + main=True) self.assertEqual(main.local.priver.keyhex, mainData['prihex']) self.assertEqual(main.local.signer.keyhex, mainData['sighex']) @@ -313,8 +312,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': otherData['sighex'], @@ -403,8 +400,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -462,7 +457,8 @@ class BasicTestCase(unittest.TestCase): stackname=mainData['name']) main = stacking.RoadStack(name=mainData['name'], store=self.store, - keep=mainKeep) + keep=mainKeep, + main=True) self.assertEqual(main.local.priver.keyhex, mainData['prihex']) self.assertEqual(main.local.signer.keyhex, mainData['sighex']) @@ -499,8 +495,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': otherData['sighex'], @@ -589,8 +583,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -648,7 +640,8 @@ class BasicTestCase(unittest.TestCase): stackname=mainData['name']) main = stacking.RoadStack(name=mainData['name'], store=self.store, - keep=mainKeep) + keep=mainKeep, + main=True) self.assertEqual(main.local.priver.keyhex, mainData['prihex']) self.assertEqual(main.local.signer.keyhex, mainData['sighex']) @@ -685,8 +678,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': otherData['sighex'], @@ -777,8 +768,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -845,7 +834,8 @@ class BasicTestCase(unittest.TestCase): stackname=mainData['name']) main = stacking.RoadStack(name=mainData['name'], store=self.store, - keep=mainKeep) + keep=mainKeep, + main=True) self.assertEqual(main.local.name, mainData['name']) self.assertEqual(main.local.uid, 1) @@ -900,8 +890,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -966,7 +954,8 @@ class BasicTestCase(unittest.TestCase): stackname=mainData['name']) main = stacking.RoadStack(name=mainData['name'], store=self.store, - keep=mainKeep) + keep=mainKeep, + main=True) self.assertEqual(main.local.name, mainData['name']) self.assertEqual(main.local.uid, 1) @@ -1022,8 +1011,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -1091,7 +1078,8 @@ class BasicTestCase(unittest.TestCase): stackname=mainData['name']) main = stacking.RoadStack(name=mainData['name'], store=self.store, - keep=mainKeep) + keep=mainKeep, + main=True) self.assertEqual(main.local.name, mainData['name']) self.assertEqual(main.local.uid, 1) @@ -1146,8 +1134,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -1184,8 +1170,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': otherData['sighex'], @@ -1262,8 +1246,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -1300,8 +1282,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': otherData['sighex'], @@ -1374,8 +1354,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -1411,8 +1389,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': otherData['sighex'], @@ -1485,8 +1461,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -1525,8 +1499,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': other1Data['name'], 'ha': ['0.0.0.0', 7531], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': other1Data['sighex'], @@ -1591,8 +1563,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': other2Data['sighex'], @@ -1649,8 +1619,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': other1Data['sighex'], @@ -1730,8 +1698,6 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], - 'main': True, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': mainData['sighex'], @@ -1770,8 +1736,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': other1Data['name'], 'ha': ['0.0.0.0', 7531], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': other1Data['sighex'], @@ -1835,8 +1799,6 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], - 'main': None, - 'mutable': None, 'sid': 0, 'nuid': 1, 'sighex': other2Data['sighex'], From e1518b7c06c2284301dae33f448f45a8204ee905 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Tue, 19 Aug 2014 22:26:28 -0600 Subject: [PATCH 10/20] no longer peristing auto --- salt/daemons/salting.py | 5 ++--- salt/daemons/test/test_saltkeep.py | 22 ---------------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index 4849dcd268..42b9c7d1a6 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -35,8 +35,7 @@ class SaltKeep(Keep): estate.name.ext estate.name.ext ''' - LocalFields = ['uid', 'name', 'ha', 'sid', - 'nuid', 'auto', 'role', 'sighex', 'prihex'] + LocalFields = ['uid', 'name', 'ha', 'sid', 'nuid', 'role', 'sighex', 'prihex'] LocalDumpFields = ['uid', 'name', 'ha', 'sid', 'nuid', 'role'] RemoteFields = ['uid', 'name', 'ha', 'sid', 'joined', 'acceptance', 'verhex', 'pubhex', 'role'] @@ -67,7 +66,7 @@ class SaltKeep(Keep): srkdata = self.saltRaetKey.read_local() if not srkdata: srkdata = dict(sign=None, priv=None) - data.update(sighex=srkdata['sign'], prihex=srkdata['priv'], auto=self.auto) + data.update(sighex=srkdata['sign'], prihex=srkdata['priv']) return data def loadRemoteData(self, name): diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index efbd3ec5ad..ffa7a88bf3 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -219,7 +219,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.never, 'role': mainData['role'], }) @@ -316,7 +315,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': raeting.autoModes.never, 'role': otherData['role'], }) @@ -404,7 +402,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.always, 'role': mainData['role'], }) @@ -499,7 +496,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': raeting.autoModes.always, 'role': otherData['role'], }) @@ -587,7 +583,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.once, 'role': mainData['role'], }) @@ -682,7 +677,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': raeting.autoModes.once, 'role': otherData['role'], }) @@ -772,7 +766,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.never, 'role': mainData['role'], }) @@ -894,7 +887,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.always, 'role': mainData['role'], }) @@ -1015,7 +1007,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.once, 'role': mainData['role'], }) @@ -1138,7 +1129,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.never, 'role': mainData['role'], }) @@ -1174,7 +1164,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': raeting.autoModes.never, 'role': otherData['role'], }) @@ -1250,7 +1239,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.always, 'role': mainData['role'], }) @@ -1286,7 +1274,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': raeting.autoModes.always, 'role': otherData['role'], }) @@ -1358,7 +1345,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.once, 'role': mainData['role'], }) @@ -1393,7 +1379,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'auto': raeting.autoModes.once, 'role': otherData['role'], }) @@ -1465,7 +1450,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.never, 'role': mainData['role'], }) @@ -1503,7 +1487,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], - 'auto': raeting.autoModes.never, 'role': other1Data['role'], }) @@ -1567,7 +1550,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], - 'auto': raeting.autoModes.never, 'role': other2Data['role'], }) @@ -1623,7 +1605,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], - 'auto': raeting.autoModes.never, 'role': other2Data['role'], }) @@ -1702,7 +1683,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'auto': raeting.autoModes.once, 'role': mainData['role'], }) @@ -1740,7 +1720,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], - 'auto': raeting.autoModes.once, 'role': other1Data['role'], }) @@ -1803,7 +1782,6 @@ class BasicTestCase(unittest.TestCase): 'nuid': 1, 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], - 'auto': raeting.autoModes.never, 'role': other2Data['role'], }) From bfcda7be68ebb5fceb9f2155f5c5dc1761350049 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Wed, 20 Aug 2014 08:45:57 -0600 Subject: [PATCH 11/20] add fuid to remote replace nuid with puid --- salt/daemons/salting.py | 17 ++++---- salt/daemons/test/test_saltkeep.py | 62 +++++++++++++++++++----------- 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index 42b9c7d1a6..4eb0545ffa 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -35,11 +35,11 @@ class SaltKeep(Keep): estate.name.ext estate.name.ext ''' - LocalFields = ['uid', 'name', 'ha', 'sid', 'nuid', 'role', 'sighex', 'prihex'] - LocalDumpFields = ['uid', 'name', 'ha', 'sid', 'nuid', 'role'] - RemoteFields = ['uid', 'name', 'ha', 'sid', 'joined', 'acceptance', - 'verhex', 'pubhex', 'role'] - RemoteDumpFields = ['uid', 'name', 'ha', 'sid', 'joined', 'role'] + LocalFields = ['uid', 'name', 'ha', 'sid', 'puid', 'role', 'sighex', 'prihex'] + LocalDumpFields = ['uid', 'name', 'ha', 'sid', 'puid', 'role'] + RemoteFields = ['name', 'uid', 'fuid', 'ha', 'sid', 'joined', 'acceptance', + 'role', 'verhex', 'pubhex'] + RemoteDumpFields = ['name', 'uid', 'fuid', 'ha', 'sid', 'joined', 'role'] Auto = False #auto accept @@ -128,11 +128,11 @@ class SaltKeep(Keep): Dump local estate ''' data = odict([ - ('uid', local.uid), ('name', local.name), + ('uid', local.uid), ('ha', local.ha), ('sid', local.sid), - ('nuid', local.stack.nuid), + ('puid', local.stack.puid), ('role', local.role), ]) if self.verifyLocalData(data, localFields = self.LocalDumpFields): @@ -145,8 +145,9 @@ class SaltKeep(Keep): Dump remote estate ''' data = odict([ - ('uid', remote.uid), ('name', remote.name), + ('uid', remote.uid), + ('fuid', remote.fuid), ('ha', remote.ha), ('sid', remote.sid), ('joined', remote.joined), diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index ffa7a88bf3..8a0135012d 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -216,7 +216,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -246,6 +246,7 @@ class BasicTestCase(unittest.TestCase): { 'remote1': {'uid': 3, + 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'sid': 0, @@ -256,6 +257,7 @@ class BasicTestCase(unittest.TestCase): 'role': data1['role'],}, 'remote2': {'uid': 4, + 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'sid': 0, @@ -312,7 +314,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'role': otherData['role'], @@ -340,6 +342,7 @@ class BasicTestCase(unittest.TestCase): 'remote3': { 'uid': 3, + 'fuid': 0, 'name': data3['name'], 'ha': ['127.0.0.1', 7534], 'sid': 0, @@ -352,6 +355,7 @@ class BasicTestCase(unittest.TestCase): 'remote4': { 'uid': 4, + 'fuid': 0, 'name': data4['name'], 'ha': ['127.0.0.1', 7535], 'sid': 0, @@ -399,7 +403,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -427,6 +431,7 @@ class BasicTestCase(unittest.TestCase): { 'remote1': {'uid': 3, + 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'sid': 0, @@ -437,6 +442,7 @@ class BasicTestCase(unittest.TestCase): 'role': data1['role'],}, 'remote2': {'uid': 4, + 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'sid': 0, @@ -493,7 +499,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'role': otherData['role'], @@ -521,6 +527,7 @@ class BasicTestCase(unittest.TestCase): 'remote3': { 'uid': 3, + 'fuid': 0, 'name': data3['name'], 'ha': ['127.0.0.1', 7534], 'sid': 0, @@ -533,6 +540,7 @@ class BasicTestCase(unittest.TestCase): 'remote4': { 'uid': 4, + 'fuid': 0, 'name': data4['name'], 'ha': ['127.0.0.1', 7535], 'sid': 0, @@ -580,7 +588,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -608,6 +616,7 @@ class BasicTestCase(unittest.TestCase): { 'remote1': {'uid': 3, + 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'sid': 0, @@ -618,6 +627,7 @@ class BasicTestCase(unittest.TestCase): 'role': data1['role'],}, 'remote2': {'uid': 4, + 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'sid': 0, @@ -674,7 +684,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'role': otherData['role'], @@ -702,6 +712,7 @@ class BasicTestCase(unittest.TestCase): 'remote3': { 'uid': 3, + 'fuid': 0, 'name': data3['name'], 'ha': ['127.0.0.1', 7534], 'sid': 0, @@ -714,6 +725,7 @@ class BasicTestCase(unittest.TestCase): 'remote4': { 'uid': 4, + 'fuid': 0, 'name': data4['name'], 'ha': ['127.0.0.1', 7535], 'sid': 0, @@ -763,7 +775,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -800,6 +812,7 @@ class BasicTestCase(unittest.TestCase): { 'remote1': {'uid': 3, + 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'sid': 0, @@ -810,6 +823,7 @@ class BasicTestCase(unittest.TestCase): 'role': data1['role'],}, 'remote2': {'uid': 4, + 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'sid': 0, @@ -884,7 +898,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -919,6 +933,7 @@ class BasicTestCase(unittest.TestCase): { 'remote1': {'uid': 3, + 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'sid': 0, @@ -929,6 +944,7 @@ class BasicTestCase(unittest.TestCase): 'role': data1['role'],}, 'remote2': {'uid': 4, + 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'sid': 0, @@ -1004,7 +1020,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -1042,6 +1058,7 @@ class BasicTestCase(unittest.TestCase): { 'remote1': {'uid': 3, + 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'sid': 0, @@ -1052,6 +1069,7 @@ class BasicTestCase(unittest.TestCase): 'role': data1['role'],}, 'remote2': {'uid': 4, + 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'sid': 0, @@ -1126,7 +1144,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -1161,7 +1179,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'role': otherData['role'], @@ -1236,7 +1254,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -1271,7 +1289,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'role': otherData['role'], @@ -1342,7 +1360,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -1376,7 +1394,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'role': otherData['role'], @@ -1447,7 +1465,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -1484,7 +1502,7 @@ class BasicTestCase(unittest.TestCase): 'name': other1Data['name'], 'ha': ['0.0.0.0', 7531], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'role': other1Data['role'], @@ -1547,7 +1565,7 @@ class BasicTestCase(unittest.TestCase): 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], 'role': other2Data['role'], @@ -1602,7 +1620,7 @@ class BasicTestCase(unittest.TestCase): 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'role': other2Data['role'], @@ -1680,7 +1698,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -1717,7 +1735,7 @@ class BasicTestCase(unittest.TestCase): 'name': other1Data['name'], 'ha': ['0.0.0.0', 7531], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], 'role': other1Data['role'], @@ -1779,7 +1797,7 @@ class BasicTestCase(unittest.TestCase): 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], 'sid': 0, - 'nuid': 1, + 'puid': 1, 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], 'role': other2Data['role'], From 27e322c3533c4bc1f2e742cb0208ebc3980dadbb Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Wed, 20 Aug 2014 15:04:26 -0600 Subject: [PATCH 12/20] added ha property to stacks --- salt/daemons/test/test_saltkeep.py | 50 +++++++++++++++--------------- salt/transport/__init__.py | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index 8a0135012d..6ec5e87429 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -210,7 +210,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.never) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -305,7 +305,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) - self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) + self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) self.assertIs(other.keep.auto, raeting.autoModes.never) self.assertDictEqual(other.keep.loadLocalData(), @@ -397,7 +397,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.always) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -490,7 +490,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) - self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) + self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) self.assertIs(other.keep.auto,raeting.autoModes.always) self.assertDictEqual(other.keep.loadLocalData(), @@ -582,7 +582,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.once) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -675,7 +675,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) - self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) + self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) self.assertIs(other.keep.auto, raeting.autoModes.once) self.assertDictEqual(other.keep.loadLocalData(), @@ -769,7 +769,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.never) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -849,7 +849,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(main.main, True) self.assertEqual(main.local.role, mainData['role']) self.assertIs(main.keep.auto, raeting.autoModes.never) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertEqual(main.local.priver.keyhex, mainData['prihex']) self.assertEqual(main.local.signer.keyhex, mainData['sighex']) @@ -892,7 +892,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.always) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -970,7 +970,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(main.main, True) self.assertEqual(main.local.role, mainData['role']) self.assertIs(main.keep.auto, raeting.autoModes.always) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertEqual(main.local.priver.keyhex, mainData['prihex']) self.assertEqual(main.local.signer.keyhex, mainData['sighex']) @@ -1014,7 +1014,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.once) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -1095,7 +1095,7 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(main.main, True) self.assertEqual(main.local.role, mainData['role']) self.assertIs(main.keep.auto, raeting.autoModes.once) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertEqual(main.local.priver.keyhex, mainData['prihex']) self.assertEqual(main.local.signer.keyhex, mainData['sighex']) @@ -1138,7 +1138,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.never) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -1171,7 +1171,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) - self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) + self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) self.assertIs(other.keep.auto, raeting.autoModes.never) self.assertDictEqual(other.keep.loadLocalData(), { @@ -1248,7 +1248,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.always) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -1281,7 +1281,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) - self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) + self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) self.assertIs(other.keep.auto, raeting.autoModes.always) self.assertDictEqual(other.keep.loadLocalData(), { @@ -1354,7 +1354,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertEqual(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertEqual(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.once) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -1387,7 +1387,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) - self.assertEqual(other.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) + self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) self.assertDictEqual(other.keep.loadLocalData(), { 'uid': 0, @@ -1459,7 +1459,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.never) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -1494,7 +1494,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other1.name, other1.keep.dirpath)) self.assertTrue(other1.keep.dirpath.endswith('other1/raet/other1')) - self.assertEqual(other1.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) + self.assertEqual(other1.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) self.assertIs(other1.keep.auto, raeting.autoModes.never) self.assertDictEqual(other1.keep.loadLocalData(), { @@ -1557,7 +1557,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other2.name, other2.keep.dirpath)) self.assertTrue(other2.keep.dirpath.endswith('other2/raet/other2')) - self.assertEqual(other2.local.ha, ("0.0.0.0", 7532)) + self.assertEqual(other2.ha, ("0.0.0.0", 7532)) self.assertIs(other2.keep.auto, raeting.autoModes.never) self.assertDictEqual(other2.keep.loadLocalData(), { @@ -1612,7 +1612,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other2.name, other2.keep.dirpath)) self.assertTrue(other2.keep.dirpath.endswith('other2/raet/other2')) - self.assertEqual(other2.local.ha, ("0.0.0.0", 7532)) + self.assertEqual(other2.ha, ("0.0.0.0", 7532)) self.assertIs(other2.keep.auto, raeting.autoModes.never) self.assertDictEqual(other2.keep.loadLocalData(), { @@ -1692,7 +1692,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0}\nkeep dirpath = {1}\n".format( main.name, main.keep.dirpath)) self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) - self.assertTrue(main.local.ha, ("0.0.0.0", raeting.RAET_PORT)) + self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.once) self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], @@ -1727,7 +1727,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other1.name, other1.keep.dirpath)) self.assertTrue(other1.keep.dirpath.endswith('other1/raet/other1')) - self.assertEqual(other1.local.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) + self.assertEqual(other1.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) self.assertIs(other1.keep.auto, raeting.autoModes.once) self.assertDictEqual(other1.keep.loadLocalData(), { @@ -1789,7 +1789,7 @@ class BasicTestCase(unittest.TestCase): console.terse("{0} keep dirpath = {1}\n".format( other2.name, other2.keep.dirpath)) self.assertTrue(other2.keep.dirpath.endswith('other2/raet/other2')) - self.assertEqual(other2.local.ha, ("0.0.0.0", 7532)) + self.assertEqual(other2.ha, ("0.0.0.0", 7532)) self.assertIs(other2.keep.auto, raeting.autoModes.never) self.assertDictEqual(other2.keep.loadLocalData(), { diff --git a/salt/transport/__init__.py b/salt/transport/__init__.py index 29b0d76d4d..39b1f54141 100644 --- a/salt/transport/__init__.py +++ b/salt/transport/__init__.py @@ -97,7 +97,7 @@ class RAETChannel(Channel): self.stack = jobber_stack else: self.stack = jobber_stack = self._setup_stack() - log.debug("Using Jobber Stack at = {0}\n".format(self.stack.local.ha)) + log.debug("Using Jobber Stack at = {0}\n".format(self.stack.ha)) def crypted_transfer_decode_dictentry(self, load, dictkey=None, tries=3, timeout=60): ''' From 5ac568af750ac17f66fb962eea6b1b45b746fe86 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Wed, 20 Aug 2014 16:22:54 -0600 Subject: [PATCH 13/20] Added iha persitence to estates --- salt/daemons/salting.py | 10 +++++--- salt/daemons/test/test_saltkeep.py | 40 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index 4eb0545ffa..15ae9c0f49 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -35,11 +35,11 @@ class SaltKeep(Keep): estate.name.ext estate.name.ext ''' - LocalFields = ['uid', 'name', 'ha', 'sid', 'puid', 'role', 'sighex', 'prihex'] - LocalDumpFields = ['uid', 'name', 'ha', 'sid', 'puid', 'role'] - RemoteFields = ['name', 'uid', 'fuid', 'ha', 'sid', 'joined', 'acceptance', + LocalFields = ['uid', 'name', 'ha', 'iha', 'sid', 'puid', 'role', 'sighex', 'prihex'] + LocalDumpFields = ['uid', 'name', 'ha', 'iha', 'sid', 'puid', 'role'] + RemoteFields = ['name', 'uid', 'fuid', 'ha', 'iha', 'sid', 'joined', 'acceptance', 'role', 'verhex', 'pubhex'] - RemoteDumpFields = ['name', 'uid', 'fuid', 'ha', 'sid', 'joined', 'role'] + RemoteDumpFields = ['name', 'uid', 'fuid', 'ha', 'iha', 'sid', 'joined', 'role'] Auto = False #auto accept @@ -131,6 +131,7 @@ class SaltKeep(Keep): ('name', local.name), ('uid', local.uid), ('ha', local.ha), + ('iha', local.iha), ('sid', local.sid), ('puid', local.stack.puid), ('role', local.role), @@ -149,6 +150,7 @@ class SaltKeep(Keep): ('uid', remote.uid), ('fuid', remote.fuid), ('ha', remote.ha), + ('iha', remote.iha), ('sid', remote.sid), ('joined', remote.joined), ('role', remote.role), diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index 6ec5e87429..159a11dbe8 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -215,6 +215,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -249,6 +250,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -260,6 +262,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -313,6 +316,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -345,6 +349,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data3['name'], 'ha': ['127.0.0.1', 7534], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -358,6 +363,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data4['name'], 'ha': ['127.0.0.1', 7535], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -402,6 +408,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -434,6 +441,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -445,6 +453,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -498,6 +507,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -530,6 +540,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data3['name'], 'ha': ['127.0.0.1', 7534], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -543,6 +554,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data4['name'], 'ha': ['127.0.0.1', 7535], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -587,6 +599,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -619,6 +632,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -630,6 +644,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -683,6 +698,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -715,6 +731,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data3['name'], 'ha': ['127.0.0.1', 7534], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -728,6 +745,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data4['name'], 'ha': ['127.0.0.1', 7535], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -774,6 +792,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -815,6 +834,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -826,6 +846,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -897,6 +918,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -936,6 +958,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -947,6 +970,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -1019,6 +1043,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1061,6 +1086,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data1['name'], 'ha': ['127.0.0.1', 7532], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -1072,6 +1098,7 @@ class BasicTestCase(unittest.TestCase): 'fuid': 0, 'name': data2['name'], 'ha': ['127.0.0.1', 7533], + 'iha': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -1143,6 +1170,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1178,6 +1206,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -1253,6 +1282,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1288,6 +1318,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -1359,6 +1390,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1393,6 +1425,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -1464,6 +1497,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1501,6 +1535,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': other1Data['name'], 'ha': ['0.0.0.0', 7531], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': other1Data['sighex'], @@ -1564,6 +1599,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': other2Data['sighex'], @@ -1619,6 +1655,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': other1Data['sighex'], @@ -1697,6 +1734,7 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1734,6 +1772,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': other1Data['name'], 'ha': ['0.0.0.0', 7531], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': other1Data['sighex'], @@ -1796,6 +1835,7 @@ class BasicTestCase(unittest.TestCase): 'uid': 0, 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], + 'iha': None, 'sid': 0, 'puid': 1, 'sighex': other2Data['sighex'], From 231b9eb88a410903bf837bba8efaa76adcfc9b9d Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Wed, 20 Aug 2014 17:02:22 -0600 Subject: [PATCH 14/20] added natted flag to estates --- salt/daemons/salting.py | 14 +++++++---- salt/daemons/test/test_saltkeep.py | 40 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index 15ae9c0f49..4c0906b87e 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -35,11 +35,13 @@ class SaltKeep(Keep): estate.name.ext estate.name.ext ''' - LocalFields = ['uid', 'name', 'ha', 'iha', 'sid', 'puid', 'role', 'sighex', 'prihex'] - LocalDumpFields = ['uid', 'name', 'ha', 'iha', 'sid', 'puid', 'role'] - RemoteFields = ['name', 'uid', 'fuid', 'ha', 'iha', 'sid', 'joined', 'acceptance', - 'role', 'verhex', 'pubhex'] - RemoteDumpFields = ['name', 'uid', 'fuid', 'ha', 'iha', 'sid', 'joined', 'role'] + LocalFields = ['uid', 'name', 'ha', 'iha', 'natted', 'sid', 'puid', + 'role', 'sighex', 'prihex'] + LocalDumpFields = ['uid', 'name', 'ha', 'iha', 'natted', 'sid', 'puid', 'role'] + RemoteFields = ['name', 'uid', 'fuid', 'ha', 'iha', 'natted', 'sid', 'joined', + 'acceptance', 'role', 'verhex', 'pubhex'] + RemoteDumpFields = ['name', 'uid', 'fuid', 'ha', 'iha', 'natted', 'sid', + 'joined', 'role'] Auto = False #auto accept @@ -132,6 +134,7 @@ class SaltKeep(Keep): ('uid', local.uid), ('ha', local.ha), ('iha', local.iha), + ('natted', local.natted), ('sid', local.sid), ('puid', local.stack.puid), ('role', local.role), @@ -151,6 +154,7 @@ class SaltKeep(Keep): ('fuid', remote.fuid), ('ha', remote.ha), ('iha', remote.iha), + ('natted', remote.natted), ('sid', remote.sid), ('joined', remote.joined), ('role', remote.role), diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index 159a11dbe8..d6df0371e9 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -216,6 +216,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -251,6 +252,7 @@ class BasicTestCase(unittest.TestCase): 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -263,6 +265,7 @@ class BasicTestCase(unittest.TestCase): 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -317,6 +320,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -350,6 +354,7 @@ class BasicTestCase(unittest.TestCase): 'name': data3['name'], 'ha': ['127.0.0.1', 7534], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -364,6 +369,7 @@ class BasicTestCase(unittest.TestCase): 'name': data4['name'], 'ha': ['127.0.0.1', 7535], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -409,6 +415,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -442,6 +449,7 @@ class BasicTestCase(unittest.TestCase): 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -454,6 +462,7 @@ class BasicTestCase(unittest.TestCase): 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -508,6 +517,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -541,6 +551,7 @@ class BasicTestCase(unittest.TestCase): 'name': data3['name'], 'ha': ['127.0.0.1', 7534], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -555,6 +566,7 @@ class BasicTestCase(unittest.TestCase): 'name': data4['name'], 'ha': ['127.0.0.1', 7535], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -600,6 +612,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -633,6 +646,7 @@ class BasicTestCase(unittest.TestCase): 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -645,6 +659,7 @@ class BasicTestCase(unittest.TestCase): 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -699,6 +714,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -732,6 +748,7 @@ class BasicTestCase(unittest.TestCase): 'name': data3['name'], 'ha': ['127.0.0.1', 7534], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -746,6 +763,7 @@ class BasicTestCase(unittest.TestCase): 'name': data4['name'], 'ha': ['127.0.0.1', 7535], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -793,6 +811,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -835,6 +854,7 @@ class BasicTestCase(unittest.TestCase): 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -847,6 +867,7 @@ class BasicTestCase(unittest.TestCase): 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 0, @@ -919,6 +940,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -959,6 +981,7 @@ class BasicTestCase(unittest.TestCase): 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -971,6 +994,7 @@ class BasicTestCase(unittest.TestCase): 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -1044,6 +1068,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1087,6 +1112,7 @@ class BasicTestCase(unittest.TestCase): 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -1099,6 +1125,7 @@ class BasicTestCase(unittest.TestCase): 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'iha': None, + 'natted': None, 'sid': 0, 'joined': None, 'acceptance': 1, @@ -1171,6 +1198,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1207,6 +1235,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -1283,6 +1312,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1319,6 +1349,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -1391,6 +1422,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1426,6 +1458,7 @@ class BasicTestCase(unittest.TestCase): 'name': otherData['name'], 'ha': ['0.0.0.0', 7531], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': otherData['sighex'], @@ -1498,6 +1531,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1536,6 +1570,7 @@ class BasicTestCase(unittest.TestCase): 'name': other1Data['name'], 'ha': ['0.0.0.0', 7531], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': other1Data['sighex'], @@ -1600,6 +1635,7 @@ class BasicTestCase(unittest.TestCase): 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': other2Data['sighex'], @@ -1656,6 +1692,7 @@ class BasicTestCase(unittest.TestCase): 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': other1Data['sighex'], @@ -1735,6 +1772,7 @@ class BasicTestCase(unittest.TestCase): 'name': mainData['name'], 'ha': ['0.0.0.0', 7530], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': mainData['sighex'], @@ -1773,6 +1811,7 @@ class BasicTestCase(unittest.TestCase): 'name': other1Data['name'], 'ha': ['0.0.0.0', 7531], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': other1Data['sighex'], @@ -1836,6 +1875,7 @@ class BasicTestCase(unittest.TestCase): 'name': other2Data['name'], 'ha': ['0.0.0.0', 7532], 'iha': None, + 'natted': None, 'sid': 0, 'puid': 1, 'sighex': other2Data['sighex'], From 391c055f9eeb738543338276f10bccfc3ef8137d Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Mon, 15 Sep 2014 12:39:18 -0600 Subject: [PATCH 15/20] Updated SaltKeep to new semantics Got some tests working --- salt/daemons/salting.py | 105 ++++++----- salt/daemons/test/test_saltkeep.py | 293 +++++++++++++++++++---------- 2 files changed, 252 insertions(+), 146 deletions(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index 4c0906b87e..d9a311c395 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -35,15 +35,16 @@ class SaltKeep(Keep): estate.name.ext estate.name.ext ''' - LocalFields = ['uid', 'name', 'ha', 'iha', 'natted', 'sid', 'puid', - 'role', 'sighex', 'prihex'] - LocalDumpFields = ['uid', 'name', 'ha', 'iha', 'natted', 'sid', 'puid', 'role'] - RemoteFields = ['name', 'uid', 'fuid', 'ha', 'iha', 'natted', 'sid', 'joined', - 'acceptance', 'role', 'verhex', 'pubhex'] - RemoteDumpFields = ['name', 'uid', 'fuid', 'ha', 'iha', 'natted', 'sid', - 'joined', 'role'] - - Auto = False #auto accept + LocalFields = ['name', 'uid', 'ha', 'iha', 'natted', 'fqdn', 'dyned', 'sid', + 'puid', 'aha', 'role', 'sighex','prihex'] + LocalDumpFields = ['name', 'uid', 'ha', 'iha', 'natted', 'fqdn', 'dyned', 'sid', + 'puid', 'aha', 'role'] + RemoteFields = ['name', 'uid', 'fuid', 'ha', 'iha', 'natted', 'fqdn', 'dyned', + 'sid', 'main', 'application', 'joined', + 'role', 'acceptance', 'verhex', 'pubhex'] + RemoteDumpFields = ['name', 'uid', 'fuid', 'ha', 'iha', 'natted', 'fqdn', 'dyned', + 'sid', 'main', 'application', 'joined', 'role'] + Auto = raeting.autoModes.never #auto accept def __init__(self, opts, prefix='estate', basedirpath='', auto=None, **kwa): ''' @@ -68,7 +69,8 @@ class SaltKeep(Keep): srkdata = self.saltRaetKey.read_local() if not srkdata: srkdata = dict(sign=None, priv=None) - data.update(sighex=srkdata['sign'], prihex=srkdata['priv']) + data.update([('sighex', srkdata['sign']), + ('prihex', srkdata['priv'])]) return data def loadRemoteData(self, name): @@ -87,13 +89,13 @@ class SaltKeep(Keep): break if not keydata: - data.update(acceptance=None, - verhex=None, - pubhex=None) + data.update([('acceptance', None), + ('verhex', None), + ('pubhex', None)]) else: data.update(acceptance=raeting.ACCEPTANCES[status], - verhex=keydata['verify'], - pubhex=keydata['pub']) + verhex=keydata['verify'], + pubhex=keydata['pub']) return data @@ -103,9 +105,9 @@ class SaltKeep(Keep): ''' keeps = super(SaltKeep, self).loadAllRemoteData() for name, data in keeps.items(): - keeps[name].update(acceptance=None, - verhex=None, - pubhex=None) + keeps[name].update([('acceptance', None), + ('verhex', None), + ('pubhex', None)]) for status, mids in self.saltRaetKey.list_keys().items(): for mid in mids: @@ -113,16 +115,16 @@ class SaltKeep(Keep): if keydata: for name, data in keeps.items(): if data['role'] == mid: - keeps[name].update(acceptance=raeting.ACCEPTANCES[status], - verhex=keydata['verify'], - pubhex=keydata['pub']) + keeps[name].update( + [('acceptance', raeting.ACCEPTANCES[status]), + ('verhex', keydata['verify']), + ('pubhex', keydata['pub'])]) return keeps - def clearAllRemoteData(self): + def clearAllRemoteRoleData(self): ''' - Remove all the remote estate files + Remove all the role data files ''' - super(SaltKeep, self).clearAllRemoteData() self.saltRaetKey.delete_all() def dumpLocal(self, local): @@ -135,11 +137,14 @@ class SaltKeep(Keep): ('ha', local.ha), ('iha', local.iha), ('natted', local.natted), + ('fqdn', local.fqdn), + ('dyned', local.dyned), ('sid', local.sid), ('puid', local.stack.puid), + ('aha', local.stack.aha), ('role', local.role), ]) - if self.verifyLocalData(data, localFields = self.LocalDumpFields): + if self.verifyLocalData(data, localFields =self.LocalDumpFields): self.dumpLocalData(data) self.saltRaetKey.write_local(local.priver.keyhex, local.signer.keyhex) @@ -155,7 +160,11 @@ class SaltKeep(Keep): ('ha', remote.ha), ('iha', remote.iha), ('natted', remote.natted), + ('fqdn', remote.fqdn), + ('dyned', remote.dyned), ('sid', remote.sid), + ('main', remote.main), + ('application', remote.application), ('joined', remote.joined), ('role', remote.role), ]) @@ -168,39 +177,36 @@ class SaltKeep(Keep): remote.pubber.keyhex, remote.verfer.keyhex) + def statusRemote(self, remote, dump=True): + ''' + Calls .statusRole on remote role and keys and updates remote.acceptance + dump indicates if statusRole should update persisted values when + appropriate. - def replaceRemoteRole(self, remote, old): + Returns status + Where status is acceptance status of role and keys + and has value from raeting.acceptances ''' - Replace the Salt RaetKey record at old role when remote.role has changed - ''' - new = remote.role - if new != old: - #self.dumpRemote(remote) - # manually fix up acceptance if not pending - # will be pending by default unless autoaccept - if remote.acceptance == raeting.acceptances.accepted: - self.acceptRemote(remote) - elif remote.acceptance == raeting.acceptances.rejected: - self.rejectRemote(remote) + status = self.statusRole(role=remote.role, + verhex=remote.verfer.keyhex, + pubhex=remote.pubber.keyhex, + dump=dump) - self.saltRaetKey.delete_key(old) #now delete old key file + remote.acceptance = status - def statusRemote(self, remote, verhex, pubhex, main=True, dump=True): + return status + + def statusRole(self, role, verhex, pubhex, dump=True): ''' - Evaluate acceptance status of remote estate per its keys - persist key data differentially based on status + Returns status + + Where status is acceptance status of role and keys + and has value from raeting.acceptances ''' - status = raeting.ACCEPTANCES[self.saltRaetKey.status(remote.role, + status = raeting.ACCEPTANCES[self.saltRaetKey.status(role, pubhex, verhex)] - if status != raeting.acceptances.rejected: - if (verhex and verhex != remote.verfer.keyhex): - remote.verfer = nacling.Verifier(verhex) - if (pubhex and pubhex != remote.pubber.keyhex): - remote.pubber = nacling.Publican(pubhex) - remote.acceptance = status - return status def rejectRemote(self, remote): @@ -232,4 +238,3 @@ def clearAllKeep(dirpath): road = RoadKeep(dirpath=dirpath) road.clearLocalData() road.clearAllRemoteData() - diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index d6df0371e9..033d1c9b59 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -104,6 +104,7 @@ class BasicTestCase(unittest.TestCase): ''' data = odict() data['name'] = name + data['role'] = role or name data['basedirpath'] = os.path.join(cachedirpath, 'raet') signer = nacling.Signer() data['sighex'] = signer.keyhex @@ -111,11 +112,11 @@ class BasicTestCase(unittest.TestCase): privateer = nacling.Privateer() data['prihex'] = privateer.keyhex data['pubhex'] = privateer.pubhex - data['role'] = role or name + return data - def createRoadStack(self, data, keep, uid=0, main=None, ha=None, mutable=None): + def createRoadStack(self, data, keep, uid=None, main=None, ha=None, mutable=None): ''' Creates stack and local estate from data with local estate.uid = uid @@ -143,13 +144,19 @@ class BasicTestCase(unittest.TestCase): return stack - def join(self, other, main, duration=1.0): + def join(self, initiator, correspondent, deid=None, duration=1.0): ''' Utility method to do join. Call from test method. ''' console.terse("\nJoin Transaction **************\n") - other.join() - self.service(main, other, duration=duration) + if not initiator.remotes: + remote = initiator.addRemote(estating.RemoteEstate(stack=initiator, + fuid=0, # vacuous join + sid=0, # always 0 for join + ha=correspondent.local.ha)) + deid = remote.uid + initiator.join(uid=deid) + self.service(correspondent, initiator, duration=duration) def allow(self, other, main, duration=1.0): ''' @@ -202,7 +209,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -212,21 +218,23 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.never) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, - 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + self.assertDictEqual(main.keep.loadLocalData(), {'name': mainData['name'], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], + 'role': mainData['role'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'role': mainData['role'], }) data1 = self.createRoadData(name='remote1', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -234,7 +242,6 @@ class BasicTestCase(unittest.TestCase): data2 = self.createRoadData(name='remote2', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -247,31 +254,41 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadAllRemoteData(), { 'remote1': - {'uid': 3, + {'name': data1['name'], + 'uid': 2, 'fuid': 0, - 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data1['role'], 'acceptance': 0, 'verhex': data1['verhex'], 'pubhex': data1['pubhex'], - 'role': data1['role'],}, + }, 'remote2': - {'uid': 4, + {'name': data2['name'], + 'uid': 3, 'fuid': 0, - 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data2['role'], 'acceptance': 0, 'verhex': data2['verhex'], 'pubhex': data2['pubhex'], - 'role': data2['role'],} + } }) # now recreate with saved data @@ -303,7 +320,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -316,21 +332,23 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(other.keep.loadLocalData(), { - 'uid': 0, 'name': otherData['name'], - 'ha': ['0.0.0.0', 7531], + 'uid': 1, + 'ha': ['127.0.0.1', 7531], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7531], + 'role': otherData['role'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'role': otherData['role'], }) data3 = self.createRoadData(name='remote3', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - uid=3, name=data3['name'], ha=('127.0.0.1', 7534), verkey=data3['verhex'], @@ -338,7 +356,6 @@ class BasicTestCase(unittest.TestCase): data4 = self.createRoadData(name='remote4', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - uid=4, name=data4['name'], ha=('127.0.0.1', 7535), verkey=data4['verhex'], @@ -349,33 +366,41 @@ class BasicTestCase(unittest.TestCase): { 'remote3': { - 'uid': 3, - 'fuid': 0, 'name': data3['name'], + 'uid': 2, + 'fuid': 0, 'ha': ['127.0.0.1', 7534], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data3['role'], 'acceptance': 0, 'verhex': data3['verhex'], 'pubhex': data3['pubhex'], - 'role': data3['role'], }, 'remote4': { - 'uid': 4, - 'fuid': 0, 'name': data4['name'], + 'uid': 3, + 'fuid': 0, 'ha': ['127.0.0.1', 7535], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data4['role'], 'acceptance': 0, 'verhex': data4['verhex'], 'pubhex': data4['pubhex'], - 'role': data4['role'], } }) @@ -401,7 +426,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -411,21 +435,24 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.always) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, + self.assertDictEqual(main.keep.loadLocalData(), { 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], + 'role': mainData['role'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'role': mainData['role'], }) data1 = self.createRoadData(name='remote1', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -433,7 +460,6 @@ class BasicTestCase(unittest.TestCase): data2 = self.createRoadData(name='remote2', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -444,31 +470,41 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadAllRemoteData(), { 'remote1': - {'uid': 3, + {'name': data1['name'], + 'uid': 2, 'fuid': 0, - 'name': data1['name'], 'ha': ['127.0.0.1', 7532], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data1['role'], 'acceptance': 1, 'verhex': data1['verhex'], 'pubhex': data1['pubhex'], - 'role': data1['role'],}, + }, 'remote2': - {'uid': 4, + {'name': data2['name'], + 'uid': 3, 'fuid': 0, - 'name': data2['name'], 'ha': ['127.0.0.1', 7533], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data2['role'], 'acceptance': 1, 'verhex': data2['verhex'], 'pubhex': data2['pubhex'], - 'role': data2['role'],} + } }) # now recreate with saved data @@ -500,7 +536,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -513,21 +548,23 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(other.keep.loadLocalData(), { - 'uid': 0, 'name': otherData['name'], - 'ha': ['0.0.0.0', 7531], + 'uid': 1, + 'ha': ['127.0.0.1', 7531], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7531], + 'role': otherData['role'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'role': otherData['role'], }) data3 = self.createRoadData(name='remote3', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - uid=3, name=data3['name'], ha=('127.0.0.1', 7534), verkey=data3['verhex'], @@ -535,7 +572,6 @@ class BasicTestCase(unittest.TestCase): data4 = self.createRoadData(name='remote4', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - uid=4, name=data4['name'], ha=('127.0.0.1', 7535), verkey=data4['verhex'], @@ -546,33 +582,41 @@ class BasicTestCase(unittest.TestCase): { 'remote3': { - 'uid': 3, - 'fuid': 0, 'name': data3['name'], + 'uid': 2, + 'fuid': 0, 'ha': ['127.0.0.1', 7534], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data3['role'], 'acceptance': 1, 'verhex': data3['verhex'], 'pubhex': data3['pubhex'], - 'role': data3['role'], }, 'remote4': { - 'uid': 4, - 'fuid': 0, 'name': data4['name'], + 'uid': 3, + 'fuid': 0, 'ha': ['127.0.0.1', 7535], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data4['role'], 'acceptance': 1, 'verhex': data4['verhex'], 'pubhex': data4['pubhex'], - 'role': data4['role'], } }) @@ -598,7 +642,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -608,13 +651,17 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.once) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, + self.assertDictEqual(main.keep.loadLocalData(), { 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], 'role': mainData['role'], @@ -622,7 +669,6 @@ class BasicTestCase(unittest.TestCase): data1 = self.createRoadData(name='remote1', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -630,7 +676,6 @@ class BasicTestCase(unittest.TestCase): data2 = self.createRoadData(name='remote2', cachedirpath=opts['cachedir']) main.addRemote(estating.RemoteEstate(stack=main, - uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -641,31 +686,43 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadAllRemoteData(), { 'remote1': - {'uid': 3, - 'fuid': 0, + { 'name': data1['name'], + 'uid': 2, + 'fuid': 0, 'ha': ['127.0.0.1', 7532], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data1['role'], 'acceptance': 1, 'verhex': data1['verhex'], 'pubhex': data1['pubhex'], - 'role': data1['role'],}, + }, 'remote2': - {'uid': 4, - 'fuid': 0, + { 'name': data2['name'], + 'uid': 3, + 'fuid': 0, 'ha': ['127.0.0.1', 7533], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data2['role'], 'acceptance': 1, 'verhex': data2['verhex'], 'pubhex': data2['pubhex'], - 'role': data2['role'],} + } }) # now recreate with saved data @@ -697,7 +754,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -710,21 +766,23 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(other.keep.loadLocalData(), { - 'uid': 0, 'name': otherData['name'], - 'ha': ['0.0.0.0', 7531], + 'uid': 1, + 'ha': ['127.0.0.1', 7531], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7531], + 'role': otherData['role'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'role': otherData['role'], }) data3 = self.createRoadData(name='remote3', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - uid=3, name=data3['name'], ha=('127.0.0.1', 7534), verkey=data3['verhex'], @@ -732,7 +790,6 @@ class BasicTestCase(unittest.TestCase): data4 = self.createRoadData(name='remote4', cachedirpath=opts['cachedir']) other.addRemote(estating.RemoteEstate(stack=other, - uid=4, name=data4['name'], ha=('127.0.0.1', 7535), verkey=data4['verhex'], @@ -743,33 +800,41 @@ class BasicTestCase(unittest.TestCase): { 'remote3': { - 'uid': 3, - 'fuid': 0, 'name': data3['name'], + 'uid': 2, + 'fuid': 0, 'ha': ['127.0.0.1', 7534], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data3['role'], 'acceptance': 1, 'verhex': data3['verhex'], 'pubhex': data3['pubhex'], - 'role': data3['role'], }, 'remote4': { - 'uid': 4, - 'fuid': 0, 'name': data4['name'], + 'uid': 3, + 'fuid': 0, 'ha': ['127.0.0.1', 7535], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data4['role'], 'acceptance': 1, 'verhex': data4['verhex'], 'pubhex': data4['pubhex'], - 'role': data4['role'], } }) @@ -849,31 +914,43 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadAllRemoteData(), { 'remote1': - {'uid': 3, - 'fuid': 0, + { 'name': data1['name'], + 'uid': 3, + 'fuid': 0, 'ha': ['127.0.0.1', 7532], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data1['role'], 'acceptance': 0, 'verhex': data1['verhex'], 'pubhex': data1['pubhex'], - 'role': data1['role'],}, + }, 'remote2': - {'uid': 4, - 'fuid': 0, + { 'name': data2['name'], + 'uid': 4, + 'fuid': 0, 'ha': ['127.0.0.1', 7533], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data2['role'], 'acceptance': 0, 'verhex': data1['verhex'], 'pubhex': data1['pubhex'], - 'role': data2['role'],} + } }) # now recreate with saved data @@ -976,31 +1053,43 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadAllRemoteData(), { 'remote1': - {'uid': 3, - 'fuid': 0, + { 'name': data1['name'], + 'uid': 3, + 'fuid': 0, 'ha': ['127.0.0.1', 7532], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data1['role'], 'acceptance': 1, 'verhex': data2['verhex'], 'pubhex': data2['pubhex'], - 'role': data1['role'],}, + }, 'remote2': - {'uid': 4, - 'fuid': 0, + { 'name': data2['name'], + 'uid': 4, + 'fuid': 0, 'ha': ['127.0.0.1', 7533], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data2['role'], 'acceptance': 1, 'verhex': data2['verhex'], 'pubhex': data2['pubhex'], - 'role': data2['role'],} + } }) # now recreate with saved data @@ -1076,7 +1165,7 @@ class BasicTestCase(unittest.TestCase): 'role': mainData['role'], }) - # add multiple remotes all with same role + # add multiple remotes all with same role but different keys data1 = self.createRoadData(name='remote1', cachedirpath=opts['cachedir'], role='primary') @@ -1107,31 +1196,43 @@ class BasicTestCase(unittest.TestCase): self.assertDictEqual(main.keep.loadAllRemoteData(), { 'remote1': - {'uid': 3, - 'fuid': 0, + { 'name': data1['name'], + 'uid': 3, + 'fuid': 0, 'ha': ['127.0.0.1', 7532], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data1['role'], 'acceptance': 1, 'verhex': data1['verhex'], 'pubhex': data1['pubhex'], - 'role': data1['role'],}, + }, 'remote2': - {'uid': 4, - 'fuid': 0, + { 'name': data2['name'], + 'uid': 4, + 'fuid': 0, 'ha': ['127.0.0.1', 7533], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, + 'main': False, + 'application': 0, 'sid': 0, 'joined': None, + 'role': data2['role'], 'acceptance': 1, 'verhex': data1['verhex'], 'pubhex': data1['pubhex'], - 'role': data2['role'],} + } }) # now recreate with saved data From e15d4f5fdf4db4f1e57fc41661ae660c2d70b2b5 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Mon, 15 Sep 2014 16:14:32 -0600 Subject: [PATCH 16/20] SaltKeep tests now passing --- salt/daemons/salting.py | 46 ++++- salt/daemons/test/test_saltkeep.py | 289 ++++++++++++++++------------- salt/key.py | 17 ++ 3 files changed, 217 insertions(+), 135 deletions(-) diff --git a/salt/daemons/salting.py b/salt/daemons/salting.py index d9a311c395..4c79431278 100644 --- a/salt/daemons/salting.py +++ b/salt/daemons/salting.py @@ -58,11 +58,23 @@ class SaltKeep(Keep): raeting.autoModes.never))) self.saltRaetKey = RaetKey(opts) + def clearAllDir(self): + ''' + Clear all keep directories + ''' + super(SaltKeep, self).clearAllDir() + self.clearRoleDir() + + def clearRoleDir(self): + ''' + Clear the Role directory + ''' + self.saltRaetKey.delete_pki_dir() + def loadLocalData(self): ''' Load and Return the data from the local estate ''' - data = super(SaltKeep, self).loadLocalData() if not data: return None @@ -73,6 +85,18 @@ class SaltKeep(Keep): ('prihex', srkdata['priv'])]) return data + def clearLocalRoleData(self): + ''' + Clear the local file + ''' + self.saltRaetKey.delete_local() + + def clearLocalRoleDir(self): + ''' + Clear the Local Role directory + ''' + self.saltRaetKey.delete_pki_dir() + def loadRemoteData(self, name): ''' Load and Return the data from the remote file @@ -121,12 +145,24 @@ class SaltKeep(Keep): ('pubhex', keydata['pub'])]) return keeps + def clearRemoteRoleData(self, role): + ''' + Clear data from the role data file + ''' + self.saltRaetKey.delete_key(role) #now delete role key file + def clearAllRemoteRoleData(self): ''' Remove all the role data files ''' self.saltRaetKey.delete_all() + def clearRemoteRoleDir(self): + ''' + Clear the Remote Role directory + ''' + self.saltRaetKey.delete_pki_dir() + def dumpLocal(self, local): ''' Dump local estate @@ -230,11 +266,3 @@ class SaltKeep(Keep): mid = remote.role self.saltRaetKey.accept(match=mid, include_rejected=True) remote.acceptance = raeting.acceptances.accepted - -def clearAllKeep(dirpath): - ''' - Convenience function to clear all road keep data in dirpath - ''' - road = RoadKeep(dirpath=dirpath) - road.clearLocalData() - road.clearAllRemoteData() diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index 033d1c9b59..65bf98a619 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -187,8 +187,8 @@ class BasicTestCase(unittest.TestCase): main.serviceAll() if not (main.transactions or other.transactions): break - self.store.advanceStamp(0.1) - time.sleep(0.1) + self.store.advanceStamp(0.05) + time.sleep(0.05) def testBasic(self): ''' @@ -862,7 +862,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -872,16 +871,19 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.never) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, - 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + self.assertDictEqual(main.keep.loadLocalData(), {'name': mainData['name'], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], + 'role': mainData['role'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'role': mainData['role'], }) # add multiple remotes all with same role @@ -889,7 +891,6 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -900,7 +901,6 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -916,7 +916,7 @@ class BasicTestCase(unittest.TestCase): 'remote1': { 'name': data1['name'], - 'uid': 3, + 'uid': 2, 'fuid': 0, 'ha': ['127.0.0.1', 7532], 'iha': None, @@ -935,7 +935,7 @@ class BasicTestCase(unittest.TestCase): 'remote2': { 'name': data2['name'], - 'uid': 4, + 'uid': 3, 'fuid': 0, 'ha': ['127.0.0.1', 7533], 'iha': None, @@ -1003,7 +1003,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1013,16 +1012,20 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.always) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, + self.assertDictEqual(main.keep.loadLocalData(), { 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], + 'role': mainData['role'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'role': mainData['role'], }) # add multiple remotes all with same role @@ -1030,7 +1033,6 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -1041,7 +1043,6 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -1055,7 +1056,7 @@ class BasicTestCase(unittest.TestCase): 'remote1': { 'name': data1['name'], - 'uid': 3, + 'uid': 2, 'fuid': 0, 'ha': ['127.0.0.1', 7532], 'iha': None, @@ -1074,7 +1075,7 @@ class BasicTestCase(unittest.TestCase): 'remote2': { 'name': data2['name'], - 'uid': 4, + 'uid': 3, 'fuid': 0, 'ha': ['127.0.0.1', 7533], 'iha': None, @@ -1143,7 +1144,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1153,16 +1153,20 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.once) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, + self.assertDictEqual(main.keep.loadLocalData(), { 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], + 'role': mainData['role'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'role': mainData['role'], }) # add multiple remotes all with same role but different keys @@ -1170,7 +1174,6 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - uid=3, name=data1['name'], ha=('127.0.0.1', 7532), verkey=data1['verhex'], @@ -1181,7 +1184,6 @@ class BasicTestCase(unittest.TestCase): cachedirpath=opts['cachedir'], role='primary') main.addRemote(estating.RemoteEstate(stack=main, - uid=4, name=data2['name'], ha=('127.0.0.1', 7533), verkey=data2['verhex'], @@ -1198,7 +1200,7 @@ class BasicTestCase(unittest.TestCase): 'remote1': { 'name': data1['name'], - 'uid': 3, + 'uid': 2, 'fuid': 0, 'ha': ['127.0.0.1', 7532], 'iha': None, @@ -1217,7 +1219,7 @@ class BasicTestCase(unittest.TestCase): 'remote2': { 'name': data2['name'], - 'uid': 4, + 'uid': 3, 'fuid': 0, 'ha': ['127.0.0.1', 7533], 'iha': None, @@ -1266,11 +1268,11 @@ class BasicTestCase(unittest.TestCase): main.server.close() - def testBootstrapClean(self): + def testBootstrapNever(self): ''' - Bootstap to allowed + Bootstap to allowed with never mode on main ''' - console.terse("{0}\n".format(self.testBootstrapClean.__doc__)) + console.terse("{0}\n".format(self.testBootstrapNever.__doc__)) opts = self.createOpts(name='main', dirpath=self.tempDirpath, @@ -1285,7 +1287,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1295,23 +1296,28 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.never) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, + self.assertDictEqual(main.keep.loadLocalData(), { 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], + 'role': mainData['role'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'role': mainData['role'], }) opts = self.createOpts(name='other', dirpath=self.tempDirpath, openMode=False, - autoAccept=False) - otherData = self.createRoadData(name='other', cachedirpath=opts['cachedir'] ) + autoAccept=True) + otherData = self.createRoadData(name='other', + cachedirpath=opts['cachedir'] ) otherKeep = salting.SaltKeep(opts=opts, basedirpath=otherData['basedirpath'], stackname=otherData['name']) @@ -1320,7 +1326,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -1329,19 +1334,22 @@ class BasicTestCase(unittest.TestCase): other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) - self.assertIs(other.keep.auto, raeting.autoModes.never) + self.assertIs(other.keep.auto, raeting.autoModes.once) self.assertDictEqual(other.keep.loadLocalData(), { - 'uid': 0, 'name': otherData['name'], - 'ha': ['0.0.0.0', 7531], + 'uid': 1, + 'ha': ['127.0.0.1', 7531], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7531], + 'role': otherData['role'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'role': otherData['role'], }) self.join(other, main) @@ -1372,17 +1380,18 @@ class BasicTestCase(unittest.TestCase): # now delete a key and see if road keep file is also deleted main.keep.saltRaetKey.delete_key(match=other.local.role) - remote = main.remotes[other.local.uid] + remote = main.remotes[2] path = os.path.join(main.keep.remotedirpath, "{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext)) self.assertFalse(os.path.exists(path)) - main.server.close() - other.server.close() + for stack in [main, other]: + stack.server.close() + stack.clearAllKeeps() def testBootstrapOpen(self): ''' - Bootstap to allowed + Bootstap to allowed with open mode on main ''' console.terse("{0}\n".format(self.testBootstrapOpen.__doc__)) @@ -1399,7 +1408,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1409,21 +1417,25 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.always) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, + self.assertDictEqual(main.keep.loadLocalData(), { 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], + 'role': mainData['role'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'role': mainData['role'], }) opts = self.createOpts(name='other', dirpath=self.tempDirpath, - openMode=True, + openMode=False, autoAccept=True) otherData = self.createRoadData(name='other', cachedirpath=opts['cachedir'] ) otherKeep = salting.SaltKeep(opts=opts, @@ -1434,7 +1446,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -1443,19 +1454,22 @@ class BasicTestCase(unittest.TestCase): other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) - self.assertIs(other.keep.auto, raeting.autoModes.always) + self.assertIs(other.keep.auto, raeting.autoModes.once) self.assertDictEqual(other.keep.loadLocalData(), { - 'uid': 0, 'name': otherData['name'], - 'ha': ['0.0.0.0', 7531], + 'uid': 1, + 'ha': ['127.0.0.1', 7531], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7531], + 'role': otherData['role'], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], - 'role': otherData['role'], }) self.join(other, main) @@ -1482,17 +1496,18 @@ class BasicTestCase(unittest.TestCase): # now delete a key and see if road keep file is also deleted main.keep.saltRaetKey.delete_key(match=other.local.role) - remote = main.remotes[other.local.uid] + remote = main.remotes[2] path = os.path.join(main.keep.remotedirpath, "{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext)) self.assertFalse(os.path.exists(path)) - main.server.close() - other.server.close() + for stack in [main, other]: + stack.server.close() + stack.clearAllKeeps() def testBootstrapAuto(self): ''' - Bootstap to allowed + Bootstap to allowed with auto accept on main ''' console.terse("{0}\n".format(self.testBootstrapAuto.__doc__)) @@ -1509,7 +1524,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1519,16 +1533,20 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertEqual(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.once) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, + self.assertDictEqual(main.keep.loadLocalData(), { 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], + 'role': mainData['role'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'role': mainData['role'], }) opts = self.createOpts(name='other', @@ -1544,7 +1562,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(otherKeep.loadAllRemoteData(), {}) other = self.createRoadStack(data=otherData, - uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=otherKeep) @@ -1553,15 +1570,19 @@ class BasicTestCase(unittest.TestCase): other.name, other.keep.dirpath)) self.assertTrue(other.keep.dirpath.endswith('other/raet/other')) self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) + self.assertIs(other.keep.auto, raeting.autoModes.once) self.assertDictEqual(other.keep.loadLocalData(), { - 'uid': 0, 'name': otherData['name'], - 'ha': ['0.0.0.0', 7531], + 'uid': 1, + 'ha': ['127.0.0.1', 7531], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7531], 'sighex': otherData['sighex'], 'prihex': otherData['prihex'], 'role': otherData['role'], @@ -1591,19 +1612,20 @@ class BasicTestCase(unittest.TestCase): # now delete a key and see if road keep file is also deleted main.keep.saltRaetKey.delete_key(match=other.local.role) - remote = main.remotes[other.local.uid] + remote = main.remotes[2] path = os.path.join(main.keep.remotedirpath, "{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext)) self.assertFalse(os.path.exists(path)) - main.server.close() - other.server.close() + for stack in [main, other]: + stack.server.close() + stack.clearAllKeeps() - def testBootstrapRole(self): + def testBootstrapRoleNever(self): ''' - Bootstap to allowed with multiple remotes using same role + Bootstap to allowed with multiple remotes using same role with never main ''' - console.terse("{0}\n".format(self.testBootstrapRole.__doc__)) + console.terse("{0}\n".format(self.testBootstrapRoleNever.__doc__)) opts = self.createOpts(name='main', dirpath=self.tempDirpath, @@ -1618,7 +1640,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1628,22 +1649,26 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.never) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, + self.assertDictEqual(main.keep.loadLocalData(), { 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], + 'role': mainData['role'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'role': mainData['role'], }) opts = self.createOpts(name='other1', dirpath=self.tempDirpath, openMode=False, - autoAccept=False) + autoAccept=True) other1Data = self.createRoadData(name='other1', cachedirpath=opts['cachedir'], role='primary') @@ -1655,7 +1680,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(other1Keep.loadAllRemoteData(), {}) other1 = self.createRoadStack(data=other1Data, - uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=other1Keep) @@ -1664,19 +1688,22 @@ class BasicTestCase(unittest.TestCase): other1.name, other1.keep.dirpath)) self.assertTrue(other1.keep.dirpath.endswith('other1/raet/other1')) self.assertEqual(other1.ha, ("0.0.0.0", raeting.RAET_TEST_PORT)) - self.assertIs(other1.keep.auto, raeting.autoModes.never) + self.assertIs(other1.keep.auto, raeting.autoModes.once) self.assertDictEqual(other1.keep.loadLocalData(), { - 'uid': 0, 'name': other1Data['name'], - 'ha': ['0.0.0.0', 7531], + 'uid': 1, + 'ha': ['127.0.0.1', 7531], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7531], + 'role': other1Data['role'], 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], - 'role': other1Data['role'], }) self.join(other1, main) @@ -1708,7 +1735,7 @@ class BasicTestCase(unittest.TestCase): opts = self.createOpts(name='other2', dirpath=self.tempDirpath, openMode=False, - autoAccept=False) + autoAccept=True) other2Data = self.createRoadData(name='other2', cachedirpath=opts['cachedir'], role='primary') @@ -1720,7 +1747,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(other2Keep.loadAllRemoteData(), {}) other2 = self.createRoadStack(data=other2Data, - uid=0, main=None, ha=("", 7532), keep=other2Keep) @@ -1729,16 +1755,19 @@ class BasicTestCase(unittest.TestCase): other2.name, other2.keep.dirpath)) self.assertTrue(other2.keep.dirpath.endswith('other2/raet/other2')) self.assertEqual(other2.ha, ("0.0.0.0", 7532)) - self.assertIs(other2.keep.auto, raeting.autoModes.never) + self.assertIs(other2.keep.auto, raeting.autoModes.once) self.assertDictEqual(other2.keep.loadLocalData(), { - 'uid': 0, 'name': other2Data['name'], - 'ha': ['0.0.0.0', 7532], + 'uid': 1, + 'ha': ['127.0.0.1', 7532], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7532], 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], 'role': other2Data['role'], @@ -1747,7 +1776,7 @@ class BasicTestCase(unittest.TestCase): # should not join since role same but keys different self.join(other2, main) self.assertEqual(len(main.transactions), 0) # rejected since not same keys - self.assertEqual(other2.remotes.values()[0].joined, False) + self.assertEqual(len(other2.remotes), 0) self.assertEqual(len(main.remotes), 1) #main.removeRemote(main.nameRemotes[other2.local.name], clear=True) other2.server.close() @@ -1755,15 +1784,15 @@ class BasicTestCase(unittest.TestCase): path = os.path.join(main.keep.remotedirpath, "{0}.{1}.{2}".format(main.keep.prefix, other2.local.name, main.keep.ext)) self.assertFalse(os.path.exists(path)) - shutil.rmtree(opts['pki_dir']) - - + other2.keep.clearRoleDir() + self.assertFalse(os.path.exists(opts['pki_dir'])) + #shutil.rmtree(opts['pki_dir']) # recreate other2 stack but use same role and same keys as other1 opts = self.createOpts(name='other2', dirpath=self.tempDirpath, openMode=False, - autoAccept=False) + autoAccept=True) other2Data = self.createRoadData(name='other2', cachedirpath=opts['cachedir'], role='primary') @@ -1777,7 +1806,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(other2Keep.loadAllRemoteData(), {}) other2 = self.createRoadStack(data=other2Data, - uid=0, main=None, ha=("", 7532), keep=other2Keep) @@ -1786,19 +1814,22 @@ class BasicTestCase(unittest.TestCase): other2.name, other2.keep.dirpath)) self.assertTrue(other2.keep.dirpath.endswith('other2/raet/other2')) self.assertEqual(other2.ha, ("0.0.0.0", 7532)) - self.assertIs(other2.keep.auto, raeting.autoModes.never) + self.assertIs(other2.keep.auto, raeting.autoModes.once) self.assertDictEqual(other2.keep.loadLocalData(), { - 'uid': 0, 'name': other2Data['name'], - 'ha': ['0.0.0.0', 7532], + 'uid': 1, + 'ha': ['127.0.0.1', 7532], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7532], + 'role': other2Data['role'], 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], - 'role': other2Data['role'], }) # should join since same role and keys @@ -1824,25 +1855,24 @@ class BasicTestCase(unittest.TestCase): "{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext)) self.assertTrue(os.path.exists(path)) - # now delete a key and see if both road keep file are also deleted main.keep.saltRaetKey.delete_key(match=other1.local.role) - remote = main.remotes[other1.local.uid] + remote = main.remotes[2] path = os.path.join(main.keep.remotedirpath, "{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext)) self.assertFalse(os.path.exists(path)) - remote = main.remotes[other2.local.uid] + remote = main.remotes[4] path = os.path.join(main.keep.remotedirpath, "{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext)) self.assertFalse(os.path.exists(path)) - main.server.close() - other1.server.close() - other2.server.close() + for stack in [main, other1, other2]: + stack.server.close() + stack.clearAllKeeps() def testBootstrapRoleAuto(self): ''' - Bootstap to allowed with multiple remotes using same role + Bootstap to allowed with multiple remotes using same role with auto main ''' console.terse("{0}\n".format(self.testBootstrapRoleAuto.__doc__)) @@ -1859,7 +1889,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(mainKeep.loadAllRemoteData(), {}) main = self.createRoadStack(data=mainData, - uid=1, main=True, ha=None, #default ha is ("", raeting.RAET_PORT) keep=mainKeep) @@ -1869,16 +1898,20 @@ class BasicTestCase(unittest.TestCase): self.assertTrue(main.keep.dirpath.endswith('main/raet/main')) self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT)) self.assertIs(main.keep.auto, raeting.autoModes.once) - self.assertDictEqual(main.keep.loadLocalData(), {'uid': 1, + self.assertDictEqual(main.keep.loadLocalData(), { 'name': mainData['name'], - 'ha': ['0.0.0.0', 7530], + 'uid': 1, + 'ha': ['127.0.0.1', 7530], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7530], + 'role': mainData['role'], 'sighex': mainData['sighex'], 'prihex': mainData['prihex'], - 'role': mainData['role'], }) opts = self.createOpts(name='other1', @@ -1896,7 +1929,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(other1Keep.loadAllRemoteData(), {}) other1 = self.createRoadStack(data=other1Data, - uid=0, main=None, ha=("", raeting.RAET_TEST_PORT), keep=other1Keep) @@ -1908,16 +1940,19 @@ class BasicTestCase(unittest.TestCase): self.assertIs(other1.keep.auto, raeting.autoModes.once) self.assertDictEqual(other1.keep.loadLocalData(), { - 'uid': 0, 'name': other1Data['name'], - 'ha': ['0.0.0.0', 7531], + 'uid': 1, + 'ha': ['127.0.0.1', 7531], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7531], + 'role': other1Data['role'], 'sighex': other1Data['sighex'], 'prihex': other1Data['prihex'], - 'role': other1Data['role'], }) self.join(other1, main) @@ -1945,7 +1980,7 @@ class BasicTestCase(unittest.TestCase): opts = self.createOpts(name='other2', dirpath=self.tempDirpath, openMode=False, - autoAccept=False) + autoAccept=True) other2Data = self.createRoadData(name='other2', cachedirpath=opts['cachedir'], role='primary') @@ -1960,7 +1995,6 @@ class BasicTestCase(unittest.TestCase): self.assertEqual(other2Keep.loadAllRemoteData(), {}) other2 = self.createRoadStack(data=other2Data, - uid=0, main=None, ha=("", 7532), keep=other2Keep) @@ -1969,22 +2003,25 @@ class BasicTestCase(unittest.TestCase): other2.name, other2.keep.dirpath)) self.assertTrue(other2.keep.dirpath.endswith('other2/raet/other2')) self.assertEqual(other2.ha, ("0.0.0.0", 7532)) - self.assertIs(other2.keep.auto, raeting.autoModes.never) + self.assertIs(other2.keep.auto, raeting.autoModes.once) self.assertDictEqual(other2.keep.loadLocalData(), { - 'uid': 0, 'name': other2Data['name'], - 'ha': ['0.0.0.0', 7532], + 'uid': 1, + 'ha': ['127.0.0.1', 7532], 'iha': None, 'natted': None, + 'fqdn': '1.0.0.127.in-addr.arpa', + 'dyned': None, 'sid': 0, 'puid': 1, + 'aha': ['0.0.0.0', 7532], + 'role': other2Data['role'], 'sighex': other2Data['sighex'], 'prihex': other2Data['prihex'], - 'role': other2Data['role'], }) - # should join since same role and keys + # should join since open mode self.join(other2, main) self.assertEqual(len(main.transactions), 0) @@ -2010,18 +2047,18 @@ class BasicTestCase(unittest.TestCase): # now delete a key and see if both road keep file are also deleted main.keep.saltRaetKey.delete_key(match=other1.local.role) - remote = main.remotes[other1.local.uid] + remote = main.remotes[2] path = os.path.join(main.keep.remotedirpath, "{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext)) self.assertFalse(os.path.exists(path)) - remote = main.remotes[other2.local.uid] + remote = main.remotes[3] path = os.path.join(main.keep.remotedirpath, "{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext)) self.assertFalse(os.path.exists(path)) - main.server.close() - other1.server.close() - other2.server.close() + for stack in [main, other1, other2]: + stack.server.close() + stack.clearAllKeeps() def runOne(test): ''' @@ -2042,10 +2079,10 @@ def runSome(): 'testBasicRole', 'testBasicRoleOpen', 'testBasicRoleAuto', - 'testBootstrapClean', + 'testBootstrapNever', 'testBootstrapOpen', 'testBootstrapAuto', - 'testBootstrapRole', + 'testBootstrapRoleNever', 'testBootstrapRoleAuto', ] diff --git a/salt/key.py b/salt/key.py index bd20b776a2..f5cfa7e96b 100644 --- a/salt/key.py +++ b/salt/key.py @@ -1206,3 +1206,20 @@ class RaetKey(Key): fp_.write(self.serial.dumps(keydata)) os.chmod(path, stat.S_IRUSR) os.umask(c_umask) + + def delete_local(self): + ''' + Delete the local private key file + ''' + path = os.path.join(self.opts['pki_dir'], 'local.key') + if os.path.isfile(path): + os.remove(path) + + def delete_pki_dir(self): + ''' + Delete the private key directory + ''' + path = self.opts['pki_dir'] + if os.path.exists(path): + #os.rmdir(path) + shutil.rmtree(path) From cc13292e6644611931a7ce5533131d1a267ce8ab Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Mon, 15 Sep 2014 16:45:59 -0600 Subject: [PATCH 17/20] updating behaviors for new semantics --- salt/daemons/flo/core.py | 20 ++++++++++++-------- salt/daemons/flo/master.flo | 2 +- salt/daemons/test/master.flo | 2 +- salt/daemons/test/minion.flo | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/salt/daemons/flo/core.py b/salt/daemons/flo/core.py index a7bc5e1726..fd4bc983a1 100644 --- a/salt/daemons/flo/core.py +++ b/salt/daemons/flo/core.py @@ -21,7 +21,7 @@ import salt.utils.args import salt.transport from raet import raeting, nacling from raet.road.stacking import RoadStack -from raet.road.estating import LocalEstate +from raet.road.estating import LocalEstate, RemoteEstate from raet.lane.stacking import LaneStack from raet.lane.yarding import RemoteYard @@ -111,7 +111,7 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): 'ival': {'name': 'master', 'main': False, 'mutable': False, - 'eid': 0, + 'uid': None, 'sigkey': None, 'prikey': None}}, } @@ -136,7 +136,7 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): prikey = self.local.data.prikey main = self.local.data.main mutable = self.opts.value.get('open_mode', self.local.data.mutable) - eid = self.local.data.eid + uid = self.local.data.uid ha = (self.opts.value['interface'], self.opts.value['raet_port']) @@ -152,7 +152,7 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): self.stack.value = RoadStack(store=self.store, keep=keep, name=name, - uid=eid, + uid=uid, ha=ha, sigkey=sigkey, prikey=prikey, @@ -183,7 +183,6 @@ class SaltRaetRoadStackCloser(ioflo.base.deeding.Deed): if self.stack.value and isinstance(self.stack.value, RoadStack): self.stack.value.server.close() - class SaltRaetRoadStackJoiner(ioflo.base.deeding.Deed): ''' Initiates join transaction with master @@ -208,8 +207,12 @@ class SaltRaetRoadStackJoiner(ioflo.base.deeding.Deed): ''' stack = self.stack.value if stack and isinstance(stack, RoadStack): - stack.join(ha=self.mha, timeout=0.0) - + if not stack.remotes: + stack.addRemote(RemoteEstate(stack=stack, + fuid=0, # vacuous join + sid=0, # always 0 for join + ha=self.mha)) + stack.join(uid=stack.remotes.values()[0].uid, timeout=0.0) class SaltRaetRoadStackJoined(ioflo.base.deeding.Deed): ''' @@ -740,7 +743,8 @@ class Router(ioflo.base.deeding.Deed): elif d_share == 'remote_cmd': # Send it to a remote worker if 'load' in msg: - msg['load']['id'] = sender + role = self.udp_stack.value.nameRemotes[sender].role + msg['load']['id'] = role #sender # should this be role XXXX self.uxd_stack.value.transmit(msg, self.uxd_stack.value.fetchUidByName(next(self.workers.value))) elif d_share == 'fun': diff --git a/salt/daemons/flo/master.flo b/salt/daemons/flo/master.flo index 289c1b3d92..dd1f0b7814 100644 --- a/salt/daemons/flo/master.flo +++ b/salt/daemons/flo/master.flo @@ -2,7 +2,7 @@ house master -init .raet.udp.stack.local to eid 1 main true name "master" +init .raet.udp.stack.local to main true name "master" init .salt.uxd.stack.local to yid 0 name "master" lanename "master" diff --git a/salt/daemons/test/master.flo b/salt/daemons/test/master.flo index cf1198cfee..08f9a3cd63 100644 --- a/salt/daemons/test/master.flo +++ b/salt/daemons/test/master.flo @@ -2,7 +2,7 @@ house master -init .raet.udp.stack.local to eid 1 name "master" host "" port 7530 main true +init .raet.udp.stack.local to name "master" host "" port 7530 main true #init port in .raet.udp.stack.local from value in .salt.etc.raet_port diff --git a/salt/daemons/test/minion.flo b/salt/daemons/test/minion.flo index 6b1fe9efc2..c8acde30a2 100644 --- a/salt/daemons/test/minion.flo +++ b/salt/daemons/test/minion.flo @@ -2,7 +2,7 @@ house minion -init .raet.udp.stack.local to eid 0 name "minion" host "" port 7531 main false +init .raet.udp.stack.local to name "minion" host "" port 7531 main false #init port in .raet.udp.stack.local from value in .salt.etc.raet_port #init .salt.etc.master to "127.0.0.1" From 8855520820671173d55c2db1ac00b74689ebef29 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Wed, 17 Sep 2014 11:31:23 -0600 Subject: [PATCH 18/20] Added raet_mutable and raet_main config opts to salt. raet_mutable enables (True) a mutable raet road where rejoins can change road data otherwise no changes allowed on rejoin raet_main enables (True) the raet road stack to accept vacuous joins otherwise no vacuous joins accepted --- salt/config.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/salt/config.py b/salt/config.py index fcd79d2318..7bab087eb0 100644 --- a/salt/config.py +++ b/salt/config.py @@ -243,7 +243,13 @@ VALID_OPTS = { 'ssh_sudo': bool, 'ssh_timeout': float, 'ssh_user': str, + 'ioflo_verbose': int, + 'ioflo_period': float, + 'ioflo_realtime': bool, + 'ioflo_console_logdir': str, 'raet_port': int, + 'raet_mutable': bool, + 'raet_main': bool, 'sqlite_queue_dir': str, 'queue_dirs': list, 'restart_on_error': bool, @@ -371,7 +377,10 @@ DEFAULT_MINION_OPTS = { 'ioflo_verbose': 0, 'ioflo_period': 0.1, 'ioflo_realtime': True, + 'ioflo_console_logdir': '', 'raet_port': 4510, + 'raet_mutable': False, + 'raet_main': False, 'restart_on_error': False, 'ping_interval': 0, 'username': None, @@ -531,7 +540,10 @@ DEFAULT_MASTER_OPTS = { 'ioflo_verbose': 0, 'ioflo_period': 0.01, 'ioflo_realtime': True, + 'ioflo_console_logdir': '', 'raet_port': 4506, + 'raet_mutable': False, + 'raet_main': True, 'sqlite_queue_dir': os.path.join(salt.syspaths.CACHE_DIR, 'master', 'queues'), 'queue_dirs': [], 'cli_summary': False, From ea1aa72115e91445e568a136932c90483549408b Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Wed, 17 Sep 2014 13:04:02 -0600 Subject: [PATCH 19/20] road stack setup now uses opts 'raet_mutable' and 'raet_main' --- salt/daemons/flo/core.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/salt/daemons/flo/core.py b/salt/daemons/flo/core.py index fd4bc983a1..bbfd67abe6 100644 --- a/salt/daemons/flo/core.py +++ b/salt/daemons/flo/core.py @@ -53,7 +53,6 @@ except ImportError: pass log = logging.getLogger(__name__) - class SaltRaetCleanup(ioflo.base.deeding.Deed): ''' Cleanup stray lane keep directories not reaped @@ -134,8 +133,10 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): name = self.opts.value.get('id', self.local.data.name) sigkey = self.local.data.sigkey prikey = self.local.data.prikey - main = self.local.data.main - mutable = self.opts.value.get('open_mode', self.local.data.mutable) + main = self.opts.value.get('raet_main', self.local.data.main) + mutable = self.opts.value.get('raet_mutable', self.local.data.mutable) + always = self.opts.value.get('open_mode', False) + mutable = mutable or always # open_made when True takes precedence uid = self.local.data.uid ha = (self.opts.value['interface'], self.opts.value['raet_port']) From 9b54e5b55a3e22a052c83164573eececb2e1f97d Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Wed, 17 Sep 2014 13:49:29 -0600 Subject: [PATCH 20/20] lint fixes --- salt/daemons/flo/core.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/salt/daemons/flo/core.py b/salt/daemons/flo/core.py index bbfd67abe6..c47c35c10c 100644 --- a/salt/daemons/flo/core.py +++ b/salt/daemons/flo/core.py @@ -21,7 +21,7 @@ import salt.utils.args import salt.transport from raet import raeting, nacling from raet.road.stacking import RoadStack -from raet.road.estating import LocalEstate, RemoteEstate +from raet.road.estating import RemoteEstate from raet.lane.stacking import LaneStack from raet.lane.yarding import RemoteYard @@ -53,6 +53,7 @@ except ImportError: pass log = logging.getLogger(__name__) + class SaltRaetCleanup(ioflo.base.deeding.Deed): ''' Cleanup stray lane keep directories not reaped @@ -136,7 +137,7 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed): main = self.opts.value.get('raet_main', self.local.data.main) mutable = self.opts.value.get('raet_mutable', self.local.data.mutable) always = self.opts.value.get('open_mode', False) - mutable = mutable or always # open_made when True takes precedence + mutable = mutable or always # open_made when True takes precedence uid = self.local.data.uid ha = (self.opts.value['interface'], self.opts.value['raet_port']) @@ -184,6 +185,7 @@ class SaltRaetRoadStackCloser(ioflo.base.deeding.Deed): if self.stack.value and isinstance(self.stack.value, RoadStack): self.stack.value.server.close() + class SaltRaetRoadStackJoiner(ioflo.base.deeding.Deed): ''' Initiates join transaction with master @@ -210,11 +212,12 @@ class SaltRaetRoadStackJoiner(ioflo.base.deeding.Deed): if stack and isinstance(stack, RoadStack): if not stack.remotes: stack.addRemote(RemoteEstate(stack=stack, - fuid=0, # vacuous join - sid=0, # always 0 for join + fuid=0, # vacuous join + sid=0, # always 0 for join ha=self.mha)) stack.join(uid=stack.remotes.values()[0].uid, timeout=0.0) + class SaltRaetRoadStackJoined(ioflo.base.deeding.Deed): ''' Updates status with .joined of zeroth remote estate (master) @@ -745,7 +748,7 @@ class Router(ioflo.base.deeding.Deed): # Send it to a remote worker if 'load' in msg: role = self.udp_stack.value.nameRemotes[sender].role - msg['load']['id'] = role #sender # should this be role XXXX + msg['load']['id'] = role # sender # should this be role XXXX self.uxd_stack.value.transmit(msg, self.uxd_stack.value.fetchUidByName(next(self.workers.value))) elif d_share == 'fun':