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:
        print("Need to create forest: {0}".format(name))
        f = Forest(name)
        f.create(conn)

# Update forests
for config in data['forests']:
    name = config['forest-name']
    f = Forest.unmarshal(config)
    print("Updating forest: {0}".format(name))
    f.update(conn)

# Create databases
for config in data['databases']:
    name = config['database-name']
    def close(self, conn, group='Default'):
        closed = False
        while not closed:
            closed = True

            newitems = []
            for key in self.servers:
                item = self.servers[key]
                if item is None:
                    closed = False
                    newitems.append(Server.lookup(conn, key, group))

            for server in newitems:
                self._close_over_server(server)

            newitems = []
            for key in self.databases:
                item = self.databases[key]
                if item is None:
                    closed = False
                    newitems.append(Database.lookup(conn, key))

            for database in newitems:
                self._close_over_database(database)

            newitems = []
            for key in self.forests:
                item = self.forests[key]
                if item is None:
                    closed = False
                    newitems.append(Forest.lookup(conn, key))

            for forest in newitems:
                self._close_over_forest(forest)

            newitems = []
            for key in self.users:
                item = self.users[key]
                if item is None:
                    closed = False
                    newitems.append(User.lookup(conn, key))

            for user in newitems:
                self._close_over_user(user)

            newitems = []
            for key in self.roles:
                item = self.roles[key]
                if item is None:
                    closed = False
                    newitems.append(Role.lookup(conn, key))

            for role in newitems:
                self._close_over_role(role)

            delitems = []
            newitems = []
            for key in self.privileges:
                item = self.privileges[key]
                parts = key.split("|")
                kind = parts[0]
                name = parts[1]
                if isinstance(item, str):
                    closed = False
                    if "//" in key:
                        # Assume it's an action
                        priv = Privilege.lookup(conn, action=name, kind=kind)
                        delitems.append(key)
                    else:
                        priv = Privilege.lookup(conn, name, kind)
                    newitems.append(priv)

            for item in delitems:
                del self.privileges[item]

            for priv in newitems:
                self._close_over_privilege(priv)