Beispiel #1
0
 def __call__(self, args, extra_args=None):
     repo = RepomanClient(config.host, config.port, config.proxy)
     try:
         repo.download_image(args.image, args.dest)
     except RepomanError, e:
         print e
         sys.exit(1)
Beispiel #2
0
 def __call__(self, args, extra_args=None):
     repo = RepomanClient(config.host, config.port, config.proxy)
     try:
         me = repo.whoami()
         print me.get('user_name')
     except RepomanError, e:
         print e
         sys.exit(1)
Beispiel #3
0
 def __call__(self, args, extra_args=None):
     repo = RepomanClient(config.host, config.port, config.proxy)
     try:
         group = repo.describe_group(args.group)
         display.describe_group(group, long=args.long)
     except RepomanError, e:
         print e
         sys.exit(1)
Beispiel #4
0
 def __call__(self, args, extra_args=None):
     repo = RepomanClient(config.host, config.port, config.proxy)
     try:
         image = repo.describe_image(args.image)
         display.describe_user(image, long=args.long)
     except RepomanError, e:
         print e
         sys.exit(1)
Beispiel #5
0
 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)
Beispiel #6
0
 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)
Beispiel #7
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger("DownloadImage")
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        try:
            repo.download_image(args.image, args.dest)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #8
0
    def __call__(self, args, extra_args=None):
        repo = RepomanClient(config.host, config.port, config.proxy)

        kwargs = {'name':args.new}
        try:
            repo.modify_image(args.old, **kwargs)
            print "[OK]     Renaming image."
        except RepomanError, e:
            print "[FAILED] Renaming image.\n\t-%s" % e
            sys.exit(1)
Beispiel #9
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('DownloadImage')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        try:
            repo.download_image(args.image, args.dest)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #10
0
 def __call__(self, args, extra_args=None):
     log = logging.getLogger('DescribeGroup')
     log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))
     
     repo = RepomanClient(config.host, config.port, config.proxy)
     try:
         group = repo.describe_group(args.group)
         display.describe_group(group, long=args.long)
     except RepomanError, e:
         print e
         sys.exit(1)
Beispiel #11
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('DescribeImage')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        try:
            image = repo.describe_image(args.image)
            display.describe_user(image, long=args.long)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #12
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('DescribeGroup')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        try:
            group = repo.describe_group(args.group)
            display.describe_group(group, long=args.long)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #13
0
 def __call__(self, args, extra_args=None):
     log = logging.getLogger('DescribeImage')
     log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))
 
     repo = RepomanClient(config.host, config.port, config.proxy)
     try:
         image = repo.describe_image(args.image)
         display.describe_user(image, long=args.long)
     except RepomanError, e:
         print e
         sys.exit(1)
Beispiel #14
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger("RemoveUserFromGroup")
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        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)
Beispiel #15
0
    def __call__(self, args, extra_args=None):
        repo = RepomanClient(config.host, config.port, config.proxy)
        if not args.force:
            if not yes_or_no():
                print "Aborting group deletion"
                return

        try:
            repo.remove_group(args.group)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #16
0
    def __call__(self, args, extra_args=None):
        repo = RepomanClient(config.host, config.port, config.proxy)
        if args.group:
            kwargs = {'group':args.group}
        else:
            kwargs = {}

        try:
            users = repo.list_users(**kwargs)
            display.display_user_list(users, long=args.long)
        except RepomanError, e:
            print e.message
            sys.exit(1)
Beispiel #17
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('UploadImage')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        try:
            #########################
            sign(args.file, args.sign)
            #########################
            repo.upload_image(args.image, args.file)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #18
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('RemoveUserFromGroup')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        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)
Beispiel #19
0
 def __call__(self, args, extra_args=None):
     log = logging.getLogger('RemovePermission')
     log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))
 
     repo = RepomanClient(config.host, config.port, config.proxy)
     for p in args.permissions:
         status = "Removing permission: '%s' from group: '%s'" % (p, args.group)
         try:
             log.debug(status)
             repo.remove_permission(args.group, p)
             print "[OK]     %s" % status
         except RepomanError, e:
             print "[FAILED] %s\n\t-%s" % (status, e)
Beispiel #20
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger("UploadImage")
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        try:
            #########################
            sign(args.file, args.sign)
            #########################
            repo.upload_image(args.image, args.file)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #21
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('Rename')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))
        
        repo = RepomanClient(config.host, config.port, config.proxy)

        kwargs = {'name':args.new}
        log.debug("kwargs: '%s'" % kwargs)
        try:
            repo.modify_image(args.old, **kwargs)
            print "[OK]     Renaming image."
        except RepomanError, e:
            print "[FAILED] Renaming image.\n\t-%s" % e
            sys.exit(1)
Beispiel #22
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('Rename')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)

        kwargs = {'name': args.new}
        log.debug("kwargs: '%s'" % kwargs)
        try:
            repo.modify_image(args.old, **kwargs)
            print "[OK]     Renaming image."
        except RepomanError, e:
            print "[FAILED] Renaming image.\n\t-%s" % e
            sys.exit(1)
Beispiel #23
0
    def __call__(self, args, extra_args=None):
        repo = RepomanClient(config.host, config.port, config.proxy)
        if not args.force:
            print ("WARNING:\n"
                    "\tdeleting an image cannot be undone.\n")
            if not yes_or_no():
                print "Aborting user deletion"
                return

        try:
            repo.remove_image(args.image)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #24
0
 def __call__(self, args, extra_args=None):
     repo = RepomanClient(config.host, config.port, config.proxy)
     if not args.force:
         print ("WARNING:\n"
                 "\tAll images owned by the user will be removed.\n"
                 "\tThis operation cannot be undone!")
         if not yes_or_no():
             print "Aborting user deletion"
             return
     try:
         repo.remove_user(args.user)
     except RepomanError, e:
         print e
         sys.exit(1)
Beispiel #25
0
    def __call__(self, args, extra_args=None):
        repo = RepomanClient(config.host, config.port, config.proxy)
        if args.all:
            kwargs = {'list_all':True}
        elif args.user:
            kwargs = {'user':args.user}
        else:
            kwargs = {}

        try:
            groups = repo.list_groups(**kwargs)
            display.display_group_list(groups, long=args.long)
        except RepomanError, e:
            print e.message
            sys.exit(1)
Beispiel #26
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('RemoveGroup')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))
    
        repo = RepomanClient(config.host, config.port, config.proxy)
        if not args.force:
            if not yes_or_no():
                print "Aborting group deletion"
                return

        try:
            repo.remove_group(args.group)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #27
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('RemoveGroup')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        if not args.force:
            if not yes_or_no():
                print "Aborting group deletion"
                return

        try:
            repo.remove_group(args.group)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #28
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('RemoveImage')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        if not args.force:
            print("WARNING:\n" "\tdeleting an image cannot be undone.\n")
            if not yes_or_no():
                print "Aborting user deletion"
                return

        try:
            repo.remove_image(args.image)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #29
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('UnshareImage')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        status = "Unshared image: '%s' with: '%s'"
        if args.user:
            func = repo.unshare_with_user
            kwargs = {'user': args.user}
            status = status % (args.image, args.user)
        elif args.group:
            func = repo.unshare_with_group
            kwargs = {'group': args.group}
            status = status % (args.image, args.group)
        else:
            kwargs = {}

        log.debug("kwargs: '%s'" % kwargs)

        try:
            func(args.image, **kwargs)
            print "[OK]     %s" % status
        except RepomanError, e:
            print "[FAILED] %s\n\t-%s" % (status, e)
            sys.exit(1)
Beispiel #30
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('RemoveUser')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        if not args.force:
            print(
                "WARNING:\n"
                "\tAll images owned by the user will be removed.\n"
                "\tThis operation cannot be undone!")
            if not yes_or_no():
                print "Aborting user deletion"
                return
        try:
            repo.remove_user(args.user)
        except RepomanError, e:
            print e
            sys.exit(1)
Beispiel #31
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('ListUsers')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        if args.group:
            kwargs = {'group': args.group}
        else:
            kwargs = {}

        log.debug("kwargs: '%s'" % kwargs)

        try:
            users = repo.list_users(**kwargs)
            display.display_user_list(users, long=args.long)
        except RepomanError, e:
            print e.message
            sys.exit(1)
Beispiel #32
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('ListUsers')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))
    
        repo = RepomanClient(config.host, config.port, config.proxy)
        if args.group:
            kwargs = {'group':args.group}
        else:
            kwargs = {}
            
        log.debug("kwargs: '%s'" % kwargs)

        try:
            users = repo.list_users(**kwargs)
            display.display_user_list(users, long=args.long)
        except RepomanError, e:
            print e.message
            sys.exit(1)
Beispiel #33
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('ModifyImage')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        if extra_args:
            try:
                kwargs = parse_unknown_args(extra_args)
            except ArgumentFormatError, e:
                print e.message
                sys.exit(1)
Beispiel #34
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('ListGroups')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))
    
        repo = RepomanClient(config.host, config.port, config.proxy)
        if args.all:
            kwargs = {'list_all':True}
        elif args.user:
            kwargs = {'user':args.user}
        else:
            kwargs = {}

        log.debug("kwargs: '%s'" % kwargs)

        try:
            groups = repo.list_groups(**kwargs)
            display.display_group_list(groups, long=args.long)
        except RepomanError, e:
            print e.message
            sys.exit(1)
Beispiel #35
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('ListGroups')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        repo = RepomanClient(config.host, config.port, config.proxy)
        if args.all:
            kwargs = {'list_all': True}
        elif args.user:
            kwargs = {'user': args.user}
        else:
            kwargs = {}

        log.debug("kwargs: '%s'" % kwargs)

        try:
            groups = repo.list_groups(**kwargs)
            display.display_group_list(groups, long=args.long)
        except RepomanError, e:
            print e.message
            sys.exit(1)
Beispiel #36
0
    def __call__(self, args, extra_args=None):
        #TODO: impliment sharedwith calls
        repo = RepomanClient(config.host, config.port, config.proxy)
        if args.all:
            kwargs = {'list_all':True}
        elif args.group and not args.user:
            kwargs = {'group':args.group}
        elif args.user and not args.group:
            if args.sharedwith:
                pass
            else:
                kwargs = {'user':args.user}
        else:
            if args.sharedwith:
                pass
            else:
                kwargs = {}

        try:
            images = repo.list_images(**kwargs)
            display.display_image_list(images, long=args.long)
        except RepomanError, e:
            print e.message
            sys.exit(1)
Beispiel #37
0
    def get_repoman_client(self, server_string=None):
        user_proxy = cherrypy.request.wsgi_environ['X509_USER_PROXY']
        # Check to make sure proxy is RFC 3820 compliant.
        cmd = [app_config.get_grid_proxy_info_command(), '-f', user_proxy]
        cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
        if cmd_output.find('RFC 3820 compliant') == -1:
            # Non RFC 3820 compilant proxy detected... throw an exception
            raise InvalidUserProxy(
                'You are using a non RFC 3820 proxy.  The repoman server currently only accepts RFC 3820 compliant impersonation proxies.<p>To correct this problem, first replace your user proxy in the MyProxy server with a RFC 3820 compliant proxy and then click <a href="/webui/delete_cached_user_proxy">here</a> to clear the cached user proxy.</p>'
            )

        server = app_config.get_repoman_server()
        port = 443
        fields = []
        if server_string != None:
            fields = server_string.split(':')
        if len(fields) > 1 and fields[1].isdigit():
            port = int(fields[1])
        elif len(fields) == 1:
            server = fields[0]
        return RepomanClient(host=server, port=port, proxy=user_proxy)
Beispiel #38
0
    def __call__(self, args, extra_args=None):
        log = logging.getLogger('ListImages')
        log.debug("args: '%s' extra_args: '%s'" % (args, extra_args))

        #TODO: impliment sharedwith calls
        repo = RepomanClient(config.host, config.port, config.proxy)
        if args.all:
            func = repo.list_all_images
            kwargs = {}
        elif args.group and not args.user:
            func = repo.list_images_shared_with_group
            kwargs = {'group': args.group}
        elif args.user and not args.group:
            if args.sharedwith:
                func = repo.list_images_shared_with_user
                kwargs = {'user': args.user}
            else:
                func = repo.list_user_images
                kwargs = {'user': args.user}
        else:
            if args.sharedwith:
                # shared with you
                func = repo.list_images_shared_with_user
                kwargs = {}
            else:
                func = repo.list_current_user_images
                kwargs = {}

        log.debug("function: '%s'" % func)
        log.debug("kwargs: '%s'" % kwargs)

        try:
            images = func(**kwargs)
            display.display_image_list(images, long=args.long)
        except RepomanError, e:
            print e.message
            sys.exit(1)
Beispiel #39
0
 def __call__(self, args, extra_args=None):
     repo = RepomanClient(config.host, config.port, config.proxy)
     me = repo.whoami()
     display.display_user(me)