Merge remote-tracking branch 'cdist/master'

This commit is contained in:
Steven Armstrong 2011-09-26 15:44:59 +02:00
commit 10ee0c2425
10 changed files with 67 additions and 91 deletions

View file

@ -21,23 +21,16 @@
#
import argparse
import datetime
import logging
import multiprocessing
import os
import re
import subprocess
import shutil
import stat
import sys
import tempfile
log = logging.getLogger(__name__)
# Ensure our /lib/ is included into PYTHON_PATH
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), '../lib'))
)
os.path.join(os.path.dirname(os.path.realpath(__file__)), '../lib')))
TYPE_PREFIX = "__"

View file

@ -1,36 +0,0 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# 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/>.
#
#
# Use stdin as the manifest to deploy on the given host.
#
. cdist-config
[ $# -eq 1 ] || __cdist_usage "<target host>"
set -eu
__cdist_target_host="$1"
shift
cat >> "$__cdist_tmp_file"
chmod +x "$__cdist_tmp_file"
export __cdist_manifest_init="$__cdist_tmp_file"
cdist-deploy-to "$__cdist_target_host"

View file

@ -1,30 +0,0 @@
cdist-deploy-stdin-to(1)
========================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-deploy-stdin-to - Deploy the configuration given on stdin to host
SYNOPSIS
--------
echo "__file /tmp/whatever" | cdist-deploy-stdin-to HOSTNAME
DESCRIPTION
-----------
Use stdin as the manifest for cdist-deploy-to.
SEE ALSO
--------
- cdist(7)
- cdist-deploy-to(1)
COPYING
-------
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

0
lib/cdist/config.py Executable file → Normal file
View file

0
lib/cdist/emulator.py Executable file → Normal file
View file

View file

@ -24,6 +24,8 @@ import subprocess
log = logging.getLogger(__name__)
import cdist
def shell_run_or_debug_fail(script, *args, **kargs):
# Manually execute /bin/sh, because sh -e does what we want
# and sh -c -e does not exit if /bin/false called
@ -50,11 +52,11 @@ def shell_run_or_debug_fail(script, *args, **kargs):
print(script_fd.read())
script_fd.close()
except IOError as error:
raise CdistError(str(error))
raise cdist.Error(str(error))
raise CdistError("Command failed (shell): " + " ".join(*args))
raise cdist.Error("Command failed (shell): " + " ".join(*args))
except OSError as error:
raise CdistError(" ".join(*args) + ": " + error.args[1])
raise cdist.Error(" ".join(*args) + ": " + error.args[1])
def run_or_fail(*args, **kargs):
@ -66,6 +68,6 @@ def run_or_fail(*args, **kargs):
try:
subprocess.check_call(*args, **kargs)
except subprocess.CalledProcessError:
raise CdistError("Command failed: " + " ".join(*args))
raise cdist.Error("Command failed: " + " ".join(*args))
except OSError as error:
raise CdistError(" ".join(*args) + ": " + error.args[1])
raise cdist.Error(" ".join(*args) + ": " + error.args[1])

0
lib/cdist/install.py Executable file → Normal file
View file

59
test.py Executable file
View file

@ -0,0 +1,59 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 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 os
import sys
import unittest
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib')))
import cdist
import cdist.config
import cdist.exec
class Exec(unittest.TestCase):
def test_local_success(self):
try:
cdist.exec.run_or_fail(["/bin/true"])
except cdist.Error:
failed = True
else:
failed = False
self.assertFalse(failed)
def test_local_fail(self):
try:
cdist.exec.run_or_fail(["/bin/false"])
except cdist.Error:
failed = True
else:
failed = False
self.assertTrue(failed)
if __name__ == '__main__':
unittest.main()

View file

@ -1,12 +0,0 @@
import cdist
import unittest
class CdistGeneric(unittest.TestCase):
def test_initial_manifest(self):
self.assertEqual(numeral, result)
if __name__ == '__main__':
unittest.main()