def run(self):
        """
        Locate and update the currently deployed origin file.
        """
        self.originfile = self._get_deployed_origin()
        log.debug("Loading ostree origin file: %s" % self.originfile)
        origin_cfg = config.KeyFileConfigParser(self.originfile)
        old_refspec = origin_cfg.get('origin', 'refspec')

        if len(self.repo_config.remotes):
            log.warn("Multiple remotes configured in %s." % self.repo_config)

        new_remote = self._get_new_refspec(old_refspec)
        if new_remote is None:
            log.warn("Unable to find matching remote for origin: %s" % old_refspec)
            log.warn("Leaving refspec in %s" % self.originfile)
            return

        new_refspec = config.replace_refspec_remote(old_refspec,
            new_remote)

        if new_refspec != old_refspec:
            log.info("Updating refspec in: %s" % self.originfile)
            log.info("    old = %s" % old_refspec)
            log.info("    new = %s" % new_refspec)
            origin_cfg.set('origin', 'refspec', new_refspec)
            origin_cfg.save()
        else:
            log.debug("No change to refspec in %s" % self.originfile)
Exemple #2
0
    def run(self):
        """
        Locate and update the currently deployed origin file.
        """
        self.originfile = self._get_deployed_origin()
        log.debug("Loading ostree origin file: %s" % self.originfile)

        # No results
        if not self.originfile:
            return

        origin_cfg = config.KeyFileConfigParser(self.originfile)

        try:
            old_refspec = origin_cfg.get('origin', 'refspec')
        except config.NoSectionError:
            log.warn("No 'origin' section found in origin file: %s" %
                     self.originfile)
            return

        if len(self.repo_config.remotes):
            log.warn("Multiple remotes configured in %s." % self.repo_config)

        new_remote = self._get_new_refspec(old_refspec)
        if new_remote is None:
            log.warn("Unable to find matching remote for origin: %s" %
                     old_refspec)
            log.warn("Leaving refspec in %s" % self.originfile)
            return

        new_refspec = config.replace_refspec_remote(old_refspec, new_remote)

        if new_refspec != old_refspec:
            log.info("Updating refspec in: %s" % self.originfile)
            log.info("    old = %s" % old_refspec)
            log.info("    new = %s" % new_refspec)
            origin_cfg.set('origin', 'refspec', new_refspec)
            origin_cfg.save()
        else:
            log.debug("No change to refspec in %s" % self.originfile)
 def test_empty_remote(self):
     refspec = ':awesomeos-controller/awesomeos8/x86_64/controller/docker'
     expected = 'newremote:awesomeos-controller/awesomeos8/x86_64/controller/docker'
     self.assertEquals(expected, config.replace_refspec_remote(
         refspec, 'newremote'))
 def test_empty_remote(self):
     refspec = ':awesomeos-controller/awesomeos8/x86_64/controller/docker'
     expected = 'newremote:awesomeos-controller/awesomeos8/x86_64/controller/docker'
     self.assertEquals(expected,
                       config.replace_refspec_remote(refspec, 'newremote'))
            #       This will need to be replaced with a more precise method.
            #       Note this also applies for the case of no matching remote names
            #       and only one remote, which will be the common case for a fresh
            #       install.
            if len(self.repo_config.remotes):
                new_remote = sorted([x.name
                                     for x in self.repo_config.remotes])[0]
                log.warn(
                    "No remotes that match refspec for deployed origin found, so "
                    "choosing the first remote names sorted: %s" % new_remote)
            else:
                # No remotes,
                log.debug("No ostree remote urls found in content.")
                return

        new_refspec = config.replace_refspec_remote(old_refspec, new_remote)

        # A KeyfileConfigParser object comparison would be useful here to
        # decide if we need to persist.

        if new_refspec != old_refspec:
            log.info("Updating refspec in: %s" % self.originfile)
            log.info("    old = %s" % old_refspec)
            log.info("    new = %s" % new_refspec)
            origin_cfg.set('origin', 'refspec', new_refspec)
            origin_cfg.save()

        else:
            log.debug("No change to refspec in %s" % self.originfile)

        # FIXME: keep track of changes to avoid this
    def run(self):
        """
        Locate and update the currently deployed origin file.
        """
        self.originfile = self._get_deployed_origin()

        # No results
        if not self.originfile:
            return

        origin_cfg = config.KeyFileConfigParser(self.originfile)

        try:
            old_refspec = origin_cfg.get('origin', 'refspec')
        except config.NoSectionError:
            log.warn("No 'origin' section found in origin file: %s" % self.originfile)
            return

        # Remove the unconfigured-state flag from the origin config.
        # Note any changes to origin_cfg here are not saved until later.
        origin_cfg = self._remove_unconfigured_flag(origin_cfg)

        if len(self.repo_config.remotes):
            log.warn("Multiple remotes configured in %s." % self.repo_config)

        new_remote = self._get_new_refspec(old_refspec)
        if new_remote is None:
            log.warn("Unable to find matching remote for origin: %s" % old_refspec)
            log.warn("Leaving refspec in %s" % self.originfile)

            # TODO: We don't have all the data and namespaces setup yet to insure
            #       we never get this scenario. A fresh installed system with a
            #       respect of
            #       "atomic-host-install:atomic-host/10.0/x86_64/standard" with
            #       remotes "atomic-host-blah-beta" and
            #       "atomic-host-super-preview". Have to update respec with a name
            #       matching at least one of the remotes, so we pick the first one.
            #       This will need to be replaced with a more precise method.
            #       Note this also applies for the case of no matching remote names
            #       and only one remote, which will be the common case for a fresh
            #       install.
            if len(self.repo_config.remotes):
                new_remote = sorted([x.name for x in self.repo_config.remotes])[0]
                log.warn("No remotes that match refspec for deployed origin found, so "
                        "choosing the first remote names sorted: %s" % new_remote)
            else:
                # No remotes,
                log.debug("No ostree remote urls found in content.")
                return

        new_refspec = config.replace_refspec_remote(old_refspec,
            new_remote)

        # A KeyfileConfigParser object comparison would be useful here to
        # decide if we need to persist.

        if new_refspec != old_refspec:
            log.info("Updating refspec in: %s" % self.originfile)
            log.info("    old = %s" % old_refspec)
            log.info("    new = %s" % new_refspec)
            origin_cfg.set('origin', 'refspec', new_refspec)
            origin_cfg.save()

        else:
            log.debug("No change to refspec in %s" % self.originfile)

        # FIXME: keep track of changes to avoid this
        #        (or write a config object differ, etc)
        log.debug("But saving %s anyway, in case other values changed.",
                  self.originfile)
        origin_cfg.save()
Exemple #7
0
    def run(self):
        """
        Locate and update the currently deployed origin file.
        """
        self.originfile = self._get_deployed_origin()
        log.debug("Loading ostree origin file: %s" % self.originfile)

        # No results
        if not self.originfile:
            return

        origin_cfg = config.KeyFileConfigParser(self.originfile)

        try:
            old_refspec = origin_cfg.get('origin', 'refspec')
        except config.NoSectionError:
            log.warn("No 'origin' section found in origin file: %s" %
                     self.originfile)
            return

        if len(self.repo_config.remotes):
            log.warn("Multiple remotes configured in %s." % self.repo_config)

        log.debug("old_refspec: %s" % old_refspec)
        new_remote = self._get_new_refspec(old_refspec)
        log.debug("new_remote: %s" % new_remote)
        if new_remote is None:
            log.warn("Unable to find matching remote for origin: %s" %
                     old_refspec)
            log.warn("Leaving refspec in %s" % self.originfile)

            # TODO: We don't have all the data and namespaces setup yet to insure
            #       we never get this scenario. A fresh installed system with a
            #       respect of
            #       "atomic-host-install:atomic-host/10.0/x86_64/standard" with
            #       remotes "atomic-host-blah-beta" and
            #       "atomic-host-super-preview". Have to update respec with a name
            #       matching at least one of the remotes, so we pick the first one.
            #       This will need to be replaced with a more precise method.
            #       Note this also applies for the case of no matching remote names
            #       and only one remote, which will be the common case for a fresh
            #       install.
            if len(self.repo_config.remotes):
                new_remote = sorted([x.name
                                     for x in self.repo_config.remotes])[0]
                log.warn(
                    "No remotes that match refspec for deployed origin found, so "
                    "choosing the first remote names sorted: %s" % new_remote)
            else:
                # No remotes,
                log.debug("No ostree remote urls found in content.")
                return

        new_refspec = config.replace_refspec_remote(old_refspec, new_remote)

        log.debug("old_refspec: %s" % old_refspec)
        log.debug("new_refspec: %s" % new_refspec)
        if new_refspec != old_refspec:
            log.info("Updating refspec in: %s" % self.originfile)
            log.info("    old = %s" % old_refspec)
            log.info("    new = %s" % new_refspec)
            origin_cfg.set('origin', 'refspec', new_refspec)
            origin_cfg.save()
        else:
            log.debug("No change to refspec in %s" % self.originfile)
            #       "atomic-host-super-preview". Have to update respec with a name
            #       matching at least one of the remotes, so we pick the first one.
            #       This will need to be replaced with a more precise method.
            #       Note this also applies for the case of no matching remote names
            #       and only one remote, which will be the common case for a fresh
            #       install.
            if len(self.repo_config.remotes):
                new_remote = sorted([x.name for x in self.repo_config.remotes])[0]
                log.warn("No remotes that match refspec for deployed origin found, so "
                        "choosing the first remote names sorted: %s" % new_remote)
            else:
                # No remotes,
                log.debug("No ostree remote urls found in content.")
                return

        new_refspec = config.replace_refspec_remote(old_refspec,
            new_remote)

        # A KeyfileConfigParser object comparison would be useful here to
        # decide if we need to persist.

        if new_refspec != old_refspec:
            log.info("Updating refspec in: %s" % self.originfile)
            log.info("    old = %s" % old_refspec)
            log.info("    new = %s" % new_refspec)
            origin_cfg.set('origin', 'refspec', new_refspec)
            origin_cfg.save()

        else:
            log.debug("No change to refspec in %s" % self.originfile)

        # FIXME: keep track of changes to avoid this
    def run(self):
        """
        Locate and update the currently deployed origin file.
        """
        self.originfile = self._get_deployed_origin()
        log.debug("Loading ostree origin file: %s" % self.originfile)

        # No results
        if not self.originfile:
            return

        origin_cfg = config.KeyFileConfigParser(self.originfile)

        try:
            old_refspec = origin_cfg.get('origin', 'refspec')
        except config.NoSectionError:
            log.warn("No 'origin' section found in origin file: %s" % self.originfile)
            return

        if len(self.repo_config.remotes):
            log.warn("Multiple remotes configured in %s." % self.repo_config)

        log.debug("old_refspec: %s" % old_refspec)
        new_remote = self._get_new_refspec(old_refspec)
        log.debug("new_remote: %s" % new_remote)
        if new_remote is None:
            log.warn("Unable to find matching remote for origin: %s" % old_refspec)
            log.warn("Leaving refspec in %s" % self.originfile)

            # TODO: We don't have all the data and namespaces setup yet to insure
            #       we never get this scenario. A fresh installed system with a
            #       respect of
            #       "atomic-host-install:atomic-host/10.0/x86_64/standard" with
            #       remotes "atomic-host-blah-beta" and
            #       "atomic-host-super-preview". Have to update respec with a name
            #       matching at least one of the remotes, so we pick the first one.
            #       This will need to be replaced with a more precise method.
            #       Note this also applies for the case of no matching remote names
            #       and only one remote, which will be the common case for a fresh
            #       install.
            if len(self.repo_config.remotes):
                new_remote = sorted([x.name for x in self.repo_config.remotes])[0]
                log.warn("No remotes that match refspec for deployed origin found, so "
                        "choosing the first remote names sorted: %s" % new_remote)
            else:
                # No remotes,
                log.debug("No ostree remote urls found in content.")
                return

        new_refspec = config.replace_refspec_remote(old_refspec,
            new_remote)

        log.debug("old_refspec: %s" % old_refspec)
        log.debug("new_refspec: %s" % new_refspec)
        if new_refspec != old_refspec:
            log.info("Updating refspec in: %s" % self.originfile)
            log.info("    old = %s" % old_refspec)
            log.info("    new = %s" % new_refspec)
            origin_cfg.set('origin', 'refspec', new_refspec)
            origin_cfg.save()
        else:
            log.debug("No change to refspec in %s" % self.originfile)
 def test_empty_remote(self):
     refspec = ":awesomeos-controller/awesomeos8/x86_64/controller/docker"
     expected = "newremote:awesomeos-controller/awesomeos8/x86_64/controller/docker"
     self.assertEquals(expected, config.replace_refspec_remote(refspec, "newremote"))