blob: 4ec2f1e183e1080a93b03071ffff11b43ce6f027 [file] [log] [blame]
Tony Mackf593dba2013-03-24 13:17:43 -04001import xmlrpclib
Tony Mack743ddf22013-04-02 07:36:25 -04002from plstackapi.importer.plclassic.site_importer import SiteImporter
3from plstackapi.importer.plclassic.user_importer import UserImporter
4from plstackapi.importer.plclassic.slice_importer import SliceImporter
5from plstackapi.importer.plclassic.sliver_importer import SliverImporter
Tony Mackf593dba2013-03-24 13:17:43 -04006
7
8class Call:
9 def __init__(self, callable, auth):
10 self.callable = callable
11 self.auth = auth
12
13 def __call__(self, *args, **kwds):
14 a = [auth] + args
15 return self.callable(*a)
16
17class API():
18 def __init__(self):
Tony Mack8eeddf92013-03-26 13:42:59 -040019 self.auth = {'AuthMethod': 'password',
20 'Username': None,
21 'AuthString': None}
Tony Mackf593dba2013-03-24 13:17:43 -040022 self.server = xmlrpclib.ServerProxy("URL", allow_none=True)
23
24 def __getattr__(self, name):
25 return Call(getattr(self.server, name), self.auth)
26
27class Importer:
28
29 def __init__(self):
Tony Mack743ddf22013-04-02 07:36:25 -040030 api = API()
Tony Mack743ddf22013-04-02 07:36:25 -040031 self.sites = SiteImporter(api)
32 self.slices = SliceImporter(api, remote_sites=self.sites.remote_sites, local_sites=self.sites.local_sites)
33 self.users = UserImporter(api)
34 self.slivers = SliverImporter(api)
Tony Mackf593dba2013-03-24 13:17:43 -040035
36 def run(self):
37 self.roles.run()
38 self.sites.run()
39 self.users.run()
40 self.slices.run()
41 self.slivers.run()
42
43