示例#1
0
 def __init__(self, user):
     self.user = dict()
     # Data representation is not the same depending on API calls
     for k, v in user.items():
         if k == 'enable':
             self.user['enabled'] = proxmox_to_ansible_bool(user['enable'])
         elif k == 'userid':
             self.user['user'] = user['userid'].split('@')[0]
             self.user['domain'] = user['userid'].split('@')[1]
             self.user[k] = v
         elif k in ['groups', 'tokens'] and (v == '' or v is None):
             self.user[k] = []
         elif k == 'groups' and type(v) == str:
             self.user['groups'] = v.split(',')
         elif k == 'tokens' and type(v) == list:
             for token in v:
                 if 'privsep' in token:
                     token['privsep'] = proxmox_to_ansible_bool(
                         token['privsep'])
             self.user['tokens'] = v
         elif k == 'tokens' and type(v) == dict:
             self.user['tokens'] = list()
             for tokenid, tokenvalues in v.items():
                 t = tokenvalues
                 t['tokenid'] = tokenid
                 if 'privsep' in tokenvalues:
                     t['privsep'] = proxmox_to_ansible_bool(
                         tokenvalues['privsep'])
                 self.user['tokens'].append(t)
         else:
             self.user[k] = v
 def __init__(self, storage):
     self.storage = storage
     # Convert proxmox representation of lists, dicts and boolean for easier
     # manipulation within ansible.
     if 'shared' in self.storage:
         self.storage['shared'] = proxmox_to_ansible_bool(self.storage['shared'])
     if 'content' in self.storage:
         self.storage['content'] = self.storage['content'].split(',')
     if 'nodes' in self.storage:
         self.storage['nodes'] = self.storage['nodes'].split(',')
     if 'prune-backups' in storage:
         options = storage['prune-backups'].split(',')
         self.storage['prune-backups'] = dict()
         for option in options:
             k, v = option.split('=')
             self.storage['prune-backups'][k] = v