23 #define PE__VARIANT_BUNDLE 1 27 next_ip(
const char *last_ip)
29 unsigned int oct1 = 0;
30 unsigned int oct2 = 0;
31 unsigned int oct3 = 0;
32 unsigned int oct4 = 0;
33 int rc = sscanf(last_ip,
"%u.%u.%u.%u", &oct1, &oct2, &oct3, &oct4);
39 }
else if (oct3 > 253) {
42 }
else if (oct4 > 253) {
54 allocate_ip(pe__bundle_variant_data_t *
data, pe__bundle_replica_t *replica,
55 char *buffer,
int max)
57 if(
data->ip_range_start == NULL) {
60 }
else if(
data->ip_last) {
61 replica->ipaddr = next_ip(
data->ip_last);
64 replica->ipaddr = strdup(
data->ip_range_start);
67 data->ip_last = replica->ipaddr;
68 switch (
data->agent_type) {
69 case PE__CONTAINER_AGENT_DOCKER:
70 case PE__CONTAINER_AGENT_PODMAN:
72 return snprintf(buffer, max,
" --add-host=%s-%d:%s",
73 data->prefix, replica->offset,
76 case PE__CONTAINER_AGENT_RKT:
77 return snprintf(buffer, max,
" --hosts-entry=%s=%s-%d",
78 replica->ipaddr,
data->prefix, replica->offset);
86 create_resource(
const char *
name,
const char *provider,
const char *kind)
111 valid_network(pe__bundle_variant_data_t *
data)
113 if(
data->ip_range_start) {
116 if(
data->control_port) {
117 if(
data->nreplicas_per_host > 1) {
118 pe_err(
"Specifying the 'control-port' for %s requires 'replicas-per-host=1'",
data->prefix);
119 data->nreplicas_per_host = 1;
131 if(
data->ip_range_start) {
133 xmlNode *xml_ip = NULL;
134 xmlNode *xml_obj = NULL;
138 xml_ip = create_resource(
id,
"heartbeat",
"IPaddr2");
143 data->prefix, replica->offset);
146 if(
data->host_network) {
150 if(
data->host_netmask) {
152 "cidr_netmask",
data->host_netmask);
167 parent->children = g_list_append(
parent->children, replica->ip);
174 pe__bundle_replica_t *replica,
177 int offset = 0, max = 4096;
178 char *buffer = calloc(1, max+1);
180 int doffset = 0, dmax = 1024;
181 char *dbuffer = calloc(1, dmax+1);
184 xmlNode *xml_container = NULL;
185 xmlNode *xml_obj = NULL;
189 xml_container = create_resource(
id,
"heartbeat",
190 PE__CONTAINER_AGENT_DOCKER_S);
195 data->prefix, replica->offset);
202 offset += snprintf(buffer+offset, max-offset,
" --restart=no");
209 if (
data->ip_range_start != NULL) {
210 offset += snprintf(buffer+offset, max-offset,
" -h %s-%d",
211 data->prefix, replica->offset);
214 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_stderr=1");
216 if (
data->container_network) {
218 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
221 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
222 data->container_network);
225 if(
data->control_port) {
226 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%s",
data->control_port);
228 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
231 for(GList *pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
232 pe__bundle_mount_t *mount = pIter->data;
234 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
236 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
239 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
241 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
242 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", source, mount->target);
246 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", mount->source, mount->target);
249 offset += snprintf(buffer+offset, max-offset,
":%s", mount->options);
253 for(GList *pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
254 pe__bundle_port_t *port = pIter->data;
256 if (replica->ipaddr) {
257 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s:%s",
258 replica->ipaddr, port->source,
262 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s", port->source, port->target);
266 if (
data->launcher_options) {
267 offset += snprintf(buffer+offset, max-offset,
" %s",
268 data->launcher_options);
271 if (
data->container_host_options) {
272 offset += snprintf(buffer + offset, max - offset,
" %s",
273 data->container_host_options);
282 if (replica->child) {
283 if (
data->container_command) {
285 "run_cmd",
data->container_command);
288 "run_cmd",
SBIN_DIR "/pacemaker-remoted");
304 }
else if ((child != NULL) &&
data->untrusted) {
311 if (
data->container_command) {
313 "run_cmd",
data->container_command);
332 parent->children = g_list_append(
parent->children, replica->container);
338 pe__bundle_replica_t *replica,
341 int offset = 0, max = 4096;
342 char *buffer = calloc(1, max+1);
344 int doffset = 0, dmax = 1024;
345 char *dbuffer = calloc(1, dmax+1);
348 xmlNode *xml_container = NULL;
349 xmlNode *xml_obj = NULL;
353 xml_container = create_resource(
id,
"heartbeat",
354 PE__CONTAINER_AGENT_PODMAN_S);
359 data->prefix, replica->offset);
374 if (
data->ip_range_start != NULL) {
375 offset += snprintf(buffer+offset, max-offset,
" -h %s-%d",
376 data->prefix, replica->offset);
379 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_stderr=1");
381 if (
data->container_network) {
384 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
387 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
388 data->container_network);
391 if(
data->control_port) {
392 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%s",
data->control_port);
394 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
397 for(GList *pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
398 pe__bundle_mount_t *mount = pIter->data;
400 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
402 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
405 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
407 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
408 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", source, mount->target);
412 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", mount->source, mount->target);
415 offset += snprintf(buffer+offset, max-offset,
":%s", mount->options);
419 for(GList *pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
420 pe__bundle_port_t *port = pIter->data;
422 if (replica->ipaddr) {
423 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s:%s",
424 replica->ipaddr, port->source,
428 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s", port->source, port->target);
432 if (
data->launcher_options) {
433 offset += snprintf(buffer+offset, max-offset,
" %s",
434 data->launcher_options);
437 if (
data->container_host_options) {
438 offset += snprintf(buffer + offset, max - offset,
" %s",
439 data->container_host_options);
448 if (replica->child) {
449 if (
data->container_command) {
451 "run_cmd",
data->container_command);
454 "run_cmd",
SBIN_DIR "/pacemaker-remoted");
470 }
else if ((child != NULL) &&
data->untrusted) {
477 if (
data->container_command) {
479 "run_cmd",
data->container_command);
499 parent->children = g_list_append(
parent->children, replica->container);
507 int offset = 0, max = 4096;
508 char *buffer = calloc(1, max+1);
510 int doffset = 0, dmax = 1024;
511 char *dbuffer = calloc(1, dmax+1);
514 xmlNode *xml_container = NULL;
515 xmlNode *xml_obj = NULL;
521 xml_container = create_resource(
id,
"heartbeat",
522 PE__CONTAINER_AGENT_RKT_S);
527 data->prefix, replica->offset);
539 if (
data->ip_range_start != NULL) {
540 offset += snprintf(buffer+offset, max-offset,
" --hostname=%s-%d",
541 data->prefix, replica->offset);
544 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_stderr=1");
546 if (
data->container_network) {
548 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
551 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
552 data->container_network);
555 if(
data->control_port) {
556 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_remote_port=%s",
data->control_port);
558 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
561 for(GList *pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
562 pe__bundle_mount_t *mount = pIter->data;
564 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
566 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
569 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
571 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
572 offset += snprintf(buffer+offset, max-offset,
" --volume vol%d,kind=host,source=%s", volid, source);
574 offset += snprintf(buffer+offset, max-offset,
",%s", mount->options);
576 offset += snprintf(buffer+offset, max-offset,
" --mount volume=vol%d,target=%s", volid, mount->target);
580 offset += snprintf(buffer+offset, max-offset,
" --volume vol%d,kind=host,source=%s", volid, mount->source);
582 offset += snprintf(buffer+offset, max-offset,
",%s", mount->options);
584 offset += snprintf(buffer+offset, max-offset,
" --mount volume=vol%d,target=%s", volid, mount->target);
589 for(GList *pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
590 pe__bundle_port_t *port = pIter->data;
592 if (replica->ipaddr) {
593 offset += snprintf(buffer+offset, max-offset,
594 " --port=%s:%s:%s", port->target,
595 replica->ipaddr, port->source);
597 offset += snprintf(buffer+offset, max-offset,
" --port=%s:%s", port->target, port->source);
601 if (
data->launcher_options) {
602 offset += snprintf(buffer+offset, max-offset,
" %s",
603 data->launcher_options);
606 if (
data->container_host_options) {
607 offset += snprintf(buffer + offset, max - offset,
" %s",
608 data->container_host_options);
617 if (replica->child) {
618 if (
data->container_command) {
620 data->container_command);
639 }
else if ((child != NULL) &&
data->untrusted) {
646 if (
data->container_command) {
648 data->container_command);
668 parent->children = g_list_append(
parent->children, replica->container);
688 g_list_foreach(rsc->
children, (GFunc) disallow_node, (gpointer)
uname);
694 pe__bundle_replica_t *replica,
697 if (replica->child && valid_network(
data)) {
698 GHashTableIter gIter;
700 xmlNode *xml_remote = NULL;
703 const char *
uname = NULL;
704 const char *connect_name = NULL;
710 replica->child->id, replica->offset);
719 connect_name = (replica->ipaddr? replica->ipaddr :
"#uname");
721 if (
data->control_port == NULL) {
732 connect_name, (
data->control_port?
733 data->control_port : port_s));
777 replica->node->weight = 500;
781 if (replica->child->allowed_nodes != NULL) {
782 g_hash_table_destroy(replica->child->allowed_nodes);
785 g_hash_table_insert(replica->child->allowed_nodes,
786 (gpointer) replica->node->details->id,
792 g_hash_table_insert(replica->child->parent->allowed_nodes,
793 (gpointer) replica->node->details->id, copy);
799 g_hash_table_iter_init(&gIter, replica->remote->allowed_nodes);
800 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&node)) {
807 replica->node->details->remote_rsc = replica->remote;
810 replica->remote->container = replica->container;
815 g_hash_table_insert(replica->node->details->attrs,
827 parent->children = g_list_append(
parent->children, replica->remote);
837 switch (
data->agent_type) {
838 case PE__CONTAINER_AGENT_DOCKER:
844 case PE__CONTAINER_AGENT_PODMAN:
850 case PE__CONTAINER_AGENT_RKT:
865 if (replica->child && replica->ipaddr) {
866 add_hash_param(replica->child->meta,
"external-ip", replica->ipaddr);
869 if (replica->remote) {
885 mount_add(pe__bundle_variant_data_t *bundle_data,
const char *source,
886 const char *
target,
const char *options, uint32_t
flags)
888 pe__bundle_mount_t *mount = calloc(1,
sizeof(pe__bundle_mount_t));
891 mount->source = strdup(source);
892 mount->target = strdup(
target);
894 mount->flags =
flags;
895 bundle_data->mounts = g_list_append(bundle_data->mounts, mount);
899 mount_free(pe__bundle_mount_t *mount)
903 free(mount->options);
908 port_free(pe__bundle_port_t *port)
915 static pe__bundle_replica_t *
919 pe__bundle_variant_data_t *bundle_data = NULL;
925 while (top->
parent != NULL) {
929 get_bundle_variant_data(bundle_data, top);
930 for (GList *gIter = bundle_data->replicas; gIter != NULL;
931 gIter = gIter->next) {
932 pe__bundle_replica_t *replica = gIter->data;
934 if (replica->remote == remote) {
946 GHashTable *params = NULL;
962 xmlNode *xml,
const char *field)
967 pe__bundle_replica_t *replica = NULL;
973 replica = replica_for_remote(rsc);
974 if (replica == NULL) {
978 node = replica->container->allocated_to;
983 node = pe__current_node(replica->container);
987 crm_trace(
"Cannot determine address for bundle connection %s", rsc->
id);
991 crm_trace(
"Setting address for bundle connection %s to bundle host %s",
993 if(xml != NULL && field != NULL) {
1000 #define pe__set_bundle_mount_flags(mount_xml, flags, flags_to_set) do { \ 1001 flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \ 1002 "Bundle mount", ID(mount_xml), flags, \ 1003 (flags_to_set), #flags_to_set); \ 1009 const char *value = NULL;
1010 xmlNode *xml_obj = NULL;
1011 xmlNode *xml_resource = NULL;
1012 pe__bundle_variant_data_t *bundle_data = NULL;
1013 bool need_log_mount = TRUE;
1018 bundle_data = calloc(1,
sizeof(pe__bundle_variant_data_t));
1020 bundle_data->prefix = strdup(rsc->
id);
1023 if (xml_obj != NULL) {
1024 bundle_data->agent_type = PE__CONTAINER_AGENT_DOCKER;
1027 if (xml_obj != NULL) {
1028 bundle_data->agent_type = PE__CONTAINER_AGENT_RKT;
1031 if (xml_obj != NULL) {
1032 bundle_data->agent_type = PE__CONTAINER_AGENT_PODMAN;
1041 if (value == NULL) {
1049 if ((value == NULL) && (bundle_data->promoted_max > 0)) {
1050 bundle_data->nreplicas = bundle_data->promoted_max;
1062 if (bundle_data->nreplicas_per_host == 1) {
1080 bundle_data->add_host = TRUE;
1083 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
1084 xml_child = pcmk__xe_next(xml_child)) {
1086 pe__bundle_port_t *port = calloc(1,
sizeof(pe__bundle_port_t));
1089 if(port->source == NULL) {
1095 if(port->source != NULL && strlen(port->source) > 0) {
1096 if(port->target == NULL) {
1097 port->target = strdup(port->source);
1099 bundle_data->ports = g_list_append(bundle_data->ports, port);
1102 pe_err(
"Invalid port directive %s",
ID(xml_child));
1109 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
1110 xml_child = pcmk__xe_next(xml_child)) {
1115 int flags = pe__bundle_mount_none;
1117 if (source == NULL) {
1120 pe__bundle_mount_subdir);
1124 mount_add(bundle_data, source,
target, options,
flags);
1125 if (strcmp(
target,
"/var/log") == 0) {
1126 need_log_mount = FALSE;
1129 pe_err(
"Invalid mount directive %s",
ID(xml_child));
1134 if (xml_obj && valid_network(bundle_data)) {
1136 xmlNode *xml_set = NULL;
1145 (bundle_data->promoted_max?
"master" 1146 : (
const char *)xml_resource->name));
1149 crm_xml_set_id(xml_set,
"%s-%s-meta", bundle_data->prefix, xml_resource->name);
1154 value = pcmk__itoa(bundle_data->nreplicas);
1159 value = pcmk__itoa(bundle_data->nreplicas_per_host);
1165 pcmk__btoa(bundle_data->nreplicas_per_host > 1));
1167 if (bundle_data->promoted_max) {
1171 value = pcmk__itoa(bundle_data->promoted_max);
1180 }
else if(xml_obj) {
1181 pe_err(
"Cannot control %s inside %s without either ip-range-start or control-port",
1182 rsc->
id,
ID(xml_obj));
1188 GList *childIter = NULL;
1190 pe__bundle_port_t *port = NULL;
1192 int offset = 0, max = 1024;
1193 char *buffer = NULL;
1196 pe_err(
"Failed unpacking resource %s",
ID(rsc->
xml));
1197 if (new_rsc != NULL && new_rsc->
fns != NULL) {
1203 bundle_data->child = new_rsc;
1229 if (need_log_mount) {
1231 pe__bundle_mount_subdir);
1234 port = calloc(1,
sizeof(pe__bundle_port_t));
1235 if(bundle_data->control_port) {
1236 port->source = strdup(bundle_data->control_port);
1248 port->target = strdup(port->source);
1249 bundle_data->ports = g_list_append(bundle_data->ports, port);
1251 buffer = calloc(1, max+1);
1252 for (childIter = bundle_data->child->children; childIter != NULL;
1253 childIter = childIter->next) {
1255 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1257 replica->child = childIter->data;
1258 replica->child->exclusive_discover = TRUE;
1259 replica->offset = lpc++;
1266 offset += allocate_ip(bundle_data, replica, buffer+offset,
1268 bundle_data->replicas = g_list_append(bundle_data->replicas,
1270 bundle_data->attribute_target = g_hash_table_lookup(replica->child->meta,
1273 bundle_data->container_host_options = buffer;
1274 if (bundle_data->attribute_target) {
1276 strdup(bundle_data->attribute_target));
1277 g_hash_table_replace(bundle_data->child->meta,
1279 strdup(bundle_data->attribute_target));
1284 int offset = 0, max = 1024;
1285 char *buffer = calloc(1, max+1);
1287 for (
int lpc = 0; lpc < bundle_data->nreplicas; lpc++) {
1288 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1290 replica->offset = lpc;
1291 offset += allocate_ip(bundle_data, replica, buffer+offset,
1293 bundle_data->replicas = g_list_append(bundle_data->replicas,
1296 bundle_data->container_host_options = buffer;
1299 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1300 gIter = gIter->next) {
1301 pe__bundle_replica_t *replica = gIter->data;
1303 if (!create_container(rsc, bundle_data, replica,
data_set)) {
1304 pe_err(
"Failed unpacking resource %s", rsc->
id);
1325 if (replica->child != NULL) {
1326 GHashTable *empty = replica->container->utilization;
1328 replica->container->utilization = replica->child->utilization;
1329 replica->child->utilization = empty;
1333 if (bundle_data->child) {
1343 gboolean child_active = rsc->
fns->
active(rsc, all);
1345 if (child_active && !all) {
1347 }
else if (!child_active && all) {
1357 pe__bundle_variant_data_t *bundle_data = NULL;
1360 get_bundle_variant_data(bundle_data, rsc);
1361 for (iter = bundle_data->replicas; iter != NULL; iter = iter->next) {
1362 pe__bundle_replica_t *replica = iter->data;
1365 rsc_active = replica_resource_active(replica->ip, all);
1366 if (rsc_active >= 0) {
1367 return (gboolean) rsc_active;
1370 rsc_active = replica_resource_active(replica->child, all);
1371 if (rsc_active >= 0) {
1372 return (gboolean) rsc_active;
1375 rsc_active = replica_resource_active(replica->container, all);
1376 if (rsc_active >= 0) {
1377 return (gboolean) rsc_active;
1380 rsc_active = replica_resource_active(replica->remote, all);
1381 if (rsc_active >= 0) {
1382 return (gboolean) rsc_active;
1405 pe__bundle_variant_data_t *bundle_data = NULL;
1408 get_bundle_variant_data(bundle_data, bundle);
1409 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1410 gIter = gIter->next) {
1411 pe__bundle_replica_t *replica = gIter->data;
1414 if (replica->node->details == node->
details) {
1415 return replica->child;
1422 print_rsc_in_list(
pe_resource_t *rsc,
const char *pre_text,
long options,
1429 rsc->
fns->
print(rsc, pre_text, options, print_data);
1437 container_agent_str(
enum pe__container_agent t)
1440 case PE__CONTAINER_AGENT_DOCKER:
return PE__CONTAINER_AGENT_DOCKER_S;
1441 case PE__CONTAINER_AGENT_RKT:
return PE__CONTAINER_AGENT_RKT_S;
1442 case PE__CONTAINER_AGENT_PODMAN:
return PE__CONTAINER_AGENT_PODMAN_S;
1446 return PE__CONTAINER_AGENT_UNKNOWN_S;
1450 bundle_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
1453 pe__bundle_variant_data_t *bundle_data = NULL;
1454 char *child_text = NULL;
1457 if (pre_text == NULL) {
1462 get_bundle_variant_data(bundle_data, rsc);
1466 status_print(
"type=\"%s\" ", container_agent_str(bundle_data->agent_type));
1473 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1474 gIter = gIter->next) {
1475 pe__bundle_replica_t *replica = gIter->data;
1478 status_print(
"%s <replica id=\"%d\">\n", pre_text, replica->offset);
1479 print_rsc_in_list(replica->ip, child_text, options, print_data);
1480 print_rsc_in_list(replica->child, child_text, options, print_data);
1481 print_rsc_in_list(replica->container, child_text, options, print_data);
1482 print_rsc_in_list(replica->remote, child_text, options, print_data);
1489 PCMK__OUTPUT_ARGS(
"bundle",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1493 uint32_t show_opts = va_arg(args, uint32_t);
1495 GList *only_node = va_arg(args, GList *);
1496 GList *only_rsc = va_arg(args, GList *);
1498 pe__bundle_variant_data_t *bundle_data = NULL;
1500 gboolean printed_header = FALSE;
1501 gboolean print_everything = TRUE;
1505 get_bundle_variant_data(bundle_data, rsc);
1513 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1514 gIter = gIter->next) {
1515 pe__bundle_replica_t *replica = gIter->data;
1517 gboolean print_ip, print_child, print_ctnr, print_remote;
1525 print_ip = replica->ip != NULL &&
1526 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1527 print_child = replica->child != NULL &&
1528 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1529 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1530 print_remote = replica->remote != NULL &&
1531 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1533 if (!print_everything && !print_ip && !print_child && !print_ctnr && !print_remote) {
1537 if (!printed_header) {
1538 printed_header = TRUE;
1542 "type", container_agent_str(bundle_data->agent_type),
1543 "image", bundle_data->image,
1550 id = pcmk__itoa(replica->offset);
1556 out->message(out, crm_map_element_name(replica->ip->xml), show_opts,
1557 replica->ip, only_node, only_rsc);
1561 out->message(out, crm_map_element_name(replica->child->xml), show_opts,
1562 replica->child, only_node, only_rsc);
1566 out->message(out, crm_map_element_name(replica->container->xml), show_opts,
1567 replica->container, only_node, only_rsc);
1571 out->message(out, crm_map_element_name(replica->remote->xml), show_opts,
1572 replica->remote, only_node, only_rsc);
1578 if (printed_header) {
1586 pe__bundle_replica_output_html(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1592 char buffer[LINE_MAX];
1598 if (replica->remote) {
1599 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1602 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1605 if (replica->ipaddr) {
1606 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1613 PCMK__OUTPUT_ARGS(
"bundle",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1617 uint32_t show_opts = va_arg(args, uint32_t);
1619 GList *only_node = va_arg(args, GList *);
1620 GList *only_rsc = va_arg(args, GList *);
1622 pe__bundle_variant_data_t *bundle_data = NULL;
1624 gboolean print_everything = TRUE;
1628 get_bundle_variant_data(bundle_data, rsc);
1636 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1637 gIter = gIter->next) {
1638 pe__bundle_replica_t *replica = gIter->data;
1639 gboolean print_ip, print_child, print_ctnr, print_remote;
1647 print_ip = replica->ip != NULL &&
1648 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1649 print_child = replica->child != NULL &&
1650 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1651 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1652 print_remote = replica->remote != NULL &&
1653 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1656 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1663 (bundle_data->nreplicas > 1)?
" set" :
"",
1664 rsc->
id, bundle_data->image,
1668 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1669 out->begin_list(out, NULL, NULL,
"Replica[%d]", replica->offset);
1673 out->message(out, crm_map_element_name(replica->ip->xml),
1674 new_show_opts, replica->ip, only_node, only_rsc);
1678 out->message(out, crm_map_element_name(replica->child->xml),
1679 new_show_opts, replica->child, only_node, only_rsc);
1683 out->message(out, crm_map_element_name(replica->container->xml),
1684 new_show_opts, replica->container, only_node, only_rsc);
1688 out->message(out, crm_map_element_name(replica->remote->xml),
1689 new_show_opts, replica->remote, only_node, only_rsc);
1692 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1695 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1699 (bundle_data->nreplicas > 1)?
" set" :
"",
1700 rsc->
id, bundle_data->image,
1704 pe__bundle_replica_output_html(out, replica, pe__current_node(replica->container),
1714 pe__bundle_replica_output_text(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1720 char buffer[LINE_MAX];
1726 if (replica->remote) {
1727 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1730 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1733 if (replica->ipaddr) {
1734 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1741 PCMK__OUTPUT_ARGS(
"bundle",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1745 uint32_t show_opts = va_arg(args, uint32_t);
1747 GList *only_node = va_arg(args, GList *);
1748 GList *only_rsc = va_arg(args, GList *);
1750 pe__bundle_variant_data_t *bundle_data = NULL;
1752 gboolean print_everything = TRUE;
1754 get_bundle_variant_data(bundle_data, rsc);
1764 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1765 gIter = gIter->next) {
1766 pe__bundle_replica_t *replica = gIter->data;
1767 gboolean print_ip, print_child, print_ctnr, print_remote;
1775 print_ip = replica->ip != NULL &&
1776 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1777 print_child = replica->child != NULL &&
1778 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1779 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1780 print_remote = replica->remote != NULL &&
1781 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1784 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1791 (bundle_data->nreplicas > 1)?
" set" :
"",
1792 rsc->
id, bundle_data->image,
1796 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1797 out->list_item(out, NULL,
"Replica[%d]", replica->offset);
1800 out->begin_list(out, NULL, NULL, NULL);
1803 out->message(out, crm_map_element_name(replica->ip->xml),
1804 new_show_opts, replica->ip, only_node, only_rsc);
1808 out->message(out, crm_map_element_name(replica->child->xml),
1809 new_show_opts, replica->child, only_node, only_rsc);
1813 out->message(out, crm_map_element_name(replica->container->xml),
1814 new_show_opts, replica->container, only_node, only_rsc);
1818 out->message(out, crm_map_element_name(replica->remote->xml),
1819 new_show_opts, replica->remote, only_node, only_rsc);
1823 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1827 (bundle_data->nreplicas > 1)?
" set" :
"",
1828 rsc->
id, bundle_data->image,
1832 pe__bundle_replica_output_text(out, replica, pe__current_node(replica->container),
1842 print_bundle_replica(pe__bundle_replica_t *replica,
const char *pre_text,
1843 long options,
void *print_data)
1849 char buffer[LINE_MAX];
1855 if (replica->remote) {
1856 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1859 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1862 if (replica->ipaddr) {
1863 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1867 node = pe__current_node(replica->container);
1868 common_print(rsc, pre_text, buffer, node, options, print_data);
1875 pe__bundle_variant_data_t *bundle_data = NULL;
1876 char *child_text = NULL;
1880 bundle_print_xml(rsc, pre_text, options, print_data);
1884 get_bundle_variant_data(bundle_data, rsc);
1886 if (pre_text == NULL) {
1891 pre_text, ((bundle_data->nreplicas > 1)?
" set" :
""),
1892 rsc->
id, bundle_data->image,
1900 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1901 gIter = gIter->next) {
1902 pe__bundle_replica_t *replica = gIter->data;
1911 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1912 status_print(
" %sReplica[%d]\n", pre_text, replica->offset);
1917 print_rsc_in_list(replica->ip, child_text, options, print_data);
1918 print_rsc_in_list(replica->container, child_text, options, print_data);
1919 print_rsc_in_list(replica->remote, child_text, options, print_data);
1920 print_rsc_in_list(replica->child, child_text, options, print_data);
1926 print_bundle_replica(replica, child_text, options, print_data);
1940 free_bundle_replica(pe__bundle_replica_t *replica)
1942 if (replica == NULL) {
1946 if (replica->node) {
1947 free(replica->node);
1948 replica->node = NULL;
1953 replica->ip->xml = NULL;
1954 replica->ip->fns->free(replica->ip);
1957 if (replica->container) {
1959 replica->container->xml = NULL;
1960 replica->container->fns->free(replica->container);
1961 replica->container = NULL;
1963 if (replica->remote) {
1965 replica->remote->xml = NULL;
1966 replica->remote->fns->free(replica->remote);
1967 replica->remote = NULL;
1969 free(replica->ipaddr);
1976 pe__bundle_variant_data_t *bundle_data = NULL;
1979 get_bundle_variant_data(bundle_data, rsc);
1982 free(bundle_data->prefix);
1983 free(bundle_data->image);
1984 free(bundle_data->control_port);
1985 free(bundle_data->host_network);
1986 free(bundle_data->host_netmask);
1987 free(bundle_data->ip_range_start);
1988 free(bundle_data->container_network);
1989 free(bundle_data->launcher_options);
1990 free(bundle_data->container_command);
1991 free(bundle_data->container_host_options);
1993 g_list_free_full(bundle_data->replicas,
1994 (GDestroyNotify) free_bundle_replica);
1995 g_list_free_full(bundle_data->mounts, (GDestroyNotify)mount_free);
1996 g_list_free_full(bundle_data->ports, (GDestroyNotify)port_free);
1999 if(bundle_data->child) {
2001 bundle_data->child->xml = NULL;
2002 bundle_data->child->fns->free(bundle_data->child);
2011 return container_role;
2027 pe__bundle_variant_data_t *bundle_data = NULL;
2029 get_bundle_variant_data(bundle_data, rsc);
2030 return bundle_data->nreplicas;
2037 pe__bundle_variant_data_t *bundle_data = NULL;
2039 get_bundle_variant_data(bundle_data, rsc);
2040 for (GList *item = bundle_data->replicas; item != NULL; item = item->next) {
2041 pe__bundle_replica_t *replica = item->data;
2044 replica->ip->fns->count(replica->ip);
2046 if (replica->child) {
2047 replica->child->fns->count(replica->child);
2049 if (replica->container) {
2050 replica->container->fns->count(replica->container);
2052 if (replica->remote) {
2053 replica->remote->fns->count(replica->remote);
2061 gboolean passes = FALSE;
2062 pe__bundle_variant_data_t *bundle_data = NULL;
2067 get_bundle_variant_data(bundle_data, rsc);
2069 for (GList *gIter = bundle_data->replicas; gIter != NULL; gIter = gIter->next) {
2070 pe__bundle_replica_t *replica = gIter->data;
2072 if (replica->ip != NULL && !replica->ip->fns->is_filtered(replica->ip, only_rsc, FALSE)) {
2075 }
else if (replica->child != NULL && !replica->child->fns->is_filtered(replica->child, only_rsc, FALSE)) {
2078 }
else if (!replica->container->fns->is_filtered(replica->container, only_rsc, FALSE)) {
2081 }
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)
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 pe__bundle_text(pcmk__output_t *out, va_list args)
Control output from tools.
gboolean pe__bundle_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
int pe__common_output_html(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, unsigned int options)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
pe_resource_t * container
#define XML_BOOLEAN_FALSE
xmlNode * first_named_child(const xmlNode *parent, const char *name)
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)
pe_resource_t * pe_find_resource(GList *rsc_list, const char *id_rh)
#define CRM_LOG_ASSERT(expr)
#define pe_rsc_allow_remote_remotes
#define XML_RSC_ATTR_INCARNATION_MAX
#define XML_RSC_ATTR_TARGET
enum rsc_role_e pe__bundle_resource_state(const pe_resource_t *rsc, gboolean current)
#define XML_RSC_ATTR_REMOTE_RA_ADDR
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
int pe__common_output_text(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, unsigned int options)
#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)
bool pe__bundle_needs_remote_name(pe_resource_t *rsc, pe_working_set_t *data_set)
void pe__free_bundle(pe_resource_t *rsc)
#define PCMK_RESOURCE_CLASS_OCF
const char * pe__add_bundle_remote_name(pe_resource_t *rsc, pe_working_set_t *data_set, xmlNode *xml, const char *field)
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
void pe__count_bundle(pe_resource_t *rsc)
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
pe_working_set_t * data_set
#define XML_TAG_META_SETS
void pcmk__str_update(char **str, const char *value)
gboolean pcmk__str_in_list(const gchar *s, GList *lst, uint32_t flags)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
void(* print)(pe_resource_t *, const char *, long, void *)
#define XML_RSC_ATTR_INCARNATION_NODEMAX
gboolean pe__bundle_active(pe_resource_t *rsc, gboolean all)
void(* free)(pe_resource_t *)
void free_xml(xmlNode *child)
enum pe_obj_types variant
int pe__bundle_xml(pcmk__output_t *out, va_list args)
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)
int pe__bundle_html(pcmk__output_t *out, va_list args)
int pe_bundle_replicas(const pe_resource_t *rsc)
Get the number of configured replicas in a bundle.
#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
#define PCMK__OUTPUT_LIST_HEADER(out_obj, cond, retcode, title...)
Cluster status and scheduling.
gboolean(* is_filtered)(pe_resource_t *, GList *, gboolean)
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)
void pe__print_bundle(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
#define status_print(fmt, args...)
This structure contains everything that makes up a single output formatter.
#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)
gboolean pe__unpack_bundle(pe_resource_t *rsc, 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.
pe_resource_t * pe__find_bundle_replica(const pe_resource_t *bundle, const pe_node_t *node)
gboolean(* active)(pe_resource_t *, gboolean)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes