-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protect config_db.json from minigraph misconfig #1727
Changes from 15 commits
b9f2080
696e791
b5e43d6
f3c97e0
6518266
097f1e9
1f293e2
6db9a0a
987bc92
9021233
d604685
c9f22b3
955e4be
1e79656
f545f41
6c3026a
8caa011
37f1f81
472c499
8efa34d
c3c46ba
75a35fa
293ac1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -414,7 +414,7 @@ def parse_xml(filename, platform=None, port_config_file=None): | |
(port_speeds_default, port_descriptions) = parse_deviceinfo(child, hwsku) | ||
|
||
current_device = [devices[key] for key in devices if key.lower() == hostname.lower()][0] | ||
results = {} | ||
results = {} | ||
results['DEVICE_METADATA'] = {'localhost': { | ||
'bgp_asn': bgp_asn, | ||
'deployment_id': deployment_id, | ||
|
@@ -447,7 +447,6 @@ def parse_xml(filename, platform=None, port_config_file=None): | |
|
||
results['INTERFACE'] = phyport_intfs | ||
results['VLAN_INTERFACE'] = vlan_intfs | ||
results['PORTCHANNEL_INTERFACE'] = pc_intfs | ||
|
||
for port_name in port_speeds_default: | ||
# ignore port not in port_config.ini | ||
|
@@ -457,9 +456,10 @@ def parse_xml(filename, platform=None, port_config_file=None): | |
ports.setdefault(port_name, {})['speed'] = port_speeds_default[port_name] | ||
|
||
for port_name in port_speed_png: | ||
# if port_name is not in port_config.ini, still consider it. | ||
# and later swss will pick up and behave on-demand port break-up. | ||
# if on-deman port break-up is not supported on a specific platform, swss will return error. | ||
# not consider port not in port_config.ini | ||
if port_name not in ports: | ||
continue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you print out warning here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
ports.setdefault(port_name, {})['speed'] = port_speed_png[port_name] | ||
|
||
for port_name, port in ports.items(): | ||
|
@@ -474,11 +474,33 @@ def parse_xml(filename, platform=None, port_config_file=None): | |
ports.setdefault(port_name, {})['description'] = port_descriptions[port_name] | ||
|
||
results['PORT'] = ports | ||
|
||
port_set = set(ports.keys()) | ||
for (pc_name, mbr_map) in pcs.items(): | ||
# remove portchannels that contain ports not existing in port_config.ini | ||
if not set(mbr_map['members']).issubset(port_set): | ||
del pcs[pc_name] | ||
|
||
results['PORTCHANNEL'] = pcs | ||
|
||
|
||
for pc_intf in pc_intfs.keys(): | ||
# remove portchannels not in PORTCHANNEL dictionary | ||
if pc_intf[0] not in pcs: | ||
del pc_intfs[pc_intf] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. print warning here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
results['PORTCHANNEL_INTERFACE'] = pc_intfs | ||
|
||
results['VLAN'] = vlans | ||
results['VLAN_MEMBER'] = vlan_members | ||
|
||
for nghbr in neighbors.keys(): | ||
# remove port not in port_config.ini | ||
if nghbr not in ports: | ||
del neighbors[nghbr] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. print warning here |
||
|
||
results['DEVICE_NEIGHBOR'] = neighbors | ||
|
||
results['DEVICE_NEIGHBOR_METADATA'] = { key:devices[key] for key in devices if key.lower() != hostname.lower() } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete this line? #Closed |
||
results['SYSLOG_SERVER'] = dict((item, {}) for item in syslog_servers) | ||
results['DHCP_SERVER'] = dict((item, {}) for item in dhcp_servers) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,6 +125,11 @@ | |
<AttachTo>fortyGigE0/4</AttachTo> | ||
<SubInterface/> | ||
</PortChannel> | ||
<PortChannel> | ||
<Name>PortChannel1001</Name> | ||
<AttachTo>Ethernet1;Ethernet2</AttachTo> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fortyGigE0/1;fortyGigE0/2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
<SubInterface/> | ||
</PortChannel> | ||
</PortChannelInterfaces> | ||
<VlanInterfaces> | ||
<VlanInterface> | ||
|
@@ -147,6 +152,16 @@ | |
<AttachTo>PortChannel01</AttachTo> | ||
<Prefix>FC00::71/126</Prefix> | ||
</IPInterface> | ||
<IPInterface> | ||
<Name i:nil="true"/> | ||
<AttachTo>PortChannel1001</AttachTo> | ||
<Prefix>10.0.0.57/31</Prefix> | ||
</IPInterface> | ||
<IPInterface> | ||
<Name i:Name="true"/> | ||
<AttachTo>PortChannel1001</AttachTo> | ||
<Prefix>FC00::72/126</Prefix> | ||
</IPInterface> | ||
<IPInterface> | ||
<Name i:nil="true"/> | ||
<AttachTo>fortyGigE0/0</AttachTo> | ||
|
@@ -193,6 +208,28 @@ | |
<StartPort>fortyGigE0/8</StartPort> | ||
<Validate>true</Validate> | ||
</DeviceLinkBase> | ||
<DeviceLinkBase i:type="DeviceInterfaceLink"> | ||
<ElementType>DeviceInterfaceLink</ElementType> | ||
<AutoNegotiation>true</AutoNegotiation> | ||
<Bandwidth>10000</Bandwidth> | ||
<EndDevice>switch-t0</EndDevice> | ||
<EndPort>Ethernet1</EndPort> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -> fortyGigE0/1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
<FlowControl>true</FlowControl> | ||
<StartDevice>ARISTA05T1</StartDevice> | ||
<StartPort>Ethernet1/32</StartPort> | ||
<Validate>true</Validate> | ||
</DeviceLinkBase> | ||
<DeviceLinkBase i:type="DeviceInterfaceLink"> | ||
<ElementType>DeviceInterfaceLink</ElementType> | ||
<AutoNegotiation>true</AutoNegotiation> | ||
<Bandwidth>10000</Bandwidth> | ||
<EndDevice>switch-t0</EndDevice> | ||
<EndPort>Ethernet2</EndPort> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -> fortyGigE0/2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
<FlowControl>true</FlowControl> | ||
<StartDevice>ARISTA06T1</StartDevice> | ||
<StartPort>Ethernet1/33</StartPort> | ||
<Validate>true</Validate> | ||
</DeviceLinkBase> | ||
</DeviceInterfaceLinks> | ||
<Devices> | ||
<Device i:type="ToRRouter"> | ||
|
@@ -240,7 +277,20 @@ | |
<EnableAutoNegotiation>true</EnableAutoNegotiation> | ||
<EnableFlowControl>true</EnableFlowControl> | ||
<Index>1</Index> | ||
<InterfaceName>fortyGigE0/1</InterfaceName> | ||
<InterfaceName>Ethernet1</InterfaceName> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be fortyGigE0/1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use fortyGigE0/1 and fortyGigE0/2, even without your patch, it does not introduce extra port into PORT but only change the order listed in PORT. Because of this bad test case in the first place, it does not catch the extra port that can be introduced in later commit 0e7a7dfa. I will confirm with other places. But here we should use Ethernet1 and Ethernet2. |
||
<InterfaceType i:nil="true"/> | ||
<MultiPortsInterface>false</MultiPortsInterface> | ||
<PortName>0</PortName> | ||
<Priority>0</Priority> | ||
<Speed>10000</Speed> | ||
</a:EthernetInterface> | ||
<a:EthernetInterface> | ||
<ElementType>DeviceInterface</ElementType> | ||
<AlternateSpeeds i:nil="true"/> | ||
<EnableAutoNegotiation>true</EnableAutoNegotiation> | ||
<EnableFlowControl>true</EnableFlowControl> | ||
<Index>1</Index> | ||
<InterfaceName>Ethernet2</InterfaceName> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -> fortyGigE0/2 |
||
<InterfaceType i:nil="true"/> | ||
<MultiPortsInterface>false</MultiPortsInterface> | ||
<PortName>0</PortName> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we treat this as a minigraph generator's bug instead of parser's bug? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we can mitigate that in minigraph, it should be ideal #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with Guohan, this is the good.
In reply to: 189410214 [](ancestors = 189410214)