1 # Thierry Parmentelat <thierry.parmentelat@inria.fr>
2 # Copyright (C) 2010 INRIA
4 # wrapper to xmlrpc server, that support dry-run commands
5 # we dont want to have to depend on PLCAPI, so:
8 # the default value is for the dry run mode
9 server_methods = [ ('GetNodes' , []),
11 ('SetNodePlainBootstrapfs', True),
12 ('DeleteNode' , True),
13 ('UpdateNode' , True),
14 ('AddInterface' , True),
15 ('AddIpAddress' , True),
17 ('GetInterfaces' , True),
19 ('AddTagType' , True),
20 ('AddInterfaceTag' , True),
21 ('GetBootMedium' , True),
22 ('GetNodeGroups' , True),
23 ('AddNodeGroup' , True),
24 ('DeleteNodeGroup', True),
25 ('GetNodeTags', True),
27 ('AddInitScript' , True),
28 ('DeleteInitScript', True),
29 ('GetInitScripts', True),
31 ('AddSiteAddress' , True),
32 ('DeleteSite' , True),
33 ('DeleteSlice' , True),
35 ('AddPersonToSlice' , True),
36 ('AddSliceToNodes' , True),
37 ('DeleteSliceFromNodes' , True),
38 ('AddSliceTag' , True),
40 ('UpdatePerson' , True),
41 ('AddRoleToPerson' , True),
42 ('AddPersonToSite' , True),
43 ('DeletePerson' , True),
44 ('AddPersonKey' , True),
45 ('GetPlcRelease', {'build': {'target-arch':'i386'}}),
47 ('GetSlices', [{'name':'dry_run_slice','node_ids':['dry_run']}]),
48 ('GetLeaseGranularity', 180),
51 ('DeleteLeases',True),
52 ('AddConfFile','True'),
54 ('system.listMethods',[]),
59 def __init__(self,server,dry_run,method,defaults):
63 self.defaults=defaults
64 def __call__ (self, *args):
66 print "dry_run:",self.method,
67 if len(args)>0 and type(args[0])==type({}) and args[0].has_key('AuthMethod'):
73 actual_method=getattr(self.server,self.method)
74 return actual_method(*args)
76 def __init__(self,url,dry_run=False):
77 self.apiserver = xmlrpclib.ServerProxy(url,allow_none=True)
79 for (method,defaults) in server_methods:
80 setattr(self,method,TestApiserver.Callable(self.apiserver,dry_run,method,defaults))
82 def set_dry_run (self, dry_run):
84 for (method,defaults) in server_methods:
85 getattr(self,method).dry_run = dry_run
87 def has_method (self, methodname):
88 return methodname in self.apiserver.system.listMethods()