20 #define PE__VARIANT_BUNDLE 1
24 next_ip(
const char *last_ip)
26 unsigned int oct1 = 0;
27 unsigned int oct2 = 0;
28 unsigned int oct3 = 0;
29 unsigned int oct4 = 0;
30 int rc = sscanf(last_ip,
"%u.%u.%u.%u", &oct1, &oct2, &oct3, &oct4);
36 }
else if (oct3 > 253) {
39 }
else if (oct4 > 253) {
51 allocate_ip(pe__bundle_variant_data_t *
data, pe__bundle_replica_t *replica,
52 char *buffer,
int max)
54 if(
data->ip_range_start == NULL) {
57 }
else if(
data->ip_last) {
58 replica->ipaddr = next_ip(
data->ip_last);
61 replica->ipaddr = strdup(
data->ip_range_start);
64 data->ip_last = replica->ipaddr;
65 switch (
data->agent_type) {
66 case PE__CONTAINER_AGENT_DOCKER:
67 case PE__CONTAINER_AGENT_PODMAN:
69 return snprintf(buffer, max,
" --add-host=%s-%d:%s",
70 data->prefix, replica->offset,
73 case PE__CONTAINER_AGENT_RKT:
74 return snprintf(buffer, max,
" --hosts-entry=%s=%s-%d",
75 replica->ipaddr,
data->prefix, replica->offset);
83 create_resource(
const char *
name,
const char *provider,
const char *kind)
108 valid_network(pe__bundle_variant_data_t *
data)
110 if(
data->ip_range_start) {
113 if(
data->control_port) {
114 if(
data->nreplicas_per_host > 1) {
115 pe_err(
"Specifying the 'control-port' for %s requires 'replicas-per-host=1'",
data->prefix);
116 data->nreplicas_per_host = 1;
128 if(
data->ip_range_start) {
130 xmlNode *xml_ip = NULL;
131 xmlNode *xml_obj = NULL;
135 xml_ip = create_resource(
id,
"heartbeat",
"IPaddr2");
140 data->prefix, replica->offset);
143 if(
data->host_network) {
147 if(
data->host_netmask) {
149 "cidr_netmask",
data->host_netmask);
160 if (!
common_unpack(xml_ip, &replica->ip, parent, data_set)) {
171 pe__bundle_replica_t *replica,
174 int offset = 0, max = 4096;
175 char *buffer = calloc(1, max+1);
177 int doffset = 0, dmax = 1024;
178 char *dbuffer = calloc(1, dmax+1);
181 xmlNode *xml_container = NULL;
182 xmlNode *xml_obj = NULL;
186 xml_container = create_resource(
id,
"heartbeat",
187 PE__CONTAINER_AGENT_DOCKER_S);
192 data->prefix, replica->offset);
199 offset += snprintf(buffer+offset, max-offset,
" --restart=no");
206 if (
data->ip_range_start != NULL) {
207 offset += snprintf(buffer+offset, max-offset,
" -h %s-%d",
208 data->prefix, replica->offset);
211 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_stderr=1");
213 if (
data->container_network) {
215 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
218 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
219 data->container_network);
222 if(
data->control_port) {
223 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%s",
data->control_port);
225 offset += snprintf(buffer+offset, max-offset,
" -e PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
228 for(
GListPtr pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
229 pe__bundle_mount_t *mount = pIter->data;
231 if (is_set(mount->flags, pe__bundle_mount_subdir)) {
233 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
236 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
238 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
239 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", source, mount->target);
243 offset += snprintf(buffer+offset, max-offset,
" -v %s:%s", mount->source, mount->target);
246 offset += snprintf(buffer+offset, max-offset,
":%s", mount->options);
250 for(
GListPtr pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
251 pe__bundle_port_t *port = pIter->data;
253 if (replica->ipaddr) {
254 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s:%s",
255 replica->ipaddr, port->source,
259 offset += snprintf(buffer+offset, max-offset,
" -p %s:%s", port->source, port->target);
263 if (
data->launcher_options) {
264 offset += snprintf(buffer+offset, max-offset,
" %s",
265 data->launcher_options);
268 if (
data->container_host_options) {
269 offset += snprintf(buffer + offset, max - offset,
" %s",
270 data->container_host_options);
279 if (replica->child) {
280 if (
data->container_command) {
282 "run_cmd",
data->container_command);
285 "run_cmd",
SBIN_DIR "/pacemaker-remoted");
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(
GListPtr pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
397 pe__bundle_mount_t *mount = pIter->data;
399 if (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(
GListPtr 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");
478 if (
data->container_command) {
480 "run_cmd",
data->container_command);
496 if (!
common_unpack(xml_container, &replica->container, parent,
508 int offset = 0, max = 4096;
509 char *buffer = calloc(1, max+1);
511 int doffset = 0, dmax = 1024;
512 char *dbuffer = calloc(1, dmax+1);
515 xmlNode *xml_container = NULL;
516 xmlNode *xml_obj = NULL;
522 xml_container = create_resource(
id,
"heartbeat",
523 PE__CONTAINER_AGENT_RKT_S);
528 data->prefix, replica->offset);
540 if (
data->ip_range_start != NULL) {
541 offset += snprintf(buffer+offset, max-offset,
" --hostname=%s-%d",
542 data->prefix, replica->offset);
545 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_stderr=1");
547 if (
data->container_network) {
549 offset += snprintf(buffer+offset, max-offset,
" --link-local-ip=%s",
552 offset += snprintf(buffer+offset, max-offset,
" --net=%s",
553 data->container_network);
556 if(
data->control_port) {
557 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_remote_port=%s",
data->control_port);
559 offset += snprintf(buffer+offset, max-offset,
" --environment=PCMK_remote_port=%d",
DEFAULT_REMOTE_PORT);
562 for(
GListPtr pIter =
data->mounts; pIter != NULL; pIter = pIter->next) {
563 pe__bundle_mount_t *mount = pIter->data;
565 if (is_set(mount->flags, pe__bundle_mount_subdir)) {
567 "%s/%s-%d", mount->source,
data->prefix, replica->offset);
570 doffset += snprintf(dbuffer+doffset, dmax-doffset,
",");
572 doffset += snprintf(dbuffer+doffset, dmax-doffset,
"%s", source);
573 offset += snprintf(buffer+offset, max-offset,
" --volume vol%d,kind=host,source=%s", volid, source);
575 offset += snprintf(buffer+offset, max-offset,
",%s", mount->options);
577 offset += snprintf(buffer+offset, max-offset,
" --mount volume=vol%d,target=%s", volid, mount->target);
581 offset += snprintf(buffer+offset, max-offset,
" --volume vol%d,kind=host,source=%s", volid, mount->source);
583 offset += snprintf(buffer+offset, max-offset,
",%s", mount->options);
585 offset += snprintf(buffer+offset, max-offset,
" --mount volume=vol%d,target=%s", volid, mount->target);
590 for(
GListPtr pIter =
data->ports; pIter != NULL; pIter = pIter->next) {
591 pe__bundle_port_t *port = pIter->data;
593 if (replica->ipaddr) {
594 offset += snprintf(buffer+offset, max-offset,
595 " --port=%s:%s:%s", port->target,
596 replica->ipaddr, port->source);
598 offset += snprintf(buffer+offset, max-offset,
" --port=%s:%s", port->target, port->source);
602 if (
data->launcher_options) {
603 offset += snprintf(buffer+offset, max-offset,
" %s",
604 data->launcher_options);
607 if (
data->container_host_options) {
608 offset += snprintf(buffer + offset, max - offset,
" %s",
609 data->container_host_options);
618 if (replica->child) {
619 if (
data->container_command) {
621 data->container_command);
649 if (
data->container_command) {
651 data->container_command);
668 if (!
common_unpack(xml_container, &replica->container, parent, data_set)) {
693 for (child = rsc->
children; child != NULL; child = child->next) {
701 pe__bundle_replica_t *replica,
704 if (replica->child && valid_network(
data)) {
705 GHashTableIter gIter;
708 xmlNode *xml_remote = NULL;
711 const char *
uname = NULL;
712 const char *connect_name = NULL;
718 replica->child->id, replica->offset);
727 connect_name = (replica->ipaddr? replica->ipaddr :
"#uname");
729 if (
data->control_port == NULL) {
740 connect_name, (
data->control_port?
741 data->control_port : port_s));
782 for (rsc_iter = data_set->
resources; rsc_iter; rsc_iter = rsc_iter->next) {
787 replica->node->weight = 500;
791 if (replica->child->allowed_nodes != NULL) {
792 g_hash_table_destroy(replica->child->allowed_nodes);
794 replica->child->allowed_nodes = g_hash_table_new_full(
crm_str_hash,
797 g_hash_table_insert(replica->child->allowed_nodes,
798 (gpointer) replica->node->details->id,
804 g_hash_table_insert(replica->child->parent->allowed_nodes,
805 (gpointer) replica->node->details->id, copy);
807 if (!
common_unpack(xml_remote, &replica->remote, parent, data_set)) {
811 g_hash_table_iter_init(&gIter, replica->remote->allowed_nodes);
812 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&node)) {
819 replica->node->details->remote_rsc = replica->remote;
822 replica->remote->container = replica->container;
827 g_hash_table_insert(replica->node->details->attrs,
849 switch (
data->agent_type) {
850 case PE__CONTAINER_AGENT_DOCKER:
851 if (!create_docker_resource(parent,
data, replica, data_set)) {
856 case PE__CONTAINER_AGENT_PODMAN:
857 if (!create_podman_resource(parent,
data, replica, data_set)) {
862 case PE__CONTAINER_AGENT_RKT:
863 if (!create_rkt_resource(parent,
data, replica, data_set)) {
871 if (create_ip_resource(parent,
data, replica, data_set) == FALSE) {
874 if(create_remote_resource(parent,
data, replica, data_set) == FALSE) {
877 if (replica->child && replica->ipaddr) {
878 add_hash_param(replica->child->meta,
"external-ip", replica->ipaddr);
881 if (replica->remote) {
897 mount_add(pe__bundle_variant_data_t *bundle_data,
const char *source,
898 const char *
target,
const char *options, uint32_t
flags)
900 pe__bundle_mount_t *mount = calloc(1,
sizeof(pe__bundle_mount_t));
902 mount->source = strdup(source);
903 mount->target = strdup(
target);
905 mount->options = strdup(options);
907 mount->flags =
flags;
908 bundle_data->mounts = g_list_append(bundle_data->mounts, mount);
912 mount_free(pe__bundle_mount_t *mount)
916 free(mount->options);
921 port_free(pe__bundle_port_t *port)
928 static pe__bundle_replica_t *
932 pe__bundle_variant_data_t *bundle_data = NULL;
938 while (top->
parent != NULL) {
942 get_bundle_variant_data(bundle_data, top);
943 for (GList *gIter = bundle_data->replicas; gIter != NULL;
944 gIter = gIter->next) {
945 pe__bundle_replica_t *replica = gIter->data;
947 if (replica->remote == remote) {
969 const char *match[3][2] = {
975 for (
int m = 0; m < 3; m++) {
991 pe__bundle_replica_t *replica = NULL;
997 replica = replica_for_remote(rsc);
998 if (replica == NULL) {
1002 node = replica->container->allocated_to;
1007 node = pe__current_node(replica->container);
1011 crm_trace(
"Cannot determine address for bundle connection %s", rsc->
id);
1015 crm_trace(
"Setting address for bundle connection %s to bundle host %s",
1017 if(xml != NULL && field != NULL) {
1027 const char *value = NULL;
1028 xmlNode *xml_obj = NULL;
1029 xmlNode *xml_resource = NULL;
1030 pe__bundle_variant_data_t *bundle_data = NULL;
1031 bool need_log_mount = TRUE;
1036 bundle_data = calloc(1,
sizeof(pe__bundle_variant_data_t));
1038 bundle_data->prefix = strdup(rsc->
id);
1041 if (xml_obj != NULL) {
1042 bundle_data->agent_type = PE__CONTAINER_AGENT_DOCKER;
1045 if (xml_obj != NULL) {
1046 bundle_data->agent_type = PE__CONTAINER_AGENT_RKT;
1049 if (xml_obj != NULL) {
1050 bundle_data->agent_type = PE__CONTAINER_AGENT_PODMAN;
1058 if (value == NULL) {
1063 if (bundle_data->promoted_max < 0) {
1064 pe_err(
"%s for %s must be nonnegative integer, using 0",
1066 bundle_data->promoted_max = 0;
1070 if ((value == NULL) && bundle_data->promoted_max) {
1071 bundle_data->nreplicas = bundle_data->promoted_max;
1075 if (bundle_data->nreplicas < 1) {
1076 pe_err(
"'replicas' for %s must be positive integer, using 1", rsc->
id);
1077 bundle_data->nreplicas = 1;
1086 bundle_data->nreplicas_per_host =
crm_parse_int(value,
"1");
1087 if (bundle_data->nreplicas_per_host < 1) {
1088 pe_err(
"'replicas-per-host' for %s must be positive integer, using 1",
1090 bundle_data->nreplicas_per_host = 1;
1092 if (bundle_data->nreplicas_per_host == 1) {
1110 bundle_data->add_host = TRUE;
1113 for (xmlNode *xml_child = __xml_first_child_element(xml_obj); xml_child != NULL;
1114 xml_child = __xml_next_element(xml_child)) {
1116 pe__bundle_port_t *port = calloc(1,
sizeof(pe__bundle_port_t));
1119 if(port->source == NULL) {
1125 if(port->source != NULL && strlen(port->source) > 0) {
1126 if(port->target == NULL) {
1127 port->target = strdup(port->source);
1129 bundle_data->ports = g_list_append(bundle_data->ports, port);
1132 pe_err(
"Invalid port directive %s",
ID(xml_child));
1139 for (xmlNode *xml_child = __xml_first_child_element(xml_obj); xml_child != NULL;
1140 xml_child = __xml_next_element(xml_child)) {
1145 int flags = pe__bundle_mount_none;
1147 if (source == NULL) {
1153 mount_add(bundle_data, source,
target, options,
flags);
1154 if (strcmp(
target,
"/var/log") == 0) {
1155 need_log_mount = FALSE;
1158 pe_err(
"Invalid mount directive %s",
ID(xml_child));
1163 if (xml_obj && valid_network(bundle_data)) {
1165 xmlNode *xml_set = NULL;
1174 (bundle_data->promoted_max?
"master"
1175 : (
const char *)xml_resource->name));
1178 crm_xml_set_id(xml_set,
"%s-%s-meta", bundle_data->prefix, xml_resource->name);
1183 value = crm_itoa(bundle_data->nreplicas);
1188 value = crm_itoa(bundle_data->nreplicas_per_host);
1194 (bundle_data->nreplicas_per_host > 1)?
1197 if (bundle_data->promoted_max) {
1201 value = crm_itoa(bundle_data->promoted_max);
1210 }
else if(xml_obj) {
1211 pe_err(
"Cannot control %s inside %s without either ip-range-start or control-port",
1212 rsc->
id,
ID(xml_obj));
1220 pe__bundle_port_t *port = NULL;
1222 int offset = 0, max = 1024;
1223 char *buffer = NULL;
1225 if (
common_unpack(xml_resource, &new_rsc, rsc, data_set) == FALSE) {
1226 pe_err(
"Failed unpacking resource %s",
ID(rsc->
xml));
1227 if (new_rsc != NULL && new_rsc->
fns != NULL) {
1233 bundle_data->child = new_rsc;
1259 if (need_log_mount) {
1261 pe__bundle_mount_subdir);
1264 port = calloc(1,
sizeof(pe__bundle_port_t));
1265 if(bundle_data->control_port) {
1266 port->source = strdup(bundle_data->control_port);
1278 port->target = strdup(port->source);
1279 bundle_data->ports = g_list_append(bundle_data->ports, port);
1281 buffer = calloc(1, max+1);
1282 for (childIter = bundle_data->child->children; childIter != NULL;
1283 childIter = childIter->next) {
1285 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1287 replica->child = childIter->data;
1288 replica->child->exclusive_discover = TRUE;
1289 replica->offset = lpc++;
1296 offset += allocate_ip(bundle_data, replica, buffer+offset,
1298 bundle_data->replicas = g_list_append(bundle_data->replicas,
1300 bundle_data->attribute_target = g_hash_table_lookup(replica->child->meta,
1303 bundle_data->container_host_options = buffer;
1304 if (bundle_data->attribute_target) {
1306 strdup(bundle_data->attribute_target));
1307 g_hash_table_replace(bundle_data->child->meta,
1309 strdup(bundle_data->attribute_target));
1314 int offset = 0, max = 1024;
1315 char *buffer = calloc(1, max+1);
1317 for (
int lpc = 0; lpc < bundle_data->nreplicas; lpc++) {
1318 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1320 replica->offset = lpc;
1321 offset += allocate_ip(bundle_data, replica, buffer+offset,
1323 bundle_data->replicas = g_list_append(bundle_data->replicas,
1326 bundle_data->container_host_options = buffer;
1329 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1330 gIter = gIter->next) {
1331 pe__bundle_replica_t *replica = gIter->data;
1333 if (!create_container(rsc, bundle_data, replica, data_set)) {
1334 pe_err(
"Failed unpacking resource %s", rsc->
id);
1340 if (bundle_data->child) {
1350 gboolean child_active = rsc->
fns->
active(rsc, all);
1352 if (child_active && !all) {
1354 }
else if (!child_active && all) {
1364 pe__bundle_variant_data_t *bundle_data = NULL;
1367 get_bundle_variant_data(bundle_data, rsc);
1368 for (iter = bundle_data->replicas; iter != NULL; iter = iter->next) {
1369 pe__bundle_replica_t *replica = iter->data;
1372 rsc_active = replica_resource_active(replica->ip, all);
1373 if (rsc_active >= 0) {
1374 return (gboolean) rsc_active;
1377 rsc_active = replica_resource_active(replica->child, all);
1378 if (rsc_active >= 0) {
1379 return (gboolean) rsc_active;
1382 rsc_active = replica_resource_active(replica->container, all);
1383 if (rsc_active >= 0) {
1384 return (gboolean) rsc_active;
1387 rsc_active = replica_resource_active(replica->remote, all);
1388 if (rsc_active >= 0) {
1389 return (gboolean) rsc_active;
1412 pe__bundle_variant_data_t *bundle_data = NULL;
1415 get_bundle_variant_data(bundle_data, bundle);
1416 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1417 gIter = gIter->next) {
1418 pe__bundle_replica_t *replica = gIter->data;
1421 if (replica->node->details == node->
details) {
1422 return replica->child;
1429 print_rsc_in_list(
pe_resource_t *rsc,
const char *pre_text,
long options,
1436 rsc->
fns->
print(rsc, pre_text, options, print_data);
1444 container_agent_str(
enum pe__container_agent t)
1447 case PE__CONTAINER_AGENT_DOCKER:
return PE__CONTAINER_AGENT_DOCKER_S;
1448 case PE__CONTAINER_AGENT_RKT:
return PE__CONTAINER_AGENT_RKT_S;
1449 case PE__CONTAINER_AGENT_PODMAN:
return PE__CONTAINER_AGENT_PODMAN_S;
1453 return PE__CONTAINER_AGENT_UNKNOWN_S;
1457 bundle_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
1460 pe__bundle_variant_data_t *bundle_data = NULL;
1461 char *child_text = NULL;
1464 if (pre_text == NULL) {
1469 get_bundle_variant_data(bundle_data, rsc);
1473 status_print(
"type=\"%s\" ", container_agent_str(bundle_data->agent_type));
1480 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1481 gIter = gIter->next) {
1482 pe__bundle_replica_t *replica = gIter->data;
1485 status_print(
"%s <replica id=\"%d\">\n", pre_text, replica->offset);
1486 print_rsc_in_list(replica->ip, child_text, options, print_data);
1487 print_rsc_in_list(replica->child, child_text, options, print_data);
1488 print_rsc_in_list(replica->container, child_text, options, print_data);
1489 print_rsc_in_list(replica->remote, child_text, options, print_data);
1496 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"struct pe_resource_t *",
"GListPtr")
1500 unsigned int options = va_arg(args,
unsigned int);
1504 pe__bundle_variant_data_t *bundle_data = NULL;
1506 gboolean printed_header = FALSE;
1510 get_bundle_variant_data(bundle_data, rsc);
1512 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1513 gIter = gIter->next) {
1514 pe__bundle_replica_t *replica = gIter->data;
1515 char *
id = crm_itoa(replica->offset);
1523 if (!printed_header) {
1524 printed_header = TRUE;
1528 ,
"type", container_agent_str(bundle_data->agent_type)
1529 ,
"image", bundle_data->image
1540 if (replica->ip != NULL) {
1541 out->message(out, crm_map_element_name(replica->ip->xml), options, replica->ip, only_show);
1544 if (replica->child != NULL) {
1545 out->message(out, crm_map_element_name(replica->child->xml), options, replica->child, only_show);
1548 out->message(out, crm_map_element_name(replica->container->xml), options, replica->container, only_show);
1550 if (replica->remote != NULL) {
1551 out->message(out, crm_map_element_name(replica->remote->xml), options, replica->remote, only_show);
1557 if (printed_header) {
1565 pe__bundle_replica_output_html(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1571 char buffer[LINE_MAX];
1577 if (replica->remote) {
1578 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1581 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1584 if (replica->ipaddr) {
1585 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1592 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"struct pe_resource_t *",
"GListPtr")
1596 unsigned int options = va_arg(args,
unsigned int);
1600 pe__bundle_variant_data_t *bundle_data = NULL;
1601 char buffer[LINE_MAX];
1605 get_bundle_variant_data(bundle_data, rsc);
1608 out->begin_list(out, NULL, NULL,
"Container bundle%s: %s [%s]%s%s",
1609 (bundle_data->nreplicas > 1)?
" set" :
"",
1610 rsc->
id, bundle_data->image,
1614 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1615 gIter = gIter->next) {
1616 pe__bundle_replica_t *replica = gIter->data;
1626 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1627 snprintf(buffer, LINE_MAX,
" Replica[%d]", replica->offset);
1631 out->begin_list(out, NULL, NULL, NULL);
1633 if (replica->ip != NULL) {
1634 out->message(out, crm_map_element_name(replica->ip->xml), options, replica->ip, only_show);
1637 if (replica->child != NULL) {
1638 out->message(out, crm_map_element_name(replica->child->xml), options, replica->child, only_show);
1641 out->message(out, crm_map_element_name(replica->container->xml), options, replica->container, only_show);
1643 if (replica->remote != NULL) {
1644 out->message(out, crm_map_element_name(replica->remote->xml), options, replica->remote, only_show);
1653 pe__bundle_replica_output_html(out, replica, pe__current_node(replica->container),
1665 pe__bundle_replica_output_text(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1671 char buffer[LINE_MAX];
1677 if (replica->remote) {
1678 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1681 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1684 if (replica->ipaddr) {
1685 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1692 PCMK__OUTPUT_ARGS(
"bundle",
"unsigned int",
"struct pe_resource_t *",
"GListPtr")
1696 unsigned int options = va_arg(args,
unsigned int);
1700 pe__bundle_variant_data_t *bundle_data = NULL;
1704 get_bundle_variant_data(bundle_data, rsc);
1706 out->begin_list(out, NULL, NULL,
"Container bundle%s: %s [%s]%s%s",
1707 (bundle_data->nreplicas > 1)?
" set" :
"",
1708 rsc->
id, bundle_data->image,
1712 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1713 gIter = gIter->next) {
1714 pe__bundle_replica_t *replica = gIter->data;
1723 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1724 out->list_item(out, NULL,
"Replica[%d]", replica->offset);
1727 out->begin_list(out, NULL, NULL, NULL);
1729 if (replica->ip != NULL) {
1730 out->message(out, crm_map_element_name(replica->ip->xml), options, replica->ip, only_show);
1733 if (replica->child != NULL) {
1734 out->message(out, crm_map_element_name(replica->child->xml), options, replica->child, only_show);
1737 out->message(out, crm_map_element_name(replica->container->xml), options, replica->container, only_show);
1739 if (replica->remote != NULL) {
1740 out->message(out, crm_map_element_name(replica->remote->xml), options, replica->remote, only_show);
1749 pe__bundle_replica_output_text(out, replica, pe__current_node(replica->container),
1759 print_bundle_replica(pe__bundle_replica_t *replica,
const char *pre_text,
1760 long options,
void *print_data)
1766 char buffer[LINE_MAX];
1772 if (replica->remote) {
1773 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1776 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1779 if (replica->ipaddr) {
1780 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1784 node = pe__current_node(replica->container);
1785 common_print(rsc, pre_text, buffer, node, options, print_data);
1792 pe__bundle_variant_data_t *bundle_data = NULL;
1793 char *child_text = NULL;
1797 bundle_print_xml(rsc, pre_text, options, print_data);
1801 get_bundle_variant_data(bundle_data, rsc);
1803 if (pre_text == NULL) {
1808 pre_text, ((bundle_data->nreplicas > 1)?
" set" :
""),
1809 rsc->
id, bundle_data->image,
1817 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1818 gIter = gIter->next) {
1819 pe__bundle_replica_t *replica = gIter->data;
1828 if (pcmk__list_of_multiple(bundle_data->replicas)) {
1829 status_print(
" %sReplica[%d]\n", pre_text, replica->offset);
1834 print_rsc_in_list(replica->ip, child_text, options, print_data);
1835 print_rsc_in_list(replica->container, child_text, options, print_data);
1836 print_rsc_in_list(replica->remote, child_text, options, print_data);
1837 print_rsc_in_list(replica->child, child_text, options, print_data);
1843 print_bundle_replica(replica, child_text, options, print_data);
1857 free_bundle_replica(pe__bundle_replica_t *replica)
1859 if (replica == NULL) {
1863 if (replica->node) {
1864 free(replica->node);
1865 replica->node = NULL;
1870 replica->ip->xml = NULL;
1871 replica->ip->fns->free(replica->ip);
1874 if (replica->container) {
1876 replica->container->xml = NULL;
1877 replica->container->fns->free(replica->container);
1878 replica->container = NULL;
1880 if (replica->remote) {
1882 replica->remote->xml = NULL;
1883 replica->remote->fns->free(replica->remote);
1884 replica->remote = NULL;
1886 free(replica->ipaddr);
1893 pe__bundle_variant_data_t *bundle_data = NULL;
1896 get_bundle_variant_data(bundle_data, rsc);
1899 free(bundle_data->prefix);
1900 free(bundle_data->image);
1901 free(bundle_data->control_port);
1902 free(bundle_data->host_network);
1903 free(bundle_data->host_netmask);
1904 free(bundle_data->ip_range_start);
1905 free(bundle_data->container_network);
1906 free(bundle_data->launcher_options);
1907 free(bundle_data->container_command);
1908 free(bundle_data->container_host_options);
1910 g_list_free_full(bundle_data->replicas,
1911 (GDestroyNotify) free_bundle_replica);
1912 g_list_free_full(bundle_data->mounts, (GDestroyNotify)mount_free);
1913 g_list_free_full(bundle_data->ports, (GDestroyNotify)port_free);
1916 if(bundle_data->child) {
1918 bundle_data->child->xml = NULL;
1919 bundle_data->child->fns->free(bundle_data->child);
1928 return container_role;
1944 pe__bundle_variant_data_t *bundle_data = NULL;
1946 get_bundle_variant_data(bundle_data, rsc);
1947 return bundle_data->nreplicas;
1954 pe__bundle_variant_data_t *bundle_data = NULL;
1956 get_bundle_variant_data(bundle_data, rsc);
1957 for (GList *item = bundle_data->replicas; item != NULL; item = item->next) {
1958 pe__bundle_replica_t *replica = item->data;
1961 replica->ip->fns->count(replica->ip);
1963 if (replica->child) {
1964 replica->child->fns->count(replica->child);
1966 if (replica->container) {
1967 replica->container->fns->count(replica->container);
1969 if (replica->remote) {
1970 replica->remote->fns->count(replica->remote);