We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Investigate RDMA nightly run failures on 202012
<!--
If you are reporting a new issue, make sure that we do not have any duplicates
already open. You can ensure this by searching the issue list for this
repository. If there is a duplicate, please close your issue and add a comment
to the existing issue instead.

If you suspect your issue is a bug, please edit your issue description to
include the BUG REPORT INFORMATION shown below. If you fail to provide this
information within 7 days, we cannot debug your issue and will close it. We
will, however, reopen it if you later provide the information.

For more information about reporting issues, see
https://github.com/Azure/SONiC/wiki#report-issues

---------------------------------------------------
GENERAL SUPPORT INFORMATION
---------------------------------------------------

The GitHub issue tracker is for bug reports and feature requests.
General support can be found at the following locations:

- SONiC Support Forums - https://groups.google.com/forum/#!forum/sonicproject

---------------------------------------------------
BUG REPORT INFORMATION
---------------------------------------------------
Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST
-->

**Description**
RDMA test runs on TD2 with 202012 are quite flaky. Different set of test failures are seen daily and sometimes test fails at pretest
09/09 run skipped all tgen tests with the following reason
SKIPPED [1] /azp/agent/_work/27/s/tests/common/helpers/assertions.py:13: Port is not mapped to the expected DUT



--- 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/testbed_vm_info.py`
Content:
```
1 #!/usr/bin/env python
2 
3 import re
4 import yaml
5 import os
6 import traceback
7 import subprocess
8 import ipaddr as ipaddress
9 from operator import itemgetter
10 from itertools import groupby
11 from collections import defaultdict
12 import re
13 
14 from ansible.parsing.dataloader import DataLoader
15 from ansible.inventory.manager import InventoryManager
16 
17 DOCUMENTATION = '''
18 module: testbed_vm_info.py
19 Ansible_version_added:  2.0.0.2
20 short_description:   Gather all related VMs info
21 Description:
22        When deploy testbed topology with VM connected to SONiC, gather neighbor VMs info for generating SONiC minigraph file
23  options:
24     base_vm:  base vm name defined in testbed.csv for the deployed topology; required: True
25     topo:     topology name defined in testbed.csv for the deployed topology; required: True
26     vm_file:  the virtual machine file path ; default: 'veos'
27 
28 Ansible_facts:
29     'neighbor_eosvm_mgmt':  all VM hosts management IPs
30     'topoall':              topology information
31 
32 '''
33 
34 EXAMPLES = '''
35     - name: gather vm information
36       testbed_vm_info: base_vm='VM0100' topo='t1' vm_file='veos'
37 '''
38 
39 ### Here are the assumption/expectation of files to gather VM informations, if the file location or name changes, please modify it here
40 TOPO_PATH = 'vars/'
41 VM_INV_FILE = 'veos'
42 
43 
44 class TestbedVMFacts():
45     """
46     Retrieve testbed VMs management information that for a specified toplogy defined in testbed.csv
47 
48     """
49 
50     def __init__(self, toponame, vmbase, vmfile):
51         CLET_SUFFIX = "-clet"
52         toponame = re.sub(CLET_SUFFIX + "$", "", toponame)
53         self.topofile = TOPO_PATH+'topo_'+toponame +'.yml'
54         self.start_index = int(re.findall('VM(\d+)', vmbase)[0])
55         self.vmhosts = {}
56         self.vmfile = vmfile
57         self.inv_mgr = InventoryManager(loader=DataLoader(), sources=self.vmfile)
58         return
59 
60 
61     def get_neighbor_eos(self):
62         eos = {}
63         with open(self.topofile) as f:
64             vm_topology = yaml.load(f)
65         self.topoall = vm_topology
66         for  vm in vm_topology['topology']['VMs']:
67             vm_index = int(vm_topology['topology']['VMs'][vm]['vm_offset'])+self.start_index
68             eos[vm] = vm_index
69         return eos
70 
71 
72 def main():
73     module = AnsibleModule(
74         argument_spec=dict(
75             base_vm=dict(required=True, type='str'),
76             topo=dict(required=True, type='str'),
77             vm_file=dict(default=VM_INV_FILE, type='str')
78         ),
79         supports_check_mode=True
80     )
81     m_args = module.params
82     topo_type = m_args['topo']
83     if 'ptf' in topo_type:
84         module.exit_json(ansible_facts={'neighbor_eosvm_mgmt': {}})
85     try:
86         vmsall = TestbedVMFacts(m_args['topo'], m_args['base_vm'], m_args['vm_file'])
87         neighbor_eos = vmsall.get_neighbor_eos()
88         for eos in neighbor_eos:
89             vmname = 'VM'+format(neighbor_eos[eos], '04d')
90             if vmname in vmsall.inv_mgr.hosts:
91                 vmsall.vmhosts[eos] = vmsall.inv_mgr.get_host(vmname).get_vars()['ansible_host']
92             else:
93                 err_msg = "cannot find the vm " + vmname + " in VM inventory file, please make sure you have enough VMs for the topology you are using"
94                 module.fail_json(msg=err_msg)
95         module.exit_json(ansible_facts={'neighbor_eosvm_mgmt':vmsall.vmhosts, 'topoall': vmsall.topoall})
96     except (IOError, OSError):
97         module.fail_json(msg="Can not find file "+vmsall.topofile+" or "+m_args['vm_file']+" or "+VM_INV_FILE)
98     except Exception as e:
99         module.fail_json(msg=traceback.format_exc())
100 
101 from ansible.module_utils.basic import *
102 if __name__ == "__main__":
103     main()
104 
105
```
--- 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/testbed_vm_info.py b/ansible/library/testbed_vm_info.py
--- a/ansible/library/testbed_vm_info.py
+++ b/ansible/library/testbed_vm_info.py
@@ -39,6 +39,7 @@
 ### Here are the assumption/expectation of files to gather VM informations, if the file location or name changes, please modify it here
 TOPO_PATH = 'vars/'
 VM_INV_FILE = 'veos'
+TGEN_MGMT_NETWORK = '10.65.32.0/24'
 
 
 class TestbedVMFacts():
@@ -51,7 +52,10 @@
         CLET_SUFFIX = "-clet"
         toponame = re.sub(CLET_SUFFIX + "$", "", toponame)
         self.topofile = TOPO_PATH+'topo_'+toponame +'.yml'
-        self.start_index = int(re.findall('VM(\d+)', vmbase)[0])
+        if vmbase != '':
+            self.start_index = int(re.findall('VM(\d+)', vmbase)[0])
+        else:
+            self.start_index = 0
         self.vmhosts = {}
         self.vmfile = vmfile
         self.inv_mgr = InventoryManager(loader=DataLoader(), sources=self.vmfile)
@@ -85,9 +89,12 @@
     try:
         vmsall = TestbedVMFacts(m_args['topo'], m_args['base_vm'], m_args['vm_file'])
         neighbor_eos = vmsall.get_neighbor_eos()
-        for eos in neighbor_eos:
+        tgen_mgmt_ips = list(ipaddress.IPNetwork(unicode(TGEN_MGMT_NETWORK)))
+        for index, eos in enumerate(neighbor_eos):
             vmname = 'VM'+format(neighbor_eos[eos], '04d')
-            if vmname in vmsall.inv_mgr.hosts:
+            if 'tgen' in topo_type:
+                vmsall.vmhosts[eos] = str(tgen_mgmt_ips[index])
+            elif vmname in vmsall.inv_mgr.hosts:
                 vmsall.vmhosts[eos] = vmsall.inv_mgr.get_host(vmname).get_vars()['ansible_host']
             else:
                 err_msg = "cannot find the vm " + vmname + " in VM inventory file, please make sure you have enough VMs for the topology you are using"

{"golden_diff": "diff --git a/ansible/library/testbed_vm_info.py b/ansible/library/testbed_vm_info.py\n--- a/ansible/library/testbed_vm_info.py\n+++ b/ansible/library/testbed_vm_info.py\n@@ -39,6 +39,7 @@\n ### Here are the assumption/expectation of files to gather VM informations, if the file location or name changes, please modify it here\n TOPO_PATH = 'vars/'\n VM_INV_FILE = 'veos'\n+TGEN_MGMT_NETWORK = '10.65.32.0/24'\n \n \n class TestbedVMFacts():\n@@ -51,7 +52,10 @@\n         CLET_SUFFIX = \"-clet\"\n         toponame = re.sub(CLET_SUFFIX + \"$\", \"\", toponame)\n         self.topofile = TOPO_PATH+'topo_'+toponame +'.yml'\n-        self.start_index = int(re.findall('VM(\\d+)', vmbase)[0])\n+        if vmbase != '':\n+            self.start_index = int(re.findall('VM(\\d+)', vmbase)[0])\n+        else:\n+            self.start_index = 0\n         self.vmhosts = {}\n         self.vmfile = vmfile\n         self.inv_mgr = InventoryManager(loader=DataLoader(), sources=self.vmfile)\n@@ -85,9 +89,12 @@\n     try:\n         vmsall = TestbedVMFacts(m_args['topo'], m_args['base_vm'], m_args['vm_file'])\n         neighbor_eos = vmsall.get_neighbor_eos()\n-        for eos in neighbor_eos:\n+        tgen_mgmt_ips = list(ipaddress.IPNetwork(unicode(TGEN_MGMT_NETWORK)))\n+        for index, eos in enumerate(neighbor_eos):\n             vmname = 'VM'+format(neighbor_eos[eos], '04d')\n-            if vmname in vmsall.inv_mgr.hosts:\n+            if 'tgen' in topo_type:\n+                vmsall.vmhosts[eos] = str(tgen_mgmt_ips[index])\n+            elif vmname in vmsall.inv_mgr.hosts:\n                 vmsall.vmhosts[eos] = vmsall.inv_mgr.get_host(vmname).get_vars()['ansible_host']\n             else:\n                 err_msg = \"cannot find the vm \" + vmname + \" in VM inventory file, please make sure you have enough VMs for the topology you are using\"\n", "issue": "Investigate RDMA nightly run failures on 202012\n<!--\r\nIf you are reporting a new issue, make sure that we do not have any duplicates\r\nalready open. You can ensure this by searching the issue list for this\r\nrepository. If there is a duplicate, please close your issue and add a comment\r\nto the existing issue instead.\r\n\r\nIf you suspect your issue is a bug, please edit your issue description to\r\ninclude the BUG REPORT INFORMATION shown below. If you fail to provide this\r\ninformation within 7 days, we cannot debug your issue and will close it. We\r\nwill, however, reopen it if you later provide the information.\r\n\r\nFor more information about reporting issues, see\r\nhttps://github.com/Azure/SONiC/wiki#report-issues\r\n\r\n---------------------------------------------------\r\nGENERAL SUPPORT INFORMATION\r\n---------------------------------------------------\r\n\r\nThe GitHub issue tracker is for bug reports and feature requests.\r\nGeneral support can be found at the following locations:\r\n\r\n- SONiC Support Forums - https://groups.google.com/forum/#!forum/sonicproject\r\n\r\n---------------------------------------------------\r\nBUG REPORT INFORMATION\r\n---------------------------------------------------\r\nUse the commands below to provide key information from your environment:\r\nYou do NOT have to include this information if this is a FEATURE REQUEST\r\n-->\r\n\r\n**Description**\r\nRDMA test runs on TD2 with 202012 are quite flaky. Different set of test failures are seen daily and sometimes test fails at pretest\r\n09/09 run skipped all tgen tests with the following reason\r\nSKIPPED [1] /azp/agent/_work/27/s/tests/common/helpers/assertions.py:13: Port is not mapped to the expected DUT\r\n\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n\nimport re\nimport yaml\nimport os\nimport traceback\nimport subprocess\nimport ipaddr as ipaddress\nfrom operator import itemgetter\nfrom itertools import groupby\nfrom collections import defaultdict\nimport re\n\nfrom ansible.parsing.dataloader import DataLoader\nfrom ansible.inventory.manager import InventoryManager\n\nDOCUMENTATION = '''\nmodule: testbed_vm_info.py\nAnsible_version_added:  2.0.0.2\nshort_description:   Gather all related VMs info\nDescription:\n       When deploy testbed topology with VM connected to SONiC, gather neighbor VMs info for generating SONiC minigraph file\n options:\n    base_vm:  base vm name defined in testbed.csv for the deployed topology; required: True\n    topo:     topology name defined in testbed.csv for the deployed topology; required: True\n    vm_file:  the virtual machine file path ; default: 'veos'\n\nAnsible_facts:\n    'neighbor_eosvm_mgmt':  all VM hosts management IPs\n    'topoall':              topology information\n\n'''\n\nEXAMPLES = '''\n    - name: gather vm information\n      testbed_vm_info: base_vm='VM0100' topo='t1' vm_file='veos'\n'''\n\n### Here are the assumption/expectation of files to gather VM informations, if the file location or name changes, please modify it here\nTOPO_PATH = 'vars/'\nVM_INV_FILE = 'veos'\n\n\nclass TestbedVMFacts():\n    \"\"\"\n    Retrieve testbed VMs management information that for a specified toplogy defined in testbed.csv\n\n    \"\"\"\n\n    def __init__(self, toponame, vmbase, vmfile):\n        CLET_SUFFIX = \"-clet\"\n        toponame = re.sub(CLET_SUFFIX + \"$\", \"\", toponame)\n        self.topofile = TOPO_PATH+'topo_'+toponame +'.yml'\n        self.start_index = int(re.findall('VM(\\d+)', vmbase)[0])\n        self.vmhosts = {}\n        self.vmfile = vmfile\n        self.inv_mgr = InventoryManager(loader=DataLoader(), sources=self.vmfile)\n        return\n\n\n    def get_neighbor_eos(self):\n        eos = {}\n        with open(self.topofile) as f:\n            vm_topology = yaml.load(f)\n        self.topoall = vm_topology\n        for  vm in vm_topology['topology']['VMs']:\n            vm_index = int(vm_topology['topology']['VMs'][vm]['vm_offset'])+self.start_index\n            eos[vm] = vm_index\n        return eos\n\n\ndef main():\n    module = AnsibleModule(\n        argument_spec=dict(\n            base_vm=dict(required=True, type='str'),\n            topo=dict(required=True, type='str'),\n            vm_file=dict(default=VM_INV_FILE, type='str')\n        ),\n        supports_check_mode=True\n    )\n    m_args = module.params\n    topo_type = m_args['topo']\n    if 'ptf' in topo_type:\n        module.exit_json(ansible_facts={'neighbor_eosvm_mgmt': {}})\n    try:\n        vmsall = TestbedVMFacts(m_args['topo'], m_args['base_vm'], m_args['vm_file'])\n        neighbor_eos = vmsall.get_neighbor_eos()\n        for eos in neighbor_eos:\n            vmname = 'VM'+format(neighbor_eos[eos], '04d')\n            if vmname in vmsall.inv_mgr.hosts:\n                vmsall.vmhosts[eos] = vmsall.inv_mgr.get_host(vmname).get_vars()['ansible_host']\n            else:\n                err_msg = \"cannot find the vm \" + vmname + \" in VM inventory file, please make sure you have enough VMs for the topology you are using\"\n                module.fail_json(msg=err_msg)\n        module.exit_json(ansible_facts={'neighbor_eosvm_mgmt':vmsall.vmhosts, 'topoall': vmsall.topoall})\n    except (IOError, OSError):\n        module.fail_json(msg=\"Can not find file \"+vmsall.topofile+\" or \"+m_args['vm_file']+\" or \"+VM_INV_FILE)\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\n", "path": "ansible/library/testbed_vm_info.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\nimport re\nimport yaml\nimport os\nimport traceback\nimport subprocess\nimport ipaddr as ipaddress\nfrom operator import itemgetter\nfrom itertools import groupby\nfrom collections import defaultdict\nimport re\n\nfrom ansible.parsing.dataloader import DataLoader\nfrom ansible.inventory.manager import InventoryManager\n\nDOCUMENTATION = '''\nmodule: testbed_vm_info.py\nAnsible_version_added:  2.0.0.2\nshort_description:   Gather all related VMs info\nDescription:\n       When deploy testbed topology with VM connected to SONiC, gather neighbor VMs info for generating SONiC minigraph file\n options:\n    base_vm:  base vm name defined in testbed.csv for the deployed topology; required: True\n    topo:     topology name defined in testbed.csv for the deployed topology; required: True\n    vm_file:  the virtual machine file path ; default: 'veos'\n\nAnsible_facts:\n    'neighbor_eosvm_mgmt':  all VM hosts management IPs\n    'topoall':              topology information\n\n'''\n\nEXAMPLES = '''\n    - name: gather vm information\n      testbed_vm_info: base_vm='VM0100' topo='t1' vm_file='veos'\n'''\n\n### Here are the assumption/expectation of files to gather VM informations, if the file location or name changes, please modify it here\nTOPO_PATH = 'vars/'\nVM_INV_FILE = 'veos'\nTGEN_MGMT_NETWORK = '10.65.32.0/24'\n\n\nclass TestbedVMFacts():\n    \"\"\"\n    Retrieve testbed VMs management information that for a specified toplogy defined in testbed.csv\n\n    \"\"\"\n\n    def __init__(self, toponame, vmbase, vmfile):\n        CLET_SUFFIX = \"-clet\"\n        toponame = re.sub(CLET_SUFFIX + \"$\", \"\", toponame)\n        self.topofile = TOPO_PATH+'topo_'+toponame +'.yml'\n        if vmbase != '':\n            self.start_index = int(re.findall('VM(\\d+)', vmbase)[0])\n        else:\n            self.start_index = 0\n        self.vmhosts = {}\n        self.vmfile = vmfile\n        self.inv_mgr = InventoryManager(loader=DataLoader(), sources=self.vmfile)\n        return\n\n\n    def get_neighbor_eos(self):\n        eos = {}\n        with open(self.topofile) as f:\n            vm_topology = yaml.load(f)\n        self.topoall = vm_topology\n        for  vm in vm_topology['topology']['VMs']:\n            vm_index = int(vm_topology['topology']['VMs'][vm]['vm_offset'])+self.start_index\n            eos[vm] = vm_index\n        return eos\n\n\ndef main():\n    module = AnsibleModule(\n        argument_spec=dict(\n            base_vm=dict(required=True, type='str'),\n            topo=dict(required=True, type='str'),\n            vm_file=dict(default=VM_INV_FILE, type='str')\n        ),\n        supports_check_mode=True\n    )\n    m_args = module.params\n    topo_type = m_args['topo']\n    if 'ptf' in topo_type:\n        module.exit_json(ansible_facts={'neighbor_eosvm_mgmt': {}})\n    try:\n        vmsall = TestbedVMFacts(m_args['topo'], m_args['base_vm'], m_args['vm_file'])\n        neighbor_eos = vmsall.get_neighbor_eos()\n        tgen_mgmt_ips = list(ipaddress.IPNetwork(unicode(TGEN_MGMT_NETWORK)))\n        for index, eos in enumerate(neighbor_eos):\n            vmname = 'VM'+format(neighbor_eos[eos], '04d')\n            if 'tgen' in topo_type:\n                vmsall.vmhosts[eos] = str(tgen_mgmt_ips[index])\n            elif vmname in vmsall.inv_mgr.hosts:\n                vmsall.vmhosts[eos] = vmsall.inv_mgr.get_host(vmname).get_vars()['ansible_host']\n            else:\n                err_msg = \"cannot find the vm \" + vmname + \" in VM inventory file, please make sure you have enough VMs for the topology you are using\"\n                module.fail_json(msg=err_msg)\n        module.exit_json(ansible_facts={'neighbor_eosvm_mgmt':vmsall.vmhosts, 'topoall': vmsall.topoall})\n    except (IOError, OSError):\n        module.fail_json(msg=\"Can not find file \"+vmsall.topofile+\" or \"+m_args['vm_file']+\" or \"+VM_INV_FILE)\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\n", "path": "ansible/library/testbed_vm_info.py"}]}