Exemplo n.º 1
0
 def setUpClass(cls):
     load('IF-MIB')
     load('SNMPv2-MIB')
     load(
         os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      "SNIMPY-MIB.mib"))
     cls.agent = agent.TestAgent()
Exemplo n.º 2
0
 def _test(self, ipv6, host):
     m = agent.TestAgent(ipv6)
     session = snmp.Session(host="{0}:{1}".format(host, m.port),
                            community="public",
                            version=2)
     try:
         ooid = mib.get('SNMPv2-MIB', 'sysDescr').oid + (0, )
         oid, a = session.get(ooid)[0]
         self.assertEqual(a, b"Snimpy Test Agent public")
     finally:
         m.terminate()
Exemplo n.º 3
0
 def testAccessNotExistentTable(self):
     """Try to walk a non-existent table"""
     agent2 = agent.TestAgent(emptyTable=False)
     try:
         manager = Manager(host="127.0.0.1:{0}".format(agent2.port),
                           community="public",
                           version=2)
         [(idx, ) for idx in manager.snimpyEmptyDescr]
     except snmp.SNMPNoSuchObject:
         pass  # That's OK
     else:
         self.assertFalse("should raise SNMPNoSuchObject exception")
     finally:
         agent2.terminate()
 def test_run_basic_mdp_and_agent_many_episodes(self):
     mdp = mdps.LineMDP(5)
     a = agent.TestAgent(len(mdp.get_actions()))
     num_epochs = 5
     epoch_length = 10
     test_epoch_length = 0
     max_steps = 100
     run_tests = False
     e = experiment.Experiment(mdp, a, num_epochs, epoch_length,
                               test_epoch_length, max_steps, run_tests)
     e.run()
     actual = e.agent.episodes
     expected = e.num_epochs * e.epoch_length
     self.assertEquals(actual, expected)
Exemplo n.º 5
0
    def Start(self, parts):
        """
        start the particle on the lowest rung
        
        Args:
        parts: single agent or any iterable of agents (can be higher dimension also)
        """

        # try treating parts as an iterable
        try:
            # if parts is an iterable run over each part
            for p in parts:
                self.Start(p)
                # call recursively to allow nested inputs

        except:  # should have reached input which is just an agent

            if (type(parts) == type(agent.TestAgent())):  # single agent
                self.start.content.occupants.append(parts)

            else:  #problem
                raise ValueError(
                    "Start must take single agent or list of agent objects")
Exemplo n.º 6
0
 def setUpClass(cls):
     mib.load('IF-MIB')
     mib.load('SNMPv2-MIB')
     cls.agent = agent.TestAgent()
Exemplo n.º 7
0
 def addAgent(cls, community, auth, priv):
     a = agent.TestAgent(community=community, authpass=auth, privpass=priv)
     cls.agents.append(a)
     return a
Exemplo n.º 8
0
 def setUpClass(cls):
     cls.agent = agent.TestAgent()