From eda15c7b0ab7665ea7a1976a452634e67730290c Mon Sep 17 00:00:00 2001 From: Daniel Poelzleithner Date: Fri, 16 Aug 2019 20:18:59 +0200 Subject: [PATCH] change bonding to static lacp aggregates --- salt/switches/3com-4200G.expect | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/salt/switches/3com-4200G.expect b/salt/switches/3com-4200G.expect index 504944a..4c7b49e 100644 --- a/salt/switches/3com-4200G.expect +++ b/salt/switches/3com-4200G.expect @@ -1,4 +1,11 @@ {# http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c02586144-1.pdf #} + +{%- set counter = {'agg': 0} -%} + +{%- macro increment(dct, key, inc=1) -%} + {% if dct.update({key: dct[key] + inc}) %} {% endif %} +{%- endmacro -%} + {%- import_yaml "netmasks.yaml" as netmasks -%} #!/usr/bin/expect -f @@ -62,6 +69,19 @@ expect "{{ hostname }}]" {%- for name, conf in switch['ports'].items() %} {%- if conf['mode'] == 'trunk' or conf['mode'] == 'bond' %} +{%- if conf['mode'] == 'bond' %} +{# generate the next aggrerate id to use #} +{{ increment(counter, 'agg') }} +send "link-aggregation group {{counter.agg}} mode static\r" +expect { + "This aggregation will be modified to static mode. Continue ?" { + send "Y\r" + } + "]" {} +} +send "link-aggregation group {{counter.agg}} description {{name}}\r" +expect "]" +{%- endif %} {%- for port in conf['ports'] %} send "interface {{ port }}\r" expect "]" @@ -69,6 +89,10 @@ send "undo stp edged-port\r" expect "]" {%- if conf['mode'] == 'bond' %} send "lacp enable\r" +expect "]" +send "undo port link-aggregation group\r" +expect "]" +send "port link-aggregation group {{counter.agg}}\r" {%- else %} send "undo lacp enable\r" {%- endif %}