Skip to content

Commit

Permalink
adding and removing users from groups
Browse files Browse the repository at this point in the history
  • Loading branch information
mvliet committed Jan 25, 2011
1 parent 89d3051 commit bdeb8fb
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions repoman-client/repoman_client/subcommands/group_membership.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from repoman_client.subcommand import SubCommand
from repoman_client.client import RepomanClient, RepomanError
from repoman_client.config import config
from argparse import ArgumentParser


class AddUser(SubCommand):
command_group = 'advanced'
command = 'add-users-to-group'
alias = None
description = 'Add make specifed users members of a group'

def get_parser(self):
p = ArgumentParser(self.description)
p.add_argument('group', help='group to add users to')
p.add_argument('-u', '--users', nargs='+', metavar='USER', help='users to add')
return p

def __call__(self, args, extra_args=None):
repo = RepomanClient(config.host, config.port, config.proxy)
for user in args.users:
status = "Adding user: `%s` to group: '%s'\t\t" % (user, args.group)
try:
repo.add_user_to_group(user, args.group)
print '[OK] %s' % status
except RepomanError, e:
print '[FAILED] %s\n\t-%s' % (status, e.message)



class RemoveUser(SubCommand):
command_group = 'advanced'
command = 'remove-users-from-group'
alias = None
description = 'Remove specifed users from group'

def get_parser(self):
p = ArgumentParser(self.description)
p.add_argument('group', help='group to add users to')
p.add_argument('-u', '--users', nargs='+', metavar='USER', help='users to add')
return p

def __call__(self, args, extra_args=None):
repo = RepomanClient(config.host, config.port, config.proxy)
for user in args.users:
status = "Removing user: `%s` from group: '%s'\t\t" % (user, args.group)
try:
repo.remove_user_from_group(user, args.group)
print '[OK] %s' % status
except RepomanError, e:
print '[FAILED] %s\n\t-%s' % (status, e.message)

0 comments on commit bdeb8fb

Please sign in to comment.