Tony Mack | f593dba | 2013-03-24 13:17:43 -0400 | [diff] [blame] | 1 | import xmlrpclib |
Tony Mack | 743ddf2 | 2013-04-02 07:36:25 -0400 | [diff] [blame^] | 2 | from plstackapi.importer.plclassic.role_importer import RoleImporter |
| 3 | from plstackapi.importer.plclassic.site_importer import SiteImporter |
| 4 | from plstackapi.importer.plclassic.user_importer import UserImporter |
| 5 | from plstackapi.importer.plclassic.slice_importer import SliceImporter |
| 6 | from plstackapi.importer.plclassic.sliver_importer import SliverImporter |
Tony Mack | f593dba | 2013-03-24 13:17:43 -0400 | [diff] [blame] | 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): |
Tony Mack | 8eeddf9 | 2013-03-26 13:42:59 -0400 | [diff] [blame] | 20 | self.auth = {'AuthMethod': 'password', |
| 21 | 'Username': None, |
| 22 | 'AuthString': None} |
Tony Mack | f593dba | 2013-03-24 13:17:43 -0400 | [diff] [blame] | 23 | self.server = xmlrpclib.ServerProxy("URL", allow_none=True) |
| 24 | |
| 25 | def __getattr__(self, name): |
| 26 | return Call(getattr(self.server, name), self.auth) |
| 27 | |
| 28 | class Importer: |
| 29 | |
| 30 | def __init__(self): |
Tony Mack | 743ddf2 | 2013-04-02 07:36:25 -0400 | [diff] [blame^] | 31 | api = API() |
| 32 | self.roles = RoleImporter(api) |
| 33 | self.sites = SiteImporter(api) |
| 34 | self.slices = SliceImporter(api, remote_sites=self.sites.remote_sites, local_sites=self.sites.local_sites) |
| 35 | self.users = UserImporter(api) |
| 36 | self.slivers = SliverImporter(api) |
Tony Mack | f593dba | 2013-03-24 13:17:43 -0400 | [diff] [blame] | 37 | |
| 38 | def run(self): |
| 39 | self.roles.run() |
| 40 | self.sites.run() |
| 41 | self.users.run() |
| 42 | self.slices.run() |
| 43 | self.slivers.run() |
| 44 | |
| 45 | |