コード例 #1
0
def removeOldImages(user):
    """
  Remove images that are installed, but are not associated with any subusers.

 >>> remove_old_images = __import__("remove-old-images")#import self
 >>> import subuserlib.classes.user,subuserlib.subuser
 >>> user = subuserlib.classes.user.User()
 >>> user.getRegistry().getSubusers().keys()
 [u'foo']
 >>> subuserlib.subuser.add(user,"bar","bar@file:///home/travis/remote-test-repo")
 Adding new temporary repository file:///home/travis/remote-test-repo
 Adding subuser bar bar@file:///home/travis/remote-test-repo
 Verifying subuser configuration.
 Verifying registry consistency...
 Unregistering any non-existant installed images.
 Checking if images need to be updated or installed...
 Installing bar ...
 Installed new image for subuser bar
 Running garbage collector on temporary repositories...
 >>> user.getRegistry().getSubusers().keys()
 [u'foo', 'bar']
 >>> [i.getImageSourceName() for i in user.getInstalledImages().values()]
 [u'foo', u'bar']
 >>> subuserlib.subuser.remove(user,"bar")
 Removing subuser bar
  If you wish to remove the subusers image, issue the command $ subuser remove-old-images
 Verifying subuser configuration.
 Verifying registry consistency...
 Unregistering any non-existant installed images.
 Checking if images need to be updated or installed...
 Running garbage collector on temporary repositories...
 >>> [i.getImageSourceName() for i in user.getInstalledImages().values()]
 [u'foo', u'bar']
 >>> remove_old_images.removeOldImages(user)
 Verifying subuser configuration.
 Verifying registry consistency...
 Unregistering any non-existant installed images.
 Checking if images need to be updated or installed...
 Running garbage collector on temporary repositories...
 Removing uneeded temporary repository: file:///home/travis/remote-test-repo
 >>> [i.getImageSourceName() for i in user.getInstalledImages().values()]
 [u'foo']
  """
    for installedImageId, installedImage in user.getInstalledImages(
    ).iteritems():
        imageInUse = False
        for _, subuser in user.getRegistry().getSubusers().iteritems():
            if subuser.getImageId() == installedImageId:
                imageInUse = True
        if not imageInUse:
            installedImage.removeDockerImage()
    subuserlib.verify.verify(user)
    user.getRegistry().commit()
コード例 #2
0
def removeOldImages(user):
  """
  Remove images that are installed, but are not associated with any subusers.

 >>> remove_old_images = __import__("remove-old-images")#import self
 >>> import subuserlib.classes.user,subuserlib.subuser
 >>> user = subuserlib.classes.user.User()
 >>> user.getRegistry().getSubusers().keys()
 [u'foo']
 >>> subuserlib.subuser.add(user,"bar","bar@file:///home/travis/remote-test-repo")
 Adding new temporary repository file:///home/travis/remote-test-repo
 Adding subuser bar bar@file:///home/travis/remote-test-repo
 Verifying subuser configuration.
 Verifying registry consistency...
 Unregistering any non-existant installed images.
 Checking if images need to be updated or installed...
 Installing bar ...
 Installed new image for subuser bar
 Running garbage collector on temporary repositories...
 >>> user.getRegistry().getSubusers().keys()
 [u'foo', 'bar']
 >>> [i.getImageSourceName() for i in user.getInstalledImages().values()]
 [u'foo', u'bar']
 >>> subuserlib.subuser.remove(user,"bar")
 Removing subuser bar
  If you wish to remove the subusers image, issue the command $ subuser remove-old-images
 Verifying subuser configuration.
 Verifying registry consistency...
 Unregistering any non-existant installed images.
 Checking if images need to be updated or installed...
 Running garbage collector on temporary repositories...
 >>> [i.getImageSourceName() for i in user.getInstalledImages().values()]
 [u'foo', u'bar']
 >>> remove_old_images.removeOldImages(user)
 Verifying subuser configuration.
 Verifying registry consistency...
 Unregistering any non-existant installed images.
 Checking if images need to be updated or installed...
 Running garbage collector on temporary repositories...
 Removing uneeded temporary repository: file:///home/travis/remote-test-repo
 >>> [i.getImageSourceName() for i in user.getInstalledImages().values()]
 [u'foo']
  """
  for installedImageId,installedImage in user.getInstalledImages().iteritems():
    imageInUse = False
    for _,subuser in user.getRegistry().getSubusers().iteritems():
      if subuser.getImageId() == installedImageId:
        imageInUse = True
    if not imageInUse:
      installedImage.removeDockerImage()
  subuserlib.verify.verify(user)
  user.getRegistry().commit()
コード例 #3
0
ファイル: list.py プロジェクト: EvgenyBahtin/subuser
def list(sysargs):
  """
  List various things: image sources, subusers, ect.

  >>> import sys
  >>> import list #import self

  Listing available images lists the images along with their default permissions.

  >>> list.list(["available"])
  Images available for instalation from the repo: default
  foo@default
   Description: 
   Maintainer: 
   Executable: /usr/bin/foo

  Similar result when listing subusers.

  >>> list.list(["subusers"])
  The following subusers are registered.
  Subuser: foo
  ------------------
  foo@default
   Description: 
   Maintainer: 
   Executable: /usr/bin/foo
  <BLANKLINE>

  And listing installed images:

  >>> list.list(["installed-images"])
  The following images are installed.
  ------------------
  Image Id: 2
  Image source: foo@default
  Last update time: 1

  > list.list(["repositories"])
  Repository: default
  ------------
  Cloned from: file:///home/travis/default-test-repo
  Currently at commit: 72e7d9c17192d47b2b2344d9eb8a325262d738fe

  In all cases, there is a ``--short`` option.

  >>> list.list(["subusers","--short"])
  foo

  >>> list.list(["available","--short"])
  foo@default

  >>> list.list(["installed-images","--short"])
  foo@default 2

  >>> list.list(["repositories","--short"])
  default

  """
  options,args = parseCliArgs(sysargs)
  if len(args)==0:
    sys.exit("Nothing to list. Issue this command with the -h argument for help.")
  user = subuserlib.classes.user.User()
  if 'available' in args:
    for repoName,repository in user.getRegistry().getRepositories().items():
      if not options.short:
        print("Images available for instalation from the repo: " + repoName)
      for _,imageSource in repository.items():
        if options.short:
          print(imageSource.getIdentifier())
        else:
          imageSource.describe()
  if 'subusers' in args:
    if not options.short:
      print("The following subusers are registered.")
    for name,subuser in user.getRegistry().getSubusers().items():
      if options.internal or not name.startswith("!"):
        if options.short:
          print(name)
        else:
          subuser.describe()
  if 'installed-images' in args:
    if not options.short:
      print("The following images are installed.")
    for id,installedImage in user.getInstalledImages().items():
      if options.short:
        try:
          identifier = installedImage.getImageSource().getIdentifier()
          if not options.broken:
            print(identifier+" "+id)
        except KeyError:
          if options.broken:
            print(id)
      else:
        print("------------------")
        installedImage.describe()
  if 'repositories' in args:
    for name,repo in user.getRegistry().getRepositories().items():
      if options.short:
        print(repo.getDisplayName())
      else:
        repo.describe()
        print("")
コード例 #4
0
ファイル: subuser-list.py プロジェクト: ruipgpinheiro/subuser
def list(sysargs):
  """
  List various things: image sources, subusers, ect.

  >>> import sys
  >>> list = __import__("subuser-list") #import self

  Listing available images lists the images along with their default permissions.

  >>> list.list(["available"])
  Images available for instalation from the repo: default
  foo@default
   Description: 
   Maintainer: 
   Executable: /usr/bin/foo

  Similar result when listing subusers.

  >>> list.list(["subusers"])
  The following subusers are registered.
  Subuser: foo
  ------------------
  foo@default
   Description: 
   Maintainer: 
   Executable: /usr/bin/foo
  <BLANKLINE>

  And listing installed images:

  >>> list.list(["installed-images"])
  The following images are installed.
  ------------------
  Image Id: 2
  Image source: foo@default
  Last update time: 1

  > list.list(["repositories"])
  Repository: default
  ------------
  Cloned from: file:///home/travis/default-test-repo
  Currently at commit: 72e7d9c17192d47b2b2344d9eb8a325262d738fe

  In all cases, there is a ``--short`` option.

  >>> list.list(["subusers","--short"])
  foo

  >>> list.list(["available","--short"])
  foo@default

  You can specify which repository to list image sources from.

  >>> list.list(["available","default","--short"])
  foo@default

  When listing available image sources, refering to a repository via a URI works as well.

  >>> list.list(["available","file:///home/travis/version-constrained-test-repo","--short"])
  Adding new temporary repository file:///home/travis/version-constrained-test-repo
  bop@file:///home/travis/version-constrained-test-repo

  >>> list.list(["installed-images","--short"])
  foo@default 2

  >>> list.list(["repositories","--short"])
  default

  """
  options,args = parseCliArgs(sysargs)
  if len(args)==0:
    sys.exit("Nothing to list. Issue this command with the -h argument for help.")
  user = subuserlib.classes.user.User()
  if args[0] == 'available':
    if len(args) > 1:
      reposToList = args[1:]
    else:
      reposToList = user.getRegistry().getRepositories().keys()
    if options.json:
      availableDict = {}
      for repoIdentifier in reposToList:
        if repoIdentifier in user.getRegistry().getRepositories():
          temp = False
        else:
          temp = True
        repository = subuserlib.resolve.resolveRepository(user,repoIdentifier)
        availableDict[repository.getName()] = repository.serializeToDict()
        if temp:
          repository.removeGitRepo()
      print(json.dumps(availableDict,indent=1,separators=(",",": ")))
      sys.exit()
    for repoIdentifier in reposToList:
      if repoIdentifier in user.getRegistry().getRepositories():
        temp = False
      else:
        temp = True
      repository =  subuserlib.resolve.resolveRepository(user,repoIdentifier)
      if not options.short:
        print("Images available for instalation from the repo: " + repository.getName())
      for _,imageSource in repository.items():
        if options.short:
          print(imageSource.getIdentifier())
        else:
          imageSource.describe()
      if temp:
        repository.removeGitRepo()
  elif args[0] == 'subusers':
    if options.json:
      print(json.dumps(user.getRegistry().getSubusers().serializeToDict(),indent=1,separators=(",",": ")))
      sys.exit()
    if not options.short:
      print("The following subusers are registered.")
    for name,subuser in user.getRegistry().getSubusers().items():
      if options.internal or not name.startswith("!"):
        if options.short:
          print(name)
        else:
          subuser.describe()
  elif args[0] == 'installed-images':
    if options.json:
      print(json.dumps(user.getInstalledImages().serializeToDict(),indent=1,separators=(",",": ")))
      sys.exit()
    if not options.short:
      print("The following images are installed.")
    for id,installedImage in user.getInstalledImages().items():
      if options.short:
        try:
          identifier = installedImage.getImageSource().getIdentifier()
          if not options.broken:
            print(identifier+" "+id)
        except KeyError:
          if options.broken:
            print(id)
      else:
        print("------------------")
        installedImage.describe()
  elif args[0] == 'repositories':
    if options.json:
      print(json.dumps(user.getRegistry().getRepositories().serializeToDict(),indent=1,separators=(",",": ")))
      sys.exit()
    for name,repo in user.getRegistry().getRepositories().items():
      if options.short:
        print(repo.getDisplayName())
      else:
        repo.describe()
        print("")
コード例 #5
0
def list(sysargs):
    """
  List various things: image sources, subusers, ect.

  >>> import sys
  >>> list = __import__("subuser-list") #import self

  Listing available images lists the images along with their default permissions.

  >>> list.list(["available"])
  foo@default

  Similar result when listing subusers.

  >>> list.list(["subusers"])
  foo

  And listing installed images:

  >>> list.list(["installed-images"])
  foo@default 2

  > list.list(["repositories"])
  foo

  In all cases, there is a ``--long`` option. (We don't test this, because the hash changes every time.)

  >> list.list(["repositories","--long"])
  Repository: default
  ------------
  Cloned from: file:///home/travis/default-test-repo
  Currently at commit: 7ef30a4e1267f9f026e3be064f120290c28ef29e
  <BLANKLINE>

  >>> list.list(["subusers","--long"])
  The following subusers are registered.
  Subuser: foo
  ------------------
  foo@default
   Description:
   Maintainer:
   Executable: /usr/bin/foo
  <BLANKLINE>

  >>> list.list(["available","--long"])
  Images available for instalation from the repo: default
  foo@default
   Description:
   Maintainer:
   Executable: /usr/bin/foo

  You can specify which repository to list image sources from.

  >>> list.list(["available","default","--long"])
  Images available for instalation from the repo: default
  foo@default
   Description:
   Maintainer:
   Executable: /usr/bin/foo

  When listing available image sources, refering to a repository via a URI works as well.

  >>> list.list(["available","file:///home/travis/version-constrained-test-repo"])
  Adding new temporary repository file:///home/travis/version-constrained-test-repo
  bop@file:///home/travis/version-constrained-test-repo

  >>> list.list(["installed-images"])
  foo@default 2

  >>> list.list(["repositories"])
  default

  """
    options, args = parseCliArgs(sysargs)
    if len(args) == 0:
        sys.exit(
            "Nothing to list. Issue this command with the -h argument for help."
        )
    user = subuserlib.classes.user.User()
    if args[0] == 'available':
        if len(args) > 1:
            reposToList = args[1:]
        else:
            reposToList = user.getRegistry().getRepositories().keys()
        if options.json:
            availableDict = {}
            for repoIdentifier in reposToList:
                if repoIdentifier in user.getRegistry().getRepositories():
                    temp = False
                else:
                    temp = True
                repository = subuserlib.resolve.resolveRepository(
                    user, repoIdentifier)
                availableDict[
                    repository.getName()] = repository.serializeToDict()
                if temp:
                    repository.removeGitRepo()
            print(json.dumps(availableDict, indent=1, separators=(",", ": ")))
            sys.exit()
        for repoIdentifier in reposToList:
            if repoIdentifier in user.getRegistry().getRepositories():
                temp = False
            else:
                temp = True
            repository = subuserlib.resolve.resolveRepository(
                user, repoIdentifier)
            if options.long:
                print("Images available for instalation from the repo: " +
                      repository.getName())
            for _, imageSource in repository.items():
                if not options.long:
                    print(imageSource.getIdentifier())
                else:
                    imageSource.describe()
            if temp:
                repository.removeGitRepo()
    elif args[0] == 'subusers':
        if options.json:
            print(
                json.dumps(user.getRegistry().getSubusers().serializeToDict(),
                           indent=1,
                           separators=(",", ": ")))
            sys.exit()
        if options.long:
            print("The following subusers are registered.")
        for name, subuser in user.getRegistry().getSubusers().items():
            if options.internal or not name.startswith("!"):
                if not options.long:
                    print(name)
                else:
                    subuser.describe()
    elif args[0] == 'installed-images':
        if options.json:
            print(
                json.dumps(user.getInstalledImages().serializeToDict(),
                           indent=1,
                           separators=(",", ": ")))
            sys.exit()
        if options.long:
            print("The following images are installed.")
        for id, installedImage in user.getInstalledImages().items():
            if not options.long:
                try:
                    identifier = installedImage.getImageSource().getIdentifier(
                    )
                    if not options.broken:
                        print(identifier + " " + id)
                except KeyError:
                    if options.broken:
                        print(id)
            else:
                print("------------------")
                installedImage.describe()
    elif args[0] == 'repositories':
        if options.json:
            print(
                json.dumps(
                    user.getRegistry().getRepositories().serializeToDict(),
                    indent=1,
                    separators=(",", ": ")))
            sys.exit()
        for name, repo in user.getRegistry().getRepositories().items():
            if not options.long:
                print(repo.getDisplayName())
            else:
                repo.describe()
                print("")
    else:
        sys.exit(args[0] + " cannot be listed. Option unrecognized.")
コード例 #6
0
def list(sysargs):
    """
  List various things: image sources, subusers, ect.

  >>> import sys
  >>> import list #import self

  Listing available images lists the images along with their default permissions.

  >>> list.list(["available"])
  Images available for instalation from the repo: default
  foo@default
   Description: 
   Maintainer: 
   Executable: /usr/bin/foo

  Similar result when listing subusers.

  >>> list.list(["subusers"])
  The following subusers are registered.
  Subuser: foo
  ------------------
  foo@default
   Description: 
   Maintainer: 
   Executable: /usr/bin/foo
  <BLANKLINE>

  And listing installed images:

  >>> list.list(["installed-images"])
  The following images are installed.
  ------------------
  Image Id: 2
  Image source: foo@default
  Last update time: 1

  > list.list(["repositories"])
  Repository: default
  ------------
  Cloned from: file:///home/travis/default-test-repo
  Currently at commit: 72e7d9c17192d47b2b2344d9eb8a325262d738fe

  In all cases, there is a ``--short`` option.

  >>> list.list(["subusers","--short"])
  foo

  >>> list.list(["available","--short"])
  foo@default

  >>> list.list(["installed-images","--short"])
  foo@default 2

  >>> list.list(["repositories","--short"])
  default

  """
    options, args = parseCliArgs(sysargs)

    if len(args) == 0:
        sys.exit(
            "Nothing to list. Issue this command with the -h argument for help."
        )

    user = subuserlib.classes.user.User()

    if 'available' in args:
        for repoName, repository in user.getRegistry().getRepositories().items(
        ):
            if not options.short:
                print("Images available for instalation from the repo: " +
                      repoName)
            for _, imageSource in repository.items():
                if options.short:
                    print(imageSource.getIdentifier())
                else:
                    imageSource.describe()

    if 'subusers' in args:
        if not options.short:
            print("The following subusers are registered.")
        for name, subuser in user.getRegistry().getSubusers().items():
            if options.internal or not name.startswith("!"):
                if options.short:
                    print(name)
                else:
                    subuser.describe()

    if 'installed-images' in args:
        if not options.short:
            print("The following images are installed.")
        for id, installedImage in user.getInstalledImages().items():
            if options.short:
                try:
                    identifier = installedImage.getImageSource().getIdentifier(
                    )
                    if not options.broken:
                        print(identifier + " " + id)
                except KeyError:
                    if options.broken:
                        print(id)
            else:
                print("------------------")
                installedImage.describe()

    if 'repositories' in args:
        for name, repo in user.getRegistry().getRepositories().items():
            if options.short:
                print(repo.getDisplayName())
            else:
                repo.describe()
                print("")
コード例 #7
0
def list(sysargs):
  """
  List various things: image sources, subusers, ect.

  >>> import sys
  >>> import list #import self

  Listing available images lists the images along with their default permissions.

  >>> list.list(["available"])
  Images available for instalation from the repo: default
  foo:
   Description: 
   Maintainer: 
   Last update time(version): 0
   Executable: /usr/bin/foo

  Similar result when listing subusers.

  >>> list.list(["subusers"])
  The following subusers are registered.
  Subuser: foo
  ------------------
  Progam:
  foo:
   Description: 
   Maintainer: 
   Last update time(version): 0
   Executable: /usr/bin/foo

  And listing installed images:

  >>> list.list(["installed-images"])
  The following images are installed.
  ------------------
  Image Id: 2
  Image source: foo@default
  Last update time: 0

  In all cases, there is a ``--short`` option.

  >>> list.list(["subusers","--short"])
  foo

  >>> list.list(["available","--short"])
  foo@default

  >>> list.list(["installed-images","--short"])
  foo@default 2

  """
  options,args = parseCliArgs(sysargs)
 
  if len(args)==0:
    sys.exit("Nothing to list. Issue this command with the -h argument for help.")
  
  user = subuserlib.classes.user.User()
  
  if 'available' in args:
    for repoName,repository in user.getRegistry().getRepositories().items():
      if not options.short:
        print("Images available for instalation from the repo: " + repoName)
      for _,imageSource in repository.items():
        if options.short:
          print(imageSource.getIdentifier())
        else:
          imageSource.describe()
  
  if 'subusers' in args:
    if not options.short:
      print("The following subusers are registered.")
    for name,subuser in user.getRegistry().getSubusers().items():
      if options.short:
        print(name)
      else:
        subuser.describe()

  if 'installed-images' in args:
    if not options.short:
      print("The following images are installed.")
    for id,installedImage in user.getInstalledImages().items():
      if options.short:
        try:
          identifier = installedImage.getImageSource().getIdentifier()
          if not options.broken:
            print(identifier+" "+id)
        except KeyError:
          if options.broken:
            print(id)
      else:
        print("------------------")
        installedImage.describe()
コード例 #8
0
def runCommand(sysargs):
    """
  List various things: image sources, subusers, ect.
  """
    options, args = parseCliArgs(sysargs)
    if len(args) == 0:
        sys.exit(
            "Nothing to list. Issue this command with the -h argument for help."
        )
    user = subuserlib.classes.user.User()
    if args[0] == 'available':
        if len(args) > 1:
            reposToList = args[1:]
        else:
            reposToList = user.getRegistry().getRepositories().keys()
        availableDict = {}
        for repoIdentifier in reposToList:
            try:
                repoIdentifier = repoIdentifier.decode("utf-8")
            except AttributeError:
                pass
            if repoIdentifier in user.getRegistry().getRepositories():
                temp = False
            else:
                temp = True
            try:
                repository = subuserlib.resolve.resolveRepository(
                    user, repoIdentifier)
            except (OSError, subuserlib.resolve.ResolutionError):
                sys.exit("Repository id: " + repoIdentifier +
                         " could not be resolved.")
            if options.json:
                availableDict[
                    repository.getName()] = repository.serializeToDict()
            else:
                if options.long:
                    subuserlib.print.printWithoutCrashing(
                        "Images available for instalation from the repo: " +
                        repository.getName())
                for imageSource in repository.getSortedList():
                    if not options.long:
                        identifier = imageSource.getIdentifier()
                        subuserlib.print.printWithoutCrashing(identifier)
                    else:
                        try:
                            imageSource.describe()
                        except SyntaxError as e:
                            subuserlib.print.printWithoutCrashing(str(e))
                            subuserlib.print.printWithoutCrashing(
                                "Cannot describe this image source as loading it is forbidden."
                            )
            if temp:
                repository.removeGitRepo()
        if options.json:
            subuserlib.print.printWithoutCrashing(
                json.dumps(availableDict, indent=1, separators=(",", ": ")))
        sys.exit()
    elif args[0] == 'subusers':
        if options.json:
            subuserlib.print.printWithoutCrashing(
                json.dumps(user.getRegistry().getSubusers().serializeToDict(),
                           indent=1,
                           separators=(",", ": ")))
            sys.exit()
        if options.long:
            subuserlib.print.printWithoutCrashing(
                "The following subusers are registered.")
        for name, subuser in user.getRegistry().getSubusers().items():
            if options.internal or not name.startswith("!"):
                if not options.long:
                    subuserlib.print.printWithoutCrashing(name)
                else:
                    subuser.describe()
    elif args[0] == 'installed-images':
        if options.json:
            subuserlib.print.printWithoutCrashing(
                json.dumps(user.getInstalledImages().serializeToDict(),
                           indent=1,
                           separators=(",", ": ")))
            sys.exit()
        if options.long:
            subuserlib.print.printWithoutCrashing(
                "The following images are installed.")
        for id, installedImage in user.getInstalledImages().items():
            if not options.long:
                try:
                    identifier = installedImage.getImageSource().getIdentifier(
                    )
                    if not options.broken:
                        subuserlib.print.printWithoutCrashing(identifier +
                                                              " " + id)
                except KeyError:
                    if options.broken:
                        subuserlib.print.printWithoutCrashing(id)
            else:
                subuserlib.print.printWithoutCrashing("------------------")
                installedImage.describe()
    elif args[0] == 'repositories':
        if options.json:
            subuserlib.print.printWithoutCrashing(
                json.dumps(
                    user.getRegistry().getRepositories().serializeToDict(),
                    indent=1,
                    separators=(",", ": ")))
            sys.exit()
        for name, repo in user.getRegistry().getRepositories().items():
            if not options.long:
                subuserlib.print.printWithoutCrashing(repo.getDisplayName())
            else:
                repo.describe()
                subuserlib.print.printWithoutCrashing("")
    else:
        sys.exit(
            args[0] +
            " cannot be listed. Option unrecognized. Use --help for help.")
コード例 #9
0
ファイル: list.py プロジェクト: awesome-docker/subuser
def runCommand(sysargs):
  """
  List various things: image sources, subusers, ect.
  """
  options,args = parseCliArgs(sysargs)
  if len(args)==0:
    sys.exit("Nothing to list. Issue this command with the -h argument for help.")
  user = subuserlib.classes.user.User()
  if args[0] == 'available':
    if len(args) > 1:
      reposToList = args[1:]
    else:
      reposToList = user.getRegistry().getRepositories().keys()
    availableDict = {}
    for repoIdentifier in reposToList:
      try:
        repoIdentifier = repoIdentifier.decode("utf-8")
      except AttributeError:
        pass
      if repoIdentifier in user.getRegistry().getRepositories():
        temp = False
      else:
        temp = True
      try:
        repository = subuserlib.resolve.resolveRepository(user,repoIdentifier)
      except (OSError,subuserlib.resolve.ResolutionError):
        sys.exit("Repository id: "+repoIdentifier+" could not be resolved.")
      if options.json:
        availableDict[repository.getName()] = repository.serializeToDict()
      else:
       if options.long:
         subuserlib.print.printWithoutCrashing("Images available for instalation from the repo: " + repository.getName())
       for imageSource in repository.getSortedList():
         if not options.long:
           identifier = imageSource.getIdentifier()
           subuserlib.print.printWithoutCrashing(identifier)
         else:
           try:
             imageSource.describe()
           except SyntaxError as e:
             subuserlib.print.printWithoutCrashing(str(e))
             subuserlib.print.printWithoutCrashing("Cannot describe this image source as loading it is forbidden.")
      if temp:
        repository.removeGitRepo()
    if options.json:
      subuserlib.print.printWithoutCrashing(json.dumps(availableDict,indent=1,separators=(",",": ")))
    sys.exit()
  elif args[0] == 'subusers':
    if options.json:
      subuserlib.print.printWithoutCrashing(json.dumps(user.getRegistry().getSubusers().serializeToDict(),indent=1,separators=(",",": ")))
      sys.exit()
    if options.long:
      subuserlib.print.printWithoutCrashing("The following subusers are registered.")
    for name,subuser in user.getRegistry().getSubusers().items():
      if options.internal or not name.startswith("!"):
        if not options.long:
          subuserlib.print.printWithoutCrashing(name)
        else:
          subuser.describe()
  elif args[0] == 'installed-images':
    if options.json:
      subuserlib.print.printWithoutCrashing(json.dumps(user.getInstalledImages().serializeToDict(),indent=1,separators=(",",": ")))
      sys.exit()
    if options.long:
      subuserlib.print.printWithoutCrashing("The following images are installed.")
    for id,installedImage in user.getInstalledImages().items():
      if not options.long:
        try:
          identifier = installedImage.getImageSource().getIdentifier()
          if not options.broken:
            subuserlib.print.printWithoutCrashing(identifier+" "+id)
        except KeyError:
          if options.broken:
            subuserlib.print.printWithoutCrashing(id)
      else:
        subuserlib.print.printWithoutCrashing("------------------")
        installedImage.describe()
  elif args[0] == 'repositories':
    if options.json:
      subuserlib.print.printWithoutCrashing(json.dumps(user.getRegistry().getRepositories().serializeToDict(),indent=1,separators=(",",": ")))
      sys.exit()
    for name,repo in user.getRegistry().getRepositories().items():
      if not options.long:
        subuserlib.print.printWithoutCrashing(repo.getDisplayName())
      else:
        repo.describe()
        subuserlib.print.printWithoutCrashing("")
  else:
    sys.exit(args[0] + " cannot be listed. Option unrecognized. Use --help for help.")