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