def test_floating_mangle_rules(self):
    router = mock.MagicMock()
    router.get.return_value = [{'host': HOSTNAME}, {'host': mock.sentinel.otherhost}]
    ri = self._create_router(router)
    floating_ip = '0.0.0.0'
    fixed_ip = '192.168.0.1'
    internal_mark = 'fake_mark'
    rtr_2_fip_name = 'fake_router'
    instance = mock.Mock()
    instance.get_rtr_ext_device_name = mock.Mock(return_value=rtr_2_fip_name)
    ri.fip_ns = instance
    mark_traffic_to_floating_ip = ('floatingip', ('-d %s/32 -i %s -j MARK --set-xmark %s' % (floating_ip, rtr_2_fip_name, internal_mark)))
    mark_traffic_from_fixed_ip = ('FORWARD', ('-s %s/32 -j $float-snat' % fixed_ip))
    actual = ri.floating_mangle_rules(floating_ip, fixed_ip, internal_mark)
    expected = [mark_traffic_to_floating_ip, mark_traffic_from_fixed_ip]
    self.assertEqual(expected, actual)
def test_floating_mangle_rules(self):
    router = mock.MagicMock()
    router.get.return_value = [{'host': HOSTNAME}, {'host': mock.sentinel.otherhost}]
    ri = self._create_router(router)
    floating_ip = '0.0.0.0'
    fixed_ip = '192.168.0.1'
    internal_mark = 'fake_mark'
    rtr_2_fip_name = 'fake_router'
    instance = mock.Mock()
    instance.get_rtr_ext_device_name = mock.Mock(return_value=rtr_2_fip_name)
    ri.fip_ns = instance
    mark_traffic_to_floating_ip = ('floatingip', ('-d %s/32 -i %s -j MARK --set-xmark %s' % (floating_ip, rtr_2_fip_name, internal_mark)))
    mark_traffic_from_fixed_ip = ('FORWARD', ('-s %s/32 -j $float-snat' % fixed_ip))
    actual = ri.floating_mangle_rules(floating_ip, fixed_ip, internal_mark)
    expected = [mark_traffic_to_floating_ip, mark_traffic_from_fixed_ip]
    self.assertEqual(expected, actual)