From: Planet-Lab Support Date: Tue, 24 Apr 2007 20:06:26 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create branch X-Git-Tag: planetlab-4_0-rc3~2 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=362b137903f44329029ebe2e29c4e70680ab8163 This commit was manufactured by cvs2svn to create branch 'planetlab-4_0-branch'. --- diff --git a/PLC/Methods/GetSlicesMD5.py b/PLC/Methods/GetSlicesMD5.py new file mode 100644 index 0000000..b7e4cde --- /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" +