aboutsummaryrefslogtreecommitdiff
path: root/util.py
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2015-04-01 18:01:45 +0100
committerSteve McIntyre <steve.mcintyre@linaro.org>2015-04-01 18:01:45 +0100
commit5fa2265dc646f0af1478e4c30ec3ec8567ad4be9 (patch)
treee18ce97fe25c39e4a8fbb71b5e8c12dab4ae08cd /util.py
parentea15fa78699ab1aca05df9d74e63b16fc21f7fd2 (diff)
Fix up huge numbers of pylint warnings
Change-Id: I9112ab123943a81e60d2c6bf096bc125e8e042b7
Diffstat (limited to 'util.py')
-rw-r--r--util.py60
1 files changed, 30 insertions, 30 deletions
diff --git a/util.py b/util.py
index 5abe16b..afb2e1f 100644
--- a/util.py
+++ b/util.py
@@ -6,9 +6,9 @@ class VlanUtil:
"""VLANd utility functions"""
def get_switch_driver(self, switch_name, config):
- logging.debug("Trying to find a driver for %s" % switch_name)
+ logging.debug("Trying to find a driver for %s", switch_name)
driver = config.switches[switch_name].driver
- logging.debug("Driver: %s" % driver)
+ logging.debug("Driver: %s", driver)
module = __import__("drivers.%s" % driver, fromlist=[driver])
class_ = getattr(module, driver)
return class_(switch_name)
@@ -17,7 +17,7 @@ class VlanUtil:
config = state.config
ret = {}
for switch_name in sorted(config.switches):
- logging.debug("Found switch %s:" % (switch_name))
+ logging.debug("Found switch %s:", switch_name)
logging.debug(" Probing...")
s = self.get_switch_driver(switch_name, config)
@@ -178,7 +178,7 @@ class VlanUtil:
raise InputError("Unknown query command \"%s\"" % command)
except InputError as e:
- logging.debug('got error %s' % e)
+ logging.debug('got error %s', e)
raise
# except:
@@ -205,9 +205,9 @@ class VlanUtil:
# 1. Database record first
try:
- logging.debug('Adding DB record first: name %s, tag %d, is_base_vlan %d' % (name, tag, is_base_vlan))
+ logging.debug('Adding DB record first: name %s, tag %d, is_base_vlan %d', name, tag, is_base_vlan)
vlan_id = db.create_vlan(name, tag, is_base_vlan)
- logging.debug('Added VLAN tag %d, name %s to the database, created VLAN ID %d' % (tag, name, vlan_id))
+ logging.debug('Added VLAN tag %d, name %s to the database, created VLAN ID %d', tag, name, vlan_id)
except InputError:
logging.debug('DB creation failed')
raise
@@ -221,7 +221,7 @@ class VlanUtil:
trunk_ports = []
switch_name = switch.name
try:
- logging.debug('Adding new VLAN to switch %s' % switch_name)
+ logging.debug('Adding new VLAN to switch %s', switch_name)
# Get the right driver
s = self.get_switch_driver(switch_name, config)
s.switch_connect(config.switches[switch_name].username,
@@ -235,7 +235,7 @@ class VlanUtil:
# 2a. Create the VLAN on the switch
s.vlan_create(tag)
s.vlan_set_name(tag, name)
- logging.debug('Added VLAN tag %d, name %s to switch %s' % (tag, name, switch_name))
+ logging.debug('Added VLAN tag %d, name %s to switch %s', tag, name, switch_name)
# 2b. Do we need to worry about trunk ports on this switch?
if 'TrunkWildCardVlans' in s.switch_get_capabilities():
@@ -247,11 +247,11 @@ class VlanUtil:
logging.debug("But it has no trunk ports defined")
trunk_ports = []
else:
- logging.debug('Found %d trunk_ports that need adjusting' % len(trunk_ports))
+ logging.debug('Found %d trunk_ports that need adjusting', len(trunk_ports))
# Modify any trunk ports as needed
for port in trunk_ports:
- logging.debug('Added VLAN tag %d, name %s to switch %s' % (tag, name, switch_name))
+ logging.debug('Added VLAN tag %d, name %s to switch %s', tag, name, switch_name)
s.port_add_trunk_to_vlan(port, tag)
# And now we're done with this switch
@@ -308,7 +308,7 @@ class VlanUtil:
config = state.config
# 1. Check for database records first
- logging.debug('Checking for ports using VLAN ID %d' % vlan_id)
+ logging.debug('Checking for ports using VLAN ID %d', vlan_id)
vlan = db.get_vlan_by_id(vlan_id)
if vlan is None:
raise InputError("VLAN ID %d does not exist" % vlan_id)
@@ -351,17 +351,17 @@ class VlanUtil:
logging.debug("But it has no trunk ports defined")
trunk_ports = []
else:
- logging.debug('Found %d trunk_ports that need adjusting' % len(trunk_ports))
+ logging.debug('Found %d trunk_ports that need adjusting', len(trunk_ports))
# Modify any trunk ports as needed
for port in trunk_ports:
s.port_remove_trunk_from_vlan(port, vlan_tag)
- logging.debug('Removed VLAN tag %d from switch %s port %s' % (vlan_tag, switch_name, port))
+ logging.debug('Removed VLAN tag %d from switch %s port %s', vlan_tag, switch_name, port)
# 2b. Remove the VLAN from the switch
- logging.debug('Removing VLAN tag %d from switch %s' % (vlan_tag, switch_name))
+ logging.debug('Removing VLAN tag %d from switch %s', vlan_tag, switch_name)
s.vlan_destroy(vlan_tag)
- logging.debug('Removed VLAN tag %d from switch %s' % (vlan_tag, switch_name))
+ logging.debug('Removed VLAN tag %d from switch %s', vlan_tag, switch_name)
# And now we're done with this switch
s.switch_disconnect()
@@ -397,9 +397,9 @@ class VlanUtil:
# 4. Finally, remove the VLAN in the DB
try:
- logging.debug('Removing DB record: VLAN ID %d' % vlan_id)
+ logging.debug('Removing DB record: VLAN ID %d', vlan_id)
vlan_id = db.delete_vlan(vlan_id)
- logging.debug('Removed VLAN ID %d from the database OK' % vlan_id)
+ logging.debug('Removed VLAN ID %d from the database OK', vlan_id)
except InputError:
logging.debug('DB deletion failed')
raise
@@ -449,7 +449,7 @@ class VlanUtil:
config.switches[switch_name].password,
config.switches[switch_name].enable_password)
except:
- logging.debug('Failed to talk to switch %s!' % switch_name)
+ logging.debug('Failed to talk to switch %s!', switch_name)
raise
try:
@@ -461,10 +461,10 @@ class VlanUtil:
logging.debug('This switch needs special trunk port handling')
vlans = s.port_get_trunk_vlan_list(port.name)
if vlans is None:
- logging.debug("But it has no VLANs defined on port %s" % port.name)
+ logging.debug("But it has no VLANs defined on port %s", port.name)
vlans = []
else:
- logging.debug('Found %d vlans that may need dropping on port %s' % (len(vlans), port.name))
+ logging.debug('Found %d vlans that may need dropping on port %s', len(vlans), port.name)
for vlan in vlans:
if vlan != state.config.vland.default_vlan_tag:
@@ -536,7 +536,7 @@ class VlanUtil:
config.switches[switch_name].password,
config.switches[switch_name].enable_password)
except:
- logging.debug('Failed to talk to switch %s!' % switch_name)
+ logging.debug('Failed to talk to switch %s!', switch_name)
raise
try:
@@ -598,7 +598,7 @@ class VlanUtil:
config.switches[switch_name].password,
config.switches[switch_name].enable_password)
except:
- logging.debug('Failed to talk to switch %s!' % switch_name)
+ logging.debug('Failed to talk to switch %s!', switch_name)
raise
try:
@@ -651,7 +651,7 @@ class VlanUtil:
config.switches[switch_name].password,
config.switches[switch_name].enable_password)
except:
- logging.debug('Failed to talk to switch %s!' % switch_name)
+ logging.debug('Failed to talk to switch %s!', switch_name)
raise
# DON'T create the switch record in the DB first - we'll want
@@ -663,7 +663,7 @@ class VlanUtil:
# Grab the VLANs defined on this switch
vlan_tags = s.vlan_get_list()
- logging.debug(' found %d vlans on the switch' % len(vlan_tags))
+ logging.debug(' found %d vlans on the switch', len(vlan_tags))
for vlan_tag in vlan_tags:
vlan_name = s.vlan_get_name(vlan_tag)
@@ -706,9 +706,9 @@ class VlanUtil:
# And now the ports
trunk_ports = []
ports = s.switch_get_port_names()
- logging.debug(' found %d ports on the switch' % len(ports))
+ logging.debug(' found %d ports on the switch', len(ports))
for port_name in ports:
- logging.debug(' trying to import port %s' % port_name)
+ logging.debug(' trying to import port %s', port_name)
port_id = None
port_mode = s.port_get_mode(port_name)
if port_mode == 'access':
@@ -720,7 +720,7 @@ class VlanUtil:
port_vlan_id = db.get_vlan_id_by_tag(port_vlans[port_name][0])
port_id = db.create_port(switch_id, port_name,
port_vlan_id, port_vlan_id)
- logging.debug(' access port, VLAN %d' % int(port_vlans[port_name][0]))
+ logging.debug(' access port, VLAN %d', int(port_vlans[port_name][0]))
# Nothing further needed
elif port_mode == 'trunk':
logging.debug(' trunk port, VLANs:')
@@ -741,7 +741,7 @@ class VlanUtil:
else:
raise CriticalError("Unrecognised port port mode %s???" % port_mode)
- logging.debug(" Added port %s, got port ID %d" % (port_name, port_id))
+ logging.debug(" Added port %s, got port ID %d", port_name, port_id)
db.set_port_mode(port_id, port_mode)
@@ -749,7 +749,7 @@ class VlanUtil:
for vlan in db.all_vlans():
if vlan.tag is not state.config.vland.default_vlan_tag:
if not vlan.tag in vlan_tags:
- logging.debug("Adding VLAN tag %d to this switch" % (vlan.tag))
+ logging.debug("Adding VLAN tag %d to this switch", vlan.tag)
s.vlan_create(vlan.tag)
s.vlan_set_name(vlan.tag, vlan.name)
@@ -762,7 +762,7 @@ class VlanUtil:
for vlan in db.all_vlans():
if vlan.vlan_id is not state.default_vlan_id:
if not vlan.tag in port_vlans[port.name]:
- logging.debug("Adding allowed VLAN tag %d to trunk port %s" % (vlan.tag, port.name))
+ logging.debug("Adding allowed VLAN tag %d to trunk port %s", vlan.tag, port.name)
s.port_add_trunk_to_vlan(port.name, vlan.tag)
# Done with this switch \o/