Пример #1
0
    def test_remote_sessions_can_continue_on_a_different_netman(self):
        with NetmanTestApp() as partial_client1, NetmanTestApp() as partial_client2:
            switch_descriptor = get_available_switch("juniper")

            client1 = partial_client1(switch_descriptor)
            first_netman_url = "{}:{}".format(client1.host, client1.port)

            client2 = partial_client2(switch_descriptor)
            second_netman_url = "{}:{}".format(client2.host, client2.port)

            remote_switch = RemoteSwitch(switch_descriptor)
            remote_switch._proxy = first_netman_url
            switch = FlowControlSwitch(remote_switch, ThreadingLockFactory().new_lock())

            with switch.transaction():
                switch.add_vlan(1498, "one")

                remote_switch._proxy = second_netman_url

                switch.add_vlan(1499, "two")

            assert_that(client1.get("/switches/{hostname}/vlans/1498").json()["name"], is_("one"))
            assert_that(client1.get("/switches/{hostname}/vlans/1499").json()["name"], is_("two"))
Пример #2
0
 def setUp(self):
     self.wrapped_switch = flexmock(
         SwitchBase(SwitchDescriptor("cisco", "name")))
     self.lock = flexmock()
     self.switch = FlowControlSwitch(self.wrapped_switch, self.lock)
Пример #3
0
 def get_switch_by_descriptor(self, switch_descriptor):
     real_switch = super(FlowControlSwitchFactory,
                         self).get_switch_by_descriptor(switch_descriptor)
     return FlowControlSwitch(real_switch,
                              lock=self._get_lock(switch_descriptor))