diff options
author | Steve McIntyre <steve.mcintyre@linaro.org> | 2014-12-23 13:44:44 +0000 |
---|---|---|
committer | Steve McIntyre <steve.mcintyre@linaro.org> | 2014-12-23 13:44:44 +0000 |
commit | 519158ef4cc064ecb79ccfb3b197cc67438c4eea (patch) | |
tree | 943645e99b0e258ab319adfba37bbc0df54b4a22 /util.py | |
parent | 3b655afb638cfeae8fcfb8ef9f3c8df5be3c6917 (diff) |
Convert get_all_switches() into a new daemon query probe_switches()
Change-Id: I94dd2d0bebadc2e14ce86caca4b6241723b159ea
Diffstat (limited to 'util.py')
-rw-r--r-- | util.py | 18 |
1 files changed, 5 insertions, 13 deletions
@@ -13,11 +13,14 @@ class VlanUtil: class_ = getattr(module, driver) return class_(switch_name) - def get_all_switches(self, config): + def probe_switches(self, state): + config = state.config for switch_name in sorted(config.switches): print "Found switch %s:" % (switch_name) print " Probing:" + ret = {} + s = self.get_switch_driver(switch_name, config) s.switch_connect(config.switches[switch_name].username, config.switches[switch_name].password, @@ -27,18 +30,7 @@ class VlanUtil: print " Switch has %d ports:" % len(s.switch_get_port_names()) for port in s.switch_get_port_names(): print " %s" % port - if 0 == 1: - mode = s.port_get_mode(port) - if mode == "trunk": - print " port %s is in trunk mode, VLAN(s):" % port - vlans = s.port_get_trunk_vlan_list(port) - for vlan in vlans: - name = s.vlan_get_name(vlan) - print " %d (%s)" % (vlan, name) - else: - vlan = s.port_get_access_vlan(port) - name = s.vlan_get_name(vlan) - print " port %s is in access mode, VLAN %d (%s):" % (port, vlan, name) + ret[switch] = 'Found switch %s with %d ports' % (switch, len(s.switch_get_port_names())) s.switch_disconnect() del(s) |