From fc1e0d9f1fbdead1ab0c548ef17ce94f64f53f0c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 26 Sep 2011 11:55:59 +0200 Subject: [PATCH 1/7] remove exec bits from copying Signed-off-by: Nico Schottelius --- lib/cdist/config.py | 0 lib/cdist/emulator.py | 0 lib/cdist/install.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 lib/cdist/config.py mode change 100755 => 100644 lib/cdist/emulator.py mode change 100755 => 100644 lib/cdist/install.py diff --git a/lib/cdist/config.py b/lib/cdist/config.py old mode 100755 new mode 100644 diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py old mode 100755 new mode 100644 diff --git a/lib/cdist/install.py b/lib/cdist/install.py old mode 100755 new mode 100644 From 6458499d2bda5eacf2f40da3515dd103cc9031e7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 26 Sep 2011 12:02:24 +0200 Subject: [PATCH 2/7] J) Signed-off-by: Nico Schottelius --- bin/cdist | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/cdist b/bin/cdist index 5e1b96bf..f8596e67 100755 --- a/bin/cdist +++ b/bin/cdist @@ -36,8 +36,7 @@ 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 = "__" From 0cd24f1544f71c63d9e8aaab7b9425b8e53c9772 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 26 Sep 2011 15:08:59 +0200 Subject: [PATCH 3/7] rename quickstart to tutorial Signed-off-by: Nico Schottelius --- doc/man/man7/{cdist-quickstart.text => cdist-tutorial.text} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/man/man7/{cdist-quickstart.text => cdist-tutorial.text} (100%) diff --git a/doc/man/man7/cdist-quickstart.text b/doc/man/man7/cdist-tutorial.text similarity index 100% rename from doc/man/man7/cdist-quickstart.text rename to doc/man/man7/cdist-tutorial.text From 597e1e73453318f7886c8eb6c63f0ab8e27bc011 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 26 Sep 2011 15:15:36 +0200 Subject: [PATCH 4/7] remove obsolete cdist-deploy-stdin-to Signed-off-by: Nico Schottelius --- bin/cdist-deploy-stdin-to | 36 ------------------------- doc/man/man1/cdist-deploy-stdin-to.text | 30 --------------------- 2 files changed, 66 deletions(-) delete mode 100755 bin/cdist-deploy-stdin-to delete mode 100644 doc/man/man1/cdist-deploy-stdin-to.text diff --git a/bin/cdist-deploy-stdin-to b/bin/cdist-deploy-stdin-to deleted file mode 100755 index 391dd431..00000000 --- a/bin/cdist-deploy-stdin-to +++ /dev/null @@ -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 . -# -# -# Use stdin as the manifest to deploy on the given host. -# - -. cdist-config -[ $# -eq 1 ] || __cdist_usage "" -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" diff --git a/doc/man/man1/cdist-deploy-stdin-to.text b/doc/man/man1/cdist-deploy-stdin-to.text deleted file mode 100644 index 14f19478..00000000 --- a/doc/man/man1/cdist-deploy-stdin-to.text +++ /dev/null @@ -1,30 +0,0 @@ -cdist-deploy-stdin-to(1) -======================== -Steven Armstrong - - -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). From 996fa75c2eff3bd0ffe4c6a10b30447a953209b1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 26 Sep 2011 15:18:55 +0200 Subject: [PATCH 5/7] cleanup cdist imports Signed-off-by: Nico Schottelius --- bin/cdist | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bin/cdist b/bin/cdist index f8596e67..d21fda40 100755 --- a/bin/cdist +++ b/bin/cdist @@ -21,16 +21,10 @@ # 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__) From ef197eebe330bcdfb1af07806b288b88c8b6cfd7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 26 Sep 2011 15:42:27 +0200 Subject: [PATCH 6/7] move test to top level Signed-off-by: Nico Schottelius --- test.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ test/cdist.py | 12 ----------- 2 files changed, 59 insertions(+), 12 deletions(-) create mode 100755 test.py delete mode 100644 test/cdist.py diff --git a/test.py b/test.py new file mode 100755 index 00000000..ad56df11 --- /dev/null +++ b/test.py @@ -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 . +# +# + + +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() diff --git a/test/cdist.py b/test/cdist.py deleted file mode 100644 index 3ccc69bc..00000000 --- a/test/cdist.py +++ /dev/null @@ -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() From 4906f604f0d1da1968c06e5e9e7cd3ca88a4c75d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 26 Sep 2011 15:42:39 +0200 Subject: [PATCH 7/7] raise cdist errors Signed-off-by: Nico Schottelius --- lib/cdist/exec.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/cdist/exec.py b/lib/cdist/exec.py index 09e4e8a4..f95ba941 100644 --- a/lib/cdist/exec.py +++ b/lib/cdist/exec.py @@ -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])