21 #define PE__VARIANT_BUNDLE 1 25 next_ip(
const char *last_ip)
27 unsigned int oct1 = 0;
28 unsigned int oct2 = 0;
29 unsigned int oct3 = 0;
30 unsigned int oct4 = 0;
31 int rc = sscanf(last_ip,
"%u.%u.%u.%u", &oct1, &oct2, &oct3, &oct4);
37 }
else if (oct3 > 253) {
40 }
else if (oct4 > 253) {
52 allocate_ip(pe__bundle_variant_data_t *
data, pe__bundle_replica_t *replica,
53 char *buffer,
int max)
55 if(
data->ip_range_start == NULL) {
58 }
else if(
data->ip_last) {
59 replica->ipaddr = next_ip(
data->ip_last);
62 replica->ipaddr = strdup(
data->ip_range_start);
65 data->ip_last = replica->ipaddr;
66 switch (
data->agent_type) {
67 case PE__CONTAINER_AGENT_DOCKER:
68 case PE__CONTAINER_AGENT_PODMAN:
70 return snprintf(buffer, max,
" --add-host=%s-%d:%s",
71 data->prefix, replica->offset,
74 case PE__CONTAINER_AGENT_RKT:
75 return snprintf(buffer, max,
" --hosts-entry=%s=%s-%d",
76 replica->ipaddr,
data->prefix, replica->offset);
84 create_resource(
const char *
name,
const char *provider,
const char *kind)
109 valid_network(pe__bundle_variant_data_t *
data)
111 if(
data->ip_range_start) {
114 if(
data->control_port) {
115 if(
data->nreplicas_per_host > 1) {
116 pe_err(
"Specifying the 'control-port' for %s requires 'replicas-per-host=1'",
data->prefix);
117 data->nreplicas_per_host = 1;
129 if(
data->ip_range_start) {
131 xmlNode *xml_ip = NULL;
132 xmlNode *xml_obj = NULL;
136 xml_ip = create_resource(
id,
"heartbeat",
"IPaddr2");
141 data->prefix, replica->offset);
144 if(
data->host_network) {
148 if(
data->host_netmask) {
150 "cidr_netmask",
data->host_netmask);
161 if (!
common_unpack(xml_ip, &replica->ip, parent, data_set)) {
172 pe__bundle_replica_t *replica,
175 int offset = 0, max = 4096;
176 char *buffer = calloc(1, max+1);
178 int doffset = 0, dmax = 1024;
179 char *dbuffer = calloc(1, dmax+1);
182 xmlNode *xml_container = NULL;
183 xmlNode *xml_obj = NULL;
187 xml_container = create_resource(
id,
"heartbeat",
188 PE__CONTAINER_AGENT_DOCKER_S);
193 data->prefix, replica->offset);
200 offset += snprintf(buffer+offset, max-offset,
" --restart=no");
207 if (
data->ip_range_start != NULL) {
208 offset += snprintf(buffer+offset, max-offset,
" -h %s-%d",
209 data->prefix, replica->offset);
212 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_stderr=1");
214 if (
data->container_network) {
216 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
219 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
220 data->container_network);
223 if(
data->control_port) {
224 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%s",
data->control_port);
226 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
229 for(
GListPtr pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
230 pe__bundle_mount_t *mount = pIter->data;
232 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
234 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
237 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
239 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
240 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", source, mount->target);
244 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", mount->source, mount->target);
247 offset += snprintf(buffer+offset, max-offset,
":%s", mount->options);
251 for(
GListPtr pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
252 pe__bundle_port_t *port = pIter->data;
254 if (replica->ipaddr) {
255 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s:%s",
256 replica->ipaddr, port->source,
260 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s", port->source, port->target);
264 if (
data->launcher_options) {
265 offset += snprintf(buffer+offset, max-offset,
" %s",
266 data->launcher_options);
269 if (
data->container_host_options) {
270 offset += snprintf(buffer + offset, max - offset,
" %s",
271 data->container_host_options);
280 if (replica->child) {
281 if (
data->container_command) {
283 "run_cmd",
data->container_command);
286 "run_cmd",
SBIN_DIR "/pacemaker-remoted");
311 if (
data->container_command) {
313 "run_cmd",
data->container_command);
329 if (!
common_unpack(xml_container, &replica->container, parent, data_set)) {
338 pe__bundle_replica_t *replica,
341 int offset = 0, max = 4096;
342 char *buffer = calloc(1, max+1);
344 int doffset = 0, dmax = 1024;
345 char *dbuffer = calloc(1, dmax+1);
348 xmlNode *xml_container = NULL;
349 xmlNode *xml_obj = NULL;
353 xml_container = create_resource(
id,
"heartbeat",
354 PE__CONTAINER_AGENT_PODMAN_S);
359 data->prefix, replica->offset);
374 if (
data->ip_range_start != NULL) {
375 offset += snprintf(buffer+offset, max-offset,
" -h %s-%d",
376 data->prefix, replica->offset);
379 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_stderr=1");
381 if (
data->container_network) {
384 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
387 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
388 data->container_network);
391 if(
data->control_port) {
392 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%s",
data->control_port);
394 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
397 for(
GListPtr pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
398 pe__bundle_mount_t *mount = pIter->data;
400 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
402 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
405 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
407 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
408 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", source, mount->target);
412 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", mount->source, mount->target);
415 offset += snprintf(buffer+offset, max-offset,
":%s", mount->options);
419 for(
GListPtr pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
420 pe__bundle_port_t *port = pIter->data;
422 if (replica->ipaddr) {
423 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s:%s",
424 replica->ipaddr, port->source,
428 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s", port->source, port->target);
432 if (
data->launcher_options) {
433 offset += snprintf(buffer+offset, max-offset,
" %s",
434 data->launcher_options);
437 if (
data->container_host_options) {
438 offset += snprintf(buffer + offset, max - offset,
" %s",
439 data->container_host_options);
448 if (replica->child) {
449 if (
data->container_command) {
451 "run_cmd",
data->container_command);
454 "run_cmd",
SBIN_DIR "/pacemaker-remoted");
479 if (
data->container_command) {
481 "run_cmd",
data->container_command);
497 if (!
common_unpack(xml_container, &replica->container, parent,
509 int offset = 0, max = 4096;
510 char *buffer = calloc(1, max+1);
512 int doffset = 0, dmax = 1024;
513 char *dbuffer = calloc(1, dmax+1);
516 xmlNode *xml_container = NULL;
517 xmlNode *xml_obj = NULL;
523 xml_container = create_resource(
id,
"heartbeat",
524 PE__CONTAINER_AGENT_RKT_S);
529 data->prefix, replica->offset);
541 if (
data->ip_range_start != NULL) {
542 offset += snprintf(buffer+offset, max-offset,
" --hostname=%s-%d",
543 data->prefix, replica->offset);
546 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_stderr=1");
548 if (
data->container_network) {
550 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
553 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
554 data->container_network);
557 if(
data->control_port) {
558 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_remote_port=%s",
data->control_port);
560 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
563 for(
GListPtr pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
564 pe__bundle_mount_t *mount = pIter->data;
566 if (
pcmk_is_set(mount->flags, pe__bundle_mount_subdir)) {
568 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
571 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
573 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
574 offset += snprintf(buffer+offset, max-offset,
" --volume vol%d,kind=host,source=%s", volid, source);
576 offset += snprintf(buffer+offset, max-offset,
",%s", mount->options);
578 offset += snprintf(buffer+offset, max-offset,
" --mount volume=vol%d,target=%s", volid, mount->target);
582 offset += snprintf(buffer+offset, max-offset,
" --volume vol%d,kind=host,source=%s", volid, mount->source);
584 offset += snprintf(buffer+offset, max-offset,
",%s", mount->options);
586 offset += snprintf(buffer+offset, max-offset,
" --mount volume=vol%d,target=%s", volid, mount->target);
591 for(
GListPtr pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
592 pe__bundle_port_t *port = pIter->data;
594 if (replica->ipaddr) {
595 offset += snprintf(buffer+offset, max-offset,
596 " --port=%s:%s:%s", port->target,
597 replica->ipaddr, port->source);
599 offset += snprintf(buffer+offset, max-offset,
" --port=%s:%s", port->target, port->source);
603 if (
data->launcher_options) {
604 offset += snprintf(buffer+offset, max-offset,
" %s",
605 data->launcher_options);
608 if (
data->container_host_options) {
609 offset += snprintf(buffer + offset, max - offset,
" %s",
610 data->container_host_options);
619 if (replica->child) {
620 if (
data->container_command) {
622 data->container_command);
650 if (
data->container_command) {
652 data->container_command);
669 if (!
common_unpack(xml_container, &replica->container, parent, data_set)) {
694 for (child = rsc->
children; child != NULL; child = child->next) {
702 pe__bundle_replica_t *replica,
705 if (replica->child && valid_network(
data)) {
706 GHashTableIter gIter;
709 xmlNode *xml_remote = NULL;
712 const char *
uname = NULL;
713 const char *connect_name = NULL;
719 replica->child->id, replica->offset);
728 connect_name = (replica->ipaddr? replica->ipaddr :
"#uname");
730 if (
data->control_port == NULL) {
741 connect_name, (
data->control_port?
742 data->control_port : port_s));
783 for (rsc_iter = data_set->
resources; rsc_iter; rsc_iter = rsc_iter->next) {
788 replica->node->weight = 500;
792 if (replica->child->allowed_nodes != NULL) {
793 g_hash_table_destroy(replica->child->allowed_nodes);
795 replica->child->allowed_nodes = g_hash_table_new_full(
crm_str_hash,
798 g_hash_table_insert(replica->child->allowed_nodes,
799 (gpointer) replica->node->details->id,
805 g_hash_table_insert(replica->child->parent->allowed_nodes,
806 (gpointer) replica->node->details->id, copy);
808 if (!
common_unpack(xml_remote, &replica->remote, parent, data_set)) {
812 g_hash_table_iter_init(&gIter, replica->remote->allowed_nodes);
813 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&node)) {
820 replica->node->details->remote_rsc = replica->remote;
823 replica->remote->container = replica->container;
828 g_hash_table_insert(replica->node->details->attrs,
850 switch (
data->agent_type) {
851 case PE__CONTAINER_AGENT_DOCKER:
852 if (!create_docker_resource(parent,
data, replica, data_set)) {
857 case PE__CONTAINER_AGENT_PODMAN:
858 if (!create_podman_resource(parent,
data, replica, data_set)) {
863 case PE__CONTAINER_AGENT_RKT:
864 if (!create_rkt_resource(parent,
data, replica, data_set)) {
872 if (create_ip_resource(parent,
data, replica, data_set) == FALSE) {
875 if(create_remote_resource(parent,
data, replica, data_set) == FALSE) {
878 if (replica->child && replica->ipaddr) {
879 add_hash_param(replica->child->meta,
"external-ip", replica->ipaddr);
882 if (replica->remote) {
898 mount_add(pe__bundle_variant_data_t *bundle_data,
const char *source,
899 const char *
target,
const char *options, uint32_t
flags)
901 pe__bundle_mount_t *mount = calloc(1,
sizeof(pe__bundle_mount_t));
903 mount->source = strdup(source);
904 mount->target = strdup(
target);
906 mount->options = strdup(options);
908 mount->flags =
flags;
909 bundle_data->mounts = g_list_append(bundle_data->mounts, mount);
913 mount_free(pe__bundle_mount_t *mount)
917 free(mount->options);
922 port_free(pe__bundle_port_t *port)
929 static pe__bundle_replica_t *
933 pe__bundle_variant_data_t *bundle_data = NULL;
939 while (top->
parent != NULL) {
943 get_bundle_variant_data(bundle_data, top);
944 for (GList *gIter = bundle_data->replicas; gIter != NULL;
945 gIter = gIter->next) {
946 pe__bundle_replica_t *replica = gIter->data;
948 if (replica->remote == remote) {
970 const char *match[3][2] = {
976 for (
int m = 0; m < 3; m++) {
992 pe__bundle_replica_t *replica = NULL;
998 replica = replica_for_remote(rsc);
999 if (replica == NULL) {
1003 node = replica->container->allocated_to;
1008 node = pe__current_node(replica->container);
1012 crm_trace(
"Cannot determine address for bundle connection %s", rsc->
id);
1016 crm_trace(
"Setting address for bundle connection %s to bundle host %s",
1018 if(xml != NULL && field != NULL) {
1025 #define pe__set_bundle_mount_flags(mount_xml, flags, flags_to_set) do { \ 1026 flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \ 1027 "Bundle mount", ID(mount_xml), flags, \ 1028 (flags_to_set), #flags_to_set); \ 1034 const char *value = NULL;
1035 xmlNode *xml_obj = NULL;
1036 xmlNode *xml_resource = NULL;
1037 pe__bundle_variant_data_t *bundle_data = NULL;
1038 bool need_log_mount = TRUE;
1043 bundle_data = calloc(1,
sizeof(pe__bundle_variant_data_t));
1045 bundle_data->prefix = strdup(rsc->
id);
1048 if (xml_obj != NULL) {
1049 bundle_data->agent_type = PE__CONTAINER_AGENT_DOCKER;
1052 if (xml_obj != NULL) {
1053 bundle_data->agent_type = PE__CONTAINER_AGENT_RKT;
1056 if (xml_obj != NULL) {
1057 bundle_data->agent_type = PE__CONTAINER_AGENT_PODMAN;
1065 if (value == NULL) {
1070 if (bundle_data->promoted_max < 0) {
1071 pe_err(
"%s for %s must be nonnegative integer, using 0",
1073 bundle_data->promoted_max = 0;
1077 if ((value == NULL) && bundle_data->promoted_max) {
1078 bundle_data->nreplicas = bundle_data->promoted_max;
1082 if (bundle_data->nreplicas < 1) {
1083 pe_err(
"'replicas' for %s must be positive integer, using 1", rsc->
id);
1084 bundle_data->nreplicas = 1;
1093 bundle_data->nreplicas_per_host =
crm_parse_int(value,
"1");
1094 if (bundle_data->nreplicas_per_host < 1) {
1095 pe_err(
"'replicas-per-host' for %s must be positive integer, using 1",
1097 bundle_data->nreplicas_per_host = 1;
1099 if (bundle_data->nreplicas_per_host == 1) {
1117 bundle_data->add_host = TRUE;
1120 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
1121 xml_child = pcmk__xe_next(xml_child)) {
1123 pe__bundle_port_t *port = calloc(1,
sizeof(pe__bundle_port_t));
1126 if(port->source == NULL) {
1132 if(port->source != NULL && strlen(port->source) > 0) {
1133 if(port->target == NULL) {
1134 port->target = strdup(port->source);
1136 bundle_data->ports = g_list_append(bundle_data->ports, port);
1139 pe_err(
"Invalid port directive %s",
ID(xml_child));
1146 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
1147 xml_child = pcmk__xe_next(xml_child)) {
1152 int flags = pe__bundle_mount_none;
1154 if (source == NULL) {
1157 pe__bundle_mount_subdir);
1161 mount_add(bundle_data, source,
target, options,
flags);
1162 if (strcmp(
target,
"/var/log") == 0) {
1163 need_log_mount = FALSE;
1166 pe_err(
"Invalid mount directive %s",
ID(xml_child));
1171 if (xml_obj && valid_network(bundle_data)) {
1173 xmlNode *xml_set = NULL;
1182 (bundle_data->promoted_max?
"master" 1183 : (
const char *)xml_resource->name));
1186 crm_xml_set_id(xml_set,
"%s-%s-meta", bundle_data->prefix, xml_resource->name);
1191 value = crm_itoa(bundle_data->nreplicas);
1196 value = crm_itoa(bundle_data->nreplicas_per_host);
1202 pcmk__btoa(bundle_data->nreplicas_per_host > 1));
1204 if (bundle_data->promoted_max) {
1208 value = crm_itoa(bundle_data->promoted_max);
1217 }
else if(xml_obj) {
1218 pe_err(
"Cannot control %s inside %s without either ip-range-start or control-port",
1219 rsc->
id,
ID(xml_obj));
1227 pe__bundle_port_t *port = NULL;
1229 int offset = 0, max = 1024;
1230 char *buffer = NULL;
1232 if (
common_unpack(xml_resource, &new_rsc, rsc, data_set) == FALSE) {
1233 pe_err(
"Failed unpacking resource %s",
ID(rsc->
xml));
1234 if (new_rsc != NULL && new_rsc->
fns != NULL) {
1240 bundle_data->child = new_rsc;
1266 if (need_log_mount) {
1268 pe__bundle_mount_subdir);
1271 port = calloc(1,
sizeof(pe__bundle_port_t));
1272 if(bundle_data->control_port) {
1273 port->source = strdup(bundle_data->control_port);
1285 port->target = strdup(port->source);
1286 bundle_data->ports = g_list_append(bundle_data->ports, port);
1288 buffer = calloc(1, max+1);
1289 for (childIter = bundle_data->child->children; childIter != NULL;
1290 childIter = childIter->next) {
1292 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1294 replica->child = childIter->data;
1295 replica->child->exclusive_discover = TRUE;
1296 replica->offset = lpc++;
1303 offset += allocate_ip(bundle_data, replica, buffer+offset,
1305 bundle_data->replicas = g_list_append(bundle_data->replicas,
1307 bundle_data->attribute_target = g_hash_table_lookup(replica->child->meta,
1310 bundle_data->container_host_options = buffer;
1311 if (bundle_data->attribute_target) {
1313 strdup(bundle_data->attribute_target));
1314 g_hash_table_replace(bundle_data->child->meta,
1316 strdup(bundle_data->attribute_target));
1321 int offset = 0, max = 1024;
1322 char *buffer = calloc(1, max+1);
1324 for (
int lpc = 0; lpc < bundle_data->nreplicas; lpc++) {
1325 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1327 replica->offset = lpc;
1328 offset += allocate_ip(bundle_data, replica, buffer+offset,
1330 bundle_data->replicas = g_list_append(bundle_data->replicas,
1333 bundle_data->container_host_options = buffer;
1336 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1337 gIter = gIter->next) {
1338 pe__bundle_replica_t *replica = gIter->data;
1340 if (!create_container(rsc, bundle_data, replica, data_set)) {
1341 pe_err(
"Failed unpacking resource %s", rsc->
id);
1347 if (bundle_data->child) {
1357 gboolean child_active = rsc->
fns->
active(rsc, all);
1359 if (child_active && !all) {
1361 }
else if (!child_active && all) {
1371 pe__bundle_variant_data_t *bundle_data = NULL;
1374 get_bundle_variant_data(bundle_data, rsc);
1375 for (iter = bundle_data->replicas; iter != NULL; iter = iter->next) {
1376 pe__bundle_replica_t *replica = iter->data;
1379 rsc_active = replica_resource_active(replica->ip, all);
1380 if (rsc_active >= 0) {
1381 return (gboolean) rsc_active;
1384 rsc_active = replica_resource_active(replica->child, all);
1385 if (rsc_active >= 0) {
1386 return (gboolean) rsc_active;
1389 rsc_active = replica_resource_active(replica->container, all);
1390 if (rsc_active >= 0) {
1391 return (gboolean) rsc_active;
1394 rsc_active = replica_resource_active(replica->remote, all);
1395 if (rsc_active >= 0) {
1396 return (gboolean) rsc_active;
1419 pe__bundle_variant_data_t *bundle_data = NULL;
1422 get_bundle_variant_data(bundle_data, bundle);
1423 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1424 gIter = gIter->next) {
1425 pe__bundle_replica_t *replica = gIter->data;
1428 if (replica->node->details == node->
details) {
1429 return replica->child;
1436 print_rsc_in_list(
pe_resource_t *rsc,
const char *pre_text,
long options,
1443 rsc->
fns->
print(rsc, pre_text, options, print_data);
1451 container_agent_str(
enum pe__container_agent t)
1454 case PE__CONTAINER_AGENT_DOCKER:
return PE__CONTAINER_AGENT_DOCKER_S;
1455 case PE__CONTAINER_AGENT_RKT:
return PE__CONTAINER_AGENT_RKT_S;
1456 case PE__CONTAINER_AGENT_PODMAN:
return PE__CONTAINER_AGENT_PODMAN_S;
1460 return PE__CONTAINER_AGENT_UNKNOWN_S;
1464 bundle_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
1467 pe__bundle_variant_data_t *bundle_data = NULL;
1468 char *child_text = NULL;
1471 if (pre_text == NULL) {
1476 get_bundle_variant_data(bundle_data, rsc);
1480 status_print(
"type=\"%s\" ", container_agent_str(bundle_data->agent_type));
1487 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1488 gIter = gIter->next) {
1489 pe__bundle_replica_t *replica = gIter->data;
1492 status_print(
"%s <replica id=\"%d\">\n", pre_text, replica->offset);
1493 print_rsc_in_list(replica->ip, child_text, options, print_data);
1494 print_rsc_in_list(replica->child, child_text, options, print_data);
1495 print_rsc_in_list(replica->container, child_text, options, print_data);
1496 print_rsc_in_list(replica->remote, child_text, options, print_data);
1503 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GListPtr",
"GListPtr")
1507 unsigned int options = va_arg(args,
unsigned int);
1512 pe__bundle_variant_data_t *bundle_data = NULL;
1514 gboolean printed_header = FALSE;
1515 gboolean print_everything = TRUE;
1519 get_bundle_variant_data(bundle_data, rsc);
1527 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1528 gIter = gIter->next) {
1529 pe__bundle_replica_t *replica = gIter->data;
1530 char *
id = crm_itoa(replica->offset);
1531 gboolean print_ip, print_child, print_ctnr, print_remote;
1539 print_ip = replica->ip != NULL &&
1540 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1541 print_child = replica->child != NULL &&
1542 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1543 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1544 print_remote = replica->remote != NULL &&
1545 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1547 if (!print_everything && !print_ip && !print_child && !print_ctnr && !print_remote) {
1551 if (!printed_header) {
1552 printed_header = TRUE;
1556 "type", container_agent_str(bundle_data->agent_type),
1557 "image", bundle_data->image,
1569 out->message(out, crm_map_element_name(replica->ip->xml), options,
1570 replica->ip, only_node, only_rsc);
1574 out->message(out, crm_map_element_name(replica->child->xml), options,
1575 replica->child, only_node, only_rsc);
1579 out->message(out, crm_map_element_name(replica->container->xml), options,
1580 replica->container, only_node, only_rsc);
1584 out->message(out, crm_map_element_name(replica->remote->xml), options,
1585 replica->remote, only_node, only_rsc);
1591 if (printed_header) {
1599 pe__bundle_replica_output_html(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1605 char buffer[LINE_MAX];
1611 if (replica->remote) {
1612 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1615 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1618 if (replica->ipaddr) {
1619 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1626 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GListPtr",
"GListPtr")
1630 unsigned int options = va_arg(args,
unsigned int);
1635 pe__bundle_variant_data_t *bundle_data = NULL;
1636 char buffer[LINE_MAX];
1638 gboolean print_everything = TRUE;
1642 get_bundle_variant_data(bundle_data, rsc);
1650 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1651 gIter = gIter->next) {
1652 pe__bundle_replica_t *replica = gIter->data;
1653 gboolean print_ip, print_child, print_ctnr, print_remote;
1661 print_ip = replica->ip != NULL &&
1662 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1663 print_child = replica->child != NULL &&
1664 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1665 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1666 print_remote = replica->remote != NULL &&
1667 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1670 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1674 unsigned int new_options = options;
1685 (bundle_data->nreplicas > 1)?
" set" :
"",
1686 rsc->
id, bundle_data->image,
1692 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1693 snprintf(buffer, LINE_MAX,
" Replica[%d]", replica->offset);
1697 out->begin_list(out, NULL, NULL, NULL);
1700 out->message(out, crm_map_element_name(replica->ip->xml),
1701 new_options, replica->ip, only_node, only_rsc);
1705 out->message(out, crm_map_element_name(replica->child->xml),
1706 new_options, replica->child, only_node, only_rsc);
1710 out->message(out, crm_map_element_name(replica->container->xml),
1711 new_options, replica->container, only_node, only_rsc);
1715 out->message(out, crm_map_element_name(replica->remote->xml),
1716 new_options, replica->remote, only_node, only_rsc);
1720 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1724 (bundle_data->nreplicas > 1)?
" set" :
"",
1725 rsc->
id, bundle_data->image,
1729 pe__bundle_replica_output_html(out, replica, pe__current_node(replica->container),
1741 pe__bundle_replica_output_text(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1747 char buffer[LINE_MAX];
1753 if (replica->remote) {
1754 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1757 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1760 if (replica->ipaddr) {
1761 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1768 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GListPtr",
"GListPtr")
1772 unsigned int options = va_arg(args,
unsigned int);
1777 pe__bundle_variant_data_t *bundle_data = NULL;
1779 gboolean print_everything = TRUE;
1781 get_bundle_variant_data(bundle_data, rsc);
1791 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1792 gIter = gIter->next) {
1793 pe__bundle_replica_t *replica = gIter->data;
1794 gboolean print_ip, print_child, print_ctnr, print_remote;
1802 print_ip = replica->ip != NULL &&
1803 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1804 print_child = replica->child != NULL &&
1805 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1806 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1807 print_remote = replica->remote != NULL &&
1808 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1811 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1815 unsigned int new_options = options;
1821 (bundle_data->nreplicas > 1)?
" set" :
"",
1822 rsc->
id, bundle_data->image,
1826 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1827 out->list_item(out, NULL,
"Replica[%d]", replica->offset);
1830 out->begin_list(out, NULL, NULL, NULL);
1833 out->message(out, crm_map_element_name(replica->ip->xml),
1834 new_options, replica->ip, only_node, only_rsc);
1838 out->message(out, crm_map_element_name(replica->child->xml),
1839 new_options, replica->child, only_node, only_rsc);
1843 out->message(out, crm_map_element_name(replica->container->xml),
1844 new_options, replica->container, only_node, only_rsc);
1848 out->message(out, crm_map_element_name(replica->remote->xml),
1849 new_options, replica->remote, only_node, only_rsc);
1853 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1857 (bundle_data->nreplicas > 1)?
" set" :
"",
1858 rsc->
id, bundle_data->image,
1862 pe__bundle_replica_output_text(out, replica, pe__current_node(replica->container),
1872 print_bundle_replica(pe__bundle_replica_t *replica,
const char *pre_text,
1873 long options,
void *print_data)
1879 char buffer[LINE_MAX];
1885 if (replica->remote) {
1886 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1889 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1892 if (replica->ipaddr) {
1893 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1897 node = pe__current_node(replica->container);
1898 common_print(rsc, pre_text, buffer, node, options, print_data);
1905 pe__bundle_variant_data_t *bundle_data = NULL;
1906 char *child_text = NULL;
1910 bundle_print_xml(rsc, pre_text, options, print_data);
1914 get_bundle_variant_data(bundle_data, rsc);
1916 if (pre_text == NULL) {
1921 pre_text, ((bundle_data->nreplicas > 1)?
" set" :
""),
1922 rsc->
id, bundle_data->image,
1930 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1931 gIter = gIter->next) {
1932 pe__bundle_replica_t *replica = gIter->data;
1941 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1942 status_print(
" %sReplica[%d]\n", pre_text, replica->offset);
1947 print_rsc_in_list(replica->ip, child_text, options, print_data);
1948 print_rsc_in_list(replica->container, child_text, options, print_data);
1949 print_rsc_in_list(replica->remote, child_text, options, print_data);
1950 print_rsc_in_list(replica->child, child_text, options, print_data);
1956 print_bundle_replica(replica, child_text, options, print_data);
1970 free_bundle_replica(pe__bundle_replica_t *replica)
1972 if (replica == NULL) {
1976 if (replica->node) {
1977 free(replica->node);
1978 replica->node = NULL;
1983 replica->ip->xml = NULL;
1984 replica->ip->fns->free(replica->ip);
1987 if (replica->container) {
1989 replica->container->xml = NULL;
1990 replica->container->fns->free(replica->container);
1991 replica->container = NULL;
1993 if (replica->remote) {
1995 replica->remote->xml = NULL;
1996 replica->remote->fns->free(replica->remote);
1997 replica->remote = NULL;
1999 free(replica->ipaddr);
2006 pe__bundle_variant_data_t *bundle_data = NULL;
2009 get_bundle_variant_data(bundle_data, rsc);
2012 free(bundle_data->prefix);
2013 free(bundle_data->image);
2014 free(bundle_data->control_port);
2015 free(bundle_data->host_network);
2016 free(bundle_data->host_netmask);
2017 free(bundle_data->ip_range_start);
2018 free(bundle_data->container_network);
2019 free(bundle_data->launcher_options);
2020 free(bundle_data->container_command);
2021 free(bundle_data->container_host_options);
2023 g_list_free_full(bundle_data->replicas,
2024 (GDestroyNotify) free_bundle_replica);
2025 g_list_free_full(bundle_data->mounts, (GDestroyNotify)mount_free);
2026 g_list_free_full(bundle_data->ports, (GDestroyNotify)port_free);
2029 if(bundle_data->child) {
2031 bundle_data->child->xml = NULL;
2032 bundle_data->child->fns->free(bundle_data->child);
2041 return container_role;
2057 pe__bundle_variant_data_t *bundle_data = NULL;
2059 get_bundle_variant_data(bundle_data, rsc);
2060 return bundle_data->nreplicas;
2067 pe__bundle_variant_data_t *bundle_data = NULL;
2069 get_bundle_variant_data(bundle_data, rsc);
2070 for (GList *item = bundle_data->replicas; item != NULL; item = item->next) {
2071 pe__bundle_replica_t *replica = item->data;
2074 replica->ip->fns->count(replica->ip);
2076 if (replica->child) {
2077 replica->child->fns->count(replica->child);
2079 if (replica->container) {
2080 replica->container->fns->count(replica->container);
2082 if (replica->remote) {
2083 replica->remote->fns->count(replica->remote);
2091 gboolean passes = FALSE;
2092 pe__bundle_variant_data_t *bundle_data = NULL;
2097 get_bundle_variant_data(bundle_data, rsc);
2099 for (GList *gIter = bundle_data->replicas; gIter != NULL; gIter = gIter->next) {
2100 pe__bundle_replica_t *replica = gIter->data;
2102 if (replica->ip != NULL && !replica->ip->fns->is_filtered(replica->ip, only_rsc, FALSE)) {
2105 }
else if (replica->child != NULL && !replica->child->fns->is_filtered(replica->child, only_rsc, FALSE)) {
2108 }
else if (!replica->container->fns->is_filtered(replica->container, only_rsc, FALSE)) {
2111 }
else if (replica->remote != NULL && !replica->remote->fns->is_filtered(replica->remote, only_rsc, FALSE)) {
#define CRM_CHECK(expr, failure_action)
int pe__common_output_html(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, long options)
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)
pe_resource_t * container
#define XML_BOOLEAN_FALSE
xmlNode * first_named_child(const xmlNode *parent, const char *name)
gboolean pcmk__str_in_list(GList *lst, const gchar *s)
resource_object_functions_t * fns
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
pe_node_t * pe__copy_node(const pe_node_t *this_node)
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
xmlNodePtr pcmk__output_xml_peek_parent(pcmk__output_t *out)
gboolean(* is_filtered)(pe_resource_t *, GListPtr, gboolean)
#define CRM_LOG_ASSERT(expr)
pe_node_t * pe_find_node(GListPtr node_list, const char *uname)
#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
#define XML_TAG_ATTR_SETS
#define XML_RSC_ATTR_PROMOTABLE
gboolean pe__bundle_is_filtered(pe_resource_t *rsc, GListPtr only_rsc, gboolean check_parent)
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)
void pe__free_bundle(pe_resource_t *rsc)
#define PCMK_RESOURCE_CLASS_OCF
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 pe__bundle_needs_remote_name(pe_resource_t *rsc)
#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 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
#define XML_TAG_META_SETS
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)
const char * pe__add_bundle_remote_name(pe_resource_t *rsc, xmlNode *xml, const char *field)
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)
pe_resource_t * pe_find_resource(GListPtr rsc_list, const char *id_rh)
int pe__bundle_html(pcmk__output_t *out, va_list args)
const xmlChar * pcmkXmlStr
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)
void void xmlNodePtr pcmk__output_xml_create_parent(pcmk__output_t *out, const char *name)
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.
#define XML_CIB_TAG_INCARNATION
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)
bool pcmk__rsc_filtered_by_node(pe_resource_t *rsc, GListPtr only_node)
void crm_xml_set_id(xmlNode *xml, const char *format,...) __attribute__((__format__(__printf__
#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)
xmlNodePtr pcmk__output_create_xml_node(pcmk__output_t *out, const char *name)
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)
int pe__common_output_text(pcmk__output_t *out, pe_resource_t *rsc, const char *name, pe_node_t *node, long options)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
gboolean(* active)(pe_resource_t *, gboolean)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes