Commit 6d4f6737 authored by Gerry Gunzenhauser's avatar Gerry Gunzenhauser

fix some generation stuff

parent a1a557a6
Pipeline #62572 failed with stages
in 7 minutes and 57 seconds
......@@ -34,7 +34,7 @@ mod rbsetup {
use crate::model::Device;
pub fn gen_syssetup(device: &Device) -> String {
let generic = format!(" {{\n /system identity set name=\"{}\"\n /system routerboard settings set auto-upgrade=yes\n", device.name);
let generic = format!(" /system identity set name=\"{}\"\n /system routerboard settings set auto-upgrade=yes\n", device.name);
let mut interfaces = " /interface ethernet\n".to_owned();
for port in device.ports.iter() {
......@@ -42,13 +42,13 @@ mod rbsetup {
interfaces += format!(" set name=\"{}\" [find where default-name=\"{}\"]\n", port.new_name, port.org_name).as_str();
}
};
interfaces += " }\n";
generic + interfaces.as_str()
}
pub fn gen_postsetup(device: &Device) -> String {
let cap_setup = " :if ([:len [/interface wireless find]]>0) do={\n /interface wireless set country=switzerland [find] frequency-mode=regulatory-domain\n /interface wireless cap set enabled=yes bridge=switch interfaces=[/interface wireless find]\n }\n".to_owned();
let mut cap_setup = " :if ([:len [/interface wireless find]]>0) do={\n /interface wireless set country=switzerland [find] frequency-mode=regulatory-domain\n /interface wireless cap set enabled=yes bridge=switch interfaces=[/interface wireless find]\n }\n".to_owned();
cap_setup += " /ip dhcp-client\n remove [find]\n add disabled=no interface=switch\n";
cap_setup
}
}
......@@ -62,14 +62,14 @@ mod gen_crs226 {
impl Generator for GenCrs226 {
fn build_configuration(&self, device: &Device) -> String {
let mut src = " {\n /interface bridge\n remove [find]\n add name=switch protocol-mode=none\n /interface bridge port\n remove [find]\n".to_owned();
let mut src = " /interface bridge\n remove [find]\n add name=switch protocol-mode=none\n /interface bridge port\n remove [find]\n".to_owned();
for port in device.ports.iter() {
if port.org_name != "switch1-cpu" {
src += format!(" add bridge=switch interface=\"{}\"\n", port.new_name).as_str();
}
}
src += " }\n {\n /interface ethernet switch egress-vlan-tag\n remove [find where !dynamic]\n";
src += " /interface ethernet switch egress-vlan-tag\n remove [find where !dynamic]\n";
for vlan in device.get_tagged_ports().iter() {
src += format!(" add tagged-ports=\"{}\" vlan={}\n", vlan.1.join(","), vlan.0).as_str()
}
......@@ -102,15 +102,14 @@ mod gen_crs326 {
impl Generator for GenCrs326 {
fn build_configuration(&self, device: &Device) -> String {
let mut src = " {\n /interface bridge\n remove [find]\n add name=switch protocol-mode=none vlan-filtering=yes\n /interface bridge port\n remove [find]\n".to_owned();
let mut src = " /interface bridge\n remove [find]\n add name=switch protocol-mode=none vlan-filtering=yes\n /interface bridge port\n remove [find]\n".to_owned();
for port in device.ports.iter() {
if port.org_name != "switch" {
src += format!(" add bridge=switch interface=\"{}\"\n", port.new_name).as_str();
}
}
src += " /ip dhcp-client\n remove [find]\n add disabled=no interface=switch\n }\n {\n /interface ethernet switch port\n";
src += " {\n /interface bridge port\n remove [find]\n";
src += " /interface bridge port\n remove [find]\n";
for port in device.ports.iter() {
if port.new_name == "switch" {
continue
......@@ -131,11 +130,10 @@ mod gen_crs326 {
}
}
src += " }\n /interface bridge vlan\n remove [find where !dynamic]\n";
src += " /interface bridge vlan\n remove [find where !dynamic]\n";
for vlan in device.get_ports_by_vlan_tagged_untagged().iter() {
src += format!(" add bridge=switch tagged=\"{}\" untagged=\"{}\" vlan-ids={}\n", (vlan.1).0.join(","), (vlan.1).1.join(","), vlan.0).as_str();
}
src += " }\n";
crate::generator::rbsetup::gen_syssetup(device) + src.as_str() + crate::generator::rbsetup::gen_postsetup(device).as_str()
}
......@@ -155,14 +153,14 @@ mod gen_rb962u {
impl Generator for GenRB962U {
fn build_configuration(&self, device: &Device) -> String {
let mut src = " {\n /interface bridge\n remove [find]\n add name=switch protocol-mode=none\n /interface bridge port\n remove [find]\n".to_owned();
let mut src = " /interface bridge\n remove [find]\n add name=switch protocol-mode=none\n /interface bridge port\n remove [find]\n".to_owned();
for port in device.ports.iter() {
if port.org_name != "switch1-cpu" {
src += format!(" add bridge=switch interface=\"{}\"\n", port.new_name).as_str();
}
}
src += " /ip dhcp-client\n remove [find]\n add disabled=no interface=switch\n }\n {\n /interface ethernet switch port\n";
src += " /interface ethernet switch port\n";
for port in device.ports.iter() {
match (port.profile.untagged_vlans.len(), port.profile.tagged_vlans.len()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment