Tony Mack | f593dba | 2013-03-24 13:17:43 -0400 | [diff] [blame^] | 1 | import xmlrpclib |
| 2 | from importer.planetstack.role_importer import RoleImporter |
| 3 | from importer.planetstack.site_importer import SiteImporter |
| 4 | from importer.planetstack.user_importer import UserImporter |
| 5 | from importer.planetstack.slice_importer import SliceImporter |
| 6 | from importer.planetstack.sliver_importer import SliverImporter |
| 7 | |
| 8 | |
| 9 | class Call: |
| 10 | def __init__(self, callable, auth): |
| 11 | self.callable = callable |
| 12 | self.auth = auth |
| 13 | |
| 14 | def __call__(self, *args, **kwds): |
| 15 | a = [auth] + args |
| 16 | return self.callable(*a) |
| 17 | |
| 18 | class API(): |
| 19 | def __init__(self): |
| 20 | self.auth = {} |
| 21 | self.server = xmlrpclib.ServerProxy("URL", allow_none=True) |
| 22 | |
| 23 | def __getattr__(self, name): |
| 24 | return Call(getattr(self.server, name), self.auth) |
| 25 | |
| 26 | class Importer: |
| 27 | |
| 28 | def __init__(self): |
| 29 | self.api = API() |
| 30 | self.roles = RoleImporter(self) |
| 31 | self.sites = SiteImporter(self) |
| 32 | self.users = UserImporter(self) |
| 33 | self.slices = SliceImporter(self) |
| 34 | self.slivers = SliverImporter(self) |
| 35 | |
| 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 | |