Permalink
Browse files

Merge branch 'master' of github.com:ClusterLabs/pacemaker

  • Loading branch information...
beekhof committed Mar 23, 2017
2 parents 99502d1 + 2c5bb2f commit 3bcff57ad4a6088ff04b2fad1675ef42267bbb5a
View
@@ -408,11 +408,8 @@ crmd_remote_proxy_new(lrmd_t *lrmd, const char *node_name, const char *session_i
.dispatch = remote_proxy_dispatch,
.destroy = remote_proxy_disconnected
};
remote_proxy_t *proxy = remote_proxy_new(lrmd, proxy_callbacks, node_name, session_id, channel);
if (safe_str_eq(channel, CRM_SYSTEM_CRMD)) {
proxy->is_local = TRUE;
}
remote_proxy_t *proxy = remote_proxy_new(lrmd, &proxy_callbacks, node_name,
session_id, channel);
return proxy;
}
@@ -525,17 +522,23 @@ crmd_remote_proxy_cb(lrmd_t *lrmd, void *userdata, xmlNode *msg)
}
return;
} else if (safe_str_eq(op, LRMD_IPC_OP_REQUEST) && proxy->is_local) {
} else if (safe_str_eq(op, LRMD_IPC_OP_REQUEST) && proxy && proxy->is_local) {
/* this is for the crmd, which we are, so don't try
* and connect/send to ourselves over ipc. instead
* do it directly.
*/
int flags = 0;
xmlNode *request = get_message_xml(msg, F_LRMD_IPC_MSG);
CRM_CHECK(request != NULL, return);
#if ENABLE_ACL
CRM_CHECK(lrm_state->node_name, return);
crm_xml_add(request, XML_ACL_TAG_ROLE, "pacemaker-remote");
crm_acl_get_set_user(request, F_LRMD_IPC_USER, lrm_state->node_name);
#endif
crmd_proxy_dispatch(session, request);
crm_element_value_int(msg, F_LRMD_IPC_MSG_FLAGS, &flags);
crm_element_value_int(msg, F_LRMD_IPC_MSG_FLAGS, &flags);
if (flags & crm_ipc_client_response) {
int msg_id = 0;
xmlNode *op_reply = create_xml_node(NULL, "ack");
View
@@ -710,7 +710,6 @@ static void cib_device_update(resource_t *rsc, pe_working_set_t *data_set)
}
extern xmlNode *do_calculations(pe_working_set_t * data_set, xmlNode * xml_input, crm_time_t * now);
extern node_t *create_node(const char *id, const char *uname, const char *type, const char *score, pe_working_set_t * data_set);
/*!
* \internal
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef CRM_COMMON_ISO8601_INTERNAL
# define CRM_COMMON_ISO8601_INTERNAL
#include <time.h>
#include <sys/time.h>
#include <ctype.h>
@@ -42,3 +44,4 @@ struct crm_time_us {
bool duration;
int useconds;
};
#endif
@@ -286,7 +286,8 @@ void print_rscs_brief(GListPtr rsc_list, const char * pre_text, long options,
void * print_data, gboolean print_all);
void pe_fence_node(pe_working_set_t * data_set, node_t * node, const char *reason);
node_t *create_node(const char *id, const char *uname, const char *type, const char *score, pe_working_set_t * data_set);
node_t *pe_create_node(const char *id, const char *uname, const char *type,
const char *score, pe_working_set_t * data_set);
bool remote_id_conflict(const char *remote_name, pe_working_set_t *data);
void common_print(resource_t * rsc, const char *pre_text, const char *name, node_t *node, long options, void *print_data);
resource_t *find_container_child(const char *stem, resource_t * rsc, node_t *node);
View
@@ -162,10 +162,6 @@ crm_clear_bit(const char *function, int line, const char *target, long long word
{
long long rc = (word & ~bit);
/* if(bit == 0x00002) { */
/* crm_err("Bit 0x%.8llx for %s cleared by %s:%d", bit, target, function, line); */
/* } */
if (rc == word) {
/* Unchanged */
} else if (target) {
@@ -182,10 +178,6 @@ crm_set_bit(const char *function, int line, const char *target, long long word,
{
long long rc = (word | bit);
/* if(bit == 0x00002) { */
/* crm_err("Bit 0x%.8llx for %s set by %s:%d", bit, target, function, line); */
/* } */
if (rc == word) {
/* Unchanged */
} else if (target) {
@@ -380,7 +372,7 @@ typedef struct remote_proxy_s {
} remote_proxy_t;
remote_proxy_t *remote_proxy_new(
lrmd_t *lrmd, struct ipc_client_callbacks proxy_callbacks,
lrmd_t *lrmd, struct ipc_client_callbacks *proxy_callbacks,
const char *node_name, const char *session_id, const char *channel);
int remote_proxy_check(lrmd_t *lrmd, GHashTable *hash);
View
@@ -17,8 +17,7 @@
#
include $(top_srcdir)/Makefile.common
AM_CPPFLAGS += -I$(top_builddir)/lib/gnu -I$(top_srcdir)/lib/gnu \
-DSBINDIR=\"$(sbindir)\"
AM_CPPFLAGS += -I$(top_builddir)/lib/gnu -I$(top_srcdir)/lib/gnu
## libraries
lib_LTLIBRARIES = libcrmcommon.la
View
@@ -216,7 +216,7 @@ pcmk_locate_sbd(void)
/* Look for the pid file */
pidfile = crm_strdup_printf("%s/sbd.pid", HA_STATE_DIR);
sbd_path = crm_strdup_printf("%s/sbd", SBINDIR);
sbd_path = crm_strdup_printf("%s/sbd", SBIN_DIR);
/* Read the pid file */
CRM_ASSERT(pidfile);
View
@@ -172,7 +172,7 @@ remote_proxy_disconnected(gpointer userdata)
}
remote_proxy_t *
remote_proxy_new(lrmd_t *lrmd, struct ipc_client_callbacks proxy_callbacks,
remote_proxy_new(lrmd_t *lrmd, struct ipc_client_callbacks *proxy_callbacks,
const char *node_name, const char *session_id, const char *channel)
{
remote_proxy_t *proxy = NULL;
@@ -187,15 +187,21 @@ remote_proxy_new(lrmd_t *lrmd, struct ipc_client_callbacks proxy_callbacks,
proxy->node_name = strdup(node_name);
proxy->session_id = strdup(session_id);
proxy->source = mainloop_add_ipc_client(channel, G_PRIORITY_LOW, 0, proxy, &proxy_callbacks);
proxy->ipc = mainloop_get_ipc_client(proxy->source);
proxy->lrm = lrmd;
if (proxy->source == NULL) {
remote_proxy_free(proxy);
remote_proxy_notify_destroy(lrmd, session_id);
return NULL;
if (safe_str_eq(crm_system_name, CRM_SYSTEM_CRMD)
&& safe_str_eq(channel, CRM_SYSTEM_CRMD)) {
/* The crmd doesn't need to connect to itself */
proxy->is_local = TRUE;
} else {
proxy->source = mainloop_add_ipc_client(channel, G_PRIORITY_LOW, 0, proxy, proxy_callbacks);
proxy->ipc = mainloop_get_ipc_client(proxy->source);
if (proxy->source == NULL) {
remote_proxy_free(proxy);
remote_proxy_notify_destroy(lrmd, session_id);
return NULL;
}
}
crm_trace("new remote proxy client established to %s on %s, session id %s",
@@ -237,7 +243,13 @@ remote_proxy_cb(lrmd_t *lrmd, const char *node_name, xmlNode *msg)
/* proxy connection no longer exists */
remote_proxy_notify_destroy(lrmd, session);
return;
} else if ((proxy->is_local == FALSE) && (crm_ipc_connected(proxy->ipc) == FALSE)) {
}
/* crmd requests MUST be handled by the crmd, not us */
CRM_CHECK(proxy->is_local == FALSE,
remote_proxy_end_session(proxy); return);
if (crm_ipc_connected(proxy->ipc) == FALSE) {
remote_proxy_end_session(proxy);
return;
}
View
@@ -32,20 +32,28 @@ void tuple_free(container_grouping_t *tuple);
static char *
next_ip(const char *last_ip)
{
int oct1 = 0;
int oct2 = 0;
int oct3 = 0;
int oct4 = 0;
unsigned int oct1 = 0;
unsigned int oct2 = 0;
unsigned int oct3 = 0;
unsigned int oct4 = 0;
int rc = sscanf(last_ip, "%u.%u.%u.%u", &oct1, &oct2, &oct3, &oct4);
int rc = sscanf(last_ip, "%d.%d.%d.%d", &oct1, &oct2, &oct3, &oct4);
if (rc != 4) {
/*@ TODO check for IPv6 */
return NULL;
} else if(oct4 > 255) {
} else if (oct3 > 253) {
return NULL;
} else if (oct4 > 253) {
++oct3;
oct4 = 1;
} else {
++oct4;
}
return crm_strdup_printf("%d.%d.%d.%d", oct1, oct2, oct3, oct4+1);
return crm_strdup_printf("%u.%u.%u.%u", oct1, oct2, oct3, oct4);
}
static int
@@ -80,29 +88,27 @@ create_resource(const char *name, const char *provider, const char *kind)
crm_xml_add(rsc, XML_ATTR_ID, name);
crm_xml_add(rsc, XML_AGENT_ATTR_CLASS, "ocf");
crm_xml_add(rsc, XML_AGENT_ATTR_PROVIDER, provider);
crm_xml_add(rsc, "type", kind);
crm_xml_add(rsc, XML_ATTR_TYPE, kind);
return rsc;
}
static void
create_nvp(xmlNode *parent, const char *name, const char *value)
{
char *id = crm_strdup_printf("%s-%s", ID(parent), name);
xmlNode *xml_nvp = create_xml_node(parent, XML_CIB_TAG_NVPAIR);
crm_xml_add(xml_nvp, XML_ATTR_ID, id); free(id);
crm_xml_set_id(xml_nvp, "%s-%s", ID(parent), name);
crm_xml_add(xml_nvp, XML_NVPAIR_ATTR_NAME, name);
crm_xml_add(xml_nvp, XML_NVPAIR_ATTR_VALUE, value);
}
static void
create_op(xmlNode *parent, const char *prefix, const char *task, const char *interval)
{
char *id = crm_strdup_printf("%s-%s-%s", prefix, task, interval);
xmlNode *xml_op = create_xml_node(parent, "op");
crm_xml_add(xml_op, XML_ATTR_ID, id); free(id);
crm_xml_set_id(xml_op, "%s-%s-%s", prefix, task, interval);
crm_xml_add(xml_op, XML_LRM_ATTR_INTERVAL, interval);
crm_xml_add(xml_op, "name", task);
}
@@ -129,13 +135,17 @@ create_ip_resource(
pe_working_set_t * data_set)
{
if(data->ip_range_start) {
char *id = crm_strdup_printf("%s-ip-%s", data->prefix, tuple->ipaddr);
xmlNode *xml_ip = create_resource(id, "heartbeat", "IPaddr2");
char *id = NULL;
xmlNode *xml_ip = NULL;
xmlNode *xml_obj = NULL;
id = crm_strdup_printf("%s-attributes-%d", data->prefix, tuple->offset);
id = crm_strdup_printf("%s-ip-%s", data->prefix, tuple->ipaddr);
crm_xml_sanitize_id(id);
xml_ip = create_resource(id, "heartbeat", "IPaddr2");
free(id);
xml_obj = create_xml_node(xml_ip, XML_TAG_ATTR_SETS);
crm_xml_add(xml_obj, XML_ATTR_ID, id); free(id);
crm_xml_set_id(xml_obj, "%s-attributes-%d", data->prefix, tuple->offset);
create_nvp(xml_obj, "ip", tuple->ipaddr);
if(data->host_network) {
@@ -174,13 +184,17 @@ create_docker_resource(
int doffset = 0, dmax = 1024;
char *dbuffer = calloc(1, dmax+1);
char *id = crm_strdup_printf("%s-docker-%d", data->prefix, tuple->offset);
xmlNode *xml_docker = create_resource(id, "heartbeat", "docker");
char *id = NULL;
xmlNode *xml_docker = NULL;
xmlNode *xml_obj = NULL;
id = crm_strdup_printf("%s-attributes-%d", data->prefix, tuple->offset);
id = crm_strdup_printf("%s-docker-%d", data->prefix, tuple->offset);
crm_xml_sanitize_id(id);
xml_docker = create_resource(id, "heartbeat", "docker");
free(id);
xml_obj = create_xml_node(xml_docker, XML_TAG_ATTR_SETS);
crm_xml_add(xml_obj, XML_ATTR_ID, id); free(id);
crm_xml_set_id(xml_obj, "%s-attributes-%d", data->prefix, tuple->offset);
create_nvp(xml_obj, "image", data->image);
create_nvp(xml_obj, "allow_pull", "true");
@@ -207,6 +221,7 @@ create_docker_resource(
}
doffset += snprintf(dbuffer+doffset, dmax-doffset, "%s", source);
offset += snprintf(buffer+offset, max-offset, " -v %s:%s", source, mount->target);
free(source);
} else {
offset += snprintf(buffer+offset, max-offset, " -v %s:%s", mount->source, mount->target);
@@ -303,22 +318,24 @@ create_remote_resource(
xmlNode *xml_obj = NULL;
xmlNode *xml_remote = NULL;
char *nodeid = crm_strdup_printf("%s-%d", data->prefix, tuple->offset);
char *id = strdup(nodeid);
char *id = NULL;
if(remote_id_conflict(id, data_set)) {
if (remote_id_conflict(nodeid, data_set)) {
// The biggest hammer we have
id = crm_strdup_printf("pcmk-internal-%s-remote-%d", tuple->child->id, tuple->offset);
CRM_ASSERT(remote_id_conflict(id, data_set) == FALSE);
} else {
id = strdup(nodeid);
}
CRM_ASSERT(remote_id_conflict(id, data_set) == FALSE);
xml_remote = create_resource(id, "pacemaker", "remote");
free(id);
xml_obj = create_xml_node(xml_remote, "operations");
create_op(xml_obj, ID(xml_remote), "monitor", "60s");
id = crm_strdup_printf("%s-attributes-%d", data->prefix, tuple->offset);
xml_obj = create_xml_node(xml_remote, XML_TAG_ATTR_SETS);
crm_xml_add(xml_obj, XML_ATTR_ID, id); free(id);
crm_xml_set_id(xml_obj, "%s-attributes-%d", data->prefix, tuple->offset);
if(tuple->ipaddr) {
create_nvp(xml_obj, "addr", tuple->ipaddr);
@@ -332,9 +349,8 @@ create_remote_resource(
create_nvp(xml_obj, "port", crm_itoa(DEFAULT_REMOTE_PORT));
}
id = crm_strdup_printf("%s-meta-%d", data->prefix, tuple->offset);
xml_obj = create_xml_node(xml_remote, XML_TAG_META_SETS);
crm_xml_add(xml_obj, XML_ATTR_ID, id); free(id);
crm_xml_set_id(xml_obj, "%s-meta-%d", data->prefix, tuple->offset);
create_nvp(xml_obj, XML_OP_ATTR_ALLOW_MIGRATE, "false");
@@ -347,7 +363,8 @@ create_remote_resource(
// tuple->docker->fillers = g_list_append(tuple->docker->fillers, child);
// -INFINITY prevents anyone else from running here
node = create_node(strdup(nodeid), nodeid, "remote", "-INFINITY", data_set);
node = pe_create_node(strdup(nodeid), nodeid, "remote", "-INFINITY",
data_set);
tuple->node = node_copy(node);
tuple->node->weight = 500;
nodeid = NULL;
@@ -496,13 +513,10 @@ container_unpack(resource_t * rsc, pe_working_set_t * data_set)
xml_resource = create_xml_node(NULL, XML_CIB_TAG_INCARNATION);
}
value = crm_strdup_printf("%s-%s", container_data->prefix, xml_resource->name);
crm_xml_add(xml_resource, XML_ATTR_ID, value);
free(value);
crm_xml_set_id(xml_resource, "%s-%s", container_data->prefix, xml_resource->name);
value = crm_strdup_printf("%s-%s-meta", container_data->prefix, xml_resource->name);
xml_set = create_xml_node(xml_resource, XML_TAG_META_SETS);
free(value);
crm_xml_set_id(xml_resource, "%s-%s-meta", container_data->prefix, xml_resource->name);
create_nvp(xml_set, XML_RSC_ATTR_ORDERED, "true");
Oops, something went wrong.

0 comments on commit 3bcff57

Please sign in to comment.