[dts] [PATCH V1 4/6] pmd_bonded_8023ad: dts configuration files

yufengx.mo at intel.com yufengx.mo at intel.com
Wed Jun 6 07:38:31 CEST 2018


From: yufengmx <yufengx.mo at intel.com>


add dts configuration support for switch equipment

Signed-off-by: yufengmx <yufengx.mo at intel.com>
---
 conf/crbs.cfg       |  2 ++
 conf/ports.cfg      |  2 ++
 conf/switch.cfg     | 27 ++++++++++++++++++++++++
 framework/config.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 90 insertions(+), 2 deletions(-)
 create mode 100644 conf/switch.cfg

diff --git a/conf/crbs.cfg b/conf/crbs.cfg
index 0a17c35..9307d48 100644
--- a/conf/crbs.cfg
+++ b/conf/crbs.cfg
@@ -7,6 +7,7 @@
 #  tester_ip: Tester ip address
 #  tester_passwd: Tester password
 #  ixia_group: IXIA group name
+#  switch_group: switch group name
 #  channels: Board channel number
 #  bypass_core0: Whether by pass core0
 [DUT IP1]
@@ -27,5 +28,6 @@ os=linux
 tester_ip=yyy.yyy.yyy.yyy
 tester_passwd=
 ixia_group=
+switch_group=
 channels=4
 bypass_core0=True
diff --git a/conf/ports.cfg b/conf/ports.cfg
index 7fa7aae..97157c4 100644
--- a/conf/ports.cfg
+++ b/conf/ports.cfg
@@ -4,6 +4,7 @@
 #     pci=Pci BDF,intf=Kernel interface;
 #     pci=Pci BDF,mac=Mac address,peer=Tester Pci BDF,numa=Port Numa 
 #     pci=Pci BDF,peer=IXIA:card.port
+#     pci=Pci BDF,peer=SWITCH:port
 #     pci=Pci BDF,peer=Tester Pci BDF,tp_ip=$(IP),tp_path=$({PERL_PATH);
 #     pci=Pci BDF,peer=Tester Pci BDF,sec_port=yes,first_port=Pci BDF;
 # [VM NAME] virtual machine name; This section is for virutal scenario
@@ -14,6 +15,7 @@ ports =
     pci=XX:XX.X,intf=eth0;
     pci=YY:YY.Y,mac=XX:XX:XX:XX:XX:XX,peer=ZZ:ZZ.Z,numa=0;
     pci=ZZ:ZZ.Y,peer=IXIA:X.Y;
+    pci=ZZ:ZZ.Y,peer=SWITCH:XXY;
     pci=0000:XX:XX.X,peer=0000:ZZ:ZZ.Z,tp_ip=127.0.0.1,tp_path=/home/libertyTrailTP_322291/perl;
     pci=0000:YY:YY.Y,peer=0000:ZZ:ZZ.Z,sec_port=yes,first_port=XX:XX.X;
 [VM NAME]
diff --git a/conf/switch.cfg b/conf/switch.cfg
new file mode 100644
index 0000000..aa3de22
--- /dev/null
+++ b/conf/switch.cfg
@@ -0,0 +1,27 @@
+# switch port Configuration
+# switch_Group1:    a name of switch work scence
+# manufacture:      switch manufacture
+# model:            switch device model
+# ip:               switch device IP address
+# user:             switch device user name
+# passwd:           switch device user password
+# auto_config:      switch auto config resources(True or False)
+# scene:            switch work scene
+# vlan:             switch vlan id
+# port-channel:     port-channel id
+# ports:            [switch port list]
+[switch_Group1]
+manufacturer=xxxxxx
+model=xxxxxx
+ip=xxx.xxx.xxx.xxx
+user=xxxx
+passwd=xxxx
+auto_config=xxxx
+scene=xxxx
+vlan=xxx
+port-channel=xxxx
+ports=
+    xxx;
+    xxx;
+    xxx;
+    xxx;
diff --git a/framework/config.py b/framework/config.py
index 71b1c37..749e979 100644
--- a/framework/config.py
+++ b/framework/config.py
@@ -1,6 +1,6 @@
 # BSD LICENSE
 #
-# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2018 Intel Corporation. All rights reserved.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,7 @@ import ConfigParser  # config parse module
 import argparse      # prase arguments module
 from settings import IXIA, CONFIG_ROOT_PATH, SUITE_SECTION_NAME
 from settings import load_global_setting, DTS_CFG_FOLDER
+from settings import SWITCH
 from exception import ConfigParseException, VirtConfigParseException, PortConfigParseException
 
 PORTCONF = "%s/ports.cfg" % CONFIG_ROOT_PATH
@@ -45,7 +46,7 @@ CRBCONF = "%s/crbs.cfg" % CONFIG_ROOT_PATH
 VIRTCONF = "%s/virt_global.cfg" % CONFIG_ROOT_PATH
 IXIACONF = "%s/ixia.cfg" % CONFIG_ROOT_PATH
 GLOBALCONF = "%s/global_suite.cfg" % CONFIG_ROOT_PATH
-
+SWITCHCONF = "%s/switch.cfg" % CONFIG_ROOT_PATH
 
 class UserConf():
 
@@ -249,6 +250,7 @@ class CrbsConf(UserConf):
     DEF_CRB = {'IP': '', 'board': 'default', 'user': '',
                'pass': '', 'tester IP': '', 'tester pass': '',
                IXIA: None, 'memory channels': 4,
+               SWITCH: None,
                'bypass core0': True}
 
     def __init__(self, crbs_conf=CRBCONF):
@@ -292,6 +294,11 @@ class CrbsConf(UserConf):
                     if value.lower() == 'none':
                         value = None
                     crb[IXIA] = value
+                elif key == 'switch_group':
+                    # None type will be check later
+                    if value.lower() == 'none':
+                        value = None
+                    crb[SWITCH] = value
                 elif key == 'channels':
                     crb['memory channels'] = int(value)
                 elif key == 'bypass_core0':
@@ -364,6 +371,56 @@ class IxiaConf(UserConf):
 
         return self.ixia_cfg
 
+
+class SwitchConf(UserConf):
+
+    def __init__(self, switch_conf=SWITCHCONF):
+        self.config_file = switch_conf
+        self.switch_cfg = {}
+        try:
+            self.switch_conf = UserConf(self.config_file)
+        except ConfigParseException:
+            self.switch_conf = None
+            raise ConfigParseException
+
+    def load_switch_config(self):
+        port_reg = r'(\S+)'
+        groups = self.switch_conf.get_sections()
+        if not groups:
+            return self.switch_cfg
+
+        keywords = ['manufacturer', 'model', 'ip', 'user', 'passwd', 'scene',
+                    'vlan', 'port-channel', 'ports', 'auto_config']
+        required_keywords = ['manufacturer', 'model', 'ip', 'user', 'passwd']
+        for group in groups:
+            switch_group = {}
+            switch_confs = self.switch_conf.load_section(group)
+            if not switch_confs:
+                continue
+            # convert file configuration to dts switchcfg
+            for conf in switch_confs:
+                _key, value = conf
+                key = _key.lower()
+                if key == 'ports':
+                    ports = self.switch_conf.load_config(value)
+                    switch_ports = []
+                    for port in ports:
+                        m = re.findall(port_reg, port)
+                        switch_ports += [port.strip() for port in m]
+                    switch_group['ports'] = switch_ports
+                elif key in keywords:
+                    switch_group[key] = value
+
+            msg_fmt = 'switch configuration file request {0} option!!!'.format
+            for i in required_keywords:
+                if i not in switch_group:
+                    print msg_fmt(i)
+
+            self.switch_cfg[group] = switch_group
+
+        return self.switch_cfg
+
+
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(
         description="Load DTS configuration files")
-- 
1.9.3



More information about the dts mailing list