diff options
author | Steve McIntyre <steve.mcintyre@linaro.org> | 2014-12-05 15:42:46 +0000 |
---|---|---|
committer | Steve McIntyre <steve.mcintyre@linaro.org> | 2014-12-05 15:42:46 +0000 |
commit | 549435fee6129d723374b3e0380acb041029130d (patch) | |
tree | 4423f6a31ac429e0a90fe8eddb30838035506a9a /db/db.py | |
parent | f36550682f4c13eb33b8fca83811c58bfe990152 (diff) |
Make the DB APi function names clearer
Change-Id: Ieed6cfbaa8dd0930f27b30d0043e400b8bed592c
Diffstat (limited to 'db/db.py')
-rw-r--r-- | db/db.py | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -42,7 +42,7 @@ class VlanDB: # Switches must be uniquely named def create_switch(self, name): - switch_id = self.get_switch_id(name) + switch_id = self.get_switch_id_by_name(name) if switch_id is not None: raise InputError("Switch name %s already exists" % name) @@ -72,12 +72,12 @@ class VlanDB: # 3. (Switch/name) must be unique def create_port(self, switch_id, name, current_vlan_id, base_vlan_id): - switch = self.get_switch(switch_id) + switch = self.get_switch_by_id(switch_id) if switch is None: raise InputError("Switch id %s does not exist" % switch_id) for vlan_id in (current_vlan_id, base_vlan_id): - vlan = self.get_vlan(vlan_id) + vlan = self.get_vlan_by_id(vlan_id) if vlan is None: raise InputError("VLAN id %s does not exist" % vlan_id) @@ -145,7 +145,7 @@ class VlanDB: # 2. The switch may not be referenced by any ports - # delete them first! def delete_switch(self, switch_id): - switch = self.get_switch(switch_id) + switch = self.get_switch_by_id(switch_id) if switch is None: raise InputError("Switch ID %s does not exist" % switch_id) ports = self.get_ports_by_switch(switch_id) @@ -161,7 +161,7 @@ class VlanDB: # 1. The port must exist # 2. The port must not be locked def delete_port(self, port_id): - port = self.get_port(port_id) + port = self.get_port_by_id(port_id) if port is None: raise InputError("Port ID %s does not exist" % port_id) if port.is_locked: @@ -175,7 +175,7 @@ class VlanDB: # 1. The VLAN # 2. The VLAN may not contain any ports - move or delete them first! def delete_vlan(self, vlan_id): - vlan = self.get_vlan(vlan_id) + vlan = self.get_vlan_by_id(vlan_id) if vlan is None: raise InputError("VLAN ID %s does not exist" % vlan_id) ports = self.get_ports_by_current_vlan(vlan_id) @@ -264,22 +264,22 @@ class VlanDB: else: return None - def get_switch(self, switch_id): + def get_switch_by_id(self, switch_id): return self._get_row("switch", "switch_id", switch_id) - def get_switch_id(self, name): + def get_switch_id_by_name(self, name): return self._get_element("switch_id", "switch", "name", name) - def get_switch_name(self, switch_id): + def get_switch_name_by_id(self, switch_id): return self._get_element("name", "switch", "switch_id", switch_id) - def get_port(self, port_id): + def get_port_by_id(self, port_id): return self._get_row("port", "port_id", port_id) - def get_port_id(self, name): + def get_port_id_by_name(self, name): return self._get_element("port_id", "port", "name", name) - def get_port_name(self, port_id): + def get_port_name_by_id(self, port_id): return self._get_element("port_name", "port", "port_id", port_id) def get_ports_by_switch(self, switch_id): @@ -294,7 +294,7 @@ class VlanDB: def get_ports_by_base_vlan(self, vlan_id): return self._get_multi_elements("port_id", "port", "base_vlan_id", vlan_id) - def get_vlan(self, vlan_id): + def get_vlan_by_id(self, vlan_id): return self._get_row("vlan", "vlan_id", vlan_id) def get_vlan_id_by_name(self, name): @@ -303,7 +303,7 @@ class VlanDB: def get_vlan_id_by_tag(self, tag): return self._get_element("vlan_id", "vlan", "tag", tag) - def get_vlan_name(self, vlan_id): + def get_vlan_name_by_id(self, vlan_id): return self._get_element("vlan_name", "vlan", "vlan_id", vlan_id) def _get_row(self, table, field, value): @@ -342,14 +342,14 @@ class VlanDB: return port_id def set_vlan(self, port_id, vlan_id): - port = self.get_port(port_id) + port = self.get_port_by_id(port_id) if port == None: raise("Port %s does not exist" % port_id) if port["is_trunk"] or port["is_locked"]: raise CriticalError("The port is locked") - vlan = self.get_vlan(vlan_id) + vlan = self.get_vlan_by_id(vlan_id) if vlan == None: raise CriticalError("VLAN %s does not exist" % vlan_id) @@ -362,7 +362,7 @@ class VlanDB: raise def restore_default_vlan(self, port_id): - port = self.get_port(port_id) + port = self.get_port_by_id(port_id) if port == None: raise CriticalError("Port %s does not exist") |