Skip to content

Commit

Permalink
Merge pull request #1703 from kgaillot/release11
Browse files Browse the repository at this point in the history
Release 1.1.20-rc3
  • Loading branch information
kgaillot committed Feb 26, 2019
2 parents 1642a7f + 5dd7f51 commit 4601a8f
Show file tree
Hide file tree
Showing 91 changed files with 1,536 additions and 1,167 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
* Tue Feb 26 2019 Ken Gaillot <kgaillot@redhat.com> Pacemaker-1.1.20-rc3
- Changesets: 12
- Diff: 14 files changed, 1021 insertions(+), 658 deletions(-)

- Changes since Pacemaker-1.1.20-rc2
+ scheduler: regression test compatibility with glib 2.59.0

* Thu Jan 31 2019 Ken Gaillot <kgaillot@redhat.com> Pacemaker-1.1.20-rc2
- Changesets: 34
- Diff: 13 files changed, 212 insertions(+), 134 deletions(-)
Expand Down
5 changes: 3 additions & 2 deletions include/crm/common/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2004-2018 Andrew Beekhof <andrew@beekhof.net>
# Copyright 2004-2019 Andrew Beekhof <andrew@beekhof.net>
#
# This source code is licensed under the GNU General Public License version 2
# or later (GPLv2+) WITHOUT ANY WARRANTY.
Expand All @@ -9,7 +9,8 @@ MAINTAINERCLEANFILES = Makefile.in

headerdir=$(pkgincludedir)/crm/common

header_HEADERS = xml.h ipc.h util.h iso8601.h mainloop.h logging.h
header_HEADERS = xml.h ipc.h util.h iso8601.h mainloop.h logging.h \
nvpair.h
noinst_HEADERS = ipcs.h internal.h remote_internal.h xml_internal.h
if BUILD_CIBSECRETS
noinst_HEADERS += cib_secrets.h
Expand Down
24 changes: 3 additions & 21 deletions include/crm/common/alerts_internal.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
/*
* Copyright (C) 2015 Andrew Beekhof <andrew@beekhof.net>
* Copyright 2015-2019 Andrew Beekhof <andrew@beekhof.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This software 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 Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/

#ifndef ALERT_INTERNAL_H
Expand All @@ -28,11 +17,6 @@
/* Default-Format-String used to pass timestamps to the alerts scripts */
# define CRM_ALERT_DEFAULT_TSTAMP_FORMAT "%H:%M:%S.%06N"

typedef struct {
char *name;
char *value;
} crm_alert_envvar_t;

enum crm_alert_flags {
crm_alert_none = 0x0000,
crm_alert_node = 0x0001,
Expand Down Expand Up @@ -80,10 +64,8 @@ enum crm_alert_keys_e {
extern const char *crm_alert_keys[CRM_ALERT_INTERNAL_KEY_MAX][3];

crm_alert_entry_t *crm_dup_alert_entry(crm_alert_entry_t *entry);
crm_alert_envvar_t *crm_dup_alert_envvar(crm_alert_envvar_t *src);
crm_alert_entry_t *crm_alert_entry_new(const char *id, const char *path);
void crm_free_alert_entry(crm_alert_entry_t *entry);
void crm_free_alert_envvar(crm_alert_envvar_t *entry);
void crm_insert_alert_key(GHashTable *table, enum crm_alert_keys_e name,
const char *value);
void crm_insert_alert_key_int(GHashTable *table, enum crm_alert_keys_e name,
Expand Down
98 changes: 98 additions & 0 deletions include/crm/common/nvpair.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 2004-2019 Andrew Beekhof <andrew@beekhof.net>
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/

#ifndef CRM_COMMON_NVPAIR__H
# define CRM_COMMON_NVPAIR__H

# ifdef __cplusplus
extern "C" {
# endif

/**
* \file
* \brief Functionality for manipulating name/value pairs
* \ingroup core
*/

# include <sys/time.h> // struct timeval
# include <glib.h> // gpointer, gboolean, guint
# include <libxml/tree.h> // xmlNode
# include <crm/crm.h>

typedef struct pcmk_nvpair_s {
char *name;
char *value;
} pcmk_nvpair_t;

GSList *pcmk_prepend_nvpair(GSList *nvpairs, const char *name, const char *value);
void pcmk_free_nvpairs(GSList *nvpairs);
GSList *pcmk_sort_nvpairs(GSList *list);
GSList *pcmk_xml_attrs2nvpairs(xmlNode *xml);
void pcmk_nvpairs2xml_attrs(GSList *list, xmlNode *xml);

xmlNode *crm_create_nvpair_xml(xmlNode *parent, const char *id,
const char *name, const char *value);
void hash2nvpair(gpointer key, gpointer value, gpointer user_data);
void hash2field(gpointer key, gpointer value, gpointer user_data);
void hash2metafield(gpointer key, gpointer value, gpointer user_data);
void hash2smartfield(gpointer key, gpointer value, gpointer user_data);
GHashTable *xml2list(xmlNode *parent);

const char *crm_xml_add(xmlNode *node, const char *name, const char *value);
const char *crm_xml_replace(xmlNode *node, const char *name, const char *value);
const char *crm_xml_add_int(xmlNode *node, const char *name, int value);
const char *crm_xml_add_ms(xmlNode *node, const char *name, guint ms);

const char *crm_element_value(const xmlNode *data, const char *name);
int crm_element_value_int(const xmlNode *data, const char *name, int *dest);
int crm_element_value_const_int(const xmlNode *data, const char *name, int *dest);
const char *crm_element_value_const(const xmlNode *data, const char *name);
int crm_element_value_timeval(const xmlNode *data, const char *name_sec,
const char *name_usec, struct timeval *dest);
char *crm_element_value_copy(const xmlNode *data, const char *name);

/*!
* \brief Copy an element from one XML object to another
*
* \param[in] obj1 Source XML
* \param[in,out] obj2 Destination XML
* \param[in] element Name of element to copy
*
* \return Pointer to copied value (from source)
*/
static inline const char *
crm_copy_xml_element(xmlNode *obj1, xmlNode *obj2, const char *element)
{
const char *value = crm_element_value(obj1, element);

crm_xml_add(obj2, element, value);
return value;
}

/*!
* \brief Add a boolean attribute to an XML object
*
* Add an attribute with the value \c XML_BOOLEAN_TRUE or \c XML_BOOLEAN_FALSE
* as appropriate to an XML object.
*
* \param[in,out] node XML object to add attribute to
* \param[in] name Name of attribute to add
* \param[in] value Boolean whose value will be tested
*
* \return Pointer to newly created XML attribute's content, or \c NULL on error
*/
static inline const char *
crm_xml_add_boolean(xmlNode *node, const char *name, gboolean value)
{
return crm_xml_add(node, name, (value? "true" : "false"));
}

# ifdef __cplusplus
}
# endif

#endif // CRM_COMMON_NVPAIR__H
79 changes: 5 additions & 74 deletions include/crm/common/xml.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2018 Andrew Beekhof <andrew@beekhof.net>
* Copyright 2004-2019 Andrew Beekhof <andrew@beekhof.net>
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
Expand All @@ -22,11 +22,12 @@
# include <errno.h>
# include <fcntl.h>

# include <crm/crm.h>

# include <libxml/tree.h>
# include <libxml/xpath.h>

# include <crm/crm.h>
# include <crm/common/nvpair.h>

/* Define compression parameters for IPC messages
*
* Compression costs a LOT, so we don't want to do it unless we're hitting
Expand All @@ -43,15 +44,6 @@

gboolean add_message_xml(xmlNode * msg, const char *field, xmlNode * xml);
xmlNode *get_message_xml(xmlNode * msg, const char *field);
GHashTable *xml2list(xmlNode * parent);

xmlNode *crm_create_nvpair_xml(xmlNode *parent, const char *id,
const char *name, const char *value);

void hash2nvpair(gpointer key, gpointer value, gpointer user_data);
void hash2field(gpointer key, gpointer value, gpointer user_data);
void hash2metafield(gpointer key, gpointer value, gpointer user_data);
void hash2smartfield(gpointer key, gpointer value, gpointer user_data);

xmlDoc *getDocPtr(xmlNode * node);

Expand All @@ -77,41 +69,6 @@ void fix_plus_plus_recursive(xmlNode * target);
*/
xmlNode *create_xml_node(xmlNode * parent, const char *name);

/*
* Make a copy of name and value and use the copied memory to create
* an attribute for node.
*
* If node, name or value are NULL, nothing is done.
*
* If name or value are an empty string, nothing is done.
*
* Returns FALSE on failure and TRUE on success.
*
*/
const char *crm_xml_add(xmlNode * node, const char *name, const char *value);

const char *crm_xml_replace(xmlNode * node, const char *name, const char *value);

const char *crm_xml_add_int(xmlNode * node, const char *name, int value);

/*!
* \brief Add a boolean attribute to an XML object
*
* Add an attribute with the value XML_BOOLEAN_TRUE or XML_BOOLEAN_FALSE
* as appropriate to an XML object.
*
* \param[in,out] node XML object to add attribute to
* \param[in] name Name of attribute to add
* \param[in] value Boolean whose value will be tested
*
* \return Pointer to newly created XML attribute's content, or NULL on error
*/
static inline const char *
crm_xml_add_boolean(xmlNode *node, const char *name, gboolean value)
{
return crm_xml_add(node, name, (value? "true" : "false"));
}

/*
* Unlink the node and set its doc pointer to NULL so free_xml()
* will act appropriately
Expand Down Expand Up @@ -188,41 +145,15 @@ int find_xml_children(xmlNode ** children, xmlNode * root,
const char *tag, const char *field, const char *value,
gboolean search_matches);

int crm_element_value_int(xmlNode * data, const char *name, int *dest);
int crm_element_value_timeval(xmlNode *data, const char *name_sec,
const char *name_usec, struct timeval *dest);
char *crm_element_value_copy(xmlNode * data, const char *name);
int crm_element_value_const_int(const xmlNode * data, const char *name, int *dest);
const char *crm_element_value_const(const xmlNode * data, const char *name);
xmlNode *get_xpath_object(const char *xpath, xmlNode * xml_obj, int error_level);
xmlNode *get_xpath_object_relative(const char *xpath, xmlNode * xml_obj, int error_level);

static inline const char *
crm_element_name(xmlNode *xml)
crm_element_name(const xmlNode *xml)
{
return xml? (const char *)(xml->name) : NULL;
}

const char *crm_element_value(xmlNode * data, const char *name);

/*!
* \brief Copy an element from one XML object to another
*
* \param[in] obj1 Source XML
* \param[in,out] obj2 Destination XML
* \param[in] element Name of element to copy
*
* \return Pointer to copied value (from source)
*/
static inline const char *
crm_copy_xml_element(xmlNode *obj1, xmlNode *obj2, const char *element)
{
const char *value = crm_element_value(obj1, element);

crm_xml_add(obj2, element, value);
return value;
}

void xml_validate(const xmlNode * root);

gboolean xml_has_children(const xmlNode * root);
Expand Down
4 changes: 2 additions & 2 deletions include/crm/pengine/internal.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2018 Andrew Beekhof <andrew@beekhof.net>
* Copyright 2004-2019 Andrew Beekhof <andrew@beekhof.net>
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
Expand Down Expand Up @@ -46,7 +46,7 @@ typedef struct pe__order_constraint_s {
} pe__ordering_t;

typedef struct notify_data_s {
GHashTable *keys;
GSList *keys; // Environment variable name/value pairs

const char *action;

Expand Down
4 changes: 2 additions & 2 deletions lib/common/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2004 Andrew Beekhof
# Copyright 2004-2019 Andrew Beekhof <andrew@beekhof.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -42,7 +42,7 @@ libcrmcommon_la_LIBADD = @LIBADD_DL@ $(GNUTLSLIBS)
libcrmcommon_la_SOURCES = compat.c digest.c ipc.c io.c procfs.c utils.c xml.c \
iso8601.c remote.c mainloop.c logging.c watchdog.c \
schemas.c strings.c xpath.c attrd_client.c alerts.c \
operations.c acl.c agents.c
operations.c acl.c agents.c nvpair.c
if BUILD_CIBSECRETS
libcrmcommon_la_SOURCES += cib_secrets.c
endif
Expand Down
21 changes: 1 addition & 20 deletions lib/common/alerts.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 Andrew Beekhof <andrew@beekhof.net>
* Copyright 2015-2019 Andrew Beekhof <andrew@beekhof.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
Expand Down Expand Up @@ -47,14 +47,6 @@ const char *crm_alert_keys[CRM_ALERT_INTERNAL_KEY_MAX][3] =
[CRM_alert_attribute_value] = {"CRM_notify_attribute_value", "CRM_alert_attribute_value", NULL}
};

void
crm_free_alert_envvar(crm_alert_envvar_t *entry)
{
free(entry->name);
free(entry->value);
free(entry);
}

/*!
* \brief Create a new alert entry structure
*
Expand Down Expand Up @@ -96,17 +88,6 @@ crm_free_alert_entry(crm_alert_entry_t *entry)
}
}

crm_alert_envvar_t *
crm_dup_alert_envvar(crm_alert_envvar_t *src)
{
crm_alert_envvar_t *dst = calloc(1, sizeof(crm_alert_envvar_t));

CRM_ASSERT(dst);
dst->name = strdup(src->name);
dst->value = src->value?strdup(src->value):NULL;
return dst;
}

/*!
* \internal
* \brief Duplicate an alert entry
Expand Down
18 changes: 17 additions & 1 deletion lib/common/crmcommon_private.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Andrew Beekhof <andrew@beekhof.net>
* Copyright 2018-2019 Andrew Beekhof <andrew@beekhof.net>
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
Expand Down Expand Up @@ -68,4 +68,20 @@ void pcmk__apply_acl(xmlNode *xml);
G_GNUC_INTERNAL
void pcmk__post_process_acl(xmlNode *xml);

G_GNUC_INTERNAL
void pcmk__mark_xml_attr_dirty(xmlAttr *a);

static inline xmlAttr *
pcmk__first_xml_attr(const xmlNode *xml)
{
return xml? xml->properties : NULL;
}

static inline const char *
pcmk__xml_attr_value(const xmlAttr *attr)
{
return ((attr == NULL) || (attr->children == NULL))? NULL
: (const char *) attr->children->content;
}

#endif // CRMCOMMON_PRIVATE__H
Loading

0 comments on commit 4601a8f

Please sign in to comment.