From 70f4e6d820bc32d74d21513e2688fe0ba045d3d8 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 10 Mar 2013 23:04:23 +0100 Subject: [PATCH] Renamed puppet-storeconfigs backend to puppet::store-configs. --- src/Makefile.am | 12 +++-- .../store-configs.c} | 52 +++++++++---------- src/daemon/sysdbd.conf.sample | 4 +- 3 files changed, 35 insertions(+), 33 deletions(-) rename src/backend/{puppet-storeconfigs.c => puppet/store-configs.c} (85%) diff --git a/src/Makefile.am b/src/Makefile.am index a2f0de0..b754beb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,9 +52,11 @@ dist_sdbconf_DATA = daemon/sysdbd.conf.sample pkgbackendlibdir = $(pkglibdir)/backend pkgbackendcollectdlibdir = $(pkgbackendlibdir)/collectd +pkgbackendpuppetlibdir = $(pkgbackendlibdir)/puppet pkgbackendlib_LTLIBRARIES = pkgbackendcollectdlib_LTLIBRARIES = +pkgbackendpuppetlib_LTLIBRARIES = if BUILD_PLUGIN_COLLECTD pkgbackendcollectdlib_LTLIBRARIES += backend/collectd/unixsock.la @@ -73,11 +75,11 @@ libsysdb_la_DEPENDENCIES += backend/mk-livestatus.la endif if BUILD_PLUGIN_PUPPETSTORECONFIGS -pkgbackendlib_LTLIBRARIES += backend/puppet-storeconfigs.la -backend_puppet_storeconfigs_la_SOURCES = backend/puppet-storeconfigs.c -backend_puppet_storeconfigs_la_LDFLAGS = -module -avoid-version -libsysdb_la_LIBADD += -dlopen backend/puppet-storeconfigs.la -libsysdb_la_DEPENDENCIES += backend/puppet-storeconfigs.la +pkgbackendpuppetlib_LTLIBRARIES += backend/puppet/store-configs.la +backend_puppet_store_configs_la_SOURCES = backend/puppet/store-configs.c +backend_puppet_store_configs_la_LDFLAGS = -module -avoid-version +libsysdb_la_LIBADD += -dlopen backend/puppet/store-configs.la +libsysdb_la_DEPENDENCIES += backend/puppet/store-configs.la endif include/sysdb.h: include/sysdb.h.in ../version diff --git a/src/backend/puppet-storeconfigs.c b/src/backend/puppet/store-configs.c similarity index 85% rename from src/backend/puppet-storeconfigs.c rename to src/backend/puppet/store-configs.c index a798777..601bc06 100644 --- a/src/backend/puppet-storeconfigs.c +++ b/src/backend/puppet/store-configs.c @@ -1,5 +1,5 @@ /* - * SysDB - src/backend/puppet-storeconfigs.c + * SysDB - src/backend/puppet/store-configs.c * Copyright (C) 2012 Sebastian 'tokkee' Harl * All rights reserved. * @@ -66,13 +66,13 @@ sdb_puppet_stcfg_get_hosts(sdb_dbi_client_t __attribute__((unused)) *client, status = sdb_store_host(&host); if (status < 0) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: Failed to " "store/update host '%s'.\n", host.host_name); free(host.host_name); return -1; } else if (! status) - sdb_log(SDB_LOG_DEBUG, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_DEBUG, "puppet::store-configs backend: " "Added/updated host '%s' (last update timestamp = " "%"PRIscTIME").\n", host.host_name, host.host_last_update); free(host.host_name); @@ -102,7 +102,7 @@ sdb_puppet_stcfg_get_attrs(sdb_dbi_client_t __attribute__((unused)) *client, status = sdb_store_attribute(&attr); if (status < 0) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: Failed to " "store/update host attribute '%s' for host '%s'.\n", attr.attr_name, attr.hostname); free(attr.hostname); @@ -131,12 +131,12 @@ sdb_puppet_stcfg_init(sdb_object_t *user_data) client = SDB_OBJ_WRAPPER(user_data)->data; if (sdb_dbi_client_connect(client)) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "Failed to connect to the storeconfigs DB.\n"); return -1; } - sdb_log(SDB_LOG_INFO, "puppet storeconfigs backend: Successfully " + sdb_log(SDB_LOG_INFO, "puppet::store-configs backend: Successfully " "connected to the storeconfigs DB.\n"); return 0; } /* sdb_puppet_stcfg_init */ @@ -151,7 +151,7 @@ sdb_puppet_stcfg_collect(sdb_object_t *user_data) client = SDB_OBJ_WRAPPER(user_data)->data; if (sdb_dbi_client_check_conn(client)) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "Connection to storeconfigs DB failed.\n"); return -1; } @@ -159,7 +159,7 @@ sdb_puppet_stcfg_collect(sdb_object_t *user_data) if (sdb_dbi_exec_query(client, "SELECT name, updated_at FROM hosts;", sdb_puppet_stcfg_get_hosts, NULL, /* #columns = */ 2, /* col types = */ SDB_TYPE_STRING, SDB_TYPE_DATETIME)) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: Failed to " "retrieve hosts from the storeconfigs DB.\n"); return -1; } @@ -177,7 +177,7 @@ sdb_puppet_stcfg_collect(sdb_object_t *user_data) sdb_puppet_stcfg_get_attrs, NULL, /* #columns = */ 4, /* col types = */ SDB_TYPE_STRING, SDB_TYPE_STRING, SDB_TYPE_STRING, SDB_TYPE_DATETIME)) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: Failed to " "retrieve host attributes from the storeconfigs DB.\n"); return -1; } @@ -200,7 +200,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci) int i; if (oconfig_get_string(ci, &name)) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Connection " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: Connection " "requires a single string argument\n" "\tUsage: \n"); return -1; @@ -214,7 +214,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci) if (! strcasecmp(child->key, "DBAdapter")) { if (oconfig_get_string(child, &driver)) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "DBAdapter requires a single string argument inside " "\n\tUsage: DBAdapter NAME\n", name); @@ -223,7 +223,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci) } else if (! strcasecmp(child->key, "DBName")) { if (oconfig_get_string(child, &database)) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "DBName requires a single string argument inside " "\n\tUsage: DBName NAME\n", name); @@ -250,7 +250,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci) if ((child->values_num != 2) || (child->values[0].type != OCONFIG_TYPE_STRING) || (child->values[1].type != OCONFIG_TYPE_STRING)) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "DBIOption requires exactly two string arguments " "inside \n" "\tUsage: DBIOption KEY VALUE\n", name); @@ -262,14 +262,14 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci) value = child->values[1].value.string; } else { - sdb_log(SDB_LOG_WARNING, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_WARNING, "puppet::store-configs backend: " "Ignoring unknown config option '%s' inside " ".\n", child->key, name); continue; } if (status) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Option " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: Option " "'%s' requires a single string argument inside " "\n\tUsage: DBAdapter NAME\n", child->key, name); @@ -281,7 +281,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci) if (! options) { if (! (options = sdb_dbi_options_create())) { char errmsg[1024]; - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "Failed to create DBI options object: %s\n", sdb_strerror(errno, errmsg, sizeof(errmsg))); continue; @@ -290,7 +290,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci) if (sdb_dbi_options_add(options, key, value)) { char errmsg[1024]; - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "Failed to add option '%s': %s\n", key, sdb_strerror(errno, errmsg, sizeof(errmsg))); continue; @@ -298,24 +298,24 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci) } if (! driver) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "Connection '%s' " "missing the 'DBAdapter' option.\n", name); return -1; } if (! database) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "Connection '%s' missing the 'DBName' option.\n", name); return -1; } - snprintf(cb_name, sizeof(cb_name), "puppet-storeconfigs-%s", name); + snprintf(cb_name, sizeof(cb_name), "puppet::storeconfigs::%s", name); cb_name[sizeof(cb_name) - 1] = '\0'; client = sdb_dbi_client_create(driver, database); if (! client) { char errbuf[1024]; - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "Failed to create DBI client: %s\n", sdb_strerror(errno, errbuf, sizeof(errbuf))); return -1; @@ -327,7 +327,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci) (void (*)(void *))sdb_dbi_client_destroy); if (! user_data) { sdb_dbi_client_destroy(client); - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: " "Failed to allocate sdb_object_t\n"); return -1; } @@ -352,7 +352,7 @@ sdb_puppet_stcfg_config(oconfig_item_t *ci) if (! strcasecmp(child->key, "Connection")) sdb_puppet_stcfg_config_conn(child); else - sdb_log(SDB_LOG_WARNING, "puppet storeconfigs backend: " + sdb_log(SDB_LOG_WARNING, "puppet::store-configs backend: " "Ignoring unknown config option '%s'.\n", child->key); } return 0; @@ -361,7 +361,7 @@ sdb_puppet_stcfg_config(oconfig_item_t *ci) int sdb_module_init(sdb_plugin_info_t *info) { - sdb_plugin_set_info(info, SDB_PLUGIN_INFO_NAME, "puppet-storeconfigs"); + sdb_plugin_set_info(info, SDB_PLUGIN_INFO_NAME, "puppet::store-configs"); sdb_plugin_set_info(info, SDB_PLUGIN_INFO_DESC, "backend accessing the Puppet stored configuration database"); sdb_plugin_set_info(info, SDB_PLUGIN_INFO_COPYRIGHT, @@ -371,13 +371,13 @@ sdb_module_init(sdb_plugin_info_t *info) sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION); if (dbi_initialize(/* driver dir = */ NULL) < 0) { - sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: failed to " + sdb_log(SDB_LOG_ERR, "puppet::store-configs backend: failed to " "initialize DBI; possibly you don't have any drivers " "installed.\n"); return -1; } - sdb_plugin_register_config("puppet-storeconfigs", + sdb_plugin_register_config("puppet::store-configs", sdb_puppet_stcfg_config); return 0; } /* sdb_version_extra */ diff --git a/src/daemon/sysdbd.conf.sample b/src/daemon/sysdbd.conf.sample index 7ca023a..304b0bb 100644 --- a/src/daemon/sysdbd.conf.sample +++ b/src/daemon/sysdbd.conf.sample @@ -26,7 +26,7 @@ Interval 300 LoadBackend "collectd::unixsock" LoadBackend "mk-livestatus" -LoadBackend "puppet-storeconfigs" +LoadBackend "puppet::store-configs" #----------------------------------------------------------------------------# # Plugin configuration: # @@ -44,7 +44,7 @@ LoadBackend "puppet-storeconfigs" - + DBAdapter "pgsql" DBName "puppet" -- 2.30.2