[cfg engine] Add support to read device description xml#775
[cfg engine] Add support to read device description xml#775taoyl-ms merged 2 commits intosonic-net:masterfrom
Conversation
| name = node.text | ||
| elif node.tag == str(QName(ns, "HwSku")): | ||
| hwsku = node.text | ||
| return (lo_prefix, mgmt_prefix, name, hwsku, d_type) |
There was a problem hiding this comment.
name [](start = 36, length = 4)
name may be not itialized. #Closed
There was a problem hiding this comment.
| return json.JSONEncoder.default(self, obj) | ||
|
|
||
| def parse_device(device): | ||
| lo_prefix = None |
There was a problem hiding this comment.
None [](start = 16, length = 4)
suggest init as empty string, so later conditional split can be simplified. #ByDesign
There was a problem hiding this comment.
Let's keep it None as returning an empty string might make template debug mroe difficult than None.
In reply to: 125150571 [](ancestors = 125150571)
src/sonic-config-engine/minigraph.py
Outdated
| (lo_prefix, mgmt_prefix, hostname, hwsku, d_type) = parse_device(root) | ||
|
|
||
| Tree = lambda: defaultdict(Tree) | ||
| results = Tree() |
There was a problem hiding this comment.
results = {} ? #Closed
There was a problem hiding this comment.
| results['inventory_hostname'] = hostname | ||
|
|
||
| lo_intfs = [] | ||
| ipn = ipaddress.IPNetwork(lo_prefix) |
There was a problem hiding this comment.
lo_prefix [](start = 30, length = 9)
handle exception? #WontFix
There was a problem hiding this comment.
I'm feeling letting the exception to be thrown out and crashing at the outermost layer is the best behavior if exception happens here.
In reply to: 125150698 [](ancestors = 125150698)
src/sonic-config-engine/minigraph.py
Outdated
| results['minigraph_lo_interfaces'] = lo_intfs | ||
|
|
||
| mgmt_intf = None | ||
| mgmtipn = ipaddress.IPNetwork(mgmt_prefix) |
There was a problem hiding this comment.
mgmtipn [](start = 4, length = 7)
mgmt_ipn? #Closed
There was a problem hiding this comment.
| def main(): | ||
| parser=argparse.ArgumentParser(description="Render configuration file from minigraph data and jinja2 template.") | ||
| parser.add_argument("-m", "--minigraph", help="minigraph xml file") | ||
| group = parser.add_mutually_exclusive_group() |
There was a problem hiding this comment.
() [](start = 47, length = 2)
If one is required, you may use 'required=True' #Closed
There was a problem hiding this comment.
| parser.add_argument("-m", "--minigraph", help="minigraph xml file") | ||
| group = parser.add_mutually_exclusive_group() | ||
| group.add_argument("-m", "--minigraph", help="minigraph xml file") | ||
| group.add_argument("-M", "--device-description", help="device description xml file") |
There was a problem hiding this comment.
group.add_argument("-M", "--device-description", help="device description xml file") [](start = 1, length = 87)
instead of adding a new option, can we treat the device xml as a variant(subset) of minigraph which only contains a subset of information?
There was a problem hiding this comment.
Don't see your point. Those are different files with different schema. I already make the output format consistence so you can use same tool and same template to generate, for example, interfaces file.
* 20b9573 2021-01-24 | [SAI]: update SAI submodule (sonic-net#775) (HEAD, origin/master, origin/HEAD) [lguohan] * 667c33d 2021-01-22 | [syncd] Comparison logic add support to LABEL attribute with higher priority (sonic-net#764) [Kamil Cudnik] * aaf5b98 2021-01-22 | [vslib]: Fix missing MACsec Create Port action (sonic-net#770) [Ze Gan] Signed-off-by: Guohan Lu <[email protected]>
* 20b9573 2021-01-24 | [SAI]: update SAI submodule (#775) (HEAD, origin/master, origin/HEAD) [lguohan] * 667c33d 2021-01-22 | [syncd] Comparison logic add support to LABEL attribute with higher priority (#764) [Kamil Cudnik] * aaf5b98 2021-01-22 | [vslib]: Fix missing MACsec Create Port action (#770) [Ze Gan] Signed-off-by: Guohan Lu <[email protected]>
* 20b9573 2021-01-24 | [SAI]: update SAI submodule (#775) (HEAD, origin/master, origin/HEAD) [lguohan] * 667c33d 2021-01-22 | [syncd] Comparison logic add support to LABEL attribute with higher priority (#764) [Kamil Cudnik] * aaf5b98 2021-01-22 | [vslib]: Fix missing MACsec Create Port action (#770) [Ze Gan] Signed-off-by: Guohan Lu <[email protected]>
* c0bdac2 2021-01-24 | [saithrift]: add correct libs to build saithrift on libsaivs (sonic-net#1184) (HEAD, origin/v1.7) [lguohan] Signed-off-by: Guohan Lu <[email protected]>
… automatically (sonic-net#775) #### Why I did it src/sonic-platform-common ``` * 91a2b87 - (HEAD -> 202405, origin/202405) Restore optoe page to default 0 for active cables (sonic-net#549) (sonic-net#47) (20 hours ago) [mssonicbld] ``` #### How I did it #### How to verify it #### Description for the changelog
No description provided.