aboutsummaryrefslogtreecommitdiff
path: root/util.py
AgeCommit message (Collapse)Author
2016-03-22Add better distinction of error casesSteve McIntyre
Add a new NotFoundError exception for use internally, so we can track specific failure cases. Also add a new Error class as a central place to store our error numbers consistently. In the API protocol, add a "NOTFOUND" error string alongside "ERROR" to help the admin interface and other callers distinguish error cases better. In the admin interface, actually return distinct non-zero errors in failure cases. Previously, almost all failures would have returned suceesfully to the calling shell. Change-Id: Ie382b737a80b7cd41c551e3a4a2a7e0827260bdc
2016-03-12Bugfix: s/if/elif/ typo in the middle of the db_update API handlerSteve McIntyre
Calls would have worked, but reported failure by falling through Change-Id: Ia262caf55ab121c1dd5ee4c4fc44e65ad2975a10
2016-03-12Start 0.6 development, and update boilerplateSteve McIntyre
Change-Id: Ie4c201b50803ef0e32cef19459088a215b95ed2d
2015-10-23Add a database last-modified-timeSteve McIntyre
Add a new table which will have one record, simply containing the last-modified-time of the database as a whole. Will be useful for caching in the visualisation layer. Create the table at startup in the main VLANd process if it doesn't exist, and create the record too. Add code to update the record on all other changes to the database. Add code to report it through the daemon.status() API call. Change-Id: I503c4371c04accb2c3f91adecc3e8a8a8614ea90
2015-10-19Update config handling for logging level, and add testSteve McIntyre
Set the default to CRITICAL only, to simplify code. Add check for the specified logging level, and a unit test for that. Change-Id: I3ffa467f001dfdfb840f312bf0df8265aac58299
2015-10-09More robust error handling and loggingSteve McIntyre
Catch and log InputError() Catch and log ValueError() and report back to the API user Change-Id: I1d7414baa4a84106439c37ad36be3578356a3371
2015-09-23Move common loglevel code into a new utility function set_logging_level()Steve McIntyre
Change-Id: I436319311192cc4ee8b29935b3acb69e0ba613e1
2015-09-18Fix format string errorSteve McIntyre
Change-Id: I2657a311d7ffe4e6e8110f60d3bc9b474672cd1a
2015-09-04Log when creating a VLAN failed, displaying the switch's errorSteve McIntyre
Change-Id: Ia2af415eaf5146d81f5b7158af2db3bd68b0ffd1
2015-09-04Correct log message when adding trunk ports to a new VLANSteve McIntyre
Change-Id: Ie7faefef06aa0cf02b125b9ea7019b9647c5a6dd
2015-09-03Compare the default_vlan_tag to vlan.tagSteve McIntyre
Previous fix was buggy and rushed. Change-Id: Ied61a46973135908e26ce8324c06a51fa64dcfa9
2015-09-03Bug fix when changing ports from access to trunk modeSteve McIntyre
Don't attempt to add the trunk to the default VLAN; it's already going to be there. Change-Id: Id06ddf000eae7d6e5f9725a251dd057a150f9ca6
2015-08-07Add trunks, simple containers to track inter-switch connectionsSteve McIntyre
To help with visualisation, add trunks - containers to describe inter-switch connections in the database. This entails: * a new table in the database called 'trunk' that contains nothing but creation time and the trunk_id field. * new trunk_id field in the port table, so that ports can either belong to one trunk or to trunk # -1 (aka none) Creating a trunk then entails: * Creating a new entry in the trunk table * Moving both ports to be attached to that trunk_id Also added helper functions and admin functions to match. Also plumbed through --lookup_ports_by_switch, --lookup_ports_by_current_vlan, --lookup_ports_by_base_vlan. Change-Id: I97f7aa9a14eecbfab9a57f5e776ad21c5944b369
2015-08-06In the backend for create_port, only allow numbersSteve McIntyre
Change-Id: Ie4d96828dfb2d6d09ce3123154cc586b6d15e97e
2015-08-05Add new methods to lookup ports by switch and port numberSteve McIntyre
Change-Id: I3464f1fad1bd3d5c421dfa2db69ddce3b95f2603
2015-08-05Add the new number field in the ports tableSteve McIntyre
Added in several places: * database creation code * port addition code Change-Id: Id4e2bd2704d5b9660df8baad34abda0f613ba4f2
2015-08-03If we're passed a VLAN tag of -1, find and allocate the first unusedSteve McIntyre
Change-Id: Ibabf1c88ec33aa382d3d35b5af468aeb3ee708a8
2015-07-27Misc small fixes after pylint checkingSteve McIntyre
Change-Id: I85c7d98b0b717163ddefea35a2a022ce7c9c1973
2015-07-24When importing a switch, handle extra port modes gracefullySteve McIntyre
If we find a switch reporting a port mode that's neither trunk nor access, don't bail out. Instead, configure the port to be "access" and treat it accordingly. For our purposes, access ports are much more common so that's why I've made this choice. Change-Id: I8ab275aa24889ce4e5bb4253370cb74317eebce1
2015-07-24More "is not" --> != fixesSteve McIntyre
Change-Id: I18331ce5ec118b3aa3dc9a040771350221217f45
2015-07-21Fix syntax for a del() callSteve McIntyre
Change-Id: I07f0020d9d66a2fe763fd17215c2f08d86e2ed65
2015-07-21Add logging in major failure paths in API callsSteve McIntyre
If we're at the point where we've found a major problem and think that we need to reset the switches, actually write an error message to the log first... Change-Id: I1eed6691dd4331c6ced95ace80ffbf4a4f938417
2015-07-17Fix daft logic bug with use of "is not"Steve McIntyre
Change-Id: I49ec436c97e09a72f820d6b46f1b7d9ee34d8a3e
2015-07-14Pass through the switch debug setting when starting up a switch driverSteve McIntyre
Change-Id: Ie6ed4574ca8cb534feb3943905ac4e446d5dc999
2015-07-09Fix major bug in util.set_port_mode()Steve McIntyre
Broken indentation -> broken behaviour. I hate python sometimes... Change-Id: I164fdc87a5a04a333dcdeee0dae53ae51699bd2e
2015-04-01Fix up huge numbers of pylint warningsSteve McIntyre
Change-Id: I9112ab123943a81e60d2c6bf096bc125e8e042b7
2015-02-13Add missing string parameters in error messageSteve McIntyre
Change-Id: Iada53658d4fc2b936da79ccae16d95b6b218e7f0
2015-02-13Check locking first on set_current_vlanSteve McIntyre
Change-Id: Ib431d4858c24e1cd90248b9afc1fd1ebb482828c
2015-02-13Check for locking on set_port_modeSteve McIntyre
Change-Id: I643aaf5f67ea0c85371d686cc8f703a5773efc7f
2015-02-12Debug cleanupsSteve McIntyre
Switch from print to logging.X() where sensible Change-Id: Ic691c64c581f6c20b7b8a1d46d25783782dd762e
2015-02-11Tweak debug outputSteve McIntyre
Change-Id: Ia8b80a40735404e076b912e0a68b0cd9dda988a3
2015-02-11Bugfix - track the right list of VLANs for the switchSteve McIntyre
Change-Id: Idf1207a4460b4cfb114d4ca811ecf43742c49a9a
2015-02-11Don't re-add VLANs to trunksSteve McIntyre
Save time and effort - keep track of the VLANs already set on a switch's trunk ports and don't try to add them again later. Change-Id: Ibeb76f568dac0b1a7eb67c1648cbd15e5680bf06
2015-02-11Remove debug messageSteve McIntyre
Change-Id: Idb2060dbd2829d6d399c1c1b45cf1641e1619eee
2015-02-09Add VLANs to new switches as needed on importSteve McIntyre
Change-Id: Idf4c5b51eee433f5af7721b5c63c4d4f0792983d
2015-02-09Bugfix: don't add a trunk port to a VLAN just before changing modeSteve McIntyre
Change-Id: I137a67cab9ffef7616af78e7c089398ddb94dbaa
2015-01-23Always set the correct mode on ports during switch importSteve McIntyre
Change-Id: I9cef69af28264d62b0c175e97cb76b769b343c1d
2015-01-23Don't attempt to remove the default VLAN from a trunk portSteve McIntyre
It won't work, and causes errors. Change-Id: Ie66630a825a247ecdd5f1620ce0be8fda3e2755e
2015-01-23Fix string comparisons on port modeSteve McIntyre
"is not" doesn't work here. :-( Change-Id: I6e9db2ab64a7b7468a705bc6a534a9ada209bd95
2015-01-23Expose db.get_vlan_id_by_tag and db.get_vlan_tag_by_id()Steve McIntyre
Change-Id: I3b48a4bbd33fe46dfebae9994ca1a1035edf7a3c
2015-01-23Add support for a shutdown call from the admin interfaceSteve McIntyre
Make sure we clean up properly and close connections. Change-Id: Iec3fede61615d4f9e4a5561006c182e7785c1977
2014-12-24Make sure we use vlan_ids, not tags, when adding new portsSteve McIntyre
Change-Id: If9c24c84fd8034fc7211717edeed4c4f2d9a9144
2014-12-23Add port names to probe_switches() outputSteve McIntyre
Change-Id: Ib1ff816ad5cbc6876e5dc500817444150d335bcd
2014-12-23Don't catch all the exceptions for now - debugging...Steve McIntyre
Change-Id: Ic98e802fae172d1af202e0e09f67c548cb307d6a
2014-12-23More tweaks to auto_import_switch() after testing:Steve McIntyre
More debug on the daemon side Cope with different VLAN setups for trunk ports We can't use set_port_mode() - add trunk ports by hand here Change-Id: Id8e001f5cf5f8a40cb4e4f88a9f1241aaf77f323
2014-12-23The detault VLAN will already exist, and will have a different nameSteve McIntyre
from switch to switch... Change-Id: I7df9c821b48bd71e9211cf3065b179b481486909
2014-12-23And return the probed dataSteve McIntyre
Change-Id: Id8930e6827dfd88a848e10c5c0507813f90e7660
2014-12-23Fix probe_switches()Steve McIntyre
Change-Id: I25953be83ede4e9edea7c5c97266420b965b10d9
2014-12-23Use the right variable name for switch_nameSteve McIntyre
Change-Id: I761f62cfc2b08ba348c76137a3f658121b115739
2014-12-23Make probe_switches() less verboseSteve McIntyre
Change-Id: I7c45429b08e26f8e1aaf55b5e2364be28b8f8b19