From c36fba4b996c084f83e8d4c4f91b050d3c37ed2b Mon Sep 17 00:00:00 2001 From: Manuel Hutter Date: Tue, 17 Jun 2014 19:04:22 +0200 Subject: [PATCH 1/6] Fixed global explorers on OSX --- cdist/conf/explorer/cpu_cores | 23 ++++++++++++++++------- cdist/conf/explorer/cpu_sockets | 21 +++++++++++++++------ cdist/conf/explorer/memory | 16 +++++++++++++--- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/cdist/conf/explorer/cpu_cores b/cdist/conf/explorer/cpu_cores index efabc848..25d91f79 100755 --- a/cdist/conf/explorer/cpu_cores +++ b/cdist/conf/explorer/cpu_cores @@ -22,10 +22,19 @@ # FIXME: other system types (not linux ...) -if [ -r /proc/cpuinfo ]; then - cores="$(cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l)" - if [ ${cores} -eq 0 ]; then - cores="1" - fi - echo "${cores}" -fi +os=$("$__explorer/os") +case "$os" in + "macosx") + echo "$(sysctl -n hw.physicalcpu)" + ;; + + *) + if [ -r /proc/cpuinfo ]; then + cores="$(cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l)" + if [ ${cores} -eq 0 ]; then + cores="1" + fi + echo "$cores" + fi + ;; +esac diff --git a/cdist/conf/explorer/cpu_sockets b/cdist/conf/explorer/cpu_sockets index 98836cec..42acac1c 100755 --- a/cdist/conf/explorer/cpu_sockets +++ b/cdist/conf/explorer/cpu_sockets @@ -22,10 +22,19 @@ # FIXME: other system types (not linux ...) -if [ -r /proc/cpuinfo ]; then - sockets="$(cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l)" - if [ ${sockets} -eq 0 ]; then - sockets="$(cat /proc/cpuinfo | grep "processor" | wc -l)" +os=$("$__explorer/os") +case "$os" in + "macosx") + echo "$(system_profiler SPHardwareDataType | grep "Number of Processors" | awk -F': ' '{print $2}')" + ;; + + *) + if [ -r /proc/cpuinfo ]; then + sockets="$(cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l)" + if [ ${sockets} -eq 0 ]; then + sockets="$(cat /proc/cpuinfo | grep "processor" | wc -l)" + fi + echo "${sockets}" fi - echo "${sockets}" -fi + ;; +esac diff --git a/cdist/conf/explorer/memory b/cdist/conf/explorer/memory index 982b5dfa..c7dc9fb3 100755 --- a/cdist/conf/explorer/memory +++ b/cdist/conf/explorer/memory @@ -22,6 +22,16 @@ # FIXME: other system types (not linux ...) -if [ -r /proc/meminfo ]; then - echo "$(cat /proc/meminfo | grep "MemTotal:" | awk '{print $2}')" -fi +os=$("$__explorer/os") +case "$os" in + "macosx") + let memsize=$(sysctl -n hw.memsize)/1024 + echo "$memsize" + ;; + + *) + if [ -r /proc/meminfo ]; then + echo "$(cat /proc/meminfo | grep "MemTotal:" | awk '{print $2}')" + fi + ;; +esac From e72782496434dd199f0816510bb189bd52d24b11 Mon Sep 17 00:00:00 2001 From: Manuel Hutter Date: Wed, 18 Jun 2014 10:19:21 +0200 Subject: [PATCH 2/6] `cat` and pipe diet --- cdist/conf/explorer/cpu_cores | 2 +- cdist/conf/explorer/cpu_sockets | 2 +- cdist/conf/explorer/memory | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cdist/conf/explorer/cpu_cores b/cdist/conf/explorer/cpu_cores index 25d91f79..7f7a955e 100755 --- a/cdist/conf/explorer/cpu_cores +++ b/cdist/conf/explorer/cpu_cores @@ -30,7 +30,7 @@ case "$os" in *) if [ -r /proc/cpuinfo ]; then - cores="$(cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l)" + cores="$(grep "core id" /proc/cpuinfo | sort | uniq | wc -l)" if [ ${cores} -eq 0 ]; then cores="1" fi diff --git a/cdist/conf/explorer/cpu_sockets b/cdist/conf/explorer/cpu_sockets index 42acac1c..8a8194df 100755 --- a/cdist/conf/explorer/cpu_sockets +++ b/cdist/conf/explorer/cpu_sockets @@ -30,7 +30,7 @@ case "$os" in *) if [ -r /proc/cpuinfo ]; then - sockets="$(cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l)" + sockets="$(grep "physical id" /proc/cpuinfo | sort | uniq | wc -l)" if [ ${sockets} -eq 0 ]; then sockets="$(cat /proc/cpuinfo | grep "processor" | wc -l)" fi diff --git a/cdist/conf/explorer/memory b/cdist/conf/explorer/memory index c7dc9fb3..a5cae048 100755 --- a/cdist/conf/explorer/memory +++ b/cdist/conf/explorer/memory @@ -31,7 +31,7 @@ case "$os" in *) if [ -r /proc/meminfo ]; then - echo "$(cat /proc/meminfo | grep "MemTotal:" | awk '{print $2}')" + echo "$(grep "MemTotal:" /proc/meminfo | awk '{print $2}')" fi ;; esac From 981f8068d26b6895e839bb0c98bd479b6edc7407 Mon Sep 17 00:00:00 2001 From: Manuel Hutter Date: Sat, 21 Jun 2014 14:24:10 +0200 Subject: [PATCH 3/6] code diet on "memory" --- cdist/conf/explorer/memory | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cdist/conf/explorer/memory b/cdist/conf/explorer/memory index a5cae048..05db865f 100755 --- a/cdist/conf/explorer/memory +++ b/cdist/conf/explorer/memory @@ -25,13 +25,12 @@ os=$("$__explorer/os") case "$os" in "macosx") - let memsize=$(sysctl -n hw.memsize)/1024 - echo "$memsize" + echo "$(sysctl -n hw.memsize)/1024" | bc ;; *) if [ -r /proc/meminfo ]; then - echo "$(grep "MemTotal:" /proc/meminfo | awk '{print $2}')" + grep "MemTotal:" /proc/meminfo | awk '{print $2}' fi ;; esac From 60b2bbf4c944bcc8819588f7ad42c186e83cf7a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Catalinas=20Jim=C3=A9nez?= Date: Sun, 21 Sep 2014 11:52:38 +0100 Subject: [PATCH 4/6] Fix messaging variables not exported in type manifest --- cdist/core/manifest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/core/manifest.py b/cdist/core/manifest.py index 95bf4c25..240e57a1 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -144,4 +144,4 @@ class Manifest(object): type_manifest = os.path.join(self.local.type_path, cdist_object.cdist_type.manifest_path) message_prefix = cdist_object.name if os.path.isfile(type_manifest): - self.local.run_script(type_manifest, env=self.env_type_manifest(cdist_object)) + self.local.run_script(type_manifest, env=self.env_type_manifest(cdist_object), message_prefix=message_prefix) From 4e9b1780e9cda6ab7b06569bb9f5cfdc4ddab2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Catalinas=20Jim=C3=A9nez?= Date: Sun, 21 Sep 2014 11:53:04 +0100 Subject: [PATCH 5/6] Fix typo in reference doc --- docs/man/cdist-reference.text.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/man/cdist-reference.text.sh b/docs/man/cdist-reference.text.sh index 7081e762..fda7aa9c 100755 --- a/docs/man/cdist-reference.text.sh +++ b/docs/man/cdist-reference.text.sh @@ -203,10 +203,10 @@ __global:: Directory that contains generic output like explorer. Available for: initial manifest, type manifest, type gencode, shell __messages_in:: - File to read messages from + File to read messages from. Available for: initial manifest, type manifest, type gencode __messages_out:: - File to write messages + File to write messages. Available for: initial manifest, type manifest, type gencode __object:: Directory that contains the current object. From cba6ce4882f489aff0b07d4e7c47a19e569eb906 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 29 Sep 2014 11:14:24 +0200 Subject: [PATCH 6/6] +changes Signed-off-by: Nico Schottelius --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 3649bf36..bec1ceed 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ Changelog 3.1.7: * Type __cdistmarker: Fix typo (Ricardo Catalinas Jiménez) + * Core: Bugfix: Export messaging to manifests (Ricardo Catalinas Jiménez) 3.1.6: 2014-08-18 * New Type: __ssh_dot_ssh