We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
SLB Test Cases

Step | Goal | Expected results
-- | -- | --
Create peering session from the SLB to Active ToR | SLB | Verify session is established
Create peering session from the SLB to Standby ToR | SLB | Verify session is established
  |   |  
Announce routes from SLB to Active ToR | SLB | Verify routes in Active ToR
Announce routes from SLB to Standby ToR | SLB | Verify routes in Standby ToR
  |   |  
Run PTF tests on Active ToR | SLB | Verify packets forwarded directly to active SLB port
Run PTF tests on Standby ToR | SLB | Verify packets forwarded via tunnel to Active ToR
  |   |  
Withdraw routes from SLB to Active ToR | SLB | Verify routes removed in Active ToR
Withdraw routes from SLB to Standby ToR | SLB | Verify routes removed in Standby ToR
  |   |  
Repeat PTF tests as above | SLB | Verify no packets forwarded
  |   |  
Simulate a mux state change for the SLB port | SLB | Verify both sessions stays established and not disrupted
  |   |  
Announce routes from SLB to new Active ToR | SLB | Verify routes in Active ToR
Announce routes from SLB to new Standby ToR | SLB | Verify routes in Standby ToR
  |   |  
Repeat PTF tests as above | SLB | Verify packet forwarding based on mux state
  |   |  
Verify teardown by shutting peering session one by one | SLB | After one session is down, verify other peering session is active and routes present



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ansible/library/dual_tor_facts.py`
Content:
```
1 from collections import defaultdict
2 class DualTorParser:
3 
4     def __init__(self, hostname, testbed_facts, host_vars, vm_config, port_alias, vlan_intfs):
5         self.hostname = hostname
6         self.testbed_facts = testbed_facts
7         self.host_vars = host_vars
8         self.vm_config = vm_config
9         self.port_alias = port_alias
10         self.vlan_intfs = vlan_intfs
11         self.dual_tor_facts = {}
12 
13     def parse_neighbor_tor(self):
14         '''
15         Parses information about the other ToR in a dual ToR pair
16         '''
17         neighbor = {}
18         neighbor['hostname'] = [dut for dut in self.testbed_facts['duts'] if dut != self.hostname][0]
19         neighbor['ip'] = self.host_vars[neighbor['hostname']]['ansible_host']
20         neighbor['hwsku'] = self.host_vars[neighbor['hostname']]['hwsku']
21 
22         self.dual_tor_facts['neighbor'] = neighbor
23 
24     def parse_tor_position(self):
25         '''
26         Determines the position ('U' for upper and 'L' for lower) of the ToR.
27 
28         The upper ToR is always the first ToR listed in the testbed file
29         '''
30         self.dual_tor_facts['positions'] = {'upper': self.testbed_facts['duts'][0], 'lower': self.testbed_facts['duts'][1]}
31 
32     def parse_loopback_ips(self):
33         '''
34         Parses the IPv4 and IPv6 loopback IPs for the DUTs
35 
36         Similar to `parse_tor_position`, the ToR which comes first in the testbed file is always assigned the first IP
37         '''
38 
39         loopback_ips = defaultdict(dict)
40         addl_loopback_ips = defaultdict(dict)
41 
42         for dut_num, dut in enumerate(self.testbed_facts['duts']):
43             loopback_ips[dut]['ipv4'] = self.vm_config['DUT']['loopback']['ipv4'][dut_num]
44             loopback_ips[dut]['ipv6'] = self.vm_config['DUT']['loopback']['ipv6'][dut_num] 
45 
46             for loopback_num in range(1, 3): # Generate two additional loopback IPs, Loopback1 and Loopback2
47                 loopback_key = 'loopback{}'.format(loopback_num)
48                 loopback_dict = {}
49                 loopback_dict['ipv4'] = self.vm_config['DUT'][loopback_key]['ipv4'][dut_num]
50                 loopback_dict['ipv6'] = self.vm_config['DUT'][loopback_key]['ipv6'][dut_num]
51                 loopback_dict['host_ip_base_index'] = loopback_num * 2
52                 addl_loopback_ips[dut][loopback_num] = loopback_dict
53 
54         self.dual_tor_facts['loopback'] = loopback_ips 
55         self.dual_tor_facts['addl_loopbacks'] = addl_loopback_ips
56 
57     def generate_cable_names(self):
58         cables = []
59 
60         for server_num, dut_intf in enumerate(self.vlan_intfs):
61             name = '{}-Servers{}-SC'.format(self.hostname, server_num)
62             cable = {"hostname": name, "dut_intf": dut_intf}
63             cables.append(cable)
64 
65         self.dual_tor_facts['cables'] = cables
66 
67     def get_dual_tor_facts(self):
68         '''
69         Gathers facts related to a dual ToR configuration
70         '''
71         if 'dualtor' in self.testbed_facts['topo']:
72             self.parse_neighbor_tor()
73             self.parse_tor_position()
74             self.generate_cable_names()
75             self.parse_loopback_ips()
76 
77         return self.dual_tor_facts
78 
79 
80 def main():
81     module = AnsibleModule(
82         argument_spec=dict(
83             hostname=dict(required=True, default=None, type='str'),
84             testbed_facts=dict(required=True, default=None, type='dict'),
85             hostvars=dict(required=True, default=None, type='dict'),
86             vm_config=dict(required=True, default=None, type='dict'),
87             port_alias=dict(required=True, default=None, type='list'),
88             vlan_intfs=dict(required=True, default=None, type='list')
89         ),
90         supports_check_mode=True
91     )
92     m_args = module.params
93     # testbed_facts ={u'comment': u'Dual-TOR testbed', u'conf-name': u'vms-kvm-dual-t0', u'ptf_ip': u'10.250.0.109', u'ptf_netmask': u'255.255.255.0', u'ptf_ipv6': u'fec0::ffff:afa:9', u'vm_base': u'VM0108', u'server': u'server_1', u'topo': u'dualtor', u'group-name': u'vms6-4', u'ptf': u'ptf-04', u'duts_map': {u'vlab-06': 1, u'vlab-05': 0}, u'ptf_netmask_v6': u'ffff:ffff:ffff:ffff::', u'ptf_image_name': u'docker-ptf', u'duts': [u'vlab-05', u'vlab-06']}
94     hostname = m_args['hostname']
95     testbed_facts = m_args['testbed_facts']
96     host_vars = m_args['hostvars']
97     vm_config = m_args['vm_config']
98     port_alias = m_args['port_alias']
99     vlan_intfs = m_args['vlan_intfs']
100     try:
101         dual_tor_parser = DualTorParser(hostname, testbed_facts, host_vars, vm_config, port_alias, vlan_intfs)
102         module.exit_json(ansible_facts={'dual_tor_facts': dual_tor_parser.get_dual_tor_facts()})
103     except Exception as e:
104         module.fail_json(msg=traceback.format_exc())
105 
106 from ansible.module_utils.basic import *
107 if __name__== "__main__":
108     main()
109
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/ansible/library/dual_tor_facts.py b/ansible/library/dual_tor_facts.py
--- a/ansible/library/dual_tor_facts.py
+++ b/ansible/library/dual_tor_facts.py
@@ -43,7 +43,7 @@
             loopback_ips[dut]['ipv4'] = self.vm_config['DUT']['loopback']['ipv4'][dut_num]
             loopback_ips[dut]['ipv6'] = self.vm_config['DUT']['loopback']['ipv6'][dut_num] 
 
-            for loopback_num in range(1, 3): # Generate two additional loopback IPs, Loopback1 and Loopback2
+            for loopback_num in range(1, 4): # Generate two additional loopback IPs, Loopback1, Loopback2, and Loopback3
                 loopback_key = 'loopback{}'.format(loopback_num)
                 loopback_dict = {}
                 loopback_dict['ipv4'] = self.vm_config['DUT'][loopback_key]['ipv4'][dut_num]

{"golden_diff": "diff --git a/ansible/library/dual_tor_facts.py b/ansible/library/dual_tor_facts.py\n--- a/ansible/library/dual_tor_facts.py\n+++ b/ansible/library/dual_tor_facts.py\n@@ -43,7 +43,7 @@\n             loopback_ips[dut]['ipv4'] = self.vm_config['DUT']['loopback']['ipv4'][dut_num]\n             loopback_ips[dut]['ipv6'] = self.vm_config['DUT']['loopback']['ipv6'][dut_num] \n \n-            for loopback_num in range(1, 3): # Generate two additional loopback IPs, Loopback1 and Loopback2\n+            for loopback_num in range(1, 4): # Generate two additional loopback IPs, Loopback1, Loopback2, and Loopback3\n                 loopback_key = 'loopback{}'.format(loopback_num)\n                 loopback_dict = {}\n                 loopback_dict['ipv4'] = self.vm_config['DUT'][loopback_key]['ipv4'][dut_num]\n", "issue": "SLB Test Cases\n\r\nStep | Goal | Expected results\r\n-- | -- | --\r\nCreate peering session from the SLB to Active ToR | SLB | Verify session is established\r\nCreate peering session from the SLB to Standby ToR | SLB | Verify session is established\r\n\u00a0 | \u00a0 | \u00a0\r\nAnnounce routes from SLB to Active ToR | SLB | Verify routes in Active ToR\r\nAnnounce routes from SLB to Standby ToR | SLB | Verify routes in Standby ToR\r\n\u00a0 | \u00a0 | \u00a0\r\nRun PTF tests on Active ToR | SLB | Verify packets forwarded directly to active SLB port\r\nRun PTF tests on Standby ToR | SLB | Verify packets forwarded via tunnel to Active ToR\r\n\u00a0 | \u00a0 | \u00a0\r\nWithdraw routes from SLB to Active ToR | SLB | Verify routes removed in Active ToR\r\nWithdraw routes from SLB to Standby ToR | SLB | Verify routes removed in Standby ToR\r\n\u00a0 | \u00a0 | \u00a0\r\nRepeat PTF tests as above | SLB | Verify no packets forwarded\r\n\u00a0 | \u00a0 | \u00a0\r\nSimulate a mux state change for the SLB port | SLB | Verify both sessions stays established and not disrupted\r\n\u00a0 | \u00a0 | \u00a0\r\nAnnounce routes from SLB to new Active ToR | SLB | Verify routes in Active ToR\r\nAnnounce routes from SLB to new Standby ToR | SLB | Verify routes in Standby ToR\r\n\u00a0 | \u00a0 | \u00a0\r\nRepeat PTF tests as above | SLB | Verify packet forwarding based on mux state\r\n\u00a0 | \u00a0 | \u00a0\r\nVerify teardown by shutting peering session one by one | SLB | After one session is down, verify other peering session is active and routes present\r\n\r\n\n", "before_files": [{"content": "from collections import defaultdict\nclass DualTorParser:\n\n    def __init__(self, hostname, testbed_facts, host_vars, vm_config, port_alias, vlan_intfs):\n        self.hostname = hostname\n        self.testbed_facts = testbed_facts\n        self.host_vars = host_vars\n        self.vm_config = vm_config\n        self.port_alias = port_alias\n        self.vlan_intfs = vlan_intfs\n        self.dual_tor_facts = {}\n\n    def parse_neighbor_tor(self):\n        '''\n        Parses information about the other ToR in a dual ToR pair\n        '''\n        neighbor = {}\n        neighbor['hostname'] = [dut for dut in self.testbed_facts['duts'] if dut != self.hostname][0]\n        neighbor['ip'] = self.host_vars[neighbor['hostname']]['ansible_host']\n        neighbor['hwsku'] = self.host_vars[neighbor['hostname']]['hwsku']\n\n        self.dual_tor_facts['neighbor'] = neighbor\n\n    def parse_tor_position(self):\n        '''\n        Determines the position ('U' for upper and 'L' for lower) of the ToR.\n\n        The upper ToR is always the first ToR listed in the testbed file\n        '''\n        self.dual_tor_facts['positions'] = {'upper': self.testbed_facts['duts'][0], 'lower': self.testbed_facts['duts'][1]}\n\n    def parse_loopback_ips(self):\n        '''\n        Parses the IPv4 and IPv6 loopback IPs for the DUTs\n\n        Similar to `parse_tor_position`, the ToR which comes first in the testbed file is always assigned the first IP\n        '''\n\n        loopback_ips = defaultdict(dict)\n        addl_loopback_ips = defaultdict(dict)\n\n        for dut_num, dut in enumerate(self.testbed_facts['duts']):\n            loopback_ips[dut]['ipv4'] = self.vm_config['DUT']['loopback']['ipv4'][dut_num]\n            loopback_ips[dut]['ipv6'] = self.vm_config['DUT']['loopback']['ipv6'][dut_num] \n\n            for loopback_num in range(1, 3): # Generate two additional loopback IPs, Loopback1 and Loopback2\n                loopback_key = 'loopback{}'.format(loopback_num)\n                loopback_dict = {}\n                loopback_dict['ipv4'] = self.vm_config['DUT'][loopback_key]['ipv4'][dut_num]\n                loopback_dict['ipv6'] = self.vm_config['DUT'][loopback_key]['ipv6'][dut_num]\n                loopback_dict['host_ip_base_index'] = loopback_num * 2\n                addl_loopback_ips[dut][loopback_num] = loopback_dict\n\n        self.dual_tor_facts['loopback'] = loopback_ips \n        self.dual_tor_facts['addl_loopbacks'] = addl_loopback_ips\n\n    def generate_cable_names(self):\n        cables = []\n\n        for server_num, dut_intf in enumerate(self.vlan_intfs):\n            name = '{}-Servers{}-SC'.format(self.hostname, server_num)\n            cable = {\"hostname\": name, \"dut_intf\": dut_intf}\n            cables.append(cable)\n\n        self.dual_tor_facts['cables'] = cables\n\n    def get_dual_tor_facts(self):\n        '''\n        Gathers facts related to a dual ToR configuration\n        '''\n        if 'dualtor' in self.testbed_facts['topo']:\n            self.parse_neighbor_tor()\n            self.parse_tor_position()\n            self.generate_cable_names()\n            self.parse_loopback_ips()\n\n        return self.dual_tor_facts\n\n\ndef main():\n    module = AnsibleModule(\n        argument_spec=dict(\n            hostname=dict(required=True, default=None, type='str'),\n            testbed_facts=dict(required=True, default=None, type='dict'),\n            hostvars=dict(required=True, default=None, type='dict'),\n            vm_config=dict(required=True, default=None, type='dict'),\n            port_alias=dict(required=True, default=None, type='list'),\n            vlan_intfs=dict(required=True, default=None, type='list')\n        ),\n        supports_check_mode=True\n    )\n    m_args = module.params\n    # testbed_facts ={u'comment': u'Dual-TOR testbed', u'conf-name': u'vms-kvm-dual-t0', u'ptf_ip': u'10.250.0.109', u'ptf_netmask': u'255.255.255.0', u'ptf_ipv6': u'fec0::ffff:afa:9', u'vm_base': u'VM0108', u'server': u'server_1', u'topo': u'dualtor', u'group-name': u'vms6-4', u'ptf': u'ptf-04', u'duts_map': {u'vlab-06': 1, u'vlab-05': 0}, u'ptf_netmask_v6': u'ffff:ffff:ffff:ffff::', u'ptf_image_name': u'docker-ptf', u'duts': [u'vlab-05', u'vlab-06']}\n    hostname = m_args['hostname']\n    testbed_facts = m_args['testbed_facts']\n    host_vars = m_args['hostvars']\n    vm_config = m_args['vm_config']\n    port_alias = m_args['port_alias']\n    vlan_intfs = m_args['vlan_intfs']\n    try:\n        dual_tor_parser = DualTorParser(hostname, testbed_facts, host_vars, vm_config, port_alias, vlan_intfs)\n        module.exit_json(ansible_facts={'dual_tor_facts': dual_tor_parser.get_dual_tor_facts()})\n    except Exception as e:\n        module.fail_json(msg=traceback.format_exc())\n\nfrom ansible.module_utils.basic import *\nif __name__== \"__main__\":\n    main()\n", "path": "ansible/library/dual_tor_facts.py"}], "after_files": [{"content": "from collections import defaultdict\nclass DualTorParser:\n\n    def __init__(self, hostname, testbed_facts, host_vars, vm_config, port_alias, vlan_intfs):\n        self.hostname = hostname\n        self.testbed_facts = testbed_facts\n        self.host_vars = host_vars\n        self.vm_config = vm_config\n        self.port_alias = port_alias\n        self.vlan_intfs = vlan_intfs\n        self.dual_tor_facts = {}\n\n    def parse_neighbor_tor(self):\n        '''\n        Parses information about the other ToR in a dual ToR pair\n        '''\n        neighbor = {}\n        neighbor['hostname'] = [dut for dut in self.testbed_facts['duts'] if dut != self.hostname][0]\n        neighbor['ip'] = self.host_vars[neighbor['hostname']]['ansible_host']\n        neighbor['hwsku'] = self.host_vars[neighbor['hostname']]['hwsku']\n\n        self.dual_tor_facts['neighbor'] = neighbor\n\n    def parse_tor_position(self):\n        '''\n        Determines the position ('U' for upper and 'L' for lower) of the ToR.\n\n        The upper ToR is always the first ToR listed in the testbed file\n        '''\n        self.dual_tor_facts['positions'] = {'upper': self.testbed_facts['duts'][0], 'lower': self.testbed_facts['duts'][1]}\n\n    def parse_loopback_ips(self):\n        '''\n        Parses the IPv4 and IPv6 loopback IPs for the DUTs\n\n        Similar to `parse_tor_position`, the ToR which comes first in the testbed file is always assigned the first IP\n        '''\n\n        loopback_ips = defaultdict(dict)\n        addl_loopback_ips = defaultdict(dict)\n\n        for dut_num, dut in enumerate(self.testbed_facts['duts']):\n            loopback_ips[dut]['ipv4'] = self.vm_config['DUT']['loopback']['ipv4'][dut_num]\n            loopback_ips[dut]['ipv6'] = self.vm_config['DUT']['loopback']['ipv6'][dut_num] \n\n            for loopback_num in range(1, 4): # Generate two additional loopback IPs, Loopback1, Loopback2, and Loopback3\n                loopback_key = 'loopback{}'.format(loopback_num)\n                loopback_dict = {}\n                loopback_dict['ipv4'] = self.vm_config['DUT'][loopback_key]['ipv4'][dut_num]\n                loopback_dict['ipv6'] = self.vm_config['DUT'][loopback_key]['ipv6'][dut_num]\n                loopback_dict['host_ip_base_index'] = loopback_num * 2\n                addl_loopback_ips[dut][loopback_num] = loopback_dict\n\n        self.dual_tor_facts['loopback'] = loopback_ips \n        self.dual_tor_facts['addl_loopbacks'] = addl_loopback_ips\n\n    def generate_cable_names(self):\n        cables = []\n\n        for server_num, dut_intf in enumerate(self.vlan_intfs):\n            name = '{}-Servers{}-SC'.format(self.hostname, server_num)\n            cable = {\"hostname\": name, \"dut_intf\": dut_intf}\n            cables.append(cable)\n\n        self.dual_tor_facts['cables'] = cables\n\n    def get_dual_tor_facts(self):\n        '''\n        Gathers facts related to a dual ToR configuration\n        '''\n        if 'dualtor' in self.testbed_facts['topo']:\n            self.parse_neighbor_tor()\n            self.parse_tor_position()\n            self.generate_cable_names()\n            self.parse_loopback_ips()\n\n        return self.dual_tor_facts\n\n\ndef main():\n    module = AnsibleModule(\n        argument_spec=dict(\n            hostname=dict(required=True, default=None, type='str'),\n            testbed_facts=dict(required=True, default=None, type='dict'),\n            hostvars=dict(required=True, default=None, type='dict'),\n            vm_config=dict(required=True, default=None, type='dict'),\n            port_alias=dict(required=True, default=None, type='list'),\n            vlan_intfs=dict(required=True, default=None, type='list')\n        ),\n        supports_check_mode=True\n    )\n    m_args = module.params\n    # testbed_facts ={u'comment': u'Dual-TOR testbed', u'conf-name': u'vms-kvm-dual-t0', u'ptf_ip': u'10.250.0.109', u'ptf_netmask': u'255.255.255.0', u'ptf_ipv6': u'fec0::ffff:afa:9', u'vm_base': u'VM0108', u'server': u'server_1', u'topo': u'dualtor', u'group-name': u'vms6-4', u'ptf': u'ptf-04', u'duts_map': {u'vlab-06': 1, u'vlab-05': 0}, u'ptf_netmask_v6': u'ffff:ffff:ffff:ffff::', u'ptf_image_name': u'docker-ptf', u'duts': [u'vlab-05', u'vlab-06']}\n    hostname = m_args['hostname']\n    testbed_facts = m_args['testbed_facts']\n    host_vars = m_args['hostvars']\n    vm_config = m_args['vm_config']\n    port_alias = m_args['port_alias']\n    vlan_intfs = m_args['vlan_intfs']\n    try:\n        dual_tor_parser = DualTorParser(hostname, testbed_facts, host_vars, vm_config, port_alias, vlan_intfs)\n        module.exit_json(ansible_facts={'dual_tor_facts': dual_tor_parser.get_dual_tor_facts()})\n    except Exception as e:\n        module.fail_json(msg=traceback.format_exc())\n\nfrom ansible.module_utils.basic import *\nif __name__== \"__main__\":\n    main()\n", "path": "ansible/library/dual_tor_facts.py"}]}