aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2015-01-23 17:47:46 +0000
committerSteve McIntyre <steve.mcintyre@linaro.org>2015-01-23 17:47:46 +0000
commit32e3a897c0e6d3b8449a5cd973c6395557926bb1 (patch)
tree4ae215afac35509b063372dc68fc2208b569f7e2 /db
parenta4bb99145d8ec2b6ef676185580bd650390be94b (diff)
Liberally add int() to force arguments to be ints
Found a horrid bug where python caching would cause code to wrongly remember the wrong type for arguments coming through. Make sure that can't happen here. Change-Id: If8d366a6655e212f3cd4356857051c6b7f6cc091
Diffstat (limited to 'db')
-rw-r--r--db/db.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/db/db.py b/db/db.py
index 5d9865b..d944f0e 100644
--- a/db/db.py
+++ b/db/db.py
@@ -307,7 +307,7 @@ class VlanDB:
#
# Returns None on failure.
def get_switch_by_id(self, switch_id):
- return self._get_row("switch", "switch_id", switch_id)
+ return self._get_row("switch", "switch_id", int(switch_id))
# Simple lookup: look up a switch by name, and return the ID of
# that switch.
@@ -321,70 +321,71 @@ class VlanDB:
#
# Returns None on failure.
def get_switch_name_by_id(self, switch_id):
- return self._get_element("name", "switch", "switch_id", switch_id)
+ return self._get_element("name", "switch", "switch_id", int(switch_id))
# Simple lookup: look up a port by ID, and return all the details
# of that port.
#
# Returns None on failure.
def get_port_by_id(self, port_id):
- return self._get_row("port", "port_id", port_id)
+ return self._get_row("port", "port_id", int(port_id))
# Simple lookup: look up a switch by ID, and return the IDs of all
# the ports on that switch.
#
# Returns None on failure.
def get_ports_by_switch(self, switch_id):
- return self._get_multi_elements("port_id", "port", "switch_id", switch_id)
+ return self._get_multi_elements("port_id", "port", "switch_id", int(switch_id))
# More complex lookup: look up all the trunk ports on a switch by
# ID
#
# Returns None on failure.
def get_trunk_port_names_by_switch(self, switch_id):
- return self._get_multi_elements2("name", "port", "switch_id", switch_id, "is_trunk", True)
+ return self._get_multi_elements2("name", "port", "switch_id", int(switch_id), "is_trunk", True)
# Simple lookup: look up a port by its name and its parent switch
# by ID, and return the ID of the port.
#
# Returns None on failure.
def get_port_by_switch_and_name(self, switch_id, name):
- return self._get_element2("port_id", "port", "switch_id", switch_id, "name", name)
+ print "Looking for switch_id %s and name %s" % (switch_id, name)
+ return self._get_element2("port_id", "port", "switch_id", int(switch_id), "name", name)
# Simple lookup: look up a port by ID, and return the current VLAN
# id of that port.
#
# Returns None on failure.
def get_current_vlan_id_by_port(self, port_id):
- return self._get_element("current_vlan_id", "port", "port_id", port_id)
+ return self._get_element("current_vlan_id", "port", "port_id", int(port_id))
# Simple lookup: look up a port by ID, and return the base VLAN
# id of that port.
#
# Returns None on failure.
def get_base_vlan_id_by_port(self, port_id):
- return self._get_element("base_vlan_id", "port", "port_id", port_id)
+ return self._get_element("base_vlan_id", "port", "port_id", int(port_id))
# Simple lookup: look up a current VLAN by ID, and return the IDs
# of all the ports on that VLAN.
#
# Returns None on failure.
def get_ports_by_current_vlan(self, vlan_id):
- return self._get_multi_elements("port_id", "port", "current_vlan_id", vlan_id)
+ return self._get_multi_elements("port_id", "port", "current_vlan_id", int(vlan_id))
# Simple lookup: look up a base VLAN by ID, and return the IDs
# of all the ports on that VLAN.
#
# Returns None on failure.
def get_ports_by_base_vlan(self, vlan_id):
- return self._get_multi_elements("port_id", "port", "base_vlan_id", vlan_id)
+ return self._get_multi_elements("port_id", "port", "base_vlan_id", int(vlan_id))
# Simple lookup: look up a VLAN by ID, and return all the details
# of that VLAN.
#
# Returns None on failure.
def get_vlan_by_id(self, vlan_id):
- return self._get_row("vlan", "vlan_id", vlan_id)
+ return self._get_row("vlan", "vlan_id", int(vlan_id))
# Simple lookup: look up a VLAN by name, and return the ID of that
# VLAN.
@@ -398,21 +399,21 @@ class VlanDB:
#
# Returns None on failure.
def get_vlan_id_by_tag(self, tag):
- return self._get_element("vlan_id", "vlan", "tag", tag)
+ return self._get_element("vlan_id", "vlan", "tag", int(tag))
# Simple lookup: look up a VLAN by ID, and return the name of that
# VLAN.
#
# Returns None on failure.
def get_vlan_name_by_id(self, vlan_id):
- return self._get_element("name", "vlan", "vlan_id", vlan_id)
+ return self._get_element("name", "vlan", "vlan_id", int(vlan_id))
# Simple lookup: look up a VLAN by ID, and return the tag of that
# VLAN.
#
# Returns None on failure.
def get_vlan_tag_by_id(self, vlan_id):
- return self._get_element("tag", "vlan", "vlan_id", vlan_id)
+ return self._get_element("tag", "vlan", "vlan_id", int(vlan_id))
# Grab one row of a query on one column; useful as a quick wrapper
def _get_row(self, table, field, value):