Example #1
0
def isInstalledImageUpToDate(installedImage):
  """
  Returns True if the installed image(including all of its dependencies, is up to date.  False otherwise.
  """
  try:
    topImageSource = installedImage.getUser().getRegistry().getRepositories()[installedImage.getSourceRepoId()][installedImage.getImageSourceName()]
  except KeyError: # Image source not found, therefore updating would be pointless.
    return True

  sourceLineage = getImageSourceLineage(topImageSource)
  installedImageLineage = subuserlib.installedImages.getImageLineage(installedImage.getUser(),installedImage.getImageId())
  return compareSourceLineageAndInstalledImageLineage(installedImage.getUser(),sourceLineage,installedImageLineage)
Example #2
0
def isInstalledImageUpToDate(installedImage):
    """
  Returns True if the installed image(including all of its dependencies, is up to date.  False otherwise.
  """
    try:
        topImageSource = installedImage.getUser().getRegistry(
        ).getRepositories()[installedImage.getSourceRepoId()][
            installedImage.getImageSourceName()]
    except KeyError:  # Image source not found, therefore updating would be pointless.
        return True

    sourceLineage = getImageSourceLineage(topImageSource)
    installedImageLineage = subuserlib.installedImages.getImageLineage(
        installedImage.getUser(), installedImage.getImageId())
    return compareSourceLineageAndInstalledImageLineage(
        installedImage.getUser(), sourceLineage, installedImageLineage)
Example #3
0
def isInstalledImageUpToDate(installedImage,checkForUpdatesExternally=False):
  """
  Returns True if the installed image(including all of its dependencies, is up to date.  False otherwise.
  """
  try:
    topImageSource = installedImage.getUser().getRegistry().getRepositories()[installedImage.getSourceRepoId()][installedImage.getImageSourceName()]
  except KeyError: # Image source not found, therefore updating would be pointless.
    return True
  # Check for updates to image sources
  sourceLineage = getImageSourceLineage(topImageSource)
  installedImageLineage = subuserlib.installedImages.getImageLineage(installedImage.getUser(),installedImage.getImageId())
  if not compareSourceLineageAndInstalledImageLineage(installedImage.getUser(),sourceLineage,installedImageLineage):
    return False
  # Check for updates externally using the images' built in check-for-updates script.
  if checkForUpdatesExternally:
    if installedImage.checkForUpdates():
      return False
  return True
Example #4
0
def isInstalledImageUpToDate(installedImage,checkForUpdatesExternally=False):
  """
  Returns True if the installed image(including all of its dependencies, is up to date.  False otherwise.
  """
  try:
    topImageSource = installedImage.getUser().getRegistry().getRepositories()[installedImage.getSourceRepoId()][installedImage.getImageSourceName()]
  except KeyError: # Image source not found, therefore updating would be pointless.
    return True
  # Check for updates to image sources
  sourceLineage = getImageSourceLineage(topImageSource)
  installedImageLineage = subuserlib.installedImages.getImageLineage(installedImage.getUser(),installedImage.getImageId())
  if not compareSourceLineageAndInstalledImageLineage(installedImage.getUser(),sourceLineage,installedImageLineage):
    return False
  # Check for updates externally using the images' built in check-for-updates script.
  if checkForUpdatesExternally:
    if installedImage.checkForUpdates():
      return False
  return True
Example #5
0
def isInstalledImageUpToDate(installedImage):
  """
  Returns True if the installed image(including all of its dependencies, is up to date.  False otherwise.
  """
  topImageSource = installedImage.getUser().getRegistry().getRepositories()[installedImage.getSourceRepoId()][installedImage.getImageSourceName()]
  sourceLineage = getImageSourceLineage(topImageSource)
  installedImageLineage = subuserlib.installedImages.getImageLineage(installedImage.getUser(),installedImage.getImageId())
  """print("Installed lineage for image:" + installedImage.getImageSourceName())
  for installedImage in installedImageLineage:
    print("  "+installedImage.getImageSourceName()+"@"+installedImage.getSourceRepoId())
  print("Source lineage for image:" + installedImage.getImageSourceName())
  for imageSource in sourceLineage:
    print("  "+imageSource.getName()+"@"+imageSource.getRepository().getName())"""
  while len(sourceLineage) > 0:
    if not len(installedImageLineage)>0:
      return False
    imageSource = sourceLineage.pop(0)
    installedImage = installedImageLineage.pop(0)
    sourcesMatch = installedImage.getImageSourceName() == imageSource.getName() and installedImage.getSourceRepoId() == imageSource.getRepository().getName()
    lastUpdateTimesMatch = installedImage.getLastUpdateTime() == imageSource.getPermissions()["last-update-time"] or not imageSource.getPermissions()["last-update-time"]
    if not (sourcesMatch and lastUpdateTimesMatch):
      if not sourcesMatch:
        installedImage.getUser().getRegistry().log("Depencies changed from "+installedImage.getImageSourceName()+"@"+installedImage.getSourceRepoId()+".  New depencency is: "+imageSource.getName()+"@"+imageSource.getRepository().getName())
      elif not lastUpdateTimesMatch:
        installedImage.getUser().getRegistry().log("Installed image "+installedImage.getImageSourceName()+"@"+installedImage.getSourceRepoId()+" is out of date.\nInstalled version:\n "+installedImage.getLastUpdateTime()+"\nCurrent version:\n "+str(imageSource.getPermissions()["last-update-time"])+"\n")
      return False
  return True
Example #6
0
def isInstalledImageUpToDate(installedImage):
    """
  Returns True if the installed image(including all of its dependencies, is up to date.  False otherwise.
  """
    try:
        topImageSource = installedImage.getUser().getRegistry(
        ).getRepositories()[installedImage.getSourceRepoId()][
            installedImage.getImageSourceName()]
    except KeyError:  # Image source not found, therefore updating would be pointless.
        return True

    sourceLineage = getImageSourceLineage(topImageSource)
    installedImageLineage = subuserlib.installedImages.getImageLineage(
        installedImage.getUser(), installedImage.getImageId())
    """print("Installed lineage for image:" + installedImage.getImageSourceName())
  for installedImage in installedImageLineage:
    print("  "+installedImage.getImageSourceName()+"@"+installedImage.getSourceRepoId())
  print("Source lineage for image:" + installedImage.getImageSourceName())
  for imageSource in sourceLineage:
    print("  "+imageSource.getName()+"@"+imageSource.getRepository().getName())"""
    while len(sourceLineage) > 0:
        if not len(installedImageLineage) > 0:
            return False
        imageSource = sourceLineage.pop(0)
        installedImage = installedImageLineage.pop(0)
        sourcesMatch = installedImage.getImageSourceName(
        ) == imageSource.getName() and installedImage.getSourceRepoId(
        ) == imageSource.getRepository().getName()
        lastUpdateTimesMatch = installedImage.getLastUpdateTime(
        ) == imageSource.getPermissions(
        )["last-update-time"] or not imageSource.getPermissions(
        )["last-update-time"]
        if not (sourcesMatch and lastUpdateTimesMatch):
            if not sourcesMatch:
                installedImage.getUser().getRegistry().log(
                    "Depencies changed from " +
                    installedImage.getImageSourceName() + "@" +
                    installedImage.getSourceRepoId() +
                    ".  New depencency is: " + imageSource.getName() + "@" +
                    imageSource.getRepository().getName())
            elif not lastUpdateTimesMatch:
                installedImage.getUser().getRegistry().log(
                    "Installed image " + installedImage.getImageSourceName() +
                    "@" + installedImage.getSourceRepoId() +
                    " is out of date.\nInstalled version:\n " +
                    installedImage.getLastUpdateTime() +
                    "\nCurrent version:\n " +
                    str(imageSource.getPermissions()["last-update-time"]) +
                    "\n")
            return False
    return True