def create(self, args, config, connection):
        name = args['name']
        password = args['password']

        if args['json'] is not None:
            user = self._read(name,
                              password,
                              args['json'],
                              connection=connection)
            name = user.user_name()
        else:
            user = User(name, password, connection=connection)

        if 'password' not in user._config:
            user._config['password'] = str(b2a_hqx(urandom(64)))

        if user.exists():
            print("Error: User already exists: {0}".format(args['name']))
            sys.exit(1)

        self.roles = []
        self._properties(user, args)
        if len(self.roles) > 0:
            user.set_role_names(self.roles)

        print("Create user {0}...".format(args['name']))
        user.create()
Exemple #2
0
    def modify(self, args, config, connection):
        user = User(args['name'], connection=connection)
        if not user.exists():
            print("Error: User does not exist: {0}".format(args['name']))
            sys.exit(1)

        if args['json'] is not None:
            user = self._read(args['name'], args['json'])

        self.roles = []
        self._properties(user, args)
        if len(self.roles) > 0:
            user.set_role_names(self.roles)

        print("Modify user {0}...".format(args['name']))
        user.update(connection)
Exemple #3
0
    def modify(self, args, config, connection):
        user = User(args['name'], connection=connection)
        if not user.exists():
            print("Error: User does not exist: {0}".format(args['name']))
            sys.exit(1)

        if args['json'] is not None:
            user = self._read(args['name'], args['json'])

        self.roles = []
        self._properties(user, args)
        if len(self.roles) > 0:
            user.set_role_names(self.roles)

        print("Modify user {0}...".format(args['name']))
        user.update(connection)
Exemple #4
0
    def create(self, args, config, connection):
        user = User(args['name'], args['password'], connection=connection)
        if user.exists():
            print("Error: User already exists: {0}".format(args['name']))
            sys.exit(1)

        if args['json'] is not None:
            user = self._read(args['name'], args['json'])

        self.roles = []
        self._properties(user, args)
        if len(self.roles) > 0:
            user.set_role_names(self.roles)

        print("Create user {0}...".format(args['name']))
        user.create()
Exemple #5
0
    def create(self, args, config, connection):
        user = User(args['name'], args['password'], connection=connection)
        if user.exists():
            print("Error: User already exists: {0}".format(args['name']))
            sys.exit(1)

        if args['json'] is not None:
            user = self._read(args['name'], args['json'])

        self.roles = []
        self._properties(user, args)
        if len(self.roles) > 0:
            user.set_role_names(self.roles)

        print("Create user {0}...".format(args['name']))
        user.create()