def _read(self,
              name,
              password,
              jsonfile,
              connection=None,
              save_connection=True):
        jf = open(jsonfile).read()
        data = json.loads(jf)

        if name is not None:
            data['user-name'] = name
        if password is not None:
            data['password'] = password

        user = User.unmarshal(data,
                              connection=connection,
                              save_connection=save_connection)
        return user
Пример #2
0
 def _read(self, name, jsonfile):
     jf = open(jsonfile).read()
     data = json.loads(jf)
     data['user-name'] = name
     user = User.unmarshal(data)
     return user
        priv = Privilege.unmarshal(config)
        print("{0} privilege: {1}".format(verb, name))
        priv.create(conn)
    else:
        verb = "Updating"
        priv = Privilege.unmarshal(config)
        print("{0} {1} privilege: {2}".format(verb, kind, name))
        priv.update(conn)

# Update users
for config in data['users']:
    name = config['user-name']
    user = User.lookup(conn, name)
    if user is None:
        verb = "Creating"
        user = User.unmarshal(config)
        # Must assign some sort of password
        user.set_password(base64.urlsafe_b64encode(os.urandom(32)).decode('utf-8'))
        print("{0} user: {1}".format(verb, name))
        user.create(conn)
    else:
        verb = "Updating"
        user = User.unmarshal(config)
        print("{0} user: {1}".format(verb, name))
        user.update(conn)

# Create forests
for config in data['forests']:
    name = config['forest-name']
    f = Forest.lookup(conn, name)
    if f is None:
Пример #4
0
 def _read(self, name, jsonfile):
     jf = open(jsonfile).read()
     data = json.loads(jf)
     data['user-name'] = name
     user = User.unmarshal(data)
     return user