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);
726 connect_name = (replica->ipaddr? replica->ipaddr :
"#uname");
728 if (
data->control_port == NULL) {
739 connect_name, (
data->control_port?
740 data->control_port : port_s));
781 for (rsc_iter = data_set->
resources; rsc_iter; rsc_iter = rsc_iter->next) {
786 replica->node->weight = 500;
790 if (replica->child->allowed_nodes != NULL) {
791 g_hash_table_destroy(replica->child->allowed_nodes);
793 replica->child->allowed_nodes = g_hash_table_new_full(
crm_str_hash,
796 g_hash_table_insert(replica->child->allowed_nodes,
797 (gpointer) replica->node->details->id,
803 g_hash_table_insert(replica->child->parent->allowed_nodes,
804 (gpointer) replica->node->details->id, copy);
806 if (!
common_unpack(xml_remote, &replica->remote, parent, data_set)) {
810 g_hash_table_iter_init(&gIter, replica->remote->allowed_nodes);
811 while (g_hash_table_iter_next(&gIter, NULL, (
void **)&node)) {
818 replica->node->details->remote_rsc = replica->remote;
821 replica->remote->container = replica->container;
826 g_hash_table_insert(replica->node->details->attrs,
848 switch (
data->agent_type) {
849 case PE__CONTAINER_AGENT_DOCKER:
850 if (!create_docker_resource(parent,
data, replica, data_set)) {
855 case PE__CONTAINER_AGENT_PODMAN:
856 if (!create_podman_resource(parent,
data, replica, data_set)) {
861 case PE__CONTAINER_AGENT_RKT:
862 if (!create_rkt_resource(parent,
data, replica, data_set)) {
870 if (create_ip_resource(parent,
data, replica, data_set) == FALSE) {
873 if(create_remote_resource(parent,
data, replica, data_set) == FALSE) {
876 if (replica->child && replica->ipaddr) {
877 add_hash_param(replica->child->meta,
"external-ip", replica->ipaddr);
880 if (replica->remote) {
896 mount_add(pe__bundle_variant_data_t *bundle_data,
const char *source,
897 const char *target,
const char *options, uint32_t
flags)
899 pe__bundle_mount_t *mount = calloc(1,
sizeof(pe__bundle_mount_t));
901 mount->source = strdup(source);
902 mount->target = strdup(target);
904 mount->options = strdup(options);
906 mount->flags =
flags;
907 bundle_data->mounts = g_list_append(bundle_data->mounts, mount);
911 mount_free(pe__bundle_mount_t *mount)
915 free(mount->options);
920 port_free(pe__bundle_port_t *port)
927 static pe__bundle_replica_t *
931 pe__bundle_variant_data_t *bundle_data = NULL;
937 while (top->
parent != NULL) {
941 get_bundle_variant_data(bundle_data, top);
942 for (GList *gIter = bundle_data->replicas; gIter != NULL;
943 gIter = gIter->next) {
944 pe__bundle_replica_t *replica = gIter->data;
946 if (replica->remote == remote) {
968 const char *match[3][2] = {
974 for (
int m = 0; m < 3; m++) {
990 pe__bundle_replica_t *replica = NULL;
996 replica = replica_for_remote(rsc);
997 if (replica == NULL) {
1001 node = replica->container->allocated_to;
1006 node = pe__current_node(replica->container);
1010 crm_trace(
"Cannot determine address for bundle connection %s", rsc->
id);
1014 crm_trace(
"Setting address for bundle connection %s to bundle host %s",
1016 if(xml != NULL && field != NULL) {
1026 const char *value = NULL;
1027 xmlNode *xml_obj = NULL;
1028 xmlNode *xml_resource = NULL;
1029 pe__bundle_variant_data_t *bundle_data = NULL;
1030 bool need_log_mount = TRUE;
1035 bundle_data = calloc(1,
sizeof(pe__bundle_variant_data_t));
1037 bundle_data->prefix = strdup(rsc->
id);
1040 if (xml_obj != NULL) {
1041 bundle_data->agent_type = PE__CONTAINER_AGENT_DOCKER;
1044 if (xml_obj != NULL) {
1045 bundle_data->agent_type = PE__CONTAINER_AGENT_RKT;
1048 if (xml_obj != NULL) {
1049 bundle_data->agent_type = PE__CONTAINER_AGENT_PODMAN;
1057 if (value == NULL) {
1062 if (bundle_data->promoted_max < 0) {
1063 pe_err(
"%s for %s must be nonnegative integer, using 0",
1065 bundle_data->promoted_max = 0;
1069 if ((value == NULL) && bundle_data->promoted_max) {
1070 bundle_data->nreplicas = bundle_data->promoted_max;
1074 if (bundle_data->nreplicas < 1) {
1075 pe_err(
"'replicas' for %s must be positive integer, using 1", rsc->
id);
1076 bundle_data->nreplicas = 1;
1085 bundle_data->nreplicas_per_host =
crm_parse_int(value,
"1");
1086 if (bundle_data->nreplicas_per_host < 1) {
1087 pe_err(
"'replicas-per-host' for %s must be positive integer, using 1",
1089 bundle_data->nreplicas_per_host = 1;
1091 if (bundle_data->nreplicas_per_host == 1) {
1109 bundle_data->add_host = TRUE;
1114 for (xmlNode *xml_child = __xml_first_child_element(xml_obj); xml_child != NULL;
1115 xml_child = __xml_next_element(xml_child)) {
1117 pe__bundle_port_t *port = calloc(1,
sizeof(pe__bundle_port_t));
1120 if(port->source == NULL) {
1126 if(port->source != NULL && strlen(port->source) > 0) {
1127 if(port->target == NULL) {
1128 port->target = strdup(port->source);
1130 bundle_data->ports = g_list_append(bundle_data->ports, port);
1133 pe_err(
"Invalid port directive %s",
ID(xml_child));
1140 for (xmlNode *xml_child = __xml_first_child_element(xml_obj); xml_child != NULL;
1141 xml_child = __xml_next_element(xml_child)) {
1146 int flags = pe__bundle_mount_none;
1148 if (source == NULL) {
1153 if (source && target) {
1154 mount_add(bundle_data, source, target, options,
flags);
1155 if (strcmp(target,
"/var/log") == 0) {
1156 need_log_mount = FALSE;
1159 pe_err(
"Invalid mount directive %s",
ID(xml_child));
1164 if (xml_obj && valid_network(bundle_data)) {
1166 xmlNode *xml_set = NULL;
1175 (bundle_data->promoted_max?
"master"
1176 : (
const char *)xml_resource->name));
1179 crm_xml_set_id(xml_set,
"%s-%s-meta", bundle_data->prefix, xml_resource->name);
1184 value = crm_itoa(bundle_data->nreplicas);
1189 value = crm_itoa(bundle_data->nreplicas_per_host);
1195 (bundle_data->nreplicas_per_host > 1)?
1198 if (bundle_data->promoted_max) {
1202 value = crm_itoa(bundle_data->promoted_max);
1211 }
else if(xml_obj) {
1212 pe_err(
"Cannot control %s inside %s without either ip-range-start or control-port",
1213 rsc->
id,
ID(xml_obj));
1221 pe__bundle_port_t *port = NULL;
1223 int offset = 0, max = 1024;
1224 char *buffer = NULL;
1226 if (
common_unpack(xml_resource, &new_rsc, rsc, data_set) == FALSE) {
1227 pe_err(
"Failed unpacking resource %s",
ID(rsc->
xml));
1228 if (new_rsc != NULL && new_rsc->
fns != NULL) {
1234 bundle_data->child = new_rsc;
1260 if (need_log_mount) {
1262 pe__bundle_mount_subdir);
1265 port = calloc(1,
sizeof(pe__bundle_port_t));
1266 if(bundle_data->control_port) {
1267 port->source = strdup(bundle_data->control_port);
1279 port->target = strdup(port->source);
1280 bundle_data->ports = g_list_append(bundle_data->ports, port);
1282 buffer = calloc(1, max+1);
1283 for (childIter = bundle_data->child->children; childIter != NULL;
1284 childIter = childIter->next) {
1286 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1288 replica->child = childIter->data;
1289 replica->child->exclusive_discover = TRUE;
1290 replica->offset = lpc++;
1297 offset += allocate_ip(bundle_data, replica, buffer+offset,
1299 bundle_data->replicas = g_list_append(bundle_data->replicas,
1301 bundle_data->attribute_target = g_hash_table_lookup(replica->child->meta,
1304 bundle_data->container_host_options = buffer;
1305 if (bundle_data->attribute_target) {
1307 strdup(bundle_data->attribute_target));
1308 g_hash_table_replace(bundle_data->child->meta,
1310 strdup(bundle_data->attribute_target));
1315 int offset = 0, max = 1024;
1316 char *buffer = calloc(1, max+1);
1318 for (
int lpc = 0; lpc < bundle_data->nreplicas; lpc++) {
1319 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1321 replica->offset = lpc;
1322 offset += allocate_ip(bundle_data, replica, buffer+offset,
1324 bundle_data->replicas = g_list_append(bundle_data->replicas,
1327 bundle_data->container_host_options = buffer;
1330 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1331 gIter = gIter->next) {
1332 pe__bundle_replica_t *replica = gIter->data;
1334 if (!create_container(rsc, bundle_data, replica, data_set)) {
1335 pe_err(
"Failed unpacking resource %s", rsc->
id);
1341 if (bundle_data->child) {
1351 gboolean child_active = rsc->
fns->
active(rsc, all);
1353 if (child_active && !all) {
1355 }
else if (!child_active && all) {
1365 pe__bundle_variant_data_t *bundle_data = NULL;
1368 get_bundle_variant_data(bundle_data, rsc);
1369 for (iter = bundle_data->replicas; iter != NULL; iter = iter->next) {
1370 pe__bundle_replica_t *replica = iter->data;
1373 rsc_active = replica_resource_active(replica->ip, all);
1374 if (rsc_active >= 0) {
1375 return (gboolean) rsc_active;
1378 rsc_active = replica_resource_active(replica->child, all);
1379 if (rsc_active >= 0) {
1380 return (gboolean) rsc_active;
1383 rsc_active = replica_resource_active(replica->container, all);
1384 if (rsc_active >= 0) {
1385 return (gboolean) rsc_active;
1388 rsc_active = replica_resource_active(replica->remote, all);
1389 if (rsc_active >= 0) {
1390 return (gboolean) rsc_active;
1413 pe__bundle_variant_data_t *bundle_data = NULL;
1416 get_bundle_variant_data(bundle_data, bundle);
1417 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1418 gIter = gIter->next) {
1419 pe__bundle_replica_t *replica = gIter->data;
1422 if (replica->node->details == node->
details) {
1423 return replica->child;
1430 print_rsc_in_list(
resource_t *rsc,
const char *pre_text,
long options,
1437 rsc->
fns->
print(rsc, pre_text, options, print_data);
1445 container_agent_str(
enum pe__container_agent t)
1448 case PE__CONTAINER_AGENT_DOCKER:
return PE__CONTAINER_AGENT_DOCKER_S;
1449 case PE__CONTAINER_AGENT_RKT:
return PE__CONTAINER_AGENT_RKT_S;
1450 case PE__CONTAINER_AGENT_PODMAN:
return PE__CONTAINER_AGENT_PODMAN_S;
1454 return PE__CONTAINER_AGENT_UNKNOWN_S;
1458 bundle_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
1461 pe__bundle_variant_data_t *bundle_data = NULL;
1462 char *child_text = NULL;
1465 if (pre_text == NULL) {
1468 child_text = crm_concat(pre_text,
" ",
' ');
1470 get_bundle_variant_data(bundle_data, rsc);
1474 status_print(
"type=\"%s\" ", container_agent_str(bundle_data->agent_type));
1481 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1482 gIter = gIter->next) {
1483 pe__bundle_replica_t *replica = gIter->data;
1486 status_print(
"%s <replica id=\"%d\">\n", pre_text, replica->offset);
1487 print_rsc_in_list(replica->ip, child_text, options, print_data);
1488 print_rsc_in_list(replica->child, child_text, options, print_data);
1489 print_rsc_in_list(replica->container, child_text, options, print_data);
1490 print_rsc_in_list(replica->remote, child_text, options, print_data);
1500 unsigned int options = va_arg(args,
unsigned int);
1502 pe__bundle_variant_data_t *bundle_data = NULL;
1507 get_bundle_variant_data(bundle_data, rsc);
1511 ,
"type", container_agent_str(bundle_data->agent_type)
1512 ,
"image", bundle_data->image
1518 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1519 gIter = gIter->next) {
1520 pe__bundle_replica_t *replica = gIter->data;
1521 char *
id = crm_itoa(replica->offset);
1529 if (replica->ip != NULL) {
1530 out->
message(out, crm_map_element_name(replica->ip->xml), options, replica->ip);
1533 if (replica->child != NULL) {
1534 out->
message(out, crm_map_element_name(replica->child->xml), options, replica->child);
1537 out->
message(out, crm_map_element_name(replica->container->xml), options, replica->container);
1539 if (replica->remote != NULL) {
1540 out->
message(out, crm_map_element_name(replica->remote->xml), options, replica->remote);
1550 pe__bundle_replica_output_html(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1557 char buffer[LINE_MAX];
1563 if (replica->remote) {
1564 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1567 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1570 if (replica->ipaddr) {
1571 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1575 node = pe__current_node(replica->container);
1582 unsigned int options = va_arg(args,
unsigned int);
1584 pe__bundle_variant_data_t *bundle_data = NULL;
1585 char buffer[LINE_MAX];
1589 get_bundle_variant_data(bundle_data, rsc);
1592 out->
begin_list(out, NULL, NULL,
"Container bundle%s: %s [%s]%s%s",
1593 (bundle_data->nreplicas > 1)?
" set" :
"",
1594 rsc->
id, bundle_data->image,
1598 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1599 gIter = gIter->next) {
1600 pe__bundle_replica_t *replica = gIter->data;
1606 if(g_list_length(bundle_data->replicas) > 1) {
1607 snprintf(buffer, LINE_MAX,
" Replica[%d]", replica->offset);
1613 if (replica->ip != NULL) {
1614 out->
message(out, crm_map_element_name(replica->ip->xml), options, replica->ip);
1617 if (replica->child != NULL) {
1618 out->
message(out, crm_map_element_name(replica->child->xml), options, replica->child);
1621 out->
message(out, crm_map_element_name(replica->container->xml), options, replica->container);
1623 if (replica->remote != NULL) {
1624 out->
message(out, crm_map_element_name(replica->remote->xml), options, replica->remote);
1629 pe__bundle_replica_output_html(out, replica, options);
1640 pe__bundle_replica_output_text(
pcmk__output_t *out, pe__bundle_replica_t *replica,
1647 char buffer[LINE_MAX];
1653 if (replica->remote) {
1654 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1657 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1660 if (replica->ipaddr) {
1661 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1665 node = pe__current_node(replica->container);
1672 unsigned int options = va_arg(args,
unsigned int);
1675 pe__bundle_variant_data_t *bundle_data = NULL;
1679 get_bundle_variant_data(bundle_data, rsc);
1681 out->
begin_list(out, NULL, NULL,
"Container bundle%s: %s [%s]%s%s",
1682 (bundle_data->nreplicas > 1)?
" set" :
"",
1683 rsc->
id, bundle_data->image,
1687 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1688 gIter = gIter->next) {
1689 pe__bundle_replica_t *replica = gIter->data;
1694 if(g_list_length(bundle_data->replicas) > 1) {
1695 out->
list_item(out, NULL,
"Replica[%d]", replica->offset);
1700 if (replica->ip != NULL) {
1701 out->
message(out, crm_map_element_name(replica->ip->xml), options, replica->ip);
1704 if (replica->child != NULL) {
1705 out->
message(out, crm_map_element_name(replica->child->xml), options, replica->child);
1708 out->
message(out, crm_map_element_name(replica->container->xml), options, replica->container);
1710 if (replica->remote != NULL) {
1711 out->
message(out, crm_map_element_name(replica->remote->xml), options, replica->remote);
1716 pe__bundle_replica_output_text(out, replica, options);
1725 print_bundle_replica(pe__bundle_replica_t *replica,
const char *pre_text,
1726 long options,
void *print_data)
1732 char buffer[LINE_MAX];
1738 if (replica->remote) {
1739 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1742 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1745 if (replica->ipaddr) {
1746 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1750 node = pe__current_node(replica->container);
1751 common_print(rsc, pre_text, buffer, node, options, print_data);
1758 pe__bundle_variant_data_t *bundle_data = NULL;
1759 char *child_text = NULL;
1763 bundle_print_xml(rsc, pre_text, options, print_data);
1767 get_bundle_variant_data(bundle_data, rsc);
1769 if (pre_text == NULL) {
1774 pre_text, ((bundle_data->nreplicas > 1)?
" set" :
""),
1775 rsc->
id, bundle_data->image,
1783 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1784 gIter = gIter->next) {
1785 pe__bundle_replica_t *replica = gIter->data;
1794 if(g_list_length(bundle_data->replicas) > 1) {
1795 status_print(
" %sReplica[%d]\n", pre_text, replica->offset);
1800 print_rsc_in_list(replica->ip, child_text, options, print_data);
1801 print_rsc_in_list(replica->container, child_text, options, print_data);
1802 print_rsc_in_list(replica->remote, child_text, options, print_data);
1803 print_rsc_in_list(replica->child, child_text, options, print_data);
1809 print_bundle_replica(replica, child_text, options, print_data);
1823 free_bundle_replica(pe__bundle_replica_t *replica)
1825 if (replica == NULL) {
1829 if (replica->node) {
1830 free(replica->node);
1831 replica->node = NULL;
1836 replica->ip->xml = NULL;
1837 replica->ip->fns->free(replica->ip);
1840 if (replica->container) {
1842 replica->container->xml = NULL;
1843 replica->container->fns->free(replica->container);
1844 replica->container = NULL;
1846 if (replica->remote) {
1848 replica->remote->xml = NULL;
1849 replica->remote->fns->free(replica->remote);
1850 replica->remote = NULL;
1852 free(replica->ipaddr);
1859 pe__bundle_variant_data_t *bundle_data = NULL;
1862 get_bundle_variant_data(bundle_data, rsc);
1865 free(bundle_data->prefix);
1866 free(bundle_data->image);
1867 free(bundle_data->control_port);
1868 free(bundle_data->host_network);
1869 free(bundle_data->host_netmask);
1870 free(bundle_data->ip_range_start);
1871 free(bundle_data->container_network);
1872 free(bundle_data->launcher_options);
1873 free(bundle_data->container_command);
1874 free(bundle_data->container_host_options);
1876 g_list_free_full(bundle_data->replicas,
1877 (GDestroyNotify) free_bundle_replica);
1878 g_list_free_full(bundle_data->mounts, (GDestroyNotify)mount_free);
1879 g_list_free_full(bundle_data->ports, (GDestroyNotify)port_free);
1882 if(bundle_data->child) {
1884 bundle_data->child->xml = NULL;
1885 bundle_data->child->fns->free(bundle_data->child);
1894 return container_role;
1910 pe__bundle_variant_data_t *bundle_data = NULL;
1912 get_bundle_variant_data(bundle_data, rsc);
1913 return bundle_data->nreplicas;
1920 pe__bundle_variant_data_t *bundle_data = NULL;
1922 get_bundle_variant_data(bundle_data, rsc);
1923 for (GList *item = bundle_data->replicas; item != NULL; item = item->next) {
1924 pe__bundle_replica_t *replica = item->data;
1927 replica->ip->fns->count(replica->ip);
1929 if (replica->child) {
1930 replica->child->fns->count(replica->child);
1932 if (replica->container) {
1933 replica->container->fns->count(replica->container);
1935 if (replica->remote) {
1936 replica->remote->fns->count(replica->remote);