22 #define PE__VARIANT_BUNDLE 1 26 next_ip(
const char *last_ip)
28 unsigned int oct1 = 0;
29 unsigned int oct2 = 0;
30 unsigned int oct3 = 0;
31 unsigned int oct4 = 0;
32 int rc = sscanf(last_ip,
"%u.%u.%u.%u", &oct1, &oct2, &oct3, &oct4);
38 }
else if (oct3 > 253) {
41 }
else if (oct4 > 253) {
53 allocate_ip(pe__bundle_variant_data_t *
data, pe__bundle_replica_t *replica,
54 char *buffer,
int max)
56 if(
data->ip_range_start == NULL) {
59 }
else if(
data->ip_last) {
60 replica->ipaddr = next_ip(
data->ip_last);
63 replica->ipaddr = strdup(
data->ip_range_start);
66 data->ip_last = replica->ipaddr;
67 switch (
data->agent_type) {
68 case PE__CONTAINER_AGENT_DOCKER:
69 case PE__CONTAINER_AGENT_PODMAN:
71 return snprintf(buffer, max,
" --add-host=%s-%d:%s",
72 data->prefix, replica->offset,
75 case PE__CONTAINER_AGENT_RKT:
76 return snprintf(buffer, max,
" --hosts-entry=%s=%s-%d",
77 replica->ipaddr,
data->prefix, replica->offset);
85 create_resource(
const char *
name,
const char *provider,
const char *kind)
110 valid_network(pe__bundle_variant_data_t *
data)
112 if(
data->ip_range_start) {
115 if(
data->control_port) {
116 if(
data->nreplicas_per_host > 1) {
117 pe_err(
"Specifying the 'control-port' for %s requires 'replicas-per-host=1'",
data->prefix);
118 data->nreplicas_per_host = 1;
130 if(
data->ip_range_start) {
132 xmlNode *xml_ip = NULL;
133 xmlNode *xml_obj = NULL;
137 xml_ip = create_resource(
id,
"heartbeat",
"IPaddr2");
142 data->prefix, replica->offset);
145 if(
data->host_network) {
149 if(
data->host_netmask) {
151 "cidr_netmask",
data->host_netmask);
162 if (!
common_unpack(xml_ip, &replica->ip, parent, data_set)) {
173 pe__bundle_replica_t *replica,
176 int offset = 0, max = 4096;
177 char *buffer = calloc(1, max+1);
179 int doffset = 0, dmax = 1024;
180 char *dbuffer = calloc(1, dmax+1);
183 xmlNode *xml_container = NULL;
184 xmlNode *xml_obj = NULL;
188 xml_container = create_resource(
id,
"heartbeat",
189 PE__CONTAINER_AGENT_DOCKER_S);
194 data->prefix, replica->offset);
201 offset += snprintf(buffer+offset, max-offset,
" --restart=no");
208 if (
data->ip_range_start != NULL) {
209 offset += snprintf(buffer+offset, max-offset,
" -h %s-%d",
210 data->prefix, replica->offset);
213 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_stderr=1");
215 if (
data->container_network) {
217 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
220 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
221 data->container_network);
224 if(
data->control_port) {
225 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%s",
data->control_port);
227 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
230 for(GList *pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
231 pe__bundle_mount_t *mount = pIter->data;
233 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
235 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
238 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
240 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
241 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", source, mount->target);
245 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", mount->source, mount->target);
248 offset += snprintf(buffer+offset, max-offset,
":%s", mount->options);
252 for(GList *pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
253 pe__bundle_port_t *port = pIter->data;
255 if (replica->ipaddr) {
256 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s:%s",
257 replica->ipaddr, port->source,
261 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s", port->source, port->target);
265 if (
data->launcher_options) {
266 offset += snprintf(buffer+offset, max-offset,
" %s",
267 data->launcher_options);
270 if (
data->container_host_options) {
271 offset += snprintf(buffer + offset, max - offset,
" %s",
272 data->container_host_options);
281 if (replica->child) {
282 if (
data->container_command) {
284 "run_cmd",
data->container_command);
287 "run_cmd",
SBIN_DIR "/pacemaker-remoted");
303 }
else if ((child != NULL) &&
data->untrusted) {
310 if (
data->container_command) {
312 "run_cmd",
data->container_command);
328 if (!
common_unpack(xml_container, &replica->container, parent, data_set)) {
337 pe__bundle_replica_t *replica,
340 int offset = 0, max = 4096;
341 char *buffer = calloc(1, max+1);
343 int doffset = 0, dmax = 1024;
344 char *dbuffer = calloc(1, dmax+1);
347 xmlNode *xml_container = NULL;
348 xmlNode *xml_obj = NULL;
352 xml_container = create_resource(
id,
"heartbeat",
353 PE__CONTAINER_AGENT_PODMAN_S);
358 data->prefix, replica->offset);
373 if (
data->ip_range_start != NULL) {
374 offset += snprintf(buffer+offset, max-offset,
" -h %s-%d",
375 data->prefix, replica->offset);
378 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_stderr=1");
380 if (
data->container_network) {
383 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
386 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
387 data->container_network);
390 if(
data->control_port) {
391 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%s",
data->control_port);
393 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
396 for(GList *pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
397 pe__bundle_mount_t *mount = pIter->data;
399 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
401 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
404 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
406 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
407 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", source, mount->target);
411 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", mount->source, mount->target);
414 offset += snprintf(buffer+offset, max-offset,
":%s", mount->options);
418 for(GList *pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
419 pe__bundle_port_t *port = pIter->data;
421 if (replica->ipaddr) {
422 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s:%s",
423 replica->ipaddr, port->source,
427 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s", port->source, port->target);
431 if (
data->launcher_options) {
432 offset += snprintf(buffer+offset, max-offset,
" %s",
433 data->launcher_options);
436 if (
data->container_host_options) {
437 offset += snprintf(buffer + offset, max - offset,
" %s",
438 data->container_host_options);
447 if (replica->child) {
448 if (
data->container_command) {
450 "run_cmd",
data->container_command);
453 "run_cmd",
SBIN_DIR "/pacemaker-remoted");
469 }
else if ((child != NULL) &&
data->untrusted) {
476 if (
data->container_command) {
478 "run_cmd",
data->container_command);
494 if (!
common_unpack(xml_container, &replica->container, parent,
506 int offset = 0, max = 4096;
507 char *buffer = calloc(1, max+1);
509 int doffset = 0, dmax = 1024;
510 char *dbuffer = calloc(1, dmax+1);
513 xmlNode *xml_container = NULL;
514 xmlNode *xml_obj = NULL;
520 xml_container = create_resource(
id,
"heartbeat",
521 PE__CONTAINER_AGENT_RKT_S);
526 data->prefix, replica->offset);
538 if (
data->ip_range_start != NULL) {
539 offset += snprintf(buffer+offset, max-offset,
" --hostname=%s-%d",
540 data->prefix, replica->offset);
543 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_stderr=1");
545 if (
data->container_network) {
547 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
550 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
551 data->container_network);
554 if(
data->control_port) {
555 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_remote_port=%s",
data->control_port);
557 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
560 for(GList *pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
561 pe__bundle_mount_t *mount = pIter->data;
563 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
565 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
568 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
570 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
571 offset += snprintf(buffer+offset, max-offset,
" --volume vol%d,kind=host,source=%s", volid, source);
573 offset += snprintf(buffer+offset, max-offset,
",%s", mount->options);
575 offset += snprintf(buffer+offset, max-offset,
" --mount volume=vol%d,target=%s", volid, mount->target);
579 offset += snprintf(buffer+offset, max-offset,
" --volume vol%d,kind=host,source=%s", volid, mount->source);
581 offset += snprintf(buffer+offset, max-offset,
",%s", mount->options);
583 offset += snprintf(buffer+offset, max-offset,
" --mount volume=vol%d,target=%s", volid, mount->target);
588 for(GList *pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
589 pe__bundle_port_t *port = pIter->data;
591 if (replica->ipaddr) {
592 offset += snprintf(buffer+offset, max-offset,
593 " --port=%s:%s:%s", port->target,
594 replica->ipaddr, port->source);
596 offset += snprintf(buffer+offset, max-offset,
" --port=%s:%s", port->target, port->source);
600 if (
data->launcher_options) {
601 offset += snprintf(buffer+offset, max-offset,
" %s",
602 data->launcher_options);
605 if (
data->container_host_options) {
606 offset += snprintf(buffer + offset, max - offset,
" %s",
607 data->container_host_options);
616 if (replica->child) {
617 if (
data->container_command) {
619 data->container_command);
638 }
else if ((child != NULL) &&
data->untrusted) {
645 if (
data->container_command) {
647 data->container_command);
664 if (!
common_unpack(xml_container, &replica->container, parent, data_set)) {
687 g_list_foreach(rsc->
children, (GFunc) disallow_node, (gpointer)
uname);
693 pe__bundle_replica_t *replica,
696 if (replica->child && valid_network(
data)) {
697 GHashTableIter gIter;
699 xmlNode *xml_remote = NULL;
702 const char *
uname = NULL;
703 const char *connect_name = NULL;
709 replica->child->id, replica->offset);
718 connect_name = (replica->ipaddr? replica->ipaddr :
"#uname");
720 if (
data->control_port == NULL) {
731 connect_name, (
data->control_port?
732 data->control_port : port_s));
773 g_list_foreach(data_set->
resources, (GFunc) disallow_node, (gpointer)
uname);
776 replica->node->weight = 500;
780 if (replica->child->allowed_nodes != NULL) {
781 g_hash_table_destroy(replica->child->allowed_nodes);
784 g_hash_table_insert(replica->child->allowed_nodes,
785 (gpointer) replica->node->details->id,
791 g_hash_table_insert(replica->child->parent->allowed_nodes,
792 (gpointer) replica->node->details->id, copy);
794 if (!
common_unpack(xml_remote, &replica->remote, parent, data_set)) {
798 g_hash_table_iter_init(&gIter, replica->remote->allowed_nodes);
799 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&node)) {
806 replica->node->details->remote_rsc = replica->remote;
809 replica->remote->container = replica->container;
814 g_hash_table_insert(replica->node->details->attrs,
836 switch (
data->agent_type) {
837 case PE__CONTAINER_AGENT_DOCKER:
838 if (!create_docker_resource(parent,
data, replica, data_set)) {
843 case PE__CONTAINER_AGENT_PODMAN:
844 if (!create_podman_resource(parent,
data, replica, data_set)) {
849 case PE__CONTAINER_AGENT_RKT:
850 if (!create_rkt_resource(parent,
data, replica, data_set)) {
858 if (create_ip_resource(parent,
data, replica, data_set) == FALSE) {
861 if(create_remote_resource(parent,
data, replica, data_set) == FALSE) {
864 if (replica->child && replica->ipaddr) {
865 add_hash_param(replica->child->meta,
"external-ip", replica->ipaddr);
868 if (replica->remote) {
884 mount_add(pe__bundle_variant_data_t *bundle_data,
const char *source,
885 const char *
target,
const char *options, uint32_t
flags)
887 pe__bundle_mount_t *mount = calloc(1,
sizeof(pe__bundle_mount_t));
889 mount->source = strdup(source);
890 mount->target = strdup(
target);
892 mount->options = strdup(options);
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;
1195 if (
common_unpack(xml_resource, &new_rsc, rsc, data_set) == FALSE) {
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);
1310 if (bundle_data->child) {
1320 gboolean child_active = rsc->
fns->
active(rsc, all);
1322 if (child_active && !all) {
1324 }
else if (!child_active && all) {
1334 pe__bundle_variant_data_t *bundle_data = NULL;
1337 get_bundle_variant_data(bundle_data, rsc);
1338 for (iter = bundle_data->replicas; iter != NULL; iter = iter->next) {
1339 pe__bundle_replica_t *replica = iter->data;
1342 rsc_active = replica_resource_active(replica->ip, all);
1343 if (rsc_active >= 0) {
1344 return (gboolean) rsc_active;
1347 rsc_active = replica_resource_active(replica->child, all);
1348 if (rsc_active >= 0) {
1349 return (gboolean) rsc_active;
1352 rsc_active = replica_resource_active(replica->container, all);
1353 if (rsc_active >= 0) {
1354 return (gboolean) rsc_active;
1357 rsc_active = replica_resource_active(replica->remote, all);
1358 if (rsc_active >= 0) {
1359 return (gboolean) rsc_active;
1382 pe__bundle_variant_data_t *bundle_data = NULL;
1385 get_bundle_variant_data(bundle_data, bundle);
1386 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1387 gIter = gIter->next) {
1388 pe__bundle_replica_t *replica = gIter->data;
1391 if (replica->node->details == node->
details) {
1392 return replica->child;
1399 print_rsc_in_list(
pe_resource_t *rsc,
const char *pre_text,
long options,
1406 rsc->
fns->
print(rsc, pre_text, options, print_data);
1414 container_agent_str(
enum pe__container_agent t)
1417 case PE__CONTAINER_AGENT_DOCKER:
return PE__CONTAINER_AGENT_DOCKER_S;
1418 case PE__CONTAINER_AGENT_RKT:
return PE__CONTAINER_AGENT_RKT_S;
1419 case PE__CONTAINER_AGENT_PODMAN:
return PE__CONTAINER_AGENT_PODMAN_S;
1423 return PE__CONTAINER_AGENT_UNKNOWN_S;
1427 bundle_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
1430 pe__bundle_variant_data_t *bundle_data = NULL;
1431 char *child_text = NULL;
1434 if (pre_text == NULL) {
1439 get_bundle_variant_data(bundle_data, rsc);
1443 status_print(
"type=\"%s\" ", container_agent_str(bundle_data->agent_type));
1450 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1451 gIter = gIter->next) {
1452 pe__bundle_replica_t *replica = gIter->data;
1455 status_print(
"%s <replica id=\"%d\">\n", pre_text, replica->offset);
1456 print_rsc_in_list(replica->ip, child_text, options, print_data);
1457 print_rsc_in_list(replica->child, child_text, options, print_data);
1458 print_rsc_in_list(replica->container, child_text, options, print_data);
1459 print_rsc_in_list(replica->remote, child_text, options, print_data);
1466 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
1470 unsigned int show_opts = va_arg(args,
unsigned int);
1472 GList *only_node = va_arg(args, GList *);
1473 GList *only_rsc = va_arg(args, GList *);
1475 pe__bundle_variant_data_t *bundle_data = NULL;
1477 gboolean printed_header = FALSE;
1478 gboolean print_everything = TRUE;
1482 get_bundle_variant_data(bundle_data, rsc);
1490 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1491 gIter = gIter->next) {
1492 pe__bundle_replica_t *replica = gIter->data;
1494 gboolean print_ip, print_child, print_ctnr, print_remote;
1502 print_ip = replica->ip != NULL &&
1503 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1504 print_child = replica->child != NULL &&
1505 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1506 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1507 print_remote = replica->remote != NULL &&
1508 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1510 if (!print_everything && !print_ip && !print_child && !print_ctnr && !print_remote) {
1514 if (!printed_header) {
1515 printed_header = TRUE;
1519 "type", container_agent_str(bundle_data->agent_type),
1520 "image", bundle_data->image,
1527 id = pcmk__itoa(replica->offset);
1533 out->message(out, crm_map_element_name(replica->ip->xml), show_opts,
1534 replica->ip, only_node, only_rsc);
1538 out->message(out, crm_map_element_name(replica->child->xml), show_opts,
1539 replica->child, only_node, only_rsc);
1543 out->message(out, crm_map_element_name(replica->container->xml), show_opts,
1544 replica->container, only_node, only_rsc);
1548 out->message(out, crm_map_element_name(replica->remote->xml), show_opts,
1549 replica->remote, only_node, only_rsc);
1555 if (printed_header) {
1563 pe__bundle_replica_output_html(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1564 pe_node_t *node,
unsigned int show_opts)
1569 char buffer[LINE_MAX];
1575 if (replica->remote) {
1576 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1579 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1582 if (replica->ipaddr) {
1583 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1590 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
1594 unsigned int show_opts = va_arg(args,
unsigned int);
1596 GList *only_node = va_arg(args, GList *);
1597 GList *only_rsc = va_arg(args, GList *);
1599 pe__bundle_variant_data_t *bundle_data = NULL;
1601 gboolean print_everything = TRUE;
1605 get_bundle_variant_data(bundle_data, rsc);
1613 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1614 gIter = gIter->next) {
1615 pe__bundle_replica_t *replica = gIter->data;
1616 gboolean print_ip, print_child, print_ctnr, print_remote;
1624 print_ip = replica->ip != NULL &&
1625 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1626 print_child = replica->child != NULL &&
1627 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1628 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1629 print_remote = replica->remote != NULL &&
1630 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1633 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1640 (bundle_data->nreplicas > 1)?
" set" :
"",
1641 rsc->
id, bundle_data->image,
1645 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1646 out->begin_list(out, NULL, NULL,
"Replica[%d]", replica->offset);
1650 out->message(out, crm_map_element_name(replica->ip->xml),
1651 new_show_opts, replica->ip, only_node, only_rsc);
1655 out->message(out, crm_map_element_name(replica->child->xml),
1656 new_show_opts, replica->child, only_node, only_rsc);
1660 out->message(out, crm_map_element_name(replica->container->xml),
1661 new_show_opts, replica->container, only_node, only_rsc);
1665 out->message(out, crm_map_element_name(replica->remote->xml),
1666 new_show_opts, replica->remote, only_node, only_rsc);
1669 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1672 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1676 (bundle_data->nreplicas > 1)?
" set" :
"",
1677 rsc->
id, bundle_data->image,
1681 pe__bundle_replica_output_html(out, replica, pe__current_node(replica->container),
1691 pe__bundle_replica_output_text(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1692 pe_node_t *node,
unsigned int show_opts)
1697 char buffer[LINE_MAX];
1703 if (replica->remote) {
1704 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1707 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1710 if (replica->ipaddr) {
1711 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1718 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
1722 unsigned int show_opts = va_arg(args,
unsigned int);
1724 GList *only_node = va_arg(args, GList *);
1725 GList *only_rsc = va_arg(args, GList *);
1727 pe__bundle_variant_data_t *bundle_data = NULL;
1729 gboolean print_everything = TRUE;
1731 get_bundle_variant_data(bundle_data, rsc);
1741 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1742 gIter = gIter->next) {
1743 pe__bundle_replica_t *replica = gIter->data;
1744 gboolean print_ip, print_child, print_ctnr, print_remote;
1752 print_ip = replica->ip != NULL &&
1753 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1754 print_child = replica->child != NULL &&
1755 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1756 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1757 print_remote = replica->remote != NULL &&
1758 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1761 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1768 (bundle_data->nreplicas > 1)?
" set" :
"",
1769 rsc->
id, bundle_data->image,
1773 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1774 out->list_item(out, NULL,
"Replica[%d]", replica->offset);
1777 out->begin_list(out, NULL, NULL, NULL);
1780 out->message(out, crm_map_element_name(replica->ip->xml),
1781 new_show_opts, replica->ip, only_node, only_rsc);
1785 out->message(out, crm_map_element_name(replica->child->xml),
1786 new_show_opts, replica->child, only_node, only_rsc);
1790 out->message(out, crm_map_element_name(replica->container->xml),
1791 new_show_opts, replica->container, only_node, only_rsc);
1795 out->message(out, crm_map_element_name(replica->remote->xml),
1796 new_show_opts, replica->remote, only_node, only_rsc);
1800 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1804 (bundle_data->nreplicas > 1)?
" set" :
"",
1805 rsc->
id, bundle_data->image,
1809 pe__bundle_replica_output_text(out, replica, pe__current_node(replica->container),
1819 print_bundle_replica(pe__bundle_replica_t *replica,
const char *pre_text,
1820 long options,
void *print_data)
1826 char buffer[LINE_MAX];
1832 if (replica->remote) {
1833 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1836 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1839 if (replica->ipaddr) {
1840 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1844 node = pe__current_node(replica->container);
1845 common_print(rsc, pre_text, buffer, node, options, print_data);
1852 pe__bundle_variant_data_t *bundle_data = NULL;
1853 char *child_text = NULL;
1857 bundle_print_xml(rsc, pre_text, options, print_data);
1861 get_bundle_variant_data(bundle_data, rsc);
1863 if (pre_text == NULL) {
1868 pre_text, ((bundle_data->nreplicas > 1)?
" set" :
""),
1869 rsc->
id, bundle_data->image,
1877 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1878 gIter = gIter->next) {
1879 pe__bundle_replica_t *replica = gIter->data;
1888 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1889 status_print(
" %sReplica[%d]\n", pre_text, replica->offset);
1894 print_rsc_in_list(replica->ip, child_text, options, print_data);
1895 print_rsc_in_list(replica->container, child_text, options, print_data);
1896 print_rsc_in_list(replica->remote, child_text, options, print_data);
1897 print_rsc_in_list(replica->child, child_text, options, print_data);
1903 print_bundle_replica(replica, child_text, options, print_data);
1917 free_bundle_replica(pe__bundle_replica_t *replica)
1919 if (replica == NULL) {
1923 if (replica->node) {
1924 free(replica->node);
1925 replica->node = NULL;
1930 replica->ip->xml = NULL;
1931 replica->ip->fns->free(replica->ip);
1934 if (replica->container) {
1936 replica->container->xml = NULL;
1937 replica->container->fns->free(replica->container);
1938 replica->container = NULL;
1940 if (replica->remote) {
1942 replica->remote->xml = NULL;
1943 replica->remote->fns->free(replica->remote);
1944 replica->remote = NULL;
1946 free(replica->ipaddr);
1953 pe__bundle_variant_data_t *bundle_data = NULL;
1956 get_bundle_variant_data(bundle_data, rsc);
1959 free(bundle_data->prefix);
1960 free(bundle_data->image);
1961 free(bundle_data->control_port);
1962 free(bundle_data->host_network);
1963 free(bundle_data->host_netmask);
1964 free(bundle_data->ip_range_start);
1965 free(bundle_data->container_network);
1966 free(bundle_data->launcher_options);
1967 free(bundle_data->container_command);
1968 free(bundle_data->container_host_options);
1970 g_list_free_full(bundle_data->replicas,
1971 (GDestroyNotify) free_bundle_replica);
1972 g_list_free_full(bundle_data->mounts, (GDestroyNotify)mount_free);
1973 g_list_free_full(bundle_data->ports, (GDestroyNotify)port_free);
1976 if(bundle_data->child) {
1978 bundle_data->child->xml = NULL;
1979 bundle_data->child->fns->free(bundle_data->child);
1988 return container_role;
2004 pe__bundle_variant_data_t *bundle_data = NULL;
2006 get_bundle_variant_data(bundle_data, rsc);
2007 return bundle_data->nreplicas;
2014 pe__bundle_variant_data_t *bundle_data = NULL;
2016 get_bundle_variant_data(bundle_data, rsc);
2017 for (GList *item = bundle_data->replicas; item != NULL; item = item->next) {
2018 pe__bundle_replica_t *replica = item->data;
2021 replica->ip->fns->count(replica->ip);
2023 if (replica->child) {
2024 replica->child->fns->count(replica->child);
2026 if (replica->container) {
2027 replica->container->fns->count(replica->container);
2029 if (replica->remote) {
2030 replica->remote->fns->count(replica->remote);
2038 gboolean passes = FALSE;
2039 pe__bundle_variant_data_t *bundle_data = NULL;
2044 get_bundle_variant_data(bundle_data, rsc);
2046 for (GList *gIter = bundle_data->replicas; gIter != NULL; gIter = gIter->next) {
2047 pe__bundle_replica_t *replica = gIter->data;
2049 if (replica->ip != NULL && !replica->ip->fns->is_filtered(replica->ip, only_rsc, FALSE)) {
2052 }
else if (replica->child != NULL && !replica->child->fns->is_filtered(replica->child, only_rsc, FALSE)) {
2055 }
else if (!replica->container->fns->is_filtered(replica->container, only_rsc, FALSE)) {
2058 }
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
#define XML_TAG_META_SETS
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