Пример #1
0
def _aug_get_or_set(augpath, new_servers=None):
    """Get or set some servers
    """
    aug = Augeas()
    aug.save()
    aug.force_reload()

    servers = []
    for path in aug.match(augpath):
        servers.append(aug.get(path))

    LOGGER.debug("Current servers: %s" % servers)

    if new_servers is not None:
        itempath = lambda idx: "%s[%d]" % (augpath, idx + 1)
        LOGGER.debug("Removing old servers: %s" % servers)
        for idx, server in enumerate(servers):
            LOGGER.debug("Removing server %s: %s" % (itempath(idx),
                                                     server))
            aug.remove(itempath(idx))
        LOGGER.debug("Setting new servers: %s" % new_servers)
        for idx, server in enumerate(new_servers):
            LOGGER.debug("Setting server %s: %s" % (itempath(idx), server))
            aug.set(itempath(idx), server)
    return servers
Пример #2
0
            def commit(self):
                aug = AugeasWrapper()

                p = "/files/etc/ntp.conf"
                aug.remove(p, False)
                aug.set(p + "/driftfile", "/var/lib/ntp/drift", False)
                aug.set(p + "/includefile", "/etc/ntp/crypto/pw", False)
                aug.set(p + "/keys", "/etc/ntp/keys", False)
                aug.save()

                config.network.timeservers(servers)

                utils.fs.Config().persist("/etc/ntp.conf")
Пример #3
0
def _aug_get_or_set(augpath, new_servers=None):
    """Get or set some servers
    """
    aug = Augeas()
    aug.save()
    aug.force_reload()

    servers = []
    for path in aug.match(augpath):
        servers.append(aug.get(path))

    LOGGER.debug("Current servers: %s" % servers)

    if new_servers is not None:
        itempath = lambda idx: "%s[%d]" % (augpath, idx + 1)
        LOGGER.debug("Removing old servers: %s" % servers)
        for idx, server in enumerate(servers):
            LOGGER.debug("Removing server %s: %s" % (itempath(idx), server))
            aug.remove(itempath(idx))
        LOGGER.debug("Setting new servers: %s" % new_servers)
        for idx, server in enumerate(new_servers):
            LOGGER.debug("Setting server %s: %s" % (itempath(idx), server))
            aug.set(itempath(idx), server)
    return servers