Skip to content

Commit

Permalink
Version specific config for SR OS (#180)
Browse files Browse the repository at this point in the history
* WA for netconf change.

* Remove unused import.

* nokia-modules obsolete in 21 / replaced by nokia-submodules. No need for netconf change to classic CLI config.

* submodules must be disabled before combined can be enabled, only admin-enable is required under netconf.

* Fix code smell.

* formatted with ruff

* formatted with ruff

* added version specific config

---------

Co-authored-by: Thomas Hendriks <thomas.hendriks@nokia.com>
Co-authored-by: Roman Dodin <dodin.roman@gmail.com>
  • Loading branch information
3 people committed Mar 26, 2024
1 parent e939d59 commit c323219
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 25 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ venv
**/vrnetlab.py
# Still allow for the common python scripts
!common/healthcheck.py
!common/vrnetlab.py
!common/vrnetlab.py

.envrc
11 changes: 11 additions & 0 deletions dev-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Developer notes

## vrnetlab module and vscode pylance

since vrnetlab module is in the `common` dir the pylance extension in vscode will not be able to find the module reference in `launch.py` files. To fix this, add the following to the `settings.json` file in vscode:

```json
{
"python.analysis.extraPaths": ["common"]
}
```
65 changes: 41 additions & 24 deletions sros/docker/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def line_card_config(
"ixr-x1": {
"deployment_model": "distributed",
# control plane (CPM)
"max_nics": 36, # 32 * qsfp28 + 4 * qsfpdd
"max_nics": 36, # 32 * qsfp28 + 4 * qsfpdd
"cp": {
"min_ram": 3,
"timos_line": "chassis=ixr-x slot=A card=cpm-ixr-x/imm32-qsfp28+4-qsfpdd",
Expand All @@ -174,7 +174,7 @@ def line_card_config(
"ixr-xs": {
"deployment_model": "distributed",
# control plane (CPM)
"max_nics": 54, # 6 * qsfpdd + 48 * sfp56
"max_nics": 54, # 6 * qsfpdd + 48 * sfp56
"cp": {
"min_ram": 3,
"timos_line": "chassis=ixr-x slot=A card=cpm-ixr-x/imm6-qsfpdd+48-sfp56",
Expand All @@ -194,7 +194,7 @@ def line_card_config(
"ixr-x3": {
"deployment_model": "distributed",
# control plane (CPM)
"max_nics": 36, # 36 * qsfpdd
"max_nics": 36, # 36 * qsfpdd
"cp": {
"min_ram": 4,
"timos_line": "chassis=ixr-x3 slot=A card=cpm-ixr-x/imm36-qsfpdd",
Expand Down Expand Up @@ -484,15 +484,15 @@ def line_card_config(
},
],
},
### SR-1 FP5 models (six variants with sfp-dd or qsfpdd only):
#SR-1 FP5 - CP Card must include CPM/IOM
### SR-1 FP5 models (six variants with sfp-dd or qsfpdd only):
# SR-1 FP5 - CP Card must include CPM/IOM
"sr-1-46s": {
"deployment_model": "distributed",
# control plane (CPM)
"max_nics": 48,
"cp": {
"min_ram": 4,
"timos_line": "slot=A chassis=sr-1-46s card=cpm-1x/i40-200g-sfpdd+6-800g-qsfpdd-1", #CP Card must include CPM/IOM
"timos_line": "slot=A chassis=sr-1-46s card=cpm-1x/i40-200g-sfpdd+6-800g-qsfpdd-1", # CP Card must include CPM/IOM
},
# line card (IOM/XCM)
"lcs": [
Expand All @@ -506,14 +506,14 @@ def line_card_config(
}
],
},
#SR-1 FP5 - CP Card must include CPM/IOM
# SR-1 FP5 - CP Card must include CPM/IOM
"sr-1-92s": {
"deployment_model": "distributed",
# control plane (CPM)
"max_nics": 48,
"cp": {
"min_ram": 4,
"timos_line": "slot=A chassis=sr-1-92s card=cpm-1x/i80-200g-sfpdd+12-400g-qsfpdd-1", #CP Card must include CPM/IOM
"timos_line": "slot=A chassis=sr-1-92s card=cpm-1x/i80-200g-sfpdd+12-400g-qsfpdd-1", # CP Card must include CPM/IOM
},
# line card (IOM/XCM)
"lcs": [
Expand All @@ -527,14 +527,14 @@ def line_card_config(
}
],
},
#SR-1 FP5 - CP Card must include CPM/IOM
# SR-1 FP5 - CP Card must include CPM/IOM
"sr-1x-92s": {
"deployment_model": "distributed",
# control plane (CPM)
"max_nics": 48,
"cp": {
"min_ram": 4,
"timos_line": "slot=A chassis=sr-1x-92s card=cpm-1x/i80-200g-sfpdd+12-800g-qsfpdd-1x", #CP Card must include CPM/IOM
"timos_line": "slot=A chassis=sr-1x-92s card=cpm-1x/i80-200g-sfpdd+12-800g-qsfpdd-1x", # CP Card must include CPM/IOM
},
# line card (IOM/XCM)
"lcs": [
Expand All @@ -548,7 +548,7 @@ def line_card_config(
}
],
},
#SR-1 FP5
# SR-1 FP5
"sr-1-24d": {
"deployment_model": "distributed",
# control plane (CPM)
Expand All @@ -569,14 +569,14 @@ def line_card_config(
}
],
},
#SR-1 FP5
# SR-1 FP5
"sr-1-48d": {
"deployment_model": "distributed",
# control plane (CPM)
"max_nics": 48,
"cp": {
"min_ram": 4,
"timos_line": "slot=A chassis=sr-1-48D card=cpm-1x/i48-400g-qsfpdd-1", #CP Card must include CPM/IOM
"timos_line": "slot=A chassis=sr-1-48D card=cpm-1x/i48-400g-qsfpdd-1", # CP Card must include CPM/IOM
},
# line card (IOM/XCM)
"lcs": [
Expand All @@ -590,7 +590,7 @@ def line_card_config(
}
],
},
#SR-1 FP5
# SR-1 FP5
"sr-1x-48d": {
"deployment_model": "distributed",
# control plane (CPM)
Expand Down Expand Up @@ -630,19 +630,16 @@ def line_card_config(
# SR OS Classic CLI common configuration
SROS_CL_COMMON_CFG = """
/configure system name {name}
/configure system netconf no shutdown
/configure system security profile \"administrative\" netconf base-op-authorization lock
/configure system login-control ssh inbound-max-sessions 30
/configure system management-interface yang-modules no nokia-modules
/configure system management-interface yang-modules nokia-combined-modules
/configure system management-interface yang-modules no base-r13-modules
/configure system netconf auto-config-save
/configure system netconf no shutdown
/configure system grpc allow-unsecure-connection
/configure system grpc gnmi auto-config-save
/configure system grpc gnmi no shutdown
/configure system grpc rib-api no shutdown
/configure system grpc no shutdown
/configure system netconf auto-config-save
/configure system netconf no shutdown
/configure system security profile "administrative" netconf base-op-authorization kill-session
/configure system security profile "administrative" netconf base-op-authorization lock
/configure system snmp packet-size 9216
Expand All @@ -655,6 +652,7 @@ def line_card_config(
/configure system security snmp community "public" r version v2c
"""


# SR OS Model-Driven CLI common configuration
SROS_MD_COMMON_CFG = """
/configure system name {name}
Expand All @@ -665,7 +663,6 @@ def line_card_config(
/configure system grpc allow-unsecure-connection
/configure system grpc gnmi auto-config-save true
/configure system grpc rib-api admin-state enable
/configure system management-interface netconf admin-state enable
/configure system management-interface netconf auto-config-save true
/configure system management-interface snmp packet-size 9216
/configure system management-interface snmp streaming admin-state enable
Expand All @@ -677,6 +674,27 @@ def line_card_config(
/configure system security snmp community "public" version v2c
"""


# get_version_specific_config returns the version specific configuration
# based on the release number.
def get_version_specific_config(major_version: int):
# releases <=22 boot with the classic CLI config by default
if major_version <= 22:
return """
/configure system management-interface yang-modules no nokia-submodules
/configure system management-interface yang-modules nokia-combined-modules
"""
# 23.x releases use the Model-Driven CLI by default
if major_version == 23:
return """
/configure system management-interface netconf admin-state enable
"""
# releases 24.3.1 and above use a new command to enable netconf server
return """
/configure system management-interface netconf listen admin-state enable
"""


# to allow writing config to tftp location we needed to spin up a normal
# tftp server in container host system. To access the host from qemu VM
# we needed to put SR OS management interface in the container host network namespace
Expand Down Expand Up @@ -1207,7 +1225,7 @@ def gen_mgmt(self):
self.nic_type + ",netdev=br-mgmt,mac=%(mac)s" % {"mac": vrnetlab.gen_mac(0)}
)
res.append("-netdev")
res.append("bridge,br=br-mgmt,id=br-mgmt" % {"i": 0})
res.append("bridge,br=br-mgmt,id=br-mgmt")

# add virtio NIC for internal control plane interface to vFPC
res.append("-device")
Expand Down Expand Up @@ -1474,11 +1492,10 @@ def getDefaultConfig() -> str:
"""Returns the default configuration for the system based on the SR OS version.
SR OS >=23 uses model-driven configuration, while SR OS <=22 uses classic configuration.
"""

if SROS_VERSION.major <= 22:
return SROS_CL_COMMON_CFG
return SROS_CL_COMMON_CFG + get_version_specific_config(SROS_VERSION.major)

return SROS_MD_COMMON_CFG
return SROS_MD_COMMON_CFG + get_version_specific_config(SROS_VERSION.major)


if __name__ == "__main__":
Expand Down

0 comments on commit c323219

Please sign in to comment.