From 192d89b4e42426ab81dc2da215390de168746d18 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Tue, 24 Apr 2007 20:06:25 +0000 Subject: [PATCH] - Returns the current md5 hash of slices.xml file (slices-0.5.xml.md5) --- PLC/Methods/GetSlicesMD5.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 PLC/Methods/GetSlicesMD5.py diff --git a/PLC/Methods/GetSlicesMD5.py b/PLC/Methods/GetSlicesMD5.py new file mode 100644 index 00000000..b7e4cde8 --- /dev/null +++ b/PLC/Methods/GetSlicesMD5.py @@ -0,0 +1,30 @@ +from PLC.Faults import * +from PLC.Method import Method +from PLC.Parameter import Parameter, Mixed +from PLC.Auth import Auth + +class GetSlicesMD5(Method): + """ + Returns the current md5 hash of slices.xml file + (slices-0.5.xml.md5) + """ + + roles = ['admin', 'pi', 'user', 'tech', 'node'] + + accepts = [ + Auth(), + ] + + returns = Parameter(str, "MD5 hash of slices.xml") + + + def call(self, auth): + try: + file_path = '/var/www/html/xml/slices-0.5.xml.md5' + slices_md5 = file(file_path).readline().strip() + if slices_md5 <> "": + return slices_md5 + raise PLCInvalidArgument, "File is empty" + except IOError: + raise PLCInvalidArgument, "No such file" + -- 2.47.0