summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2017-09-21 00:49:12 +0200
committerDaniil Baturin <daniil@baturin.org>2017-09-21 00:49:12 +0200
commit33c14bfb16a18f9dd44e8c0616d23ebce6114a7e (patch)
tree76526352cc038bd420733f3efdbd483d4aeeb747 /python
parent787825aecf4a1ebc92835a1f4a7fc953510580fc (diff)
downloadvyos-1x-33c14bfb16a18f9dd44e8c0616d23ebce6114a7e.tar.gz
vyos-1x-33c14bfb16a18f9dd44e8c0616d23ebce6114a7e.zip
T401: add functions for reading VyOS version data.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/util.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index a1a835de6..b3eff3965 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -17,6 +17,21 @@
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+import json
class ConfigError(Exception):
pass
+
+
+def get_version_data(file='/opt/vyatta/etc/version.json'):
+ with open(file, 'r') as f:
+ version_data = json.load(f)
+ return version_data
+
+def get_version(file=None):
+ version_data = None
+ if file:
+ version_data = get_version_data(file=file)
+ else:
+ version_data = get_version_data()
+ return version_data["version"]