Skip to content

Commit

Permalink
add/remove permissions from groups
Browse files Browse the repository at this point in the history
  • Loading branch information
mvliet committed Jan 25, 2011
1 parent 1e89410 commit 483f4c2
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions repoman-client/repoman_client/subcommands/permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from repoman_client.subcommand import SubCommand
from repoman_client.client import RepomanClient, RepomanError
from repoman_client.config import config
from repoman_client.subcommand import SubCommand
from argparse import ArgumentParser

class AddPermission(SubCommand):
command_group = 'advanced'
command = 'add-permissions'
alias = None
description = 'Add permissions to groups'

def get_parser(self):
p = ArgumentParser(self.description)
p.add_argument('group', help='group to add permissions to')
p.add_argument('-p', '--permissions', nargs='+', metavar='PERMISSION',
help='List of permissions to add')
return p

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


class RemovePermission(SubCommand):
command_group = 'advanced'
command = 'remove-permissions'
alias = None
description = 'Remove specified permissions from group'

def get_parser(self):
p = ArgumentParser(self.description)
p.add_argument('group', help='group to remove permissions from')
p.add_argument('-p', '--permissions', nargs='+', metavar='PERMISSION',
help='List of permissions to remove')
return p

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

0 comments on commit 483f4c2

Please sign in to comment.