Skip to content

[minigraph] generate device under test minigraph file#207

Merged
maggiemsft merged 4 commits intosonic-net:masterfrom
maggiemsft:masun/minigraph-gen
Jul 20, 2017
Merged

[minigraph] generate device under test minigraph file#207
maggiemsft merged 4 commits intosonic-net:masterfrom
maggiemsft:masun/minigraph-gen

Conversation

@maggiemsft
Copy link
Contributor

Minigraph is generated based on topology name and type defined testbed.csv
Currently it only covers t0, t1 and t1-lag for 32 ports SONiC devices
Will work on 64 ports later.

@msftclas
Copy link

msftclas commented Jul 5, 2017

@maggiemsft,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot


- block:
- name: saved original minigraph file (if original file may don't exist, then ignore errors)
shell: mv /etc/sonic/minigraph.xml /etc/sonic/minigraph.xml.ori
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ori [](start = 68, length = 3)

-> orig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably you're fixed another line. This is still 'ori'

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as commented

# Template files for generating minigraph.xml are defined in template/topo directory
#
# To generate and deploy minigraph for SONiC switch matching the VM topology please use following command
# ANSIBLE_SCP_IF_SSH=y ansible-playbook -i lab config_sonic_basedon_testbed.yml --vault-password-file=~/.password -l sonic_dut_name -e VM_base=VM0300 -e topo=t0 [-e deploy=true]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can delete "ANSIBLE_SCP_IF_SSH=y" from here. It is not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

#
# Parameters
# -l str-msn2700-01 - the sonic_dut_name you are going to generate minigraph for
# -e VM_base=VM0300 - the VM name which is used to as base to calculate VM name for this set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vm_base, not VM_base

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed

# Parameters
# -l str-msn2700-01 - the sonic_dut_name you are going to generate minigraph for
# -e VM_base=VM0300 - the VM name which is used to as base to calculate VM name for this set
# -e topo=t0 - the name of removed topo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove "removed" from here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

gather_facts: yes
tasks:
- fail: msg="need to provide topology type and vm base like topo=t0 and vm_base=VM100"
when: topo and vm_base is not defined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to check topo and vm_base in separate
I'd write it as
(topo is not defined) and (vm_base is not defined)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

when: topo and vm_base is not defined

- fail: msg="need hwsku, interface speed, netmask and interface prefix/postfix defined to generate configuration file"
when: hwsku and iface_speed and mgmt_subnet_mask_length and iface_prefix and iface_postfix is not defined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same as previous comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

eos = {}
with open(self.topofile) as f:
vm_topology = yaml.load(f)
f.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'with' keyword will close the 'f' file descriptor for you. so it's better to remove f.close() from here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed, thanks

def gather_veos_vm(self, eos_name, vm_index):
vmname = 'VM'+format(vm_index, '04d')
vmcmd = 'cat '+VM_INV_FILE+' | grep '+ vmname
p = subprocess.Popen(vmcmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably it's more clean to open the inventory file as a text file and parse it with python?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed. Thanks

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address comments I left.

# Template files for generating minigraph.xml are defined in template/topo directory
#
# To generate and deploy minigraph for SONiC switch matching the VM topology please use following command
# ansible-playbook -i lab config_sonic_basedon_testbed.yml --vault-password-file=~/.password -l sonic_dut_name -e VM_base=VM0300 -e topo=t0 [-e deploy=true]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VM_base -> vm_base


- block:
- name: saved original minigraph file (if original file may don't exist, then ignore errors)
shell: mv /etc/sonic/minigraph.xml /etc/sonic/minigraph.xml.ori
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably you're fixed another line. This is still 'ori'

dns_servers: ['10.0.0.5', '10.0.0.6']

# forced_mgmt_routes
forced_mgmt_routes: ['10.0.0.100/31', '10.250.0.8', '10.255.0.0/28']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure here: It should be '10.250.0.8' (without prefix), or '10.250.0.8/32'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked with current graph format, no /32

ansible/lab Outdated
[sonic_mlnx_40:vars]
hwsku="ACS-MSN2700"
iface_prefix="Ethernet"
iface_postfix=""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be suffix

{% endif %}
<Prefix>FC00::{{ ('%0x' % (64+index*4 +1)) | upper }}/126</Prefix>
</IPInterface>
{% endfor %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very difficult to maintain. it is better to use thi file to generate the interface name. https://github.com/Azure/sonic-buildimage/blob/master/device/arista/x86_64-arista_7050_qx32/Arista-7050-QX32/port_config.ini

In buildimage repo, it builds a debian package named sonic-device-data package. you can install the package in the sonic-mgmt docker and get the actual interface name based on port_config.ini for each hwsku.

<StartRouter>{{ inventory_hostname }}</StartRouter>
<StartPeer>FC00::{{ ('%0x' % (113 + index*4 )) | upper }}</StartPeer>
<EndRouter>ARISTA0{{ index+1 }}T1</EndRouter>
<EndPeer>FC00::{{ ('%0x' % (113 + index*4 +1)) | upper }}</EndPeer>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please be consistent on the whitespace usage

ansible/lab Outdated
[sonic_mlnx_40:vars]
hwsku="ACS-MSN2700"
iface_prefix="Ethernet"
iface_postfix=""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove iface_prefix and postfix, use port_config.ini in the buildimge repo to convert.

become: true
template: src=templates/topo/{{ template_name }}.j2
dest=/etc/sonic/minigraph.xml

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to disable /etc/sonic/updategraph.conf to avoid downloading url from dhcp

vms = {}
with open(VM_INV_FILE) as f:
lines = f.readlines()
for line in lines:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only one space here.

@lguohan
Copy link
Contributor

lguohan commented Jul 12, 2017

👎

Copy link
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use port_config.ini to get the actual port name

register: p
connection: local

#### TODO: build the package into sonic-mgmt docker and remove this block of code ####
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sonic-device-data is in sonic-mgmt docker now. you can remove this block of code now.

- fail: msg="need hwsku, interface speed, netmask and interface prefix/postfix defined to generate configuration file"
when: (hwsku is not defined) or (iface_speed is not defined) or (mgmt_subnet_mask_length is not defined)

- stat:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can assume /usr/share/sonic/device is there in the container.

file: path=/tmp/buildimage state=absent
when: p.stat.isdir is not defined
connection: local
when: p.stat.isdir is not defined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this block as well.

return
else:
self.portmap['alias'] = True
self.portmap['mapping'][mapping[0]] = mapping[2]
Copy link
Contributor

@lguohan lguohan Jul 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the portmap is index -> alias map. index is the row index in the port_config.ini. let's have the assumption that the ports in port_config.ini are from index 0 to maximum.

then if there is alias, the port_alias[index] = alias, else port_alias[index] = name.

FILE_PATH = '/usr/share/sonic/device'
PORTMAP_FILE = 'port_config.ini'

class SonicPortmap():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SonicPortAliasMap

if 'Ethernet' in line:
mapping = line.split()
if len(mapping) < 3:
self.portmap['alias'] = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is not used, remove.

<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
{% if port_alias['alias'] %}
<InterfaceName>{{ port_alias['mapping'][sonic_if_name] }}</InterfaceName>
Copy link
Contributor

@lguohan lguohan Jul 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

port_alias['mapping'][sonic_if_name] -> port_alias[index]

i do not think you really need to first construct sonic_if_name, just use the index (0~31) for 32 port minigraph. you can assume the portname is ordered by the index in the port_config.ini

- name: save original updategraph configuration (if original file may don't exist, then ignore errors)
shell: mv /etc/sonic/updategraph.conf /etc/sonic/updategrph.conf.orig
become: true
ignore_errors: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use lineinfile module to replace the enable=true line to enable=false line.

dest=/etc/sonic/minigraph.xml
become: true

- name: disable automatic minigraph update if we are deploying new minigraph into SONiC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above.

Copy link
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as comments.

@maggiemsft maggiemsft merged commit 03e9cdc into sonic-net:master Jul 20, 2017
@maggiemsft maggiemsft deleted the masun/minigraph-gen branch July 28, 2017 03:01
lguohan pushed a commit that referenced this pull request Aug 3, 2017
* generate match SONiC minigraph based on testbed name and type defined in testbed.csv

* fixes based on feedback

* using port_config to get interface name and alias and fixes based on feedback

* use index to find the port name or alias
auspham pushed a commit to auspham/sonic-mgmt that referenced this pull request May 30, 2025
…ut multi-asic (sonic-net#207)

<!--
Please make sure you've read and understood our contributing guidelines;
https://github.com/sonic-net/SONiC/blob/gh-pages/CONTRIBUTING.md

Please provide following information to help code review process a bit easier:
-->
### Description of PR
<!--
- Please include a summary of the change and which issue is fixed.
- Please also include relevant motivation and context. Where should reviewer start? background context?
- List any dependencies that are required for this change.
-->

Summary:
Fixes # (issue)

- Split the original PR sonic-net#17130 into individual PRs for each test.
- This is an enhancement to support VOQ Single DUT Multi-ASIC setup for T2 topo.

### Type of change

<!--
- Fill x for your type of change.
- e.g.
- [x] Bug fix
-->

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] New Test case
 - [ ] Skipped for non-supported platforms
- [x] Test case improvement

### Back port request
- [ ] 202012
- [ ] 202205
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [x] 202411

### Approach
#### What is the motivation for this PR?

- New testbed modification of VOQ Single DUT and multi-asic.

#### How did you do it?

- Skip internal neighbors for both VOQ single dut multi-asic as well as multi-dut multi-asic.

#### How did you verify/test it?

#### Any platform specific information?

#### Supported testbed topology if it's a new test case?

- T2 VOQ Single Dut Multi ASIC

### Documentation
<!--
(If it's a new feature, new test case)
Did you update documentation/Wiki relevant to your implementation?
Link to the wiki page?
-->
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
…onic-net#7647)

Includes below commits
```
sonic-swss
05f0438 2021-05-19 | Fix build error (sonic-net#1751) [Shi Su]
1682a8d 2021-05-12 | [Bulk mode] Improve log in bulk failures (sonic-net#1740) [Shi Su]
4509e88 2021-04-27 | [routeorch] Add support for blackhole routes (sonic-net#1723) [Shi Su]
642014d 2019-10-31 | [fix] Use the same storm detection condition for queue occupancy non-zero case as the zero case (sonic-net#1111) [Wenda Ni]

sonic-utilities
97fc442 2021-05-10 | [config]: Use mod_entry when editing VLAN_INTERFACE (sonic-net#1602) [Lawrence Lee]
f60d579 2021-04-15 | [techsupport] Update show ip interface command (sonic-net#1562) [Mahesh Maddikayala]
821d29d 2021-04-14 | Fix Multi-ASIC show specific resursive route by using common parsing function (sonic-net#1560) [gechiang]

sonic-linux-kernel
61b331f 2021-05-06 | [dps200] Add dps200 PSU module driver (sonic-net#207) [schobtr]

sonic-platform-daemons
5d2960f 2021-05-17 | [xcvrd] add support for logging mux_metrics events into state DB (sonic-net#185) [vdahiya12]
a5c9207 2021-05-11 | [thermalctld] Enable stopping thermal manager (sonic-net#180) [Junchao-Mellanox]
9123f63 2021-05-10 | [muxcable] Remove Xcvrd Sleep (sonic-net#174) [Tamer Ahmed]
```
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
sonic-net#14862)

#### Why I did it
src/linkmgrd
```
* 35f7d1c - (HEAD -> 202012, origin/202012) [202012][active-standby][bsl] fix no mux probe issue sonic-net#201 (sonic-net#206) (2 weeks ago) [Jing Zhang]
* be701fb - [202012] pick codeql fixes (sonic-net#207) (2 weeks ago) [Jing Zhang]
* 0b42cec - Enable debug symbols (sonic-net#199) (3 weeks ago) [Longxiang Lyu]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants