2011-09-26 09:45:19 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
|
|
|
|
#
|
|
|
|
# This file is part of cdist.
|
|
|
|
#
|
|
|
|
# cdist is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# cdist is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
import logging
|
2011-10-06 15:06:56 +00:00
|
|
|
import os
|
2011-10-06 15:02:37 +00:00
|
|
|
import sys
|
2011-09-26 09:45:19 +00:00
|
|
|
|
2011-10-04 16:45:29 +00:00
|
|
|
import cdist.config_install
|
2011-09-26 09:45:19 +00:00
|
|
|
|
2011-10-06 17:54:41 +00:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2011-10-04 16:45:29 +00:00
|
|
|
class Config(cdist.config_install.ConfigInstall):
|
|
|
|
pass
|
2011-09-26 09:45:19 +00:00
|
|
|
|
|
|
|
def config(args):
|
|
|
|
"""Configure remote system"""
|
|
|
|
process = {}
|
|
|
|
|
|
|
|
time_start = datetime.datetime.now()
|
|
|
|
|
2011-10-06 13:48:44 +00:00
|
|
|
os.environ['__remote_exec'] = "ssh -o User=root -q"
|
|
|
|
os.environ['__remote_copy'] = "scp -o User=root -q"
|
2011-10-06 11:34:45 +00:00
|
|
|
|
2011-09-26 09:45:19 +00:00
|
|
|
for host in args.host:
|
2011-10-07 11:36:51 +00:00
|
|
|
c = Config(host, initial_manifest=args.manifest, base_dir=args.cdist_home, debug=args.debug)
|
2011-09-26 09:45:19 +00:00
|
|
|
if args.parallel:
|
|
|
|
log.debug("Creating child process for %s", host)
|
|
|
|
process[host] = multiprocessing.Process(target=c.deploy_and_cleanup)
|
|
|
|
process[host].start()
|
|
|
|
else:
|
|
|
|
c.deploy_and_cleanup()
|
|
|
|
|
|
|
|
if args.parallel:
|
|
|
|
for p in process.keys():
|
2011-09-27 15:27:28 +00:00
|
|
|
log.debug("Joining process %s", p)
|
2011-09-26 09:45:19 +00:00
|
|
|
process[p].join()
|
|
|
|
|
|
|
|
time_end = datetime.datetime.now()
|
|
|
|
log.info("Total processing time for %s host(s): %s", len(args.host),
|
|
|
|
(time_end - time_start).total_seconds())
|