svn kwds
[plcapi.git] / PLC / Methods / GetSlicesMD5.py
1 # $Id$
2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Auth import Auth
6
7 class GetSlicesMD5(Method):
8     """
9     Returns the current md5 hash of slices.xml file
10     (slices-0.5.xml.md5)
11     """
12
13     roles = ['admin', 'pi', 'user', 'tech', 'node']
14
15     accepts = [
16         Auth(),
17         ]
18
19     returns = Parameter(str, "MD5 hash of slices.xml")
20     
21
22     def call(self, auth):
23         try:
24             file_path = '/var/www/html/xml/slices-0.5.xml.md5'
25             slices_md5 = file(file_path).readline().strip()
26             if slices_md5 <> "":                    
27                 return slices_md5
28             raise PLCInvalidArgument, "File is empty"
29         except IOError:
30             raise PLCInvalidArgument, "No such file"
31