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,
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 g_string_append_printf(buffer,
" --add-host=%s-%d:%s",
73 data->prefix, replica->offset,
76 g_string_append_printf(buffer,
" --hosts-entry=%s=%s-%d",
77 replica->ipaddr,
data->prefix,
82 case PE__CONTAINER_AGENT_RKT:
83 g_string_append_printf(buffer,
" --hosts-entry=%s=%s-%d",
84 replica->ipaddr,
data->prefix,
94 create_resource(
const char *
name,
const char *provider,
const char *kind)
119 valid_network(pe__bundle_variant_data_t *
data)
121 if(
data->ip_range_start) {
124 if(
data->control_port) {
125 if(
data->nreplicas_per_host > 1) {
126 pe_err(
"Specifying the 'control-port' for %s requires 'replicas-per-host=1'",
data->prefix);
127 data->nreplicas_per_host = 1;
137 pe__bundle_replica_t *replica)
139 if(
data->ip_range_start) {
141 xmlNode *xml_ip = NULL;
142 xmlNode *xml_obj = NULL;
146 xml_ip = create_resource(
id,
"heartbeat",
"IPaddr2");
151 data->prefix, replica->offset);
154 if(
data->host_network) {
158 if(
data->host_netmask) {
160 "cidr_netmask",
data->host_netmask);
176 parent->children = g_list_append(
parent->children, replica->ip);
182 container_agent_str(
enum pe__container_agent t)
185 case PE__CONTAINER_AGENT_DOCKER:
return PE__CONTAINER_AGENT_DOCKER_S;
186 case PE__CONTAINER_AGENT_RKT:
return PE__CONTAINER_AGENT_RKT_S;
187 case PE__CONTAINER_AGENT_PODMAN:
return PE__CONTAINER_AGENT_PODMAN_S;
191 return PE__CONTAINER_AGENT_UNKNOWN_S;
196 const pe__bundle_variant_data_t *
data,
197 pe__bundle_replica_t *replica)
200 xmlNode *xml_container = NULL;
201 xmlNode *xml_obj = NULL;
204 const char *hostname_opt = NULL;
205 const char *env_opt = NULL;
206 const char *agent_str = NULL;
209 GString *buffer = NULL;
210 GString *dbuffer = NULL;
213 switch (
data->agent_type) {
214 case PE__CONTAINER_AGENT_DOCKER:
215 case PE__CONTAINER_AGENT_PODMAN:
216 hostname_opt =
"-h ";
219 case PE__CONTAINER_AGENT_RKT:
220 hostname_opt =
"--hostname=";
221 env_opt =
"--environment=";
226 agent_str = container_agent_str(
data->agent_type);
228 buffer = g_string_sized_new(4096);
233 xml_container = create_resource(
id,
"heartbeat", agent_str);
244 if (
data->agent_type == PE__CONTAINER_AGENT_DOCKER) {
245 g_string_append(buffer,
" --restart=no");
253 if (
data->ip_range_start != NULL) {
254 g_string_append_printf(buffer,
" %s%s-%d", hostname_opt,
data->prefix,
259 if (
data->container_network != NULL) {
263 if (
data->control_port != NULL) {
265 data->control_port, NULL);
267 g_string_append_printf(buffer,
" %sPCMK_remote_port=%d", env_opt,
271 for (GList *iter =
data->mounts; iter != NULL; iter = iter->next) {
272 pe__bundle_mount_t *mount = (pe__bundle_mount_t *) iter->data;
275 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
281 switch (
data->agent_type) {
282 case PE__CONTAINER_AGENT_DOCKER:
283 case PE__CONTAINER_AGENT_PODMAN:
285 " -v ", pcmk__s(source, mount->source),
286 ":", mount->target, NULL);
288 if (mount->options != NULL) {
292 case PE__CONTAINER_AGENT_RKT:
293 g_string_append_printf(buffer,
294 " --volume vol%d,kind=host," 296 "--mount volume=vol%d,target=%s",
297 volid, pcmk__s(source, mount->source),
298 (mount->options != NULL)?
"," :
"",
299 pcmk__s(mount->options,
""),
300 volid, mount->target);
309 for (GList *iter =
data->ports; iter != NULL; iter = iter->next) {
310 pe__bundle_port_t *port = (pe__bundle_port_t *) iter->data;
312 switch (
data->agent_type) {
313 case PE__CONTAINER_AGENT_DOCKER:
314 case PE__CONTAINER_AGENT_PODMAN:
315 if (replica->ipaddr != NULL) {
317 " -p ", replica->ipaddr,
":", port->source,
318 ":", port->target, NULL);
320 }
else if (!pcmk__str_eq(
data->container_network,
"host",
324 " -p ", port->source,
":", port->target,
328 case PE__CONTAINER_AGENT_RKT:
329 if (replica->ipaddr != NULL) {
331 " --port=", port->target,
332 ":", replica->ipaddr,
":", port->source,
336 " --port=", port->target,
":", port->source,
357 if (
data->launcher_options != NULL) {
361 if (
data->container_host_options != NULL) {
366 (
const char *) buffer->str);
367 g_string_free(buffer, TRUE);
370 (dbuffer != NULL)? (
const char *) dbuffer->str :
"");
371 if (dbuffer != NULL) {
372 g_string_free(dbuffer, TRUE);
375 if (replica->child != NULL) {
376 if (
data->container_command != NULL) {
378 data->container_command);
397 }
else if ((child != NULL) &&
data->untrusted) {
404 if (
data->container_command != NULL) {
406 data->container_command);
425 parent->children = g_list_append(
parent->children, replica->container);
446 g_list_foreach(rsc->
children, (GFunc) disallow_node, (gpointer)
uname);
452 pe__bundle_replica_t *replica)
454 if (replica->child && valid_network(
data)) {
455 GHashTableIter gIter;
457 xmlNode *xml_remote = NULL;
460 const char *
uname = NULL;
461 const char *connect_name = NULL;
467 replica->child->id, replica->offset);
477 connect_name = (replica->ipaddr? replica->ipaddr :
"#uname");
479 if (
data->control_port == NULL) {
490 connect_name, (
data->control_port?
491 data->control_port : port_s));
532 g_list_foreach(
parent->cluster->resources, (GFunc) disallow_node,
536 replica->node->weight = 500;
540 if (replica->child->allowed_nodes != NULL) {
541 g_hash_table_destroy(replica->child->allowed_nodes);
544 g_hash_table_insert(replica->child->allowed_nodes,
545 (gpointer) replica->node->details->id,
551 g_hash_table_insert(replica->child->parent->allowed_nodes,
552 (gpointer) replica->node->details->id, copy);
559 g_hash_table_iter_init(&gIter, replica->remote->allowed_nodes);
560 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&node)) {
567 replica->node->details->remote_rsc = replica->remote;
570 replica->remote->container = replica->container;
575 g_hash_table_insert(replica->node->details->attrs,
587 parent->children = g_list_append(
parent->children, replica->remote);
594 pe__bundle_replica_t *replica)
598 rc = create_container_resource(
parent,
data, replica);
603 rc = create_ip_resource(
parent,
data, replica);
608 rc = create_remote_resource(
parent,
data, replica);
613 if ((replica->child != NULL) && (replica->ipaddr != NULL)) {
614 add_hash_param(replica->child->meta,
"external-ip", replica->ipaddr);
617 if (replica->remote != NULL) {
632 mount_add(pe__bundle_variant_data_t *bundle_data,
const char *source,
633 const char *
target,
const char *options, uint32_t
flags)
635 pe__bundle_mount_t *mount = calloc(1,
sizeof(pe__bundle_mount_t));
638 mount->source = strdup(source);
639 mount->target = strdup(
target);
641 mount->flags =
flags;
642 bundle_data->mounts = g_list_append(bundle_data->mounts, mount);
646 mount_free(pe__bundle_mount_t *mount)
650 free(mount->options);
655 port_free(pe__bundle_port_t *port)
662 static pe__bundle_replica_t *
666 pe__bundle_variant_data_t *bundle_data = NULL;
672 while (top->
parent != NULL) {
676 get_bundle_variant_data(bundle_data, top);
677 for (GList *gIter = bundle_data->replicas; gIter != NULL;
678 gIter = gIter->next) {
679 pe__bundle_replica_t *replica = gIter->data;
681 if (replica->remote == remote) {
693 GHashTable *params = NULL;
709 xmlNode *xml,
const char *field)
714 pe__bundle_replica_t *replica = NULL;
720 replica = replica_for_remote(rsc);
721 if (replica == NULL) {
725 node = replica->container->allocated_to;
730 node = pe__current_node(replica->container);
734 crm_trace(
"Cannot determine address for bundle connection %s", rsc->
id);
738 crm_trace(
"Setting address for bundle connection %s to bundle host %s",
739 rsc->
id, pe__node_name(node));
740 if(xml != NULL && field != NULL) {
747 #define pe__set_bundle_mount_flags(mount_xml, flags, flags_to_set) do { \ 748 flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \ 749 "Bundle mount", ID(mount_xml), flags, \ 750 (flags_to_set), #flags_to_set); \ 756 const char *value = NULL;
757 xmlNode *xml_obj = NULL;
758 xmlNode *xml_resource = NULL;
759 pe__bundle_variant_data_t *bundle_data = NULL;
760 bool need_log_mount = TRUE;
765 bundle_data = calloc(1,
sizeof(pe__bundle_variant_data_t));
767 bundle_data->prefix = strdup(rsc->
id);
770 if (xml_obj != NULL) {
771 bundle_data->agent_type = PE__CONTAINER_AGENT_DOCKER;
774 if (xml_obj != NULL) {
775 bundle_data->agent_type = PE__CONTAINER_AGENT_RKT;
778 if (xml_obj != NULL) {
779 bundle_data->agent_type = PE__CONTAINER_AGENT_PODMAN;
796 if ((value == NULL) && (bundle_data->promoted_max > 0)) {
797 bundle_data->nreplicas = bundle_data->promoted_max;
809 if (bundle_data->nreplicas_per_host == 1) {
827 bundle_data->add_host = TRUE;
830 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
831 xml_child = pcmk__xe_next(xml_child)) {
833 pe__bundle_port_t *port = calloc(1,
sizeof(pe__bundle_port_t));
836 if(port->source == NULL) {
842 if(port->source != NULL && strlen(port->source) > 0) {
843 if(port->target == NULL) {
844 port->target = strdup(port->source);
846 bundle_data->ports = g_list_append(bundle_data->ports, port);
849 pe_err(
"Invalid port directive %s",
ID(xml_child));
856 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
857 xml_child = pcmk__xe_next(xml_child)) {
862 int flags = pe__bundle_mount_none;
864 if (source == NULL) {
867 pe__bundle_mount_subdir);
871 mount_add(bundle_data, source,
target, options,
flags);
872 if (strcmp(
target,
"/var/log") == 0) {
873 need_log_mount = FALSE;
876 pe_err(
"Invalid mount directive %s",
ID(xml_child));
881 if (xml_obj && valid_network(bundle_data)) {
883 xmlNode *xml_set = NULL;
892 (bundle_data->promoted_max?
"master" 893 : (
const char *)xml_resource->name));
896 crm_xml_set_id(xml_set,
"%s-%s-meta", bundle_data->prefix, xml_resource->name);
901 value = pcmk__itoa(bundle_data->nreplicas);
906 value = pcmk__itoa(bundle_data->nreplicas_per_host);
912 pcmk__btoa(bundle_data->nreplicas_per_host > 1));
914 if (bundle_data->promoted_max) {
918 value = pcmk__itoa(bundle_data->promoted_max);
928 pe_err(
"Cannot control %s inside %s without either ip-range-start or control-port",
929 rsc->
id,
ID(xml_obj));
935 GList *childIter = NULL;
936 pe__bundle_port_t *port = NULL;
937 GString *buffer = NULL;
968 if (need_log_mount) {
970 pe__bundle_mount_subdir);
973 port = calloc(1,
sizeof(pe__bundle_port_t));
974 if(bundle_data->control_port) {
975 port->source = strdup(bundle_data->control_port);
987 port->target = strdup(port->source);
988 bundle_data->ports = g_list_append(bundle_data->ports, port);
990 buffer = g_string_sized_new(1024);
991 for (childIter = bundle_data->child->children; childIter != NULL;
992 childIter = childIter->next) {
994 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
996 replica->child = childIter->data;
997 replica->child->exclusive_discover = TRUE;
998 replica->offset = lpc++;
1005 allocate_ip(bundle_data, replica, buffer);
1006 bundle_data->replicas = g_list_append(bundle_data->replicas,
1008 bundle_data->attribute_target = g_hash_table_lookup(replica->child->meta,
1011 bundle_data->container_host_options = g_string_free(buffer, FALSE);
1013 if (bundle_data->attribute_target) {
1015 strdup(bundle_data->attribute_target));
1016 g_hash_table_replace(bundle_data->child->meta,
1018 strdup(bundle_data->attribute_target));
1023 GString *buffer = g_string_sized_new(1024);
1025 for (
int lpc = 0; lpc < bundle_data->nreplicas; lpc++) {
1026 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1028 replica->offset = lpc;
1029 allocate_ip(bundle_data, replica, buffer);
1030 bundle_data->replicas = g_list_append(bundle_data->replicas,
1033 bundle_data->container_host_options = g_string_free(buffer, FALSE);
1036 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1037 gIter = gIter->next) {
1038 pe__bundle_replica_t *replica = gIter->data;
1040 if (create_replica_resources(rsc, bundle_data, replica) !=
pcmk_rc_ok) {
1041 pe_err(
"Failed unpacking resource %s", rsc->
id);
1062 if (replica->child != NULL) {
1063 GHashTable *empty = replica->container->utilization;
1065 replica->container->utilization = replica->child->utilization;
1066 replica->child->utilization = empty;
1070 if (bundle_data->child) {
1080 gboolean child_active = rsc->
fns->
active(rsc, all);
1082 if (child_active && !all) {
1084 }
else if (!child_active && all) {
1094 pe__bundle_variant_data_t *bundle_data = NULL;
1097 get_bundle_variant_data(bundle_data, rsc);
1098 for (iter = bundle_data->replicas; iter != NULL; iter = iter->next) {
1099 pe__bundle_replica_t *replica = iter->data;
1102 rsc_active = replica_resource_active(replica->ip, all);
1103 if (rsc_active >= 0) {
1104 return (gboolean) rsc_active;
1107 rsc_active = replica_resource_active(replica->child, all);
1108 if (rsc_active >= 0) {
1109 return (gboolean) rsc_active;
1112 rsc_active = replica_resource_active(replica->container, all);
1113 if (rsc_active >= 0) {
1114 return (gboolean) rsc_active;
1117 rsc_active = replica_resource_active(replica->remote, all);
1118 if (rsc_active >= 0) {
1119 return (gboolean) rsc_active;
1142 pe__bundle_variant_data_t *bundle_data = NULL;
1145 get_bundle_variant_data(bundle_data, bundle);
1146 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1147 gIter = gIter->next) {
1148 pe__bundle_replica_t *replica = gIter->data;
1151 if (replica->node->details == node->
details) {
1152 return replica->child;
1163 print_rsc_in_list(
pe_resource_t *rsc,
const char *pre_text,
long options,
1170 rsc->
fns->
print(rsc, pre_text, options, print_data);
1182 bundle_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
1185 pe__bundle_variant_data_t *bundle_data = NULL;
1186 char *child_text = NULL;
1189 if (pre_text == NULL) {
1194 get_bundle_variant_data(bundle_data, rsc);
1198 status_print(
"type=\"%s\" ", container_agent_str(bundle_data->agent_type));
1205 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1206 gIter = gIter->next) {
1207 pe__bundle_replica_t *replica = gIter->data;
1210 status_print(
"%s <replica id=\"%d\">\n", pre_text, replica->offset);
1211 print_rsc_in_list(replica->ip, child_text, options, print_data);
1212 print_rsc_in_list(replica->child, child_text, options, print_data);
1213 print_rsc_in_list(replica->container, child_text, options, print_data);
1214 print_rsc_in_list(replica->remote, child_text, options, print_data);
1221 PCMK__OUTPUT_ARGS(
"bundle",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1225 uint32_t show_opts = va_arg(args, uint32_t);
1227 GList *only_node = va_arg(args, GList *);
1228 GList *only_rsc = va_arg(args, GList *);
1230 pe__bundle_variant_data_t *bundle_data = NULL;
1232 gboolean printed_header = FALSE;
1233 gboolean print_everything = TRUE;
1237 get_bundle_variant_data(bundle_data, rsc);
1245 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1246 gIter = gIter->next) {
1247 pe__bundle_replica_t *replica = gIter->data;
1249 gboolean print_ip, print_child, print_ctnr, print_remote;
1257 print_ip = replica->ip != NULL &&
1258 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1259 print_child = replica->child != NULL &&
1260 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1261 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1262 print_remote = replica->remote != NULL &&
1263 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1265 if (!print_everything && !print_ip && !print_child && !print_ctnr && !print_remote) {
1269 if (!printed_header) {
1270 printed_header = TRUE;
1274 "type", container_agent_str(bundle_data->agent_type),
1275 "image", bundle_data->image,
1282 id = pcmk__itoa(replica->offset);
1288 out->message(out, crm_map_element_name(replica->ip->xml), show_opts,
1289 replica->ip, only_node, only_rsc);
1293 out->message(out, crm_map_element_name(replica->child->xml), show_opts,
1294 replica->child, only_node, only_rsc);
1298 out->message(out, crm_map_element_name(replica->container->xml), show_opts,
1299 replica->container, only_node, only_rsc);
1303 out->message(out, crm_map_element_name(replica->remote->xml), show_opts,
1304 replica->remote, only_node, only_rsc);
1310 if (printed_header) {
1318 pe__bundle_replica_output_html(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1324 char buffer[LINE_MAX];
1330 if (replica->remote) {
1331 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1334 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1337 if (replica->ipaddr) {
1338 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1345 PCMK__OUTPUT_ARGS(
"bundle",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1349 uint32_t show_opts = va_arg(args, uint32_t);
1351 GList *only_node = va_arg(args, GList *);
1352 GList *only_rsc = va_arg(args, GList *);
1354 pe__bundle_variant_data_t *bundle_data = NULL;
1356 gboolean print_everything = TRUE;
1360 get_bundle_variant_data(bundle_data, rsc);
1368 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1369 gIter = gIter->next) {
1370 pe__bundle_replica_t *replica = gIter->data;
1371 gboolean print_ip, print_child, print_ctnr, print_remote;
1379 print_ip = replica->ip != NULL &&
1380 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1381 print_child = replica->child != NULL &&
1382 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1383 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1384 print_remote = replica->remote != NULL &&
1385 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1388 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1395 (bundle_data->nreplicas > 1)?
" set" :
"",
1396 rsc->
id, bundle_data->image,
1400 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1401 out->begin_list(out, NULL, NULL,
"Replica[%d]", replica->offset);
1405 out->message(out, crm_map_element_name(replica->ip->xml),
1406 new_show_opts, replica->ip, only_node, only_rsc);
1410 out->message(out, crm_map_element_name(replica->child->xml),
1411 new_show_opts, replica->child, only_node, only_rsc);
1415 out->message(out, crm_map_element_name(replica->container->xml),
1416 new_show_opts, replica->container, only_node, only_rsc);
1420 out->message(out, crm_map_element_name(replica->remote->xml),
1421 new_show_opts, replica->remote, only_node, only_rsc);
1424 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1427 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1431 (bundle_data->nreplicas > 1)?
" set" :
"",
1432 rsc->
id, bundle_data->image,
1436 pe__bundle_replica_output_html(out, replica, pe__current_node(replica->container),
1446 pe__bundle_replica_output_text(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1452 char buffer[LINE_MAX];
1458 if (replica->remote) {
1459 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1462 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1465 if (replica->ipaddr) {
1466 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1473 PCMK__OUTPUT_ARGS(
"bundle",
"uint32_t",
"pe_resource_t *",
"GList *",
"GList *")
1477 uint32_t show_opts = va_arg(args, uint32_t);
1479 GList *only_node = va_arg(args, GList *);
1480 GList *only_rsc = va_arg(args, GList *);
1482 pe__bundle_variant_data_t *bundle_data = NULL;
1484 gboolean print_everything = TRUE;
1486 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 gboolean print_ip, print_child, print_ctnr, print_remote;
1507 print_ip = replica->ip != NULL &&
1508 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1509 print_child = replica->child != NULL &&
1510 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1511 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1512 print_remote = replica->remote != NULL &&
1513 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1516 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1523 (bundle_data->nreplicas > 1)?
" set" :
"",
1524 rsc->
id, bundle_data->image,
1528 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1529 out->list_item(out, NULL,
"Replica[%d]", replica->offset);
1532 out->begin_list(out, NULL, NULL, NULL);
1535 out->message(out, crm_map_element_name(replica->ip->xml),
1536 new_show_opts, replica->ip, only_node, only_rsc);
1540 out->message(out, crm_map_element_name(replica->child->xml),
1541 new_show_opts, replica->child, only_node, only_rsc);
1545 out->message(out, crm_map_element_name(replica->container->xml),
1546 new_show_opts, replica->container, only_node, only_rsc);
1550 out->message(out, crm_map_element_name(replica->remote->xml),
1551 new_show_opts, replica->remote, only_node, only_rsc);
1555 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1559 (bundle_data->nreplicas > 1)?
" set" :
"",
1560 rsc->
id, bundle_data->image,
1564 pe__bundle_replica_output_text(out, replica, pe__current_node(replica->container),
1578 print_bundle_replica(pe__bundle_replica_t *replica,
const char *pre_text,
1579 long options,
void *print_data)
1585 char buffer[LINE_MAX];
1591 if (replica->remote) {
1592 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1595 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1598 if (replica->ipaddr) {
1599 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1603 node = pe__current_node(replica->container);
1604 common_print(rsc, pre_text, buffer, node, options, print_data);
1615 pe__bundle_variant_data_t *bundle_data = NULL;
1616 char *child_text = NULL;
1620 bundle_print_xml(rsc, pre_text, options, print_data);
1624 get_bundle_variant_data(bundle_data, rsc);
1626 if (pre_text == NULL) {
1631 pre_text, ((bundle_data->nreplicas > 1)?
" set" :
""),
1632 rsc->
id, bundle_data->image,
1640 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1641 gIter = gIter->next) {
1642 pe__bundle_replica_t *replica = gIter->data;
1651 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1652 status_print(
" %sReplica[%d]\n", pre_text, replica->offset);
1657 print_rsc_in_list(replica->ip, child_text, options, print_data);
1658 print_rsc_in_list(replica->container, child_text, options, print_data);
1659 print_rsc_in_list(replica->remote, child_text, options, print_data);
1660 print_rsc_in_list(replica->child, child_text, options, print_data);
1666 print_bundle_replica(replica, child_text, options, print_data);
1680 free_bundle_replica(pe__bundle_replica_t *replica)
1682 if (replica == NULL) {
1686 if (replica->node) {
1687 free(replica->node);
1688 replica->node = NULL;
1693 replica->ip->xml = NULL;
1694 replica->ip->fns->free(replica->ip);
1697 if (replica->container) {
1699 replica->container->xml = NULL;
1700 replica->container->fns->free(replica->container);
1701 replica->container = NULL;
1703 if (replica->remote) {
1705 replica->remote->xml = NULL;
1706 replica->remote->fns->free(replica->remote);
1707 replica->remote = NULL;
1709 free(replica->ipaddr);
1716 pe__bundle_variant_data_t *bundle_data = NULL;
1719 get_bundle_variant_data(bundle_data, rsc);
1722 free(bundle_data->prefix);
1723 free(bundle_data->image);
1724 free(bundle_data->control_port);
1725 free(bundle_data->host_network);
1726 free(bundle_data->host_netmask);
1727 free(bundle_data->ip_range_start);
1728 free(bundle_data->container_network);
1729 free(bundle_data->launcher_options);
1730 free(bundle_data->container_command);
1731 g_free(bundle_data->container_host_options);
1733 g_list_free_full(bundle_data->replicas,
1734 (GDestroyNotify) free_bundle_replica);
1735 g_list_free_full(bundle_data->mounts, (GDestroyNotify)mount_free);
1736 g_list_free_full(bundle_data->ports, (GDestroyNotify)port_free);
1739 if(bundle_data->child) {
1741 bundle_data->child->xml = NULL;
1742 bundle_data->child->fns->free(bundle_data->child);
1751 return container_role;
1767 pe__bundle_variant_data_t *bundle_data = NULL;
1769 get_bundle_variant_data(bundle_data, rsc);
1770 return bundle_data->nreplicas;
1777 pe__bundle_variant_data_t *bundle_data = NULL;
1779 get_bundle_variant_data(bundle_data, rsc);
1780 for (GList *item = bundle_data->replicas; item != NULL; item = item->next) {
1781 pe__bundle_replica_t *replica = item->data;
1784 replica->ip->fns->count(replica->ip);
1786 if (replica->child) {
1787 replica->child->fns->count(replica->child);
1789 if (replica->container) {
1790 replica->container->fns->count(replica->container);
1792 if (replica->remote) {
1793 replica->remote->fns->count(replica->remote);
1801 gboolean passes = FALSE;
1802 pe__bundle_variant_data_t *bundle_data = NULL;
1807 get_bundle_variant_data(bundle_data, rsc);
1809 for (GList *gIter = bundle_data->replicas; gIter != NULL; gIter = gIter->next) {
1810 pe__bundle_replica_t *replica = gIter->data;
1812 if (replica->ip != NULL && !replica->ip->fns->is_filtered(replica->ip, only_rsc, FALSE)) {
1815 }
else if (replica->child != NULL && !replica->child->fns->is_filtered(replica->child, only_rsc, FALSE)) {
1818 }
else if (!replica->container->fns->is_filtered(replica->container, only_rsc, FALSE)) {
1821 }
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)
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)
#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)
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)
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)
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.
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)
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 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)
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)