diff --git a/examples/device-simulation/cmdsets/cumulus_frr b/examples/device-simulation/cmdsets/cumulus_frr index 4167dc147..da00d1d4e 100644 --- a/examples/device-simulation/cmdsets/cumulus_frr +++ b/examples/device-simulation/cmdsets/cumulus_frr @@ -19,3 +19,4 @@ cat /etc/cumulus/acl/policy.conf cat /etc/default/isc-dhcp-relay cat /etc/cumulus/etc.replace/os-release cl-license +exit diff --git a/examples/device-simulation/cmdsets/cumulus_nclu b/examples/device-simulation/cmdsets/cumulus_nclu index 791cf019e..34ea0054c 100644 --- a/examples/device-simulation/cmdsets/cumulus_nclu +++ b/examples/device-simulation/cmdsets/cumulus_nclu @@ -1 +1,2 @@ net show configuration commands +exit diff --git a/examples/device-simulation/cmdsets/cumulus_nvue b/examples/device-simulation/cmdsets/cumulus_nvue index f28fdf811..0ed7d4410 100644 --- a/examples/device-simulation/cmdsets/cumulus_nvue +++ b/examples/device-simulation/cmdsets/cumulus_nvue @@ -1 +1,2 @@ nv config show --color off +exit diff --git a/examples/device-simulation/cmdsets/cumulus_quagga b/examples/device-simulation/cmdsets/cumulus_quagga index 21827e366..a35c14b6a 100644 --- a/examples/device-simulation/cmdsets/cumulus_quagga +++ b/examples/device-simulation/cmdsets/cumulus_quagga @@ -19,3 +19,4 @@ cat /etc/cumulus/acl/policy.conf cat /etc/default/isc-dhcp-relay cat /etc/cumulus/etc.replace/os-release cl-license +exit diff --git a/examples/device-simulation/yaml/cumulus_nvue-5.9.2.yaml b/examples/device-simulation/yaml/cumulus_MSN2010_5.9.2_nvue.yaml similarity index 54% rename from examples/device-simulation/yaml/cumulus_nvue-5.9.2.yaml rename to examples/device-simulation/yaml/cumulus_MSN2010_5.9.2_nvue.yaml index 97471d07c..633f271cc 100644 --- a/examples/device-simulation/yaml/cumulus_nvue-5.9.2.yaml +++ b/examples/device-simulation/yaml/cumulus_MSN2010_5.9.2_nvue.yaml @@ -214,5 +214,202 @@ commands: description: spine leaf bgp peer-group remote-as: external \e[?2004hroot@spine1-nyc2:~#\x20 + exit: |- + exit oxidized_output: | - !! needs to be written by hand or copy & paste from model output + \e[?2004l\r- header: + model: MSN2010 + nvue-api-version: nvue_v1 + rev-id: 1.0 + version: Cumulus Linux 5.9.2 + - set: + interface: + eth0: + ip: + address: + 10.xx.xx.xx/23: {} + gateway: + 10.xx.xx.yyy: {} + vrf: mgmt + type: eth + eth0,swp19-22: + link: + state: + up: {} + lo: + ip: + address: + 10.xx.xx.xx/32: {} + type: loopback + swp1-18: + description: UNUSED 25G PORTS + link: + state: + down: {} + swp1-22: + type: swp + swp19: + description: 100G Link to edge1 + swp19-22: + ip: + neighbor-discovery: + router-advertisement: + interval: 10000 + swp20: + description: 100G Link to edge2 + swp21: + description: 100G Link to leaf1 + swp22: + description: 100G Link to leaf2 + router: + bgp: + autonomous-system: 65432 + enable: on + router-id: 10.xx.xx.xx + service: + snmp-server: + enable: on + listening-address: + 10.xx.xx.xx: + vrf: mgmt + localhost: {} + username: + observium: + auth-sha: + xxxxxxxxxxxxxxxx: + encrypt-aes: + xxxxxxxxxxxxxxxx: + view: xxxxxxxxxxxxx + viewname: + xxxxxxxxxxxxx: + included: 1.3.6.1.2.1 + syslog: + mgmt: + server: + 10.xx.xx.xxx: {} + system: + aaa: + class: + nvapply: + action: allow + command-path: + /: + permission: all + nvshow: + action: allow + command-path: + /: + permission: ro + sudo: + action: allow + command-path: + /: + permission: all + role: + nvue-admin: + class: + nvapply: {} + nvue-monitor: + class: + nvshow: {} + system-admin: + class: + nvapply: {} + sudo: {} + user: + cumulus: + full-name: cumulus,,, + hashed-password: '*' + role: system-admin + api: + state: enabled + cli: + inactive-timeout: 1800 + config: + auto-save: + enable: on + snippet: + sshd_config: | + HostKeyAlgorithms ssh-rsa,ecdsa-sha2-nistp256,rsa-sha2-256,rsa-sha2-512 + PubkeyAcceptedAlgorithms +ssh-rsa + control-plane: + acl: + acl-default-dos: + inbound: {} + acl-default-whitelist: + inbound: {} + controlplane-in: + inbound: {} + hostname: spine1-nyc2 + reboot: + mode: cold + ssh-server: + authentication-retries: 10 + inactive-timeout: 1800 + login-timeout: 200 + permit-root-login: enabled + state: enabled + strict: enabled + timezone: Etc/UTC + wjh: + channel: + forwarding: + trigger: + l2: {} + l3: {} + tunnel: {} + enable: on + vrf: + default: + router: + bgp: + address-family: + ipv4-unicast: + enable: on + redistribute: + connected: + enable: on + ipv6-unicast: + enable: on + l2vpn-evpn: + enable: on + enable: on + neighbor: + swp19: + peer-group: fabric + type: unnumbered + swp20: + peer-group: fabric + type: unnumbered + swp21: + peer-group: fabric + type: unnumbered + swp22: + peer-group: fabric + type: unnumbered + path-selection: + multipath: + aspath-ignore: on + peer-group: + fabric: + address-family: + ipv4-unicast: + enable: on + nexthop-setting: self + soft-reconfiguration: on + ipv6-unicast: + enable: on + nexthop-setting: self + soft-reconfiguration: on + l2vpn-evpn: + enable: on + soft-reconfiguration: on + bfd: + detect-multiplier: 3 + enable: on + min-rx-interval: 400 + min-tx-interval: 400 + capabilities: + extended-nexthop: on + description: spine leaf bgp peer-group + remote-as: external diff --git a/lib/oxidized/model/cumulus.rb b/lib/oxidized/model/cumulus.rb index 50c8997f6..47c67c9ba 100644 --- a/lib/oxidized/model/cumulus.rb +++ b/lib/oxidized/model/cumulus.rb @@ -1,7 +1,10 @@ class Cumulus < Oxidized::Model using Refinements - prompt /^\[?[^h]+h(([\w.-]*)@(.*)):/ + # (\e\[\?\d+h)? - optional ANSI escape code + # [\w.-]+@ - user@ + # .+:.*# $ - host:path# + prompt /^(\e\[\?\d+h)?[\w.-]+@.+:.*# $/ comment '# ' # add a comment in the final conf diff --git a/spec/model/cumulus_spec.rb b/spec/model/cumulus_spec.rb new file mode 100644 index 000000000..0db41b409 --- /dev/null +++ b/spec/model/cumulus_spec.rb @@ -0,0 +1,32 @@ +require_relative 'model_helper' + +describe 'model/Cumulus' do + before(:each) do + init_model_helper + + @node = Oxidized::Node.new(name: 'example.com', + input: 'ssh', + model: 'cumulus') + end + + it 'matches different prompts' do + _('root@spine1-nyc2:~# ').must_match Cumulus.prompt + _("\e[?2004hroot@spine1-nyc2:~#\x20").must_match Cumulus.prompt + end + + it 'runs on MSN2010 with Cumulus Linux 5.9.2 (nvue mode)' do + # Reload node with vars cumulus_use_nvue set + @node = Oxidized::Node.new(name: 'example.com', + input: 'ssh', + model: 'cumulus', + vars: { cumulus_use_nvue: true }) + + mockmodel = MockSsh.new('examples/device-simulation/yaml/cumulus_MSN2010_5.9.2_nvue.yaml') + Net::SSH.stubs(:start).returns mockmodel + + status, result = @node.run + + _(status).must_equal :success + _(result.to_cfg).must_equal mockmodel.oxidized_output + end +end