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)) {
689 for (child = rsc->
children; child != NULL; child = child->next) {
697 pe__bundle_replica_t *replica,
700 if (replica->child && valid_network(
data)) {
701 GHashTableIter gIter;
702 GList *rsc_iter = NULL;
704 xmlNode *xml_remote = NULL;
707 const char *
uname = NULL;
708 const char *connect_name = NULL;
714 replica->child->id, replica->offset);
723 connect_name = (replica->ipaddr? replica->ipaddr :
"#uname");
725 if (
data->control_port == NULL) {
736 connect_name, (
data->control_port?
737 data->control_port : port_s));
778 for (rsc_iter = data_set->
resources; rsc_iter; rsc_iter = rsc_iter->next) {
783 replica->node->weight = 500;
787 if (replica->child->allowed_nodes != NULL) {
788 g_hash_table_destroy(replica->child->allowed_nodes);
791 g_hash_table_insert(replica->child->allowed_nodes,
792 (gpointer) replica->node->details->id,
798 g_hash_table_insert(replica->child->parent->allowed_nodes,
799 (gpointer) replica->node->details->id, copy);
801 if (!
common_unpack(xml_remote, &replica->remote, parent, data_set)) {
805 g_hash_table_iter_init(&gIter, replica->remote->allowed_nodes);
806 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&node)) {
813 replica->node->details->remote_rsc = replica->remote;
816 replica->remote->container = replica->container;
821 g_hash_table_insert(replica->node->details->attrs,
843 switch (
data->agent_type) {
844 case PE__CONTAINER_AGENT_DOCKER:
845 if (!create_docker_resource(parent,
data, replica, data_set)) {
850 case PE__CONTAINER_AGENT_PODMAN:
851 if (!create_podman_resource(parent,
data, replica, data_set)) {
856 case PE__CONTAINER_AGENT_RKT:
857 if (!create_rkt_resource(parent,
data, replica, data_set)) {
865 if (create_ip_resource(parent,
data, replica, data_set) == FALSE) {
868 if(create_remote_resource(parent,
data, replica, data_set) == FALSE) {
871 if (replica->child && replica->ipaddr) {
872 add_hash_param(replica->child->meta,
"external-ip", replica->ipaddr);
875 if (replica->remote) {
891 mount_add(pe__bundle_variant_data_t *bundle_data,
const char *source,
892 const char *
target,
const char *options, uint32_t
flags)
894 pe__bundle_mount_t *mount = calloc(1,
sizeof(pe__bundle_mount_t));
896 mount->source = strdup(source);
897 mount->target = strdup(
target);
899 mount->options = strdup(options);
901 mount->flags =
flags;
902 bundle_data->mounts = g_list_append(bundle_data->mounts, mount);
906 mount_free(pe__bundle_mount_t *mount)
910 free(mount->options);
915 port_free(pe__bundle_port_t *port)
922 static pe__bundle_replica_t *
926 pe__bundle_variant_data_t *bundle_data = NULL;
932 while (top->
parent != NULL) {
936 get_bundle_variant_data(bundle_data, top);
937 for (GList *gIter = bundle_data->replicas; gIter != NULL;
938 gIter = gIter->next) {
939 pe__bundle_replica_t *replica = gIter->data;
941 if (replica->remote == remote) {
953 GHashTable *params = NULL;
969 xmlNode *xml,
const char *field)
974 pe__bundle_replica_t *replica = NULL;
980 replica = replica_for_remote(rsc);
981 if (replica == NULL) {
985 node = replica->container->allocated_to;
990 node = pe__current_node(replica->container);
994 crm_trace(
"Cannot determine address for bundle connection %s", rsc->
id);
998 crm_trace(
"Setting address for bundle connection %s to bundle host %s",
1000 if(xml != NULL && field != NULL) {
1007 #define pe__set_bundle_mount_flags(mount_xml, flags, flags_to_set) do { \ 1008 flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \ 1009 "Bundle mount", ID(mount_xml), flags, \ 1010 (flags_to_set), #flags_to_set); \ 1016 const char *value = NULL;
1017 xmlNode *xml_obj = NULL;
1018 xmlNode *xml_resource = NULL;
1019 pe__bundle_variant_data_t *bundle_data = NULL;
1020 bool need_log_mount = TRUE;
1025 bundle_data = calloc(1,
sizeof(pe__bundle_variant_data_t));
1027 bundle_data->prefix = strdup(rsc->
id);
1030 if (xml_obj != NULL) {
1031 bundle_data->agent_type = PE__CONTAINER_AGENT_DOCKER;
1034 if (xml_obj != NULL) {
1035 bundle_data->agent_type = PE__CONTAINER_AGENT_RKT;
1038 if (xml_obj != NULL) {
1039 bundle_data->agent_type = PE__CONTAINER_AGENT_PODMAN;
1048 if (value == NULL) {
1056 if ((value == NULL) && (bundle_data->promoted_max > 0)) {
1057 bundle_data->nreplicas = bundle_data->promoted_max;
1069 if (bundle_data->nreplicas_per_host == 1) {
1087 bundle_data->add_host = TRUE;
1090 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
1091 xml_child = pcmk__xe_next(xml_child)) {
1093 pe__bundle_port_t *port = calloc(1,
sizeof(pe__bundle_port_t));
1096 if(port->source == NULL) {
1102 if(port->source != NULL && strlen(port->source) > 0) {
1103 if(port->target == NULL) {
1104 port->target = strdup(port->source);
1106 bundle_data->ports = g_list_append(bundle_data->ports, port);
1109 pe_err(
"Invalid port directive %s",
ID(xml_child));
1116 for (xmlNode *xml_child = pcmk__xe_first_child(xml_obj); xml_child != NULL;
1117 xml_child = pcmk__xe_next(xml_child)) {
1122 int flags = pe__bundle_mount_none;
1124 if (source == NULL) {
1127 pe__bundle_mount_subdir);
1131 mount_add(bundle_data, source,
target, options,
flags);
1132 if (strcmp(
target,
"/var/log") == 0) {
1133 need_log_mount = FALSE;
1136 pe_err(
"Invalid mount directive %s",
ID(xml_child));
1141 if (xml_obj && valid_network(bundle_data)) {
1143 xmlNode *xml_set = NULL;
1152 (bundle_data->promoted_max?
"master" 1153 : (
const char *)xml_resource->name));
1156 crm_xml_set_id(xml_set,
"%s-%s-meta", bundle_data->prefix, xml_resource->name);
1161 value = pcmk__itoa(bundle_data->nreplicas);
1166 value = pcmk__itoa(bundle_data->nreplicas_per_host);
1172 pcmk__btoa(bundle_data->nreplicas_per_host > 1));
1174 if (bundle_data->promoted_max) {
1178 value = pcmk__itoa(bundle_data->promoted_max);
1187 }
else if(xml_obj) {
1188 pe_err(
"Cannot control %s inside %s without either ip-range-start or control-port",
1189 rsc->
id,
ID(xml_obj));
1195 GList *childIter = NULL;
1197 pe__bundle_port_t *port = NULL;
1199 int offset = 0, max = 1024;
1200 char *buffer = NULL;
1202 if (
common_unpack(xml_resource, &new_rsc, rsc, data_set) == FALSE) {
1203 pe_err(
"Failed unpacking resource %s",
ID(rsc->
xml));
1204 if (new_rsc != NULL && new_rsc->
fns != NULL) {
1210 bundle_data->child = new_rsc;
1236 if (need_log_mount) {
1238 pe__bundle_mount_subdir);
1241 port = calloc(1,
sizeof(pe__bundle_port_t));
1242 if(bundle_data->control_port) {
1243 port->source = strdup(bundle_data->control_port);
1255 port->target = strdup(port->source);
1256 bundle_data->ports = g_list_append(bundle_data->ports, port);
1258 buffer = calloc(1, max+1);
1259 for (childIter = bundle_data->child->children; childIter != NULL;
1260 childIter = childIter->next) {
1262 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1264 replica->child = childIter->data;
1265 replica->child->exclusive_discover = TRUE;
1266 replica->offset = lpc++;
1273 offset += allocate_ip(bundle_data, replica, buffer+offset,
1275 bundle_data->replicas = g_list_append(bundle_data->replicas,
1277 bundle_data->attribute_target = g_hash_table_lookup(replica->child->meta,
1280 bundle_data->container_host_options = buffer;
1281 if (bundle_data->attribute_target) {
1283 strdup(bundle_data->attribute_target));
1284 g_hash_table_replace(bundle_data->child->meta,
1286 strdup(bundle_data->attribute_target));
1291 int offset = 0, max = 1024;
1292 char *buffer = calloc(1, max+1);
1294 for (
int lpc = 0; lpc < bundle_data->nreplicas; lpc++) {
1295 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1297 replica->offset = lpc;
1298 offset += allocate_ip(bundle_data, replica, buffer+offset,
1300 bundle_data->replicas = g_list_append(bundle_data->replicas,
1303 bundle_data->container_host_options = buffer;
1306 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1307 gIter = gIter->next) {
1308 pe__bundle_replica_t *replica = gIter->data;
1310 if (!create_container(rsc, bundle_data, replica, data_set)) {
1311 pe_err(
"Failed unpacking resource %s", rsc->
id);
1317 if (bundle_data->child) {
1327 gboolean child_active = rsc->
fns->
active(rsc, all);
1329 if (child_active && !all) {
1331 }
else if (!child_active && all) {
1341 pe__bundle_variant_data_t *bundle_data = NULL;
1344 get_bundle_variant_data(bundle_data, rsc);
1345 for (iter = bundle_data->replicas; iter != NULL; iter = iter->next) {
1346 pe__bundle_replica_t *replica = iter->data;
1349 rsc_active = replica_resource_active(replica->ip, all);
1350 if (rsc_active >= 0) {
1351 return (gboolean) rsc_active;
1354 rsc_active = replica_resource_active(replica->child, all);
1355 if (rsc_active >= 0) {
1356 return (gboolean) rsc_active;
1359 rsc_active = replica_resource_active(replica->container, all);
1360 if (rsc_active >= 0) {
1361 return (gboolean) rsc_active;
1364 rsc_active = replica_resource_active(replica->remote, all);
1365 if (rsc_active >= 0) {
1366 return (gboolean) rsc_active;
1389 pe__bundle_variant_data_t *bundle_data = NULL;
1392 get_bundle_variant_data(bundle_data, bundle);
1393 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1394 gIter = gIter->next) {
1395 pe__bundle_replica_t *replica = gIter->data;
1398 if (replica->node->details == node->
details) {
1399 return replica->child;
1406 print_rsc_in_list(
pe_resource_t *rsc,
const char *pre_text,
long options,
1413 rsc->
fns->
print(rsc, pre_text, options, print_data);
1421 container_agent_str(
enum pe__container_agent t)
1424 case PE__CONTAINER_AGENT_DOCKER:
return PE__CONTAINER_AGENT_DOCKER_S;
1425 case PE__CONTAINER_AGENT_RKT:
return PE__CONTAINER_AGENT_RKT_S;
1426 case PE__CONTAINER_AGENT_PODMAN:
return PE__CONTAINER_AGENT_PODMAN_S;
1430 return PE__CONTAINER_AGENT_UNKNOWN_S;
1434 bundle_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
1437 pe__bundle_variant_data_t *bundle_data = NULL;
1438 char *child_text = NULL;
1441 if (pre_text == NULL) {
1446 get_bundle_variant_data(bundle_data, rsc);
1450 status_print(
"type=\"%s\" ", container_agent_str(bundle_data->agent_type));
1457 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1458 gIter = gIter->next) {
1459 pe__bundle_replica_t *replica = gIter->data;
1462 status_print(
"%s <replica id=\"%d\">\n", pre_text, replica->offset);
1463 print_rsc_in_list(replica->ip, child_text, options, print_data);
1464 print_rsc_in_list(replica->child, child_text, options, print_data);
1465 print_rsc_in_list(replica->container, child_text, options, print_data);
1466 print_rsc_in_list(replica->remote, child_text, options, print_data);
1473 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
1477 unsigned int show_opts = va_arg(args,
unsigned int);
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 printed_header = FALSE;
1485 gboolean print_everything = TRUE;
1489 get_bundle_variant_data(bundle_data, rsc);
1497 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1498 gIter = gIter->next) {
1499 pe__bundle_replica_t *replica = gIter->data;
1501 gboolean print_ip, print_child, print_ctnr, print_remote;
1509 print_ip = replica->ip != NULL &&
1510 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1511 print_child = replica->child != NULL &&
1512 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1513 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1514 print_remote = replica->remote != NULL &&
1515 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1517 if (!print_everything && !print_ip && !print_child && !print_ctnr && !print_remote) {
1521 if (!printed_header) {
1522 printed_header = TRUE;
1526 "type", container_agent_str(bundle_data->agent_type),
1527 "image", bundle_data->image,
1534 id = pcmk__itoa(replica->offset);
1540 out->message(out, crm_map_element_name(replica->ip->xml), show_opts,
1541 replica->ip, only_node, only_rsc);
1545 out->message(out, crm_map_element_name(replica->child->xml), show_opts,
1546 replica->child, only_node, only_rsc);
1550 out->message(out, crm_map_element_name(replica->container->xml), show_opts,
1551 replica->container, only_node, only_rsc);
1555 out->message(out, crm_map_element_name(replica->remote->xml), show_opts,
1556 replica->remote, only_node, only_rsc);
1562 if (printed_header) {
1570 pe__bundle_replica_output_html(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1571 pe_node_t *node,
unsigned int show_opts)
1576 char buffer[LINE_MAX];
1582 if (replica->remote) {
1583 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1586 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1589 if (replica->ipaddr) {
1590 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1597 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
1601 unsigned int show_opts = va_arg(args,
unsigned int);
1603 GList *only_node = va_arg(args, GList *);
1604 GList *only_rsc = va_arg(args, GList *);
1606 pe__bundle_variant_data_t *bundle_data = NULL;
1608 gboolean print_everything = TRUE;
1612 get_bundle_variant_data(bundle_data, rsc);
1620 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1621 gIter = gIter->next) {
1622 pe__bundle_replica_t *replica = gIter->data;
1623 gboolean print_ip, print_child, print_ctnr, print_remote;
1631 print_ip = replica->ip != NULL &&
1632 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1633 print_child = replica->child != NULL &&
1634 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1635 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1636 print_remote = replica->remote != NULL &&
1637 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1640 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1647 (bundle_data->nreplicas > 1)?
" set" :
"",
1648 rsc->
id, bundle_data->image,
1652 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1653 out->begin_list(out, NULL, NULL,
"Replica[%d]", replica->offset);
1657 out->message(out, crm_map_element_name(replica->ip->xml),
1658 new_show_opts, replica->ip, only_node, only_rsc);
1662 out->message(out, crm_map_element_name(replica->child->xml),
1663 new_show_opts, replica->child, only_node, only_rsc);
1667 out->message(out, crm_map_element_name(replica->container->xml),
1668 new_show_opts, replica->container, only_node, only_rsc);
1672 out->message(out, crm_map_element_name(replica->remote->xml),
1673 new_show_opts, replica->remote, only_node, only_rsc);
1676 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1679 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1683 (bundle_data->nreplicas > 1)?
" set" :
"",
1684 rsc->
id, bundle_data->image,
1688 pe__bundle_replica_output_html(out, replica, pe__current_node(replica->container),
1698 pe__bundle_replica_output_text(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1699 pe_node_t *node,
unsigned int show_opts)
1704 char buffer[LINE_MAX];
1710 if (replica->remote) {
1711 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1714 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1717 if (replica->ipaddr) {
1718 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1725 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"pe_resource_t *",
"GList *",
"GList *")
1729 unsigned int show_opts = va_arg(args,
unsigned int);
1731 GList *only_node = va_arg(args, GList *);
1732 GList *only_rsc = va_arg(args, GList *);
1734 pe__bundle_variant_data_t *bundle_data = NULL;
1736 gboolean print_everything = TRUE;
1738 get_bundle_variant_data(bundle_data, rsc);
1748 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1749 gIter = gIter->next) {
1750 pe__bundle_replica_t *replica = gIter->data;
1751 gboolean print_ip, print_child, print_ctnr, print_remote;
1759 print_ip = replica->ip != NULL &&
1760 !replica->ip->fns->is_filtered(replica->ip, only_rsc, print_everything);
1761 print_child = replica->child != NULL &&
1762 !replica->child->fns->is_filtered(replica->child, only_rsc, print_everything);
1763 print_ctnr = !replica->container->fns->is_filtered(replica->container, only_rsc, print_everything);
1764 print_remote = replica->remote != NULL &&
1765 !replica->remote->fns->is_filtered(replica->remote, only_rsc, print_everything);
1768 (print_everything == FALSE && (print_ip || print_child || print_ctnr || print_remote))) {
1775 (bundle_data->nreplicas > 1)?
" set" :
"",
1776 rsc->
id, bundle_data->image,
1780 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1781 out->list_item(out, NULL,
"Replica[%d]", replica->offset);
1784 out->begin_list(out, NULL, NULL, NULL);
1787 out->message(out, crm_map_element_name(replica->ip->xml),
1788 new_show_opts, replica->ip, only_node, only_rsc);
1792 out->message(out, crm_map_element_name(replica->child->xml),
1793 new_show_opts, replica->child, only_node, only_rsc);
1797 out->message(out, crm_map_element_name(replica->container->xml),
1798 new_show_opts, replica->container, only_node, only_rsc);
1802 out->message(out, crm_map_element_name(replica->remote->xml),
1803 new_show_opts, replica->remote, only_node, only_rsc);
1807 }
else if (print_everything == FALSE && !(print_ip || print_child || print_ctnr || print_remote)) {
1811 (bundle_data->nreplicas > 1)?
" set" :
"",
1812 rsc->
id, bundle_data->image,
1816 pe__bundle_replica_output_text(out, replica, pe__current_node(replica->container),
1826 print_bundle_replica(pe__bundle_replica_t *replica,
const char *pre_text,
1827 long options,
void *print_data)
1833 char buffer[LINE_MAX];
1839 if (replica->remote) {
1840 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1843 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1846 if (replica->ipaddr) {
1847 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1851 node = pe__current_node(replica->container);
1852 common_print(rsc, pre_text, buffer, node, options, print_data);
1859 pe__bundle_variant_data_t *bundle_data = NULL;
1860 char *child_text = NULL;
1864 bundle_print_xml(rsc, pre_text, options, print_data);
1868 get_bundle_variant_data(bundle_data, rsc);
1870 if (pre_text == NULL) {
1875 pre_text, ((bundle_data->nreplicas > 1)?
" set" :
""),
1876 rsc->
id, bundle_data->image,
1884 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1885 gIter = gIter->next) {
1886 pe__bundle_replica_t *replica = gIter->data;
1895 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1896 status_print(
" %sReplica[%d]\n", pre_text, replica->offset);
1901 print_rsc_in_list(replica->ip, child_text, options, print_data);
1902 print_rsc_in_list(replica->container, child_text, options, print_data);
1903 print_rsc_in_list(replica->remote, child_text, options, print_data);
1904 print_rsc_in_list(replica->child, child_text, options, print_data);
1910 print_bundle_replica(replica, child_text, options, print_data);
1924 free_bundle_replica(pe__bundle_replica_t *replica)
1926 if (replica == NULL) {
1930 if (replica->node) {
1931 free(replica->node);
1932 replica->node = NULL;
1937 replica->ip->xml = NULL;
1938 replica->ip->fns->free(replica->ip);
1941 if (replica->container) {
1943 replica->container->xml = NULL;
1944 replica->container->fns->free(replica->container);
1945 replica->container = NULL;
1947 if (replica->remote) {
1949 replica->remote->xml = NULL;
1950 replica->remote->fns->free(replica->remote);
1951 replica->remote = NULL;
1953 free(replica->ipaddr);
1960 pe__bundle_variant_data_t *bundle_data = NULL;
1963 get_bundle_variant_data(bundle_data, rsc);
1966 free(bundle_data->prefix);
1967 free(bundle_data->image);
1968 free(bundle_data->control_port);
1969 free(bundle_data->host_network);
1970 free(bundle_data->host_netmask);
1971 free(bundle_data->ip_range_start);
1972 free(bundle_data->container_network);
1973 free(bundle_data->launcher_options);
1974 free(bundle_data->container_command);
1975 free(bundle_data->container_host_options);
1977 g_list_free_full(bundle_data->replicas,
1978 (GDestroyNotify) free_bundle_replica);
1979 g_list_free_full(bundle_data->mounts, (GDestroyNotify)mount_free);
1980 g_list_free_full(bundle_data->ports, (GDestroyNotify)port_free);
1983 if(bundle_data->child) {
1985 bundle_data->child->xml = NULL;
1986 bundle_data->child->fns->free(bundle_data->child);
1995 return container_role;
2011 pe__bundle_variant_data_t *bundle_data = NULL;
2013 get_bundle_variant_data(bundle_data, rsc);
2014 return bundle_data->nreplicas;
2021 pe__bundle_variant_data_t *bundle_data = NULL;
2023 get_bundle_variant_data(bundle_data, rsc);
2024 for (GList *item = bundle_data->replicas; item != NULL; item = item->next) {
2025 pe__bundle_replica_t *replica = item->data;
2028 replica->ip->fns->count(replica->ip);
2030 if (replica->child) {
2031 replica->child->fns->count(replica->child);
2033 if (replica->container) {
2034 replica->container->fns->count(replica->container);
2036 if (replica->remote) {
2037 replica->remote->fns->count(replica->remote);
2045 gboolean passes = FALSE;
2046 pe__bundle_variant_data_t *bundle_data = NULL;
2051 get_bundle_variant_data(bundle_data, rsc);
2053 for (GList *gIter = bundle_data->replicas; gIter != NULL; gIter = gIter->next) {
2054 pe__bundle_replica_t *replica = gIter->data;
2056 if (replica->ip != NULL && !replica->ip->fns->is_filtered(replica->ip, only_rsc, FALSE)) {
2059 }
else if (replica->child != NULL && !replica->child->fns->is_filtered(replica->child, only_rsc, FALSE)) {
2062 }
else if (!replica->container->fns->is_filtered(replica->container, only_rsc, FALSE)) {
2065 }
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)
gboolean pcmk__str_in_list(GList *lst, const gchar *s, uint32_t flags)
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
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