23 #define PE__VARIANT_BUNDLE 1 37 const pe__bundle_variant_data_t *bundle_data = NULL;
40 return bundle_data->nreplicas;
54 const pe__bundle_variant_data_t *bundle_data = NULL;
57 return bundle_data->nreplicas_per_host;
61 next_ip(
const char *last_ip)
63 unsigned int oct1 = 0;
64 unsigned int oct2 = 0;
65 unsigned int oct3 = 0;
66 unsigned int oct4 = 0;
67 int rc = sscanf(last_ip,
"%u.%u.%u.%u", &oct1, &oct2, &oct3, &oct4);
73 }
else if (oct3 > 253) {
76 }
else if (oct4 > 253) {
88 allocate_ip(pe__bundle_variant_data_t *
data, pe__bundle_replica_t *replica,
91 if(
data->ip_range_start == NULL) {
94 }
else if(
data->ip_last) {
95 replica->ipaddr = next_ip(
data->ip_last);
98 replica->ipaddr = strdup(
data->ip_range_start);
101 data->ip_last = replica->ipaddr;
102 switch (
data->agent_type) {
103 case PE__CONTAINER_AGENT_DOCKER:
104 case PE__CONTAINER_AGENT_PODMAN:
105 if (
data->add_host) {
106 g_string_append_printf(buffer,
" --add-host=%s-%d:%s",
107 data->prefix, replica->offset,
110 g_string_append_printf(buffer,
" --hosts-entry=%s=%s-%d",
111 replica->ipaddr,
data->prefix,
116 case PE__CONTAINER_AGENT_RKT:
117 g_string_append_printf(buffer,
" --hosts-entry=%s=%s-%d",
118 replica->ipaddr,
data->prefix,
128 create_resource(
const char *
name,
const char *provider,
const char *kind)
153 valid_network(pe__bundle_variant_data_t *
data)
155 if(
data->ip_range_start) {
158 if(
data->control_port) {
159 if(
data->nreplicas_per_host > 1) {
160 pe_err(
"Specifying the 'control-port' for %s requires 'replicas-per-host=1'",
data->prefix);
161 data->nreplicas_per_host = 1;
171 pe__bundle_replica_t *replica)
173 if(
data->ip_range_start) {
175 xmlNode *xml_ip = NULL;
176 xmlNode *xml_obj = NULL;
180 xml_ip = create_resource(
id,
"heartbeat",
"IPaddr2");
185 data->prefix, replica->offset);
188 if(
data->host_network) {
192 if(
data->host_netmask) {
194 "cidr_netmask",
data->host_netmask);
210 parent->children = g_list_append(
parent->children, replica->ip);
216 container_agent_str(
enum pe__container_agent t)
219 case PE__CONTAINER_AGENT_DOCKER:
return PE__CONTAINER_AGENT_DOCKER_S;
220 case PE__CONTAINER_AGENT_RKT:
return PE__CONTAINER_AGENT_RKT_S;
221 case PE__CONTAINER_AGENT_PODMAN:
return PE__CONTAINER_AGENT_PODMAN_S;
225 return PE__CONTAINER_AGENT_UNKNOWN_S;
230 const pe__bundle_variant_data_t *
data,
231 pe__bundle_replica_t *replica)
234 xmlNode *xml_container = NULL;
235 xmlNode *xml_obj = NULL;
238 const char *hostname_opt = NULL;
239 const char *env_opt = NULL;
240 const char *agent_str = NULL;
243 GString *buffer = NULL;
244 GString *dbuffer = NULL;
247 switch (
data->agent_type) {
248 case PE__CONTAINER_AGENT_DOCKER:
249 case PE__CONTAINER_AGENT_PODMAN:
250 hostname_opt =
"-h ";
253 case PE__CONTAINER_AGENT_RKT:
254 hostname_opt =
"--hostname=";
255 env_opt =
"--environment=";
260 agent_str = container_agent_str(
data->agent_type);
262 buffer = g_string_sized_new(4096);
267 xml_container = create_resource(
id,
"heartbeat", agent_str);
278 if (
data->agent_type == PE__CONTAINER_AGENT_DOCKER) {
279 g_string_append(buffer,
" --restart=no");
287 if (
data->ip_range_start != NULL) {
288 g_string_append_printf(buffer,
" %s%s-%d", hostname_opt,
data->prefix,
293 if (
data->container_network != NULL) {
297 if (
data->control_port != NULL) {
299 data->control_port, NULL);
301 g_string_append_printf(buffer,
" %sPCMK_remote_port=%d", env_opt,
305 for (GList *iter =
data->mounts; iter != NULL; iter = iter->next) {
306 pe__bundle_mount_t *mount = (pe__bundle_mount_t *) iter->data;
309 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
315 switch (
data->agent_type) {
316 case PE__CONTAINER_AGENT_DOCKER:
317 case PE__CONTAINER_AGENT_PODMAN:
319 " -v ", pcmk__s(source, mount->source),
320 ":", mount->target, NULL);
322 if (mount->options != NULL) {
326 case PE__CONTAINER_AGENT_RKT:
327 g_string_append_printf(buffer,
328 " --volume vol%d,kind=host," 330 "--mount volume=vol%d,target=%s",
331 volid, pcmk__s(source, mount->source),
332 (mount->options != NULL)?
"," :
"",
333 pcmk__s(mount->options,
""),
334 volid, mount->target);
343 for (GList *iter =
data->ports; iter != NULL; iter = iter->next) {
344 pe__bundle_port_t *port = (pe__bundle_port_t *) iter->data;
346 switch (
data->agent_type) {
347 case PE__CONTAINER_AGENT_DOCKER:
348 case PE__CONTAINER_AGENT_PODMAN:
349 if (replica->ipaddr != NULL) {
351 " -p ", replica->ipaddr,
":", port->source,
352 ":", port->target, NULL);
354 }
else if (!pcmk__str_eq(
data->container_network,
"host",
358 " -p ", port->source,
":", port->target,
362 case PE__CONTAINER_AGENT_RKT:
363 if (replica->ipaddr != NULL) {
365 " --port=", port->target,
366 ":", replica->ipaddr,
":", port->source,
370 " --port=", port->target,
":", port->source,
391 if (
data->launcher_options != NULL) {
395 if (
data->container_host_options != NULL) {
400 (
const char *) buffer->str);
401 g_string_free(buffer, TRUE);
404 (dbuffer != NULL)? (
const char *) dbuffer->str :
"");
405 if (dbuffer != NULL) {
406 g_string_free(dbuffer, TRUE);
409 if (replica->child != NULL) {
410 if (
data->container_command != NULL) {
412 data->container_command);
431 }
else if ((child != NULL) &&
data->untrusted) {
438 if (
data->container_command != NULL) {
440 data->container_command);
460 parent->children = g_list_append(
parent->children, replica->container);
481 g_list_foreach(rsc->
children, (GFunc) disallow_node, (gpointer)
uname);
487 pe__bundle_replica_t *replica)
489 if (replica->child && valid_network(
data)) {
490 GHashTableIter gIter;
492 xmlNode *xml_remote = NULL;
495 const char *
uname = NULL;
496 const char *connect_name = NULL;
502 replica->child->id, replica->offset);
512 connect_name = (replica->ipaddr? replica->ipaddr :
"#uname");
514 if (
data->control_port == NULL) {
525 connect_name, (
data->control_port?
526 data->control_port : port_s));
567 g_list_foreach(
parent->cluster->resources, (GFunc) disallow_node,
571 replica->node->weight = 500;
575 if (replica->child->allowed_nodes != NULL) {
576 g_hash_table_destroy(replica->child->allowed_nodes);
579 g_hash_table_insert(replica->child->allowed_nodes,
580 (gpointer) replica->node->details->id,
586 g_hash_table_insert(replica->child->parent->allowed_nodes,
587 (gpointer) replica->node->details->id, copy);
594 g_hash_table_iter_init(&gIter, replica->remote->allowed_nodes);
595 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&node)) {
602 replica->node->details->remote_rsc = replica->remote;
605 replica->remote->container = replica->container;
610 g_hash_table_insert(replica->node->details->attrs,
622 parent->children = g_list_append(
parent->children, replica->remote);
629 pe__bundle_replica_t *replica)
633 rc = create_container_resource(
parent,
data, replica);
638 rc = create_ip_resource(
parent,
data, replica);
643 rc = create_remote_resource(
parent,
data, replica);
648 if ((replica->child != NULL) && (replica->ipaddr != NULL)) {
649 add_hash_param(replica->child->meta,
"external-ip", replica->ipaddr);
652 if (replica->remote != NULL) {
667 mount_add(pe__bundle_variant_data_t *bundle_data,
const char *source,
668 const char *
target,
const char *options, uint32_t
flags)
670 pe__bundle_mount_t *mount = calloc(1,
sizeof(pe__bundle_mount_t));
673 mount->source = strdup(source);
674 mount->target = strdup(
target);
676 mount->flags =
flags;
677 bundle_data->mounts = g_list_append(bundle_data->mounts, mount);
681 mount_free(pe__bundle_mount_t *mount)
685 free(mount->options);
690 port_free(pe__bundle_port_t *port)
697 static pe__bundle_replica_t *
701 pe__bundle_variant_data_t *bundle_data = NULL;
707 while (top->
parent != NULL) {
711 get_bundle_variant_data(bundle_data, top);
712 for (GList *gIter = bundle_data->replicas; gIter != NULL;
713 gIter = gIter->next) {
714 pe__bundle_replica_t *replica = gIter->data;
716 if (replica->remote == remote) {
728 GHashTable *params = NULL;
744 xmlNode *xml,
const char *field)
749 pe__bundle_replica_t *replica = NULL;
755 replica = replica_for_remote(rsc);
756 if (replica == NULL) {
760 node = replica->container->allocated_to;
765 node = pe__current_node(replica->container);
769 crm_trace(
"Cannot determine address for bundle connection %s", rsc->
id);
773 crm_trace(
"Setting address for bundle connection %s to bundle host %s",
774 rsc->
id, pe__node_name(node));
775 if(xml != NULL && field != NULL) {
782 #define pe__set_bundle_mount_flags(mount_xml, flags, flags_to_set) do { \ 783 flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \ 784 "Bundle mount", ID(mount_xml), flags, \ 785 (flags_to_set), #flags_to_set); \ 791 const char *value = NULL;
792 xmlNode *xml_obj = NULL;
793 xmlNode *xml_resource = NULL;
794 pe__bundle_variant_data_t *bundle_data = NULL;
795 bool need_log_mount = TRUE;
800 bundle_data = calloc(1,
sizeof(pe__bundle_variant_data_t));
802 bundle_data->prefix = strdup(rsc->
id);
805 if (xml_obj != NULL) {
806 bundle_data->agent_type = PE__CONTAINER_AGENT_DOCKER;
809 if (xml_obj != NULL) {
810 bundle_data->agent_type = PE__CONTAINER_AGENT_RKT;
813 if (xml_obj != NULL) {
814 bundle_data->agent_type = PE__CONTAINER_AGENT_PODMAN;
831 if ((value == NULL) && (bundle_data->promoted_max > 0)) {
832 bundle_data->nreplicas = bundle_data->promoted_max;
844 if (bundle_data->nreplicas_per_host == 1) {
862 bundle_data->add_host = TRUE;
865 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
866 xml_child = pcmk__xe_next(xml_child)) {
868 pe__bundle_port_t *port = calloc(1,
sizeof(pe__bundle_port_t));
871 if(port->source == NULL) {
877 if(port->source != NULL && strlen(port->source) > 0) {
878 if(port->target == NULL) {
879 port->target = strdup(port->source);
881 bundle_data->ports = g_list_append(bundle_data->ports, port);
884 pe_err(
"Invalid port directive %s",
ID(xml_child));
891 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
892 xml_child = pcmk__xe_next(xml_child)) {
897 int flags = pe__bundle_mount_none;
899 if (source == NULL) {
902 pe__bundle_mount_subdir);
906 mount_add(bundle_data, source,
target, options,
flags);
907 if (strcmp(
target,
"/var/log") == 0) {
908 need_log_mount = FALSE;
911 pe_err(
"Invalid mount directive %s",
ID(xml_child));
916 if (xml_obj && valid_network(bundle_data)) {
918 xmlNode *xml_set = NULL;
927 (bundle_data->promoted_max?
"master" 928 : (
const char *)xml_resource->name));
931 crm_xml_set_id(xml_set,
"%s-%s-meta", bundle_data->prefix, xml_resource->name);
936 value = pcmk__itoa(bundle_data->nreplicas);
941 value = pcmk__itoa(bundle_data->nreplicas_per_host);
947 pcmk__btoa(bundle_data->nreplicas_per_host > 1));
949 if (bundle_data->promoted_max) {
953 value = pcmk__itoa(bundle_data->promoted_max);
963 pe_err(
"Cannot control %s inside %s without either ip-range-start or control-port",
964 rsc->
id,
ID(xml_obj));
970 GList *childIter = NULL;
971 pe__bundle_port_t *port = NULL;
972 GString *buffer = NULL;
1003 if (need_log_mount) {
1005 pe__bundle_mount_subdir);
1008 port = calloc(1,
sizeof(pe__bundle_port_t));
1009 if(bundle_data->control_port) {
1010 port->source = strdup(bundle_data->control_port);
1022 port->target = strdup(port->source);
1023 bundle_data->ports = g_list_append(bundle_data->ports, port);
1025 buffer = g_string_sized_new(1024);
1026 for (childIter = bundle_data->child->children; childIter != NULL;
1027 childIter = childIter->next) {
1029 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1031 replica->child = childIter->data;
1032 replica->child->exclusive_discover = TRUE;
1033 replica->offset = lpc++;
1040 allocate_ip(bundle_data, replica, buffer);
1041 bundle_data->replicas = g_list_append(bundle_data->replicas,
1043 bundle_data->attribute_target = g_hash_table_lookup(replica->child->meta,
1046 bundle_data->container_host_options = g_string_free(buffer, FALSE);
1048 if (bundle_data->attribute_target) {
1050 strdup(bundle_data->attribute_target));
1051 g_hash_table_replace(bundle_data->child->meta,
1053 strdup(bundle_data->attribute_target));
1058 GString *buffer = g_string_sized_new(1024);
1060 for (
int lpc = 0; lpc < bundle_data->nreplicas; lpc++) {
1061 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1063 replica->offset = lpc;
1064 allocate_ip(bundle_data, replica, buffer);
1065 bundle_data->replicas = g_list_append(bundle_data->replicas,
1068 bundle_data->container_host_options = g_string_free(buffer, FALSE);
1071 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1072 gIter = gIter->next) {
1073 pe__bundle_replica_t *replica = gIter->data;
1075 if (create_replica_resources(rsc, bundle_data, replica) !=
pcmk_rc_ok) {
1076 pe_err(
"Failed unpacking resource %s", rsc->
id);
1097 if (replica->child != NULL) {
1098 GHashTable *empty = replica->container->utilization;
1100 replica->container->utilization = replica->child->utilization;
1101 replica->child->utilization = empty;
1105 if (bundle_data->child) {
1115 gboolean child_active = rsc->
fns->
active(rsc, all);
1117 if (child_active && !all) {
1119 }
else if (!child_active && all) {
1129 pe__bundle_variant_data_t *bundle_data = NULL;
1132 get_bundle_variant_data(bundle_data, rsc);
1133 for (iter = bundle_data->replicas; iter != NULL; iter = iter->next) {
1134 pe__bundle_replica_t *replica = iter->data;
1137 rsc_active = replica_resource_active(replica->ip, all);
1138 if (rsc_active >= 0) {
1139 return (gboolean) rsc_active;
1142 rsc_active = replica_resource_active(replica->child, all);
1143 if (rsc_active >= 0) {
1144 return (gboolean) rsc_active;
1147 rsc_active = replica_resource_active(replica->container, all);
1148 if (rsc_active >= 0) {
1149 return (gboolean) rsc_active;
1152 rsc_active = replica_resource_active(replica->remote, all);
1153 if (rsc_active >= 0) {
1154 return (gboolean) rsc_active;
1177 pe__bundle_variant_data_t *bundle_data = NULL;
1180 get_bundle_variant_data(bundle_data, bundle);
1181 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1182 gIter = gIter->next) {
1183 pe__bundle_replica_t *replica = gIter->data;
1186 if (replica->node->details == node->
details) {
1187 return replica->child;
1198 print_rsc_in_list(
pe_resource_t *rsc,
const char *pre_text,
long options,
1205 rsc->
fns->
print(rsc, pre_text, options, print_data);
1217 bundle_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
1220 pe__bundle_variant_data_t *bundle_data = NULL;
1221 char *child_text = NULL;
1224 if (pre_text == NULL) {
1229 get_bundle_variant_data(bundle_data, rsc);
1233 status_print(
"type=\"%s\" ", container_agent_str(bundle_data->agent_type));
1240 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1241 gIter = gIter->next) {
1242 pe__bundle_replica_t *replica = gIter->data;
1246 pre_text, replica->offset);
1247 print_rsc_in_list(replica->ip, child_text, options, print_data);
1248 print_rsc_in_list(replica->child, child_text, options, print_data);
1249 print_rsc_in_list(replica->container, child_text, options, print_data);
1250 print_rsc_in_list(replica->remote, child_text, options, print_data);
1257 PCMK__OUTPUT_ARGS(
"bundle",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1261 uint32_t show_opts = va_arg(args, uint32_t);
1263 GList *only_node = va_arg(args, GList *);
1264 GList *only_rsc = va_arg(args, GList *);
1266 pe__bundle_variant_data_t *bundle_data = NULL;
1268 gboolean printed_header = FALSE;
1269 gboolean print_everything = TRUE;
1271 const char *desc = NULL;
1275 get_bundle_variant_data(bundle_data, rsc);
1283 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1284 gIter = gIter->next) {
1285 pe__bundle_replica_t *replica = gIter->data;
1287 gboolean print_ip, print_child, print_ctnr, print_remote;
1295 print_ip = replica->ip != NULL &&
1296 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1297 print_child = replica->child != NULL &&
1298 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1299 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1300 print_remote = replica->remote != NULL &&
1301 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1303 if (!print_everything && !print_ip && !print_child && !print_ctnr && !print_remote) {
1307 if (!printed_header) {
1308 printed_header = TRUE;
1314 "type", container_agent_str(bundle_data->agent_type),
1315 "image", bundle_data->image,
1320 "description", desc);
1324 id = pcmk__itoa(replica->offset);
1330 out->message(out, crm_map_element_name(replica->ip->xml), show_opts,
1331 replica->ip, only_node, only_rsc);
1335 out->message(out, crm_map_element_name(replica->child->xml), show_opts,
1336 replica->child, only_node, only_rsc);
1340 out->message(out, crm_map_element_name(replica->container->xml), show_opts,
1341 replica->container, only_node, only_rsc);
1345 out->message(out, crm_map_element_name(replica->remote->xml), show_opts,
1346 replica->remote, only_node, only_rsc);
1352 if (printed_header) {
1360 pe__bundle_replica_output_html(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1366 char buffer[LINE_MAX];
1372 if (replica->remote) {
1373 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1376 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1379 if (replica->ipaddr) {
1380 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1400 return " (maintenance)";
1403 return " (unmanaged)";
1408 PCMK__OUTPUT_ARGS(
"bundle",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1412 uint32_t show_opts = va_arg(args, uint32_t);
1414 GList *only_node = va_arg(args, GList *);
1415 GList *only_rsc = va_arg(args, GList *);
1417 const char *desc = NULL;
1418 pe__bundle_variant_data_t *bundle_data = NULL;
1420 gboolean print_everything = TRUE;
1424 get_bundle_variant_data(bundle_data, rsc);
1434 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1435 gIter = gIter->next) {
1436 pe__bundle_replica_t *replica = gIter->data;
1437 gboolean print_ip, print_child, print_ctnr, print_remote;
1445 print_ip = replica->ip != NULL &&
1446 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1447 print_child = replica->child != NULL &&
1448 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1449 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1450 print_remote = replica->remote != NULL &&
1451 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1454 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1461 (bundle_data->nreplicas > 1)?
" set" :
"",
1462 rsc->
id, bundle_data->image,
1464 desc ?
" (" :
"", desc ? desc :
"", desc ?
")" :
"",
1465 get_unmanaged_str(rsc));
1467 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1468 out->begin_list(out, NULL, NULL,
"Replica[%d]", replica->offset);
1472 out->message(out, crm_map_element_name(replica->ip->xml),
1473 new_show_opts, replica->ip, only_node, only_rsc);
1477 out->message(out, crm_map_element_name(replica->child->xml),
1478 new_show_opts, replica->child, only_node, only_rsc);
1482 out->message(out, crm_map_element_name(replica->container->xml),
1483 new_show_opts, replica->container, only_node, only_rsc);
1487 out->message(out, crm_map_element_name(replica->remote->xml),
1488 new_show_opts, replica->remote, only_node, only_rsc);
1491 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1494 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1498 (bundle_data->nreplicas > 1)?
" set" :
"",
1499 rsc->
id, bundle_data->image,
1501 desc ?
" (" :
"", desc ? desc :
"", desc ?
")" :
"",
1502 get_unmanaged_str(rsc));
1504 pe__bundle_replica_output_html(out, replica, pe__current_node(replica->container),
1514 pe__bundle_replica_output_text(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1520 char buffer[LINE_MAX];
1526 if (replica->remote) {
1527 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1530 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1533 if (replica->ipaddr) {
1534 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1541 PCMK__OUTPUT_ARGS(
"bundle",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1545 uint32_t show_opts = va_arg(args, uint32_t);
1547 GList *only_node = va_arg(args, GList *);
1548 GList *only_rsc = va_arg(args, GList *);
1550 const char *desc = NULL;
1551 pe__bundle_variant_data_t *bundle_data = NULL;
1553 gboolean print_everything = TRUE;
1557 get_bundle_variant_data(bundle_data, rsc);
1567 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1568 gIter = gIter->next) {
1569 pe__bundle_replica_t *replica = gIter->data;
1570 gboolean print_ip, print_child, print_ctnr, print_remote;
1578 print_ip = replica->ip != NULL &&
1579 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1580 print_child = replica->child != NULL &&
1581 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1582 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1583 print_remote = replica->remote != NULL &&
1584 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1587 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1594 (bundle_data->nreplicas > 1)?
" set" :
"",
1595 rsc->
id, bundle_data->image,
1597 desc ?
" (" :
"", desc ? desc :
"", desc ?
")" :
"",
1598 get_unmanaged_str(rsc));
1600 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1601 out->list_item(out, NULL,
"Replica[%d]", replica->offset);
1604 out->begin_list(out, NULL, NULL, NULL);
1607 out->message(out, crm_map_element_name(replica->ip->xml),
1608 new_show_opts, replica->ip, only_node, only_rsc);
1612 out->message(out, crm_map_element_name(replica->child->xml),
1613 new_show_opts, replica->child, only_node, only_rsc);
1617 out->message(out, crm_map_element_name(replica->container->xml),
1618 new_show_opts, replica->container, only_node, only_rsc);
1622 out->message(out, crm_map_element_name(replica->remote->xml),
1623 new_show_opts, replica->remote, only_node, only_rsc);
1627 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1631 (bundle_data->nreplicas > 1)?
" set" :
"",
1632 rsc->
id, bundle_data->image,
1634 desc ?
" (" :
"", desc ? desc :
"", desc ?
")" :
"",
1635 get_unmanaged_str(rsc));
1637 pe__bundle_replica_output_text(out, replica, pe__current_node(replica->container),
1651 print_bundle_replica(pe__bundle_replica_t *replica,
const char *pre_text,
1652 long options,
void *print_data)
1658 char buffer[LINE_MAX];
1664 if (replica->remote) {
1665 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1668 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1671 if (replica->ipaddr) {
1672 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1676 node = pe__current_node(replica->container);
1677 common_print(rsc, pre_text, buffer, node, options, print_data);
1688 pe__bundle_variant_data_t *bundle_data = NULL;
1689 char *child_text = NULL;
1693 bundle_print_xml(rsc, pre_text, options, print_data);
1697 get_bundle_variant_data(bundle_data, rsc);
1699 if (pre_text == NULL) {
1704 pre_text, ((bundle_data->nreplicas > 1)?
" set" :
""),
1705 rsc->
id, bundle_data->image,
1713 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1714 gIter = gIter->next) {
1715 pe__bundle_replica_t *replica = gIter->data;
1724 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1725 status_print(
" %sReplica[%d]\n", pre_text, replica->offset);
1730 print_rsc_in_list(replica->ip, child_text, options, print_data);
1731 print_rsc_in_list(replica->container, child_text, options, print_data);
1732 print_rsc_in_list(replica->remote, child_text, options, print_data);
1733 print_rsc_in_list(replica->child, child_text, options, print_data);
1739 print_bundle_replica(replica, child_text, options, print_data);
1753 free_bundle_replica(pe__bundle_replica_t *replica)
1755 if (replica == NULL) {
1759 if (replica->node) {
1760 free(replica->node);
1761 replica->node = NULL;
1766 replica->ip->xml = NULL;
1767 replica->ip->fns->free(replica->ip);
1770 if (replica->container) {
1772 replica->container->xml = NULL;
1773 replica->container->fns->free(replica->container);
1774 replica->container = NULL;
1776 if (replica->remote) {
1778 replica->remote->xml = NULL;
1779 replica->remote->fns->free(replica->remote);
1780 replica->remote = NULL;
1782 free(replica->ipaddr);
1789 pe__bundle_variant_data_t *bundle_data = NULL;
1792 get_bundle_variant_data(bundle_data, rsc);
1795 free(bundle_data->prefix);
1796 free(bundle_data->image);
1797 free(bundle_data->control_port);
1798 free(bundle_data->host_network);
1799 free(bundle_data->host_netmask);
1800 free(bundle_data->ip_range_start);
1801 free(bundle_data->container_network);
1802 free(bundle_data->launcher_options);
1803 free(bundle_data->container_command);
1804 g_free(bundle_data->container_host_options);
1806 g_list_free_full(bundle_data->replicas,
1807 (GDestroyNotify) free_bundle_replica);
1808 g_list_free_full(bundle_data->mounts, (GDestroyNotify)mount_free);
1809 g_list_free_full(bundle_data->ports, (GDestroyNotify)port_free);
1812 if(bundle_data->child) {
1814 bundle_data->child->xml = NULL;
1815 bundle_data->child->fns->free(bundle_data->child);
1824 return container_role;
1840 pe__bundle_variant_data_t *bundle_data = NULL;
1842 get_bundle_variant_data(bundle_data, rsc);
1843 return bundle_data->nreplicas;
1850 pe__bundle_variant_data_t *bundle_data = NULL;
1852 get_bundle_variant_data(bundle_data, rsc);
1853 for (GList *item = bundle_data->replicas; item != NULL; item = item->next) {
1854 pe__bundle_replica_t *replica = item->data;
1857 replica->ip->fns->count(replica->ip);
1859 if (replica->child) {
1860 replica->child->fns->count(replica->child);
1862 if (replica->container) {
1863 replica->container->fns->count(replica->container);
1865 if (replica->remote) {
1866 replica->remote->fns->count(replica->remote);
1873 gboolean check_parent)
1875 gboolean passes = FALSE;
1876 pe__bundle_variant_data_t *bundle_data = NULL;
1881 get_bundle_variant_data(bundle_data, rsc);
1883 for (GList *gIter = bundle_data->replicas; gIter != NULL; gIter = gIter->next) {
1884 pe__bundle_replica_t *replica = gIter->data;
1886 if (replica->ip != NULL && !replica->ip->fns->is_filtered(replica->ip, only_rsc, FALSE)) {
1889 }
else if (replica->child != NULL && !replica->child->fns->is_filtered(replica->child, only_rsc, FALSE)) {
1892 }
else if (!replica->container->fns->is_filtered(replica->container, only_rsc, FALSE)) {
1895 }
else if (replica->remote != NULL && !replica->remote->fns->is_filtered(replica->remote, only_rsc, FALSE)) {
1918 GList *containers = NULL;
1919 const pe__bundle_variant_data_t *
data = NULL;
1921 get_bundle_variant_data(
data, bundle);
1922 for (GList *iter =
data->replicas; iter != NULL; iter = iter->next) {
1923 pe__bundle_replica_t *replica = iter->data;
1925 containers = g_list_append(containers, replica->container);
1933 unsigned int *count_clean)
1938 GList *containers = NULL;
1940 GHashTable *nodes = NULL;
1941 const pe__bundle_variant_data_t *
data = NULL;
1943 if (count_all != NULL) {
1946 if (count_clean != NULL) {
1956 get_bundle_variant_data(
data, rsc);
1957 for (iter =
data->replicas; iter != NULL; iter = iter->next) {
1958 pe__bundle_replica_t *replica = iter->data;
1960 if (replica->container->running_on != NULL) {
1961 containers = g_list_append(containers, replica->container);
1964 if (containers == NULL) {
1974 if (pcmk__list_of_1(containers)) {
1975 container = containers->data;
1976 node = container->
fns->
active_node(container, count_all, count_clean);
1977 g_list_free(containers);
1982 nodes = g_hash_table_new(NULL, NULL);
1983 for (iter = containers; iter != NULL; iter = iter->next) {
1984 container = iter->data;
1986 for (GList *node_iter = container->
running_on; node_iter != NULL;
1987 node_iter = node_iter->next) {
1988 node = node_iter->data;
1991 if (g_hash_table_insert(nodes, (gpointer) node->
details,
2001 g_list_free(containers);
2002 g_hash_table_destroy(nodes);
#define CRM_CHECK(expr, failure_action)
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.
int pcmk__scan_min_int(const char *text, int *result, int minimum)
int pe__bundle_max_per_node(const pe_resource_t *rsc)
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)
const pe_resource_t * pe__const_top_resource(const pe_resource_t *rsc, bool include_bundle)
void pcmk__add_separated_word(GString **list, size_t init_size, const char *word, const char *separator)
#define PCMK_RESOURCE_CLASS_OCF
pe_resource_t * pe_find_resource(GList *rsc_list, const char *id_rh)
#define CRM_LOG_ASSERT(expr)
const char * pe__resource_description(const pe_resource_t *rsc, uint32_t show_opts)
#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)
pe_node_t *(* active_node)(const pe_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
#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)
GList * pe__bundle_containers(const pe_resource_t *bundle)
void pe__free_bundle(pe_resource_t *rsc)
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...)
void pcmk__g_strcat(GString *buffer,...) G_GNUC_NULL_TERMINATED
bool xml_contains_remote_node(xmlNode *xml)
bool pe__bundle_needs_remote_name(pe_resource_t *rsc)
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)
#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)
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)
gboolean(* is_filtered)(const pe_resource_t *, GList *, gboolean)
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
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)
bool pe__count_active_node(const pe_resource_t *rsc, pe_node_t *node, pe_node_t **active, unsigned int *count_all, unsigned int *count_clean)
int crm_str_to_boolean(const char *s, int *ret)
#define XML_RSC_ATTR_PROMOTED_MAX
const char * rsc_printable_id(const pe_resource_t *rsc)
#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)
#define pe_rsc_replica_container
void add_hash_param(GHashTable *hash, const char *name, const char *value)
void pe__print_bundle(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
#define status_print(fmt, args...)
pe_node_t * pe__bundle_active_node(const pe_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
This structure contains everything that makes up a single output formatter.
GHashTable * pe_rsc_params(pe_resource_t *rsc, const pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
#define pe__clear_resource_flags(resource, flags_to_clear)
pe_node_t * pe_find_node(const GList *node_list, const char *node_name)
Find a node by name in a list of nodes.
rsc_role_e
Possible roles that a resource can be in.
#define pe_rsc_maintenance
pe_node_t * pe_create_node(const char *id, const char *uname, const char *type, const char *score, pe_working_set_t *data_set)
pe_working_set_t * cluster
int pe__common_output_text(pcmk__output_t *out, const pe_resource_t *rsc, const char *name, const pe_node_t *node, unsigned int options)
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 pe__bundle_is_filtered(const pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
int pe__common_output_html(pcmk__output_t *out, const pe_resource_t *rsc, const char *name, const pe_node_t *node, unsigned int options)
void common_print(pe_resource_t *rsc, const char *pre_text, const char *name, const pe_node_t *node, long options, void *print_data)
int pe__bundle_max(const pe_resource_t *rsc)
int pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc, pe_resource_t *parent, pe_working_set_t *data_set)
gboolean(* active)(pe_resource_t *, gboolean)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes
gboolean pcmk__str_in_list(const gchar *s, const GList *lst, uint32_t flags)