21 #define PE__VARIANT_BUNDLE 1
25 next_ip(
const char *last_ip)
27 unsigned int oct1 = 0;
28 unsigned int oct2 = 0;
29 unsigned int oct3 = 0;
30 unsigned int oct4 = 0;
31 int rc = sscanf(last_ip,
"%u.%u.%u.%u", &oct1, &oct2, &oct3, &oct4);
37 }
else if (oct3 > 253) {
40 }
else if (oct4 > 253) {
52 allocate_ip(pe__bundle_variant_data_t *
data, pe__bundle_replica_t *replica,
53 char *buffer,
int max)
55 if(data->ip_range_start == NULL) {
58 }
else if(data->ip_last) {
59 replica->ipaddr = next_ip(data->ip_last);
62 replica->ipaddr = strdup(data->ip_range_start);
65 data->ip_last = replica->ipaddr;
66 switch (data->agent_type) {
67 case PE__CONTAINER_AGENT_DOCKER:
68 case PE__CONTAINER_AGENT_PODMAN:
70 return snprintf(buffer, max,
" --add-host=%s-%d:%s",
71 data->prefix, replica->offset,
74 case PE__CONTAINER_AGENT_RKT:
75 return snprintf(buffer, max,
" --hosts-entry=%s=%s-%d",
76 replica->ipaddr, data->prefix, replica->offset);
84 create_resource(
const char *
name,
const char *provider,
const char *kind)
109 valid_network(pe__bundle_variant_data_t *data)
111 if(data->ip_range_start) {
114 if(data->control_port) {
115 if(data->nreplicas_per_host > 1) {
116 pe_err(
"Specifying the 'control-port' for %s requires 'replicas-per-host=1'", data->prefix);
117 data->nreplicas_per_host = 1;
126 create_ip_resource(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
129 if(data->ip_range_start) {
131 xmlNode *xml_ip = NULL;
132 xmlNode *xml_obj = NULL;
136 xml_ip = create_resource(
id,
"heartbeat",
"IPaddr2");
141 data->prefix, replica->offset);
144 if(data->host_network) {
148 if(data->host_netmask) {
150 "cidr_netmask", data->host_netmask);
161 if (!
common_unpack(xml_ip, &replica->ip, parent, data_set)) {
171 create_docker_resource(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
172 pe__bundle_replica_t *replica,
175 int offset = 0, max = 4096;
176 char *buffer = calloc(1, max+1);
178 int doffset = 0, dmax = 1024;
179 char *dbuffer = calloc(1, dmax+1);
182 xmlNode *xml_container = NULL;
183 xmlNode *xml_obj = NULL;
187 xml_container = create_resource(
id,
"heartbeat",
188 PE__CONTAINER_AGENT_DOCKER_S);
193 data->prefix, replica->offset);
200 offset += snprintf(buffer+offset, max-offset,
" --restart=no");
207 if (data->ip_range_start != NULL) {
208 offset += snprintf(buffer+offset, max-offset,
" -h %s-%d",
209 data->prefix, replica->offset);
212 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_stderr=1");
214 if (data->container_network) {
216 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
219 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
220 data->container_network);
223 if(data->control_port) {
224 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%s", data->control_port);
226 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
229 for(GList *pIter = data->mounts; pIter != NULL; pIter = pIter->next) {
230 pe__bundle_mount_t *mount = pIter->data;
232 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
234 "%s/%s-%d", mount->source, data->prefix, replica->offset);
237 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
239 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
240 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", source, mount->target);
244 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", mount->source, mount->target);
247 offset += snprintf(buffer+offset, max-offset,
":%s", mount->options);
251 for(GList *pIter = data->ports; pIter != NULL; pIter = pIter->next) {
252 pe__bundle_port_t *port = pIter->data;
254 if (replica->ipaddr) {
255 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s:%s",
256 replica->ipaddr, port->source,
258 }
else if(!pcmk__str_eq(data->container_network,
"host",
pcmk__str_casei)) {
260 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s", port->source, port->target);
264 if (data->launcher_options) {
265 offset += snprintf(buffer+offset, max-offset,
" %s",
266 data->launcher_options);
269 if (data->container_host_options) {
270 offset += snprintf(buffer + offset, max - offset,
" %s",
271 data->container_host_options);
280 if (replica->child) {
281 if (data->container_command) {
283 "run_cmd", data->container_command);
286 "run_cmd",
SBIN_DIR "/pacemaker-remoted");
302 }
else if ((child != NULL) && data->untrusted) {
309 if (data->container_command) {
311 "run_cmd", data->container_command);
327 if (!
common_unpack(xml_container, &replica->container, parent, data_set)) {
335 create_podman_resource(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
336 pe__bundle_replica_t *replica,
339 int offset = 0, max = 4096;
340 char *buffer = calloc(1, max+1);
342 int doffset = 0, dmax = 1024;
343 char *dbuffer = calloc(1, dmax+1);
346 xmlNode *xml_container = NULL;
347 xmlNode *xml_obj = NULL;
351 xml_container = create_resource(
id,
"heartbeat",
352 PE__CONTAINER_AGENT_PODMAN_S);
357 data->prefix, replica->offset);
372 if (data->ip_range_start != NULL) {
373 offset += snprintf(buffer+offset, max-offset,
" -h %s-%d",
374 data->prefix, replica->offset);
377 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_stderr=1");
379 if (data->container_network) {
382 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
385 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
386 data->container_network);
389 if(data->control_port) {
390 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%s", data->control_port);
392 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
395 for(GList *pIter = data->mounts; pIter != NULL; pIter = pIter->next) {
396 pe__bundle_mount_t *mount = pIter->data;
398 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
400 "%s/%s-%d", mount->source, data->prefix, replica->offset);
403 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
405 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
406 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", source, mount->target);
410 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", mount->source, mount->target);
413 offset += snprintf(buffer+offset, max-offset,
":%s", mount->options);
417 for(GList *pIter = data->ports; pIter != NULL; pIter = pIter->next) {
418 pe__bundle_port_t *port = pIter->data;
420 if (replica->ipaddr) {
421 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s:%s",
422 replica->ipaddr, port->source,
424 }
else if(!pcmk__str_eq(data->container_network,
"host",
pcmk__str_casei)) {
426 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s", port->source, port->target);
430 if (data->launcher_options) {
431 offset += snprintf(buffer+offset, max-offset,
" %s",
432 data->launcher_options);
435 if (data->container_host_options) {
436 offset += snprintf(buffer + offset, max - offset,
" %s",
437 data->container_host_options);
446 if (replica->child) {
447 if (data->container_command) {
449 "run_cmd", data->container_command);
452 "run_cmd",
SBIN_DIR "/pacemaker-remoted");
468 }
else if ((child != NULL) && data->untrusted) {
475 if (data->container_command) {
477 "run_cmd", data->container_command);
493 if (!
common_unpack(xml_container, &replica->container, parent,
502 create_rkt_resource(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
505 int offset = 0, max = 4096;
506 char *buffer = calloc(1, max+1);
508 int doffset = 0, dmax = 1024;
509 char *dbuffer = calloc(1, dmax+1);
512 xmlNode *xml_container = NULL;
513 xmlNode *xml_obj = NULL;
519 xml_container = create_resource(
id,
"heartbeat",
520 PE__CONTAINER_AGENT_RKT_S);
525 data->prefix, replica->offset);
537 if (data->ip_range_start != NULL) {
538 offset += snprintf(buffer+offset, max-offset,
" --hostname=%s-%d",
539 data->prefix, replica->offset);
542 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_stderr=1");
544 if (data->container_network) {
546 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
549 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
550 data->container_network);
553 if(data->control_port) {
554 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_remote_port=%s", data->control_port);
556 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
559 for(GList *pIter = data->mounts; pIter != NULL; pIter = pIter->next) {
560 pe__bundle_mount_t *mount = pIter->data;
562 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
564 "%s/%s-%d", mount->source, data->prefix, replica->offset);
567 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
569 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
570 offset += snprintf(buffer+offset, max-offset,
" --volume vol%d,kind=host,source=%s", volid, source);
572 offset += snprintf(buffer+offset, max-offset,
",%s", mount->options);
574 offset += snprintf(buffer+offset, max-offset,
" --mount volume=vol%d,target=%s", volid, mount->target);
578 offset += snprintf(buffer+offset, max-offset,
" --volume vol%d,kind=host,source=%s", volid, mount->source);
580 offset += snprintf(buffer+offset, max-offset,
",%s", mount->options);
582 offset += snprintf(buffer+offset, max-offset,
" --mount volume=vol%d,target=%s", volid, mount->target);
587 for(GList *pIter = data->ports; pIter != NULL; pIter = pIter->next) {
588 pe__bundle_port_t *port = pIter->data;
590 if (replica->ipaddr) {
591 offset += snprintf(buffer+offset, max-offset,
592 " --port=%s:%s:%s", port->target,
593 replica->ipaddr, port->source);
595 offset += snprintf(buffer+offset, max-offset,
" --port=%s:%s", port->target, port->source);
599 if (data->launcher_options) {
600 offset += snprintf(buffer+offset, max-offset,
" %s",
601 data->launcher_options);
604 if (data->container_host_options) {
605 offset += snprintf(buffer + offset, max - offset,
" %s",
606 data->container_host_options);
615 if (replica->child) {
616 if (data->container_command) {
618 data->container_command);
637 }
else if ((child != NULL) && data->untrusted) {
644 if (data->container_command) {
646 data->container_command);
663 if (!
common_unpack(xml_container, &replica->container, parent, data_set)) {
679 gpointer match = g_hash_table_lookup(rsc->
allowed_nodes, uname);
688 for (child = rsc->
children; child != NULL; child = child->next) {
695 create_remote_resource(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
696 pe__bundle_replica_t *replica,
699 if (replica->child && valid_network(data)) {
700 GHashTableIter gIter;
701 GList *rsc_iter = NULL;
703 xmlNode *xml_remote = NULL;
706 const char *uname = NULL;
707 const char *connect_name = NULL;
713 replica->child->id, replica->offset);
722 connect_name = (replica->ipaddr? replica->ipaddr :
"#uname");
724 if (data->control_port == NULL) {
735 connect_name, (data->control_port?
736 data->control_port : port_s));
745 uname =
ID(xml_remote);
777 for (rsc_iter = data_set->
resources; rsc_iter; rsc_iter = rsc_iter->next) {
782 replica->node->weight = 500;
786 if (replica->child->allowed_nodes != NULL) {
787 g_hash_table_destroy(replica->child->allowed_nodes);
790 g_hash_table_insert(replica->child->allowed_nodes,
791 (gpointer) replica->node->details->id,
797 g_hash_table_insert(replica->child->parent->allowed_nodes,
798 (gpointer) replica->node->details->id, copy);
800 if (!
common_unpack(xml_remote, &replica->remote, parent, data_set)) {
804 g_hash_table_iter_init(&gIter, replica->remote->allowed_nodes);
805 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&node)) {
812 replica->node->details->remote_rsc = replica->remote;
815 replica->remote->container = replica->container;
820 g_hash_table_insert(replica->node->details->attrs,
838 create_container(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
842 switch (data->agent_type) {
843 case PE__CONTAINER_AGENT_DOCKER:
844 if (!create_docker_resource(parent, data, replica, data_set)) {
849 case PE__CONTAINER_AGENT_PODMAN:
850 if (!create_podman_resource(parent, data, replica, data_set)) {
855 case PE__CONTAINER_AGENT_RKT:
856 if (!create_rkt_resource(parent, data, replica, data_set)) {
864 if (create_ip_resource(parent, data, replica, data_set) == FALSE) {
867 if(create_remote_resource(parent, data, replica, data_set) == FALSE) {
870 if (replica->child && replica->ipaddr) {
871 add_hash_param(replica->child->meta,
"external-ip", replica->ipaddr);
874 if (replica->remote) {
890 mount_add(pe__bundle_variant_data_t *bundle_data,
const char *source,
891 const char *
target,
const char *options, uint32_t
flags)
893 pe__bundle_mount_t *mount = calloc(1,
sizeof(pe__bundle_mount_t));
895 mount->source = strdup(source);
896 mount->target = strdup(target);
898 mount->options = strdup(options);
900 mount->flags =
flags;
901 bundle_data->mounts = g_list_append(bundle_data->mounts, mount);
905 mount_free(pe__bundle_mount_t *mount)
909 free(mount->options);
914 port_free(pe__bundle_port_t *port)
921 static pe__bundle_replica_t *
925 pe__bundle_variant_data_t *bundle_data = NULL;
931 while (top->
parent != NULL) {
935 get_bundle_variant_data(bundle_data, top);
936 for (GList *gIter = bundle_data->replicas; gIter != NULL;
937 gIter = gIter->next) {
938 pe__bundle_replica_t *replica = gIter->data;
940 if (replica->remote == remote) {
952 GHashTable *params = NULL;
968 xmlNode *xml,
const char *field)
973 pe__bundle_replica_t *replica = NULL;
979 replica = replica_for_remote(rsc);
980 if (replica == NULL) {
984 node = replica->container->allocated_to;
989 node = pe__current_node(replica->container);
993 crm_trace(
"Cannot determine address for bundle connection %s", rsc->
id);
997 crm_trace(
"Setting address for bundle connection %s to bundle host %s",
999 if(xml != NULL && field != NULL) {
1006 #define pe__set_bundle_mount_flags(mount_xml, flags, flags_to_set) do { \
1007 flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \
1008 "Bundle mount", ID(mount_xml), flags, \
1009 (flags_to_set), #flags_to_set); \
1015 const char *value = NULL;
1016 xmlNode *xml_obj = NULL;
1017 xmlNode *xml_resource = NULL;
1018 pe__bundle_variant_data_t *bundle_data = NULL;
1019 bool need_log_mount = TRUE;
1024 bundle_data = calloc(1,
sizeof(pe__bundle_variant_data_t));
1026 bundle_data->prefix = strdup(rsc->
id);
1029 if (xml_obj != NULL) {
1030 bundle_data->agent_type = PE__CONTAINER_AGENT_DOCKER;
1033 if (xml_obj != NULL) {
1034 bundle_data->agent_type = PE__CONTAINER_AGENT_RKT;
1037 if (xml_obj != NULL) {
1038 bundle_data->agent_type = PE__CONTAINER_AGENT_PODMAN;
1047 if (value == NULL) {
1055 if ((value == NULL) && (bundle_data->promoted_max > 0)) {
1056 bundle_data->nreplicas = bundle_data->promoted_max;
1068 if (bundle_data->nreplicas_per_host == 1) {
1086 bundle_data->add_host = TRUE;
1089 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
1090 xml_child = pcmk__xe_next(xml_child)) {
1092 pe__bundle_port_t *port = calloc(1,
sizeof(pe__bundle_port_t));
1095 if(port->source == NULL) {
1101 if(port->source != NULL && strlen(port->source) > 0) {
1102 if(port->target == NULL) {
1103 port->target = strdup(port->source);
1105 bundle_data->ports = g_list_append(bundle_data->ports, port);
1108 pe_err(
"Invalid port directive %s",
ID(xml_child));
1115 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
1116 xml_child = pcmk__xe_next(xml_child)) {
1121 int flags = pe__bundle_mount_none;
1123 if (source == NULL) {
1126 pe__bundle_mount_subdir);
1129 if (source && target) {
1130 mount_add(bundle_data, source, target, options, flags);
1131 if (strcmp(target,
"/var/log") == 0) {
1132 need_log_mount = FALSE;
1135 pe_err(
"Invalid mount directive %s",
ID(xml_child));
1140 if (xml_obj && valid_network(bundle_data)) {
1142 xmlNode *xml_set = NULL;
1151 (bundle_data->promoted_max?
"master"
1152 : (
const char *)xml_resource->name));
1155 crm_xml_set_id(xml_set,
"%s-%s-meta", bundle_data->prefix, xml_resource->name);
1160 value = pcmk__itoa(bundle_data->nreplicas);
1165 value = pcmk__itoa(bundle_data->nreplicas_per_host);
1171 pcmk__btoa(bundle_data->nreplicas_per_host > 1));
1173 if (bundle_data->promoted_max) {
1177 value = pcmk__itoa(bundle_data->promoted_max);
1186 }
else if(xml_obj) {
1187 pe_err(
"Cannot control %s inside %s without either ip-range-start or control-port",
1188 rsc->
id,
ID(xml_obj));
1194 GList *childIter = NULL;
1196 pe__bundle_port_t *port = NULL;
1198 int offset = 0, max = 1024;
1199 char *buffer = NULL;
1201 if (
common_unpack(xml_resource, &new_rsc, rsc, data_set) == FALSE) {
1202 pe_err(
"Failed unpacking resource %s",
ID(rsc->
xml));
1203 if (new_rsc != NULL && new_rsc->
fns != NULL) {
1209 bundle_data->child = new_rsc;
1235 if (need_log_mount) {
1237 pe__bundle_mount_subdir);
1240 port = calloc(1,
sizeof(pe__bundle_port_t));
1241 if(bundle_data->control_port) {
1242 port->source = strdup(bundle_data->control_port);
1254 port->target = strdup(port->source);
1255 bundle_data->ports = g_list_append(bundle_data->ports, port);
1257 buffer = calloc(1, max+1);
1258 for (childIter = bundle_data->child->children; childIter != NULL;
1259 childIter = childIter->next) {
1261 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1263 replica->child = childIter->data;
1264 replica->child->exclusive_discover = TRUE;
1265 replica->offset = lpc++;
1272 offset += allocate_ip(bundle_data, replica, buffer+offset,
1274 bundle_data->replicas = g_list_append(bundle_data->replicas,
1276 bundle_data->attribute_target = g_hash_table_lookup(replica->child->meta,
1279 bundle_data->container_host_options = buffer;
1280 if (bundle_data->attribute_target) {
1282 strdup(bundle_data->attribute_target));
1283 g_hash_table_replace(bundle_data->child->meta,
1285 strdup(bundle_data->attribute_target));
1290 int offset = 0, max = 1024;
1291 char *buffer = calloc(1, max+1);
1293 for (
int lpc = 0; lpc < bundle_data->nreplicas; lpc++) {
1294 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1296 replica->offset = lpc;
1297 offset += allocate_ip(bundle_data, replica, buffer+offset,
1299 bundle_data->replicas = g_list_append(bundle_data->replicas,
1302 bundle_data->container_host_options = buffer;
1305 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1306 gIter = gIter->next) {
1307 pe__bundle_replica_t *replica = gIter->data;
1309 if (!create_container(rsc, bundle_data, replica, data_set)) {
1310 pe_err(
"Failed unpacking resource %s", rsc->
id);
1316 if (bundle_data->child) {
1326 gboolean child_active = rsc->
fns->
active(rsc, all);
1328 if (child_active && !all) {
1330 }
else if (!child_active && all) {
1340 pe__bundle_variant_data_t *bundle_data = NULL;
1343 get_bundle_variant_data(bundle_data, rsc);
1344 for (iter = bundle_data->replicas; iter != NULL; iter = iter->next) {
1345 pe__bundle_replica_t *replica = iter->data;
1348 rsc_active = replica_resource_active(replica->ip, all);
1349 if (rsc_active >= 0) {
1350 return (gboolean) rsc_active;
1353 rsc_active = replica_resource_active(replica->child, all);
1354 if (rsc_active >= 0) {
1355 return (gboolean) rsc_active;
1358 rsc_active = replica_resource_active(replica->container, all);
1359 if (rsc_active >= 0) {
1360 return (gboolean) rsc_active;
1363 rsc_active = replica_resource_active(replica->remote, all);
1364 if (rsc_active >= 0) {
1365 return (gboolean) rsc_active;
1388 pe__bundle_variant_data_t *bundle_data = NULL;
1391 get_bundle_variant_data(bundle_data, bundle);
1392 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1393 gIter = gIter->next) {
1394 pe__bundle_replica_t *replica = gIter->data;
1397 if (replica->node->details == node->
details) {
1398 return replica->child;
1405 print_rsc_in_list(
pe_resource_t *rsc,
const char *pre_text,
long options,
1412 rsc->
fns->
print(rsc, pre_text, options, print_data);
1413 if (options & pe_print_html) {
1420 container_agent_str(
enum pe__container_agent t)
1423 case PE__CONTAINER_AGENT_DOCKER:
return PE__CONTAINER_AGENT_DOCKER_S;
1424 case PE__CONTAINER_AGENT_RKT:
return PE__CONTAINER_AGENT_RKT_S;
1425 case PE__CONTAINER_AGENT_PODMAN:
return PE__CONTAINER_AGENT_PODMAN_S;
1429 return PE__CONTAINER_AGENT_UNKNOWN_S;
1433 bundle_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
1436 pe__bundle_variant_data_t *bundle_data = NULL;
1437 char *child_text = NULL;
1440 if (pre_text == NULL) {
1445 get_bundle_variant_data(bundle_data, rsc);
1449 status_print(
"type=\"%s\" ", container_agent_str(bundle_data->agent_type));
1456 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1457 gIter = gIter->next) {
1458 pe__bundle_replica_t *replica = gIter->data;
1461 status_print(
"%s <replica id=\"%d\">\n", pre_text, replica->offset);
1462 print_rsc_in_list(replica->ip, child_text, options, print_data);
1463 print_rsc_in_list(replica->child, child_text, options, print_data);
1464 print_rsc_in_list(replica->container, child_text, options, print_data);
1465 print_rsc_in_list(replica->remote, child_text, options, print_data);
1472 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
1476 unsigned int options = va_arg(args,
unsigned int);
1478 GList *only_node = va_arg(args, GList *);
1479 GList *only_rsc = va_arg(args, GList *);
1481 pe__bundle_variant_data_t *bundle_data = NULL;
1483 gboolean printed_header = FALSE;
1484 gboolean print_everything = TRUE;
1488 get_bundle_variant_data(bundle_data, rsc);
1496 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1497 gIter = gIter->next) {
1498 pe__bundle_replica_t *replica = gIter->data;
1499 char *
id = pcmk__itoa(replica->offset);
1500 gboolean print_ip, print_child, print_ctnr, print_remote;
1508 print_ip = replica->ip != NULL &&
1509 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1510 print_child = replica->child != NULL &&
1511 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1512 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1513 print_remote = replica->remote != NULL &&
1514 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1516 if (!print_everything && !print_ip && !print_child && !print_ctnr && !print_remote) {
1520 if (!printed_header) {
1521 printed_header = TRUE;
1525 "type", container_agent_str(bundle_data->agent_type),
1526 "image", bundle_data->image,
1538 out->message(out, crm_map_element_name(replica->ip->xml), options,
1539 replica->ip, only_node, only_rsc);
1543 out->message(out, crm_map_element_name(replica->child->xml), options,
1544 replica->child, only_node, only_rsc);
1548 out->message(out, crm_map_element_name(replica->container->xml), options,
1549 replica->container, only_node, only_rsc);
1553 out->message(out, crm_map_element_name(replica->remote->xml), options,
1554 replica->remote, only_node, only_rsc);
1560 if (printed_header) {
1568 pe__bundle_replica_output_html(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1574 char buffer[LINE_MAX];
1580 if (replica->remote) {
1581 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1584 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1587 if (replica->ipaddr) {
1588 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1595 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
1599 unsigned int options = va_arg(args,
unsigned int);
1601 GList *only_node = va_arg(args, GList *);
1602 GList *only_rsc = va_arg(args, GList *);
1604 pe__bundle_variant_data_t *bundle_data = NULL;
1605 char buffer[LINE_MAX];
1607 gboolean print_everything = TRUE;
1611 get_bundle_variant_data(bundle_data, rsc);
1619 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1620 gIter = gIter->next) {
1621 pe__bundle_replica_t *replica = gIter->data;
1622 gboolean print_ip, print_child, print_ctnr, print_remote;
1630 print_ip = replica->ip != NULL &&
1631 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1632 print_child = replica->child != NULL &&
1633 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1634 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1635 print_remote = replica->remote != NULL &&
1636 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1639 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1643 unsigned int new_options = options;
1654 (bundle_data->nreplicas > 1)?
" set" :
"",
1655 rsc->
id, bundle_data->image,
1661 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1662 snprintf(buffer, LINE_MAX,
" Replica[%d]", replica->offset);
1666 out->begin_list(out, NULL, NULL, NULL);
1669 out->message(out, crm_map_element_name(replica->ip->xml),
1670 new_options, replica->ip, only_node, only_rsc);
1674 out->message(out, crm_map_element_name(replica->child->xml),
1675 new_options, replica->child, only_node, only_rsc);
1679 out->message(out, crm_map_element_name(replica->container->xml),
1680 new_options, replica->container, only_node, only_rsc);
1684 out->message(out, crm_map_element_name(replica->remote->xml),
1685 new_options, replica->remote, only_node, only_rsc);
1689 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1693 (bundle_data->nreplicas > 1)?
" set" :
"",
1694 rsc->
id, bundle_data->image,
1698 pe__bundle_replica_output_html(out, replica, pe__current_node(replica->container),
1710 pe__bundle_replica_output_text(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1716 char buffer[LINE_MAX];
1722 if (replica->remote) {
1723 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1726 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1729 if (replica->ipaddr) {
1730 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1737 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
1741 unsigned int options = va_arg(args,
unsigned int);
1743 GList *only_node = va_arg(args, GList *);
1744 GList *only_rsc = va_arg(args, GList *);
1746 pe__bundle_variant_data_t *bundle_data = NULL;
1748 gboolean print_everything = TRUE;
1750 get_bundle_variant_data(bundle_data, rsc);
1760 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1761 gIter = gIter->next) {
1762 pe__bundle_replica_t *replica = gIter->data;
1763 gboolean print_ip, print_child, print_ctnr, print_remote;
1771 print_ip = replica->ip != NULL &&
1772 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1773 print_child = replica->child != NULL &&
1774 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1775 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1776 print_remote = replica->remote != NULL &&
1777 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1780 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1784 unsigned int new_options = options;
1790 (bundle_data->nreplicas > 1)?
" set" :
"",
1791 rsc->
id, bundle_data->image,
1795 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1796 out->list_item(out, NULL,
"Replica[%d]", replica->offset);
1799 out->begin_list(out, NULL, NULL, NULL);
1802 out->message(out, crm_map_element_name(replica->ip->xml),
1803 new_options, replica->ip, only_node, only_rsc);
1807 out->message(out, crm_map_element_name(replica->child->xml),
1808 new_options, replica->child, only_node, only_rsc);
1812 out->message(out, crm_map_element_name(replica->container->xml),
1813 new_options, replica->container, only_node, only_rsc);
1817 out->message(out, crm_map_element_name(replica->remote->xml),
1818 new_options, replica->remote, only_node, only_rsc);
1822 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1826 (bundle_data->nreplicas > 1)?
" set" :
"",
1827 rsc->
id, bundle_data->image,
1831 pe__bundle_replica_output_text(out, replica, pe__current_node(replica->container),
1841 print_bundle_replica(pe__bundle_replica_t *replica,
const char *pre_text,
1842 long options,
void *print_data)
1848 char buffer[LINE_MAX];
1854 if (replica->remote) {
1855 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1858 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1861 if (replica->ipaddr) {
1862 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1866 node = pe__current_node(replica->container);
1867 common_print(rsc, pre_text, buffer, node, options, print_data);
1874 pe__bundle_variant_data_t *bundle_data = NULL;
1875 char *child_text = NULL;
1879 bundle_print_xml(rsc, pre_text, options, print_data);
1883 get_bundle_variant_data(bundle_data, rsc);
1885 if (pre_text == NULL) {
1890 pre_text, ((bundle_data->nreplicas > 1)?
" set" :
""),
1891 rsc->
id, bundle_data->image,
1894 if (options & pe_print_html) {
1899 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1900 gIter = gIter->next) {
1901 pe__bundle_replica_t *replica = gIter->data;
1904 if (options & pe_print_html) {
1910 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1911 status_print(
" %sReplica[%d]\n", pre_text, replica->offset);
1913 if (options & pe_print_html) {
1916 print_rsc_in_list(replica->ip, child_text, options, print_data);
1917 print_rsc_in_list(replica->container, child_text, options, print_data);
1918 print_rsc_in_list(replica->remote, child_text, options, print_data);
1919 print_rsc_in_list(replica->child, child_text, options, print_data);
1920 if (options & pe_print_html) {
1925 print_bundle_replica(replica, child_text, options, print_data);
1929 if (options & pe_print_html) {
1933 if (options & pe_print_html) {
1939 free_bundle_replica(pe__bundle_replica_t *replica)
1941 if (replica == NULL) {
1945 if (replica->node) {
1946 free(replica->node);
1947 replica->node = NULL;
1952 replica->ip->xml = NULL;
1953 replica->ip->fns->free(replica->ip);
1956 if (replica->container) {
1958 replica->container->xml = NULL;
1959 replica->container->fns->free(replica->container);
1960 replica->container = NULL;
1962 if (replica->remote) {
1964 replica->remote->xml = NULL;
1965 replica->remote->fns->free(replica->remote);
1966 replica->remote = NULL;
1968 free(replica->ipaddr);
1975 pe__bundle_variant_data_t *bundle_data = NULL;
1978 get_bundle_variant_data(bundle_data, rsc);
1981 free(bundle_data->prefix);
1982 free(bundle_data->image);
1983 free(bundle_data->control_port);
1984 free(bundle_data->host_network);
1985 free(bundle_data->host_netmask);
1986 free(bundle_data->ip_range_start);
1987 free(bundle_data->container_network);
1988 free(bundle_data->launcher_options);
1989 free(bundle_data->container_command);
1990 free(bundle_data->container_host_options);
1992 g_list_free_full(bundle_data->replicas,
1993 (GDestroyNotify) free_bundle_replica);
1994 g_list_free_full(bundle_data->mounts, (GDestroyNotify)mount_free);
1995 g_list_free_full(bundle_data->ports, (GDestroyNotify)port_free);
1998 if(bundle_data->child) {
2000 bundle_data->child->xml = NULL;
2001 bundle_data->child->fns->free(bundle_data->child);
2010 return container_role;
2026 pe__bundle_variant_data_t *bundle_data = NULL;
2028 get_bundle_variant_data(bundle_data, rsc);
2029 return bundle_data->nreplicas;
2036 pe__bundle_variant_data_t *bundle_data = NULL;
2038 get_bundle_variant_data(bundle_data, rsc);
2039 for (GList *item = bundle_data->replicas; item != NULL; item = item->next) {
2040 pe__bundle_replica_t *replica = item->data;
2043 replica->ip->fns->count(replica->ip);
2045 if (replica->child) {
2046 replica->child->fns->count(replica->child);
2048 if (replica->container) {
2049 replica->container->fns->count(replica->container);
2051 if (replica->remote) {
2052 replica->remote->fns->count(replica->remote);
2060 gboolean passes = FALSE;
2061 pe__bundle_variant_data_t *bundle_data = NULL;
2066 get_bundle_variant_data(bundle_data, rsc);
2068 for (GList *gIter = bundle_data->replicas; gIter != NULL; gIter = gIter->next) {
2069 pe__bundle_replica_t *replica = gIter->data;
2071 if (replica->ip != NULL && !replica->ip->fns->is_filtered(replica->ip, only_rsc, FALSE)) {
2074 }
else if (replica->child != NULL && !replica->child->fns->is_filtered(replica->child, only_rsc, FALSE)) {
2077 }
else if (!replica->container->fns->is_filtered(replica->container, only_rsc, FALSE)) {
2080 }
else if (replica->remote != NULL && !replica->remote->fns->is_filtered(replica->remote, only_rsc, FALSE)) {
#define CRM_CHECK(expr, failure_action)
pe_node_t * pe_find_node(GList *node_list, const char *uname)
int pe__common_output_html(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, long options)
xmlNodePtr pcmk__output_create_xml_node(pcmk__output_t *out, const char *name,...)
xmlNode * crm_create_op_xml(xmlNode *parent, const char *prefix, const char *task, const char *interval_spec, const char *timeout)
Create a CIB XML element for an operation.
bool pe__is_guest_or_remote_node(const pe_node_t *node)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
pe_resource_t * container
void pe__free_bundle(pe_resource_t *rsc)
#define XML_BOOLEAN_FALSE
enum rsc_role_e pe__bundle_resource_state(const pe_resource_t *rsc, gboolean current)
xmlNode * first_named_child(const xmlNode *parent, const char *name)
gboolean pcmk__str_in_list(GList *lst, const gchar *s)
resource_object_functions_t * fns
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
pe_node_t * pe__copy_node(const pe_node_t *this_node)
bool pe__bundle_needs_remote_name(pe_resource_t *rsc, pe_working_set_t *data_set)
xmlNodePtr pcmk__output_xml_peek_parent(pcmk__output_t *out)
pe_resource_t * pe_find_resource(GList *rsc_list, const char *id_rh)
#define CRM_LOG_ASSERT(expr)
void pe__print_bundle(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
#define pe_rsc_allow_remote_remotes
#define XML_RSC_ATTR_INCARNATION_MAX
#define XML_RSC_ATTR_TARGET
#define XML_RSC_ATTR_REMOTE_RA_ADDR
gboolean pe__unpack_bundle(pe_resource_t *rsc, pe_working_set_t *data_set)
int pe__bundle_html(pcmk__output_t *out, va_list args)
void crm_xml_sanitize_id(char *id)
Sanitize a string so it is usable as an XML ID.
#define pe__set_resource_flags(resource, flags_to_set)
#define DEFAULT_REMOTE_PORT
#define DEFAULT_REMOTE_KEY_LOCATION
#define XML_TAG_ATTR_SETS
#define XML_RSC_ATTR_PROMOTABLE
xmlNode * pe_create_remote_xml(xmlNode *parent, const char *uname, const char *container_id, const char *migrateable, const char *is_managed, const char *start_timeout, const char *server, const char *port)
pe_resource_t * pe__find_bundle_replica(const pe_resource_t *bundle, const pe_node_t *node)
#define PCMK_RESOURCE_CLASS_OCF
int pe__bundle_text(pcmk__output_t *out, va_list args)
char * crm_element_value_copy(const xmlNode *data, const char *name)
Retrieve a copy of the value of an XML attribute.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
#define PCMK__OUTPUT_ARGS(ARGS...)
int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name, size_t pairs_count,...)
#define crm_trace(fmt, args...)
bool xml_contains_remote_node(xmlNode *xml)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
void crm_xml_set_id(xmlNode *xml, const char *format,...) G_GNUC_PRINTF(2
struct pe_node_shared_s * details
#define pe__set_bundle_mount_flags(mount_xml, flags, flags_to_set)
#define XML_AGENT_ATTR_PROVIDER
void common_free(pe_resource_t *rsc)
GHashTable * pe_rsc_params(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
#define XML_RSC_ATTR_ORDERED
#define XML_TAG_META_SETS
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define XML_RSC_ATTR_INCARNATION_NODEMAX
gboolean pe__bundle_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
void free_xml(xmlNode *child)
enum pe_obj_types variant
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
void common_print(pe_resource_t *rsc, const char *pre_text, const char *name, pe_node_t *node, long options, void *print_data)
void(* print)(pe_resource_t *, const char *, long, void *)
const char * pe__add_bundle_remote_name(pe_resource_t *rsc, pe_working_set_t *data_set, xmlNode *xml, const char *field)
const xmlChar * pcmkXmlStr
#define XML_RSC_ATTR_UNIQUE
#define PCMK__OUTPUT_LIST_FOOTER(out_obj, retcode)
int crm_str_to_boolean(const char *s, int *ret)
#define XML_RSC_ATTR_PROMOTED_MAX
int pe__bundle_xml(pcmk__output_t *out, va_list args)
gboolean(* is_filtered)(pe_resource_t *, GList *, gboolean)
#define PCMK__OUTPUT_LIST_HEADER(out_obj, cond, retcode, title...)
Cluster status and scheduling.
bool pcmk__rsc_filtered_by_node(pe_resource_t *rsc, GList *only_node)
#define XML_CIB_TAG_INCARNATION
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
const char * rsc_printable_id(pe_resource_t *rsc)
#define status_print(fmt, args...)
This structure contains everything that makes up a single output formatter.
void(* free)(pe_resource_t *)
#define pe__clear_resource_flags(resource, flags_to_clear)
rsc_role_e
Possible roles that a resource can be in.
pe_node_t * pe_create_node(const char *id, const char *uname, const char *type, const char *score, pe_working_set_t *data_set)
gboolean common_unpack(xmlNode *xml_obj, pe_resource_t **rsc, pe_resource_t *parent, pe_working_set_t *data_set)
#define pe_rsc_trace(rsc, fmt, args...)
xmlNode * crm_create_nvpair_xml(xmlNode *parent, const char *id, const char *name, const char *value)
Create an XML name/value pair.
gboolean(* active)(pe_resource_t *, gboolean)
int pe__common_output_text(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, long options)
void pe__count_bundle(pe_resource_t *rsc)
xmlNodePtr pcmk__output_xml_create_parent(pcmk__output_t *out, const char *name,...)
int pe_bundle_replicas(const pe_resource_t *rsc)
Get the number of configured replicas in a bundle.
gboolean pe__bundle_active(pe_resource_t *rsc, gboolean all)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes