2 # wrapper to xmlrpc server, that support dry-run commands
3 # we dont want to have to depend on PLCAPI, so:
6 server_methods = [ ('GetNodes' , []),
10 ('AddInterface' , True),
11 ('GetInterfaces' , True),
13 ('AddTagType' , True),
14 ('AddInterfaceSetting' , True),
15 ('GetBootMedium' , True),
16 ('GetNodeGroups' , True),
17 ('AddNodeGroup' , True),
18 ('DeleteNodeGroup', True),
19 ('GetNodeTags', True),
21 ('AddInitScript' , True),
22 ('DeleteInitScript', True),
23 ('GetInitScripts', True),
25 ('AddSiteAddress' , True),
26 ('DeleteSite' , True),
27 ('DeleteSlice' , True),
29 ('AddPersonToSlice' , True),
30 ('AddSliceToNodes' , True),
31 ('AddSliceAttribute' , True),
33 ('UpdatePerson' , True),
34 ('AddRoleToPerson' , True),
35 ('AddPersonToSite' , True),
36 ('DeletePerson' , True),
37 ('AddPersonKey' , True),
38 ('GetPlcRelease', {'build': {'target-arch':'i386'}}),
44 def __init__(self,server,dry_run,method,defaults):
48 self.defaults=defaults
49 def __call__ (self, *args):
51 print "dry_run:",self.method,
52 if len(args)>0 and type(args[0])==type({}) and args[0].has_key('AuthMethod'):
58 actual_method=getattr(self.server,self.method)
59 return actual_method(*args)
61 def __init__(self,url,dry_run=False):
62 self.apiserver = xmlrpclib.Server(url,allow_none=True)
64 for (method,defaults) in server_methods:
65 setattr(self,method,TestApiserver.Callable(self.apiserver,dry_run,method,defaults))