Exemplo n.º 1
0
 def make_config(self):
     p = os.path.join(config.LOCAL_SERVICES_DIR, config.REGISTRY_CONFIG_FILE)
     with open(p) as fp:
         registry_config = load_config(fp)
     for k, v in self.params.iteritems():
         if not registry_config.get(k, None):
             continue
         if not isinstance(v, dict):
             registry_config[k] = v
             continue
         for s, p in v.iteritems():
             registry_config[k][s] = p
     rp = os.path.join(config.REMOTE_REGISTRY_CONFIG_PATH, config.REGISTRY_CONFIG_FILE)
     return make_remote_file(
             self.uploader, rp,
             dump_config(registry_config, default_flow_style=False)
     )
Exemplo n.º 2
0
#!/usr/bin/python
# coding:utf-8

import logging
from armin.client import generate_ssh_clients
from armin.utils import load_config

logger = logging.getLogger(__name__)

if __name__ == "__main__":
    # logging.basicConfig(level=logging.INFO)
    with open("test.yaml") as f:
        config = load_config(f)
    test_config = config["test"]
    clients = generate_ssh_clients(test_config)
    count = 1
    for _, host in clients.iteritems():
        logger.info(host.server)
        print host.server
        for method, params in test_config["methods"].iteritems():
            func = getattr(host, method, None)
            if not func:
                logger.info("method %s not allowed", method)
                continue
            print "*" * 40
            print method
            if method == "set_hostname":
                hostname = params.get("hostname")
                # TODO check
                if params.get("incr", False):
                    hostname = "%s%d" % (hostname, count)