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;
125 create_ip_resource(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
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)) {
170 create_docker_resource(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
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;
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,
257 }
else if(
safe_str_neq(data->container_network,
"host")) {
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)) {
336 create_podman_resource(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
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;
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,
425 }
else if(
safe_str_neq(data->container_network,
"host")) {
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,
505 create_rkt_resource(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
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;
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)) {
684 gpointer match = g_hash_table_lookup(rsc->
allowed_nodes, uname);
693 for (child = rsc->
children; child != NULL; child = child->next) {
694 disallow_node((
resource_t *) (child->data), uname);
700 create_remote_resource(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
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));
749 uname =
ID(xml_remote);
781 for (rsc_iter = data_set->
resources; rsc_iter; rsc_iter = rsc_iter->next) {
782 disallow_node((
resource_t *) (rsc_iter->data), uname);
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,
844 create_container(
pe_resource_t *parent, pe__bundle_variant_data_t *data,
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,
int 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;
1034 bundle_data = calloc(1,
sizeof(pe__bundle_variant_data_t));
1036 bundle_data->prefix = strdup(rsc->
id);
1039 if (xml_obj != NULL) {
1040 bundle_data->agent_type = PE__CONTAINER_AGENT_DOCKER;
1043 if (xml_obj != NULL) {
1044 bundle_data->agent_type = PE__CONTAINER_AGENT_RKT;
1047 if (xml_obj != NULL) {
1048 bundle_data->agent_type = PE__CONTAINER_AGENT_PODMAN;
1056 if (value == NULL) {
1061 if (bundle_data->promoted_max < 0) {
1062 pe_err(
"%s for %s must be nonnegative integer, using 0",
1064 bundle_data->promoted_max = 0;
1068 if ((value == NULL) && bundle_data->promoted_max) {
1069 bundle_data->nreplicas = bundle_data->promoted_max;
1073 if (bundle_data->nreplicas < 1) {
1074 pe_err(
"'replicas' for %s must be positive integer, using 1", rsc->
id);
1075 bundle_data->nreplicas = 1;
1084 bundle_data->nreplicas_per_host =
crm_parse_int(value,
"1");
1085 if (bundle_data->nreplicas_per_host < 1) {
1086 pe_err(
"'replicas-per-host' for %s must be positive integer, using 1",
1088 bundle_data->nreplicas_per_host = 1;
1090 if (bundle_data->nreplicas_per_host == 1) {
1108 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)) {
1147 if (source == NULL) {
1152 if (source && target) {
1153 mount_add(bundle_data, source, target, options, flags);
1155 pe_err(
"Invalid mount directive %s",
ID(xml_child));
1160 if (xml_obj && valid_network(bundle_data)) {
1162 xmlNode *xml_set = NULL;
1171 (bundle_data->promoted_max?
"master"
1172 : (
const char *)xml_resource->name));
1175 crm_xml_set_id(xml_set,
"%s-%s-meta", bundle_data->prefix, xml_resource->name);
1180 value = crm_itoa(bundle_data->nreplicas);
1185 value = crm_itoa(bundle_data->nreplicas_per_host);
1191 (bundle_data->nreplicas_per_host > 1)?
1194 if (bundle_data->promoted_max) {
1198 value = crm_itoa(bundle_data->promoted_max);
1207 }
else if(xml_obj) {
1208 pe_err(
"Cannot control %s inside %s without either ip-range-start or control-port",
1209 rsc->
id,
ID(xml_obj));
1217 pe__bundle_port_t *port = NULL;
1219 int offset = 0, max = 1024;
1220 char *buffer = NULL;
1222 if (
common_unpack(xml_resource, &new_rsc, rsc, data_set) == FALSE) {
1223 pe_err(
"Failed unpacking resource %s",
ID(rsc->
xml));
1224 if (new_rsc != NULL && new_rsc->
fns != NULL) {
1230 bundle_data->child = new_rsc;
1258 port = calloc(1,
sizeof(pe__bundle_port_t));
1259 if(bundle_data->control_port) {
1260 port->source = strdup(bundle_data->control_port);
1272 port->target = strdup(port->source);
1273 bundle_data->ports = g_list_append(bundle_data->ports, port);
1275 buffer = calloc(1, max+1);
1276 for (childIter = bundle_data->child->children; childIter != NULL;
1277 childIter = childIter->next) {
1279 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1281 replica->child = childIter->data;
1282 replica->child->exclusive_discover = TRUE;
1283 replica->offset = lpc++;
1290 offset += allocate_ip(bundle_data, replica, buffer+offset,
1292 bundle_data->replicas = g_list_append(bundle_data->replicas,
1294 bundle_data->attribute_target = g_hash_table_lookup(replica->child->meta,
1297 bundle_data->container_host_options = buffer;
1298 if (bundle_data->attribute_target) {
1300 strdup(bundle_data->attribute_target));
1301 g_hash_table_replace(bundle_data->child->meta,
1303 strdup(bundle_data->attribute_target));
1308 int offset = 0, max = 1024;
1309 char *buffer = calloc(1, max+1);
1311 for (
int lpc = 0; lpc < bundle_data->nreplicas; lpc++) {
1312 pe__bundle_replica_t *replica = calloc(1,
sizeof(pe__bundle_replica_t));
1314 replica->offset = lpc;
1315 offset += allocate_ip(bundle_data, replica, buffer+offset,
1317 bundle_data->replicas = g_list_append(bundle_data->replicas,
1320 bundle_data->container_host_options = buffer;
1323 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1324 gIter = gIter->next) {
1325 pe__bundle_replica_t *replica = gIter->data;
1327 if (!create_container(rsc, bundle_data, replica, data_set)) {
1328 pe_err(
"Failed unpacking resource %s", rsc->
id);
1334 if (bundle_data->child) {
1344 gboolean child_active = rsc->
fns->
active(rsc, all);
1346 if (child_active && !all) {
1348 }
else if (!child_active && all) {
1358 pe__bundle_variant_data_t *bundle_data = NULL;
1361 get_bundle_variant_data(bundle_data, rsc);
1362 for (iter = bundle_data->replicas; iter != NULL; iter = iter->next) {
1363 pe__bundle_replica_t *replica = iter->data;
1366 rsc_active = replica_resource_active(replica->ip, all);
1367 if (rsc_active >= 0) {
1368 return (gboolean) rsc_active;
1371 rsc_active = replica_resource_active(replica->child, all);
1372 if (rsc_active >= 0) {
1373 return (gboolean) rsc_active;
1376 rsc_active = replica_resource_active(replica->container, all);
1377 if (rsc_active >= 0) {
1378 return (gboolean) rsc_active;
1381 rsc_active = replica_resource_active(replica->remote, all);
1382 if (rsc_active >= 0) {
1383 return (gboolean) rsc_active;
1406 pe__bundle_variant_data_t *bundle_data = NULL;
1409 get_bundle_variant_data(bundle_data, bundle);
1410 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1411 gIter = gIter->next) {
1412 pe__bundle_replica_t *replica = gIter->data;
1415 if (replica->node->details == node->
details) {
1416 return replica->child;
1423 print_rsc_in_list(
resource_t *rsc,
const char *pre_text,
long options,
1430 rsc->
fns->
print(rsc, pre_text, options, print_data);
1431 if (options & pe_print_html) {
1438 container_agent_str(
enum pe__container_agent t)
1441 case PE__CONTAINER_AGENT_DOCKER:
return PE__CONTAINER_AGENT_DOCKER_S;
1442 case PE__CONTAINER_AGENT_RKT:
return PE__CONTAINER_AGENT_RKT_S;
1443 case PE__CONTAINER_AGENT_PODMAN:
return PE__CONTAINER_AGENT_PODMAN_S;
1447 return PE__CONTAINER_AGENT_UNKNOWN_S;
1451 bundle_print_xml(
pe_resource_t *rsc,
const char *pre_text,
long options,
1454 pe__bundle_variant_data_t *bundle_data = NULL;
1455 char *child_text = NULL;
1458 if (pre_text == NULL) {
1461 child_text = crm_concat(pre_text,
" ",
' ');
1463 get_bundle_variant_data(bundle_data, rsc);
1467 status_print(
"type=\"%s\" ", container_agent_str(bundle_data->agent_type));
1474 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1475 gIter = gIter->next) {
1476 pe__bundle_replica_t *replica = gIter->data;
1479 status_print(
"%s <replica id=\"%d\">\n", pre_text, replica->offset);
1480 print_rsc_in_list(replica->ip, child_text, options, print_data);
1481 print_rsc_in_list(replica->child, child_text, options, print_data);
1482 print_rsc_in_list(replica->container, child_text, options, print_data);
1483 print_rsc_in_list(replica->remote, child_text, options, print_data);
1491 print_bundle_replica(pe__bundle_replica_t *replica,
const char *pre_text,
1492 long options,
void *print_data)
1498 char buffer[LINE_MAX];
1504 if (replica->remote) {
1505 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1508 offset += snprintf(buffer + offset, LINE_MAX - offset,
"%s",
1511 if (replica->ipaddr) {
1512 offset += snprintf(buffer + offset, LINE_MAX - offset,
" (%s)",
1516 node = pe__current_node(replica->container);
1517 common_print(rsc, pre_text, buffer, node, options, print_data);
1524 pe__bundle_variant_data_t *bundle_data = NULL;
1525 char *child_text = NULL;
1529 bundle_print_xml(rsc, pre_text, options, print_data);
1533 get_bundle_variant_data(bundle_data, rsc);
1535 if (pre_text == NULL) {
1540 pre_text, ((bundle_data->nreplicas > 1)?
" set" :
""),
1541 rsc->
id, bundle_data->image,
1544 if (options & pe_print_html) {
1549 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1550 gIter = gIter->next) {
1551 pe__bundle_replica_t *replica = gIter->data;
1554 if (options & pe_print_html) {
1560 if(g_list_length(bundle_data->replicas) > 1) {
1561 status_print(
" %sReplica[%d]\n", pre_text, replica->offset);
1563 if (options & pe_print_html) {
1566 print_rsc_in_list(replica->ip, child_text, options, print_data);
1567 print_rsc_in_list(replica->container, child_text, options, print_data);
1568 print_rsc_in_list(replica->remote, child_text, options, print_data);
1569 print_rsc_in_list(replica->child, child_text, options, print_data);
1570 if (options & pe_print_html) {
1575 print_bundle_replica(replica, child_text, options, print_data);
1579 if (options & pe_print_html) {
1583 if (options & pe_print_html) {
1589 free_bundle_replica(pe__bundle_replica_t *replica)
1591 if (replica == NULL) {
1595 if (replica->node) {
1596 free(replica->node);
1597 replica->node = NULL;
1602 replica->ip->xml = NULL;
1603 replica->ip->fns->free(replica->ip);
1606 if (replica->container) {
1608 replica->container->xml = NULL;
1609 replica->container->fns->free(replica->container);
1610 replica->container = NULL;
1612 if (replica->remote) {
1614 replica->remote->xml = NULL;
1615 replica->remote->fns->free(replica->remote);
1616 replica->remote = NULL;
1618 free(replica->ipaddr);
1625 pe__bundle_variant_data_t *bundle_data = NULL;
1628 get_bundle_variant_data(bundle_data, rsc);
1631 free(bundle_data->prefix);
1632 free(bundle_data->image);
1633 free(bundle_data->control_port);
1634 free(bundle_data->host_network);
1635 free(bundle_data->host_netmask);
1636 free(bundle_data->ip_range_start);
1637 free(bundle_data->container_network);
1638 free(bundle_data->launcher_options);
1639 free(bundle_data->container_command);
1640 free(bundle_data->container_host_options);
1642 g_list_free_full(bundle_data->replicas,
1643 (GDestroyNotify) free_bundle_replica);
1644 g_list_free_full(bundle_data->mounts, (GDestroyNotify)mount_free);
1645 g_list_free_full(bundle_data->ports, (GDestroyNotify)port_free);
1648 if(bundle_data->child) {
1650 bundle_data->child->xml = NULL;
1651 bundle_data->child->fns->free(bundle_data->child);
1660 return container_role;
1676 pe__bundle_variant_data_t *bundle_data = NULL;
1678 get_bundle_variant_data(bundle_data, rsc);
1679 return bundle_data->nreplicas;
bool remote_id_conflict(const char *remote_name, pe_working_set_t *data)
#define CRM_CHECK(expr, failure_action)
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.
gboolean safe_str_neq(const char *a, const char *b)
node_t * node_copy(const node_t *this_node)
pe_resource_t * container
node_t * pe_create_node(const char *id, const char *uname, const char *type, const char *score, pe_working_set_t *data_set)
void pe__free_bundle(pe_resource_t *rsc)
#define XML_BOOLEAN_FALSE
enum rsc_role_e pe__bundle_resource_state(const pe_resource_t *rsc, gboolean current)
xmlNode * first_named_child(const xmlNode *parent, const char *name)
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)
gboolean common_unpack(xmlNode *xml_obj, resource_t **rsc, resource_t *parent, pe_working_set_t *data_set)
void common_free(resource_t *rsc)
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.
#define status_print(fmt, args...)
gboolean pe__is_guest_or_remote_node(pe_node_t *node)
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
#define CRM_LOG_ASSERT(expr)
pe_node_t * pe_find_node(GListPtr node_list, const char *uname)
#define clear_bit(word, bit)
void pe__print_bundle(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
#define pe_rsc_allow_remote_remotes
#define XML_RSC_ATTR_INCARNATION_MAX
bool pe__bundle_needs_remote_name(pe_resource_t *rsc)
#define XML_RSC_ATTR_TARGET
#define XML_RSC_ATTR_REMOTE_RA_ADDR
gboolean pe__unpack_bundle(pe_resource_t *rsc, pe_working_set_t *data_set)
void crm_xml_sanitize_id(char *id)
Sanitize a string so it is usable as an XML ID.
#define DEFAULT_REMOTE_PORT
#define DEFAULT_REMOTE_KEY_LOCATION
#define XML_TAG_ATTR_SETS
#define XML_RSC_ATTR_PROMOTABLE
pe_resource_t * pe__find_bundle_replica(const pe_resource_t *bundle, const pe_node_t *node)
#define set_bit(word, bit)
#define PCMK_RESOURCE_CLASS_OCF
char * crm_element_value_copy(const xmlNode *data, const char *name)
Retrieve a copy of the value of an XML attribute.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
const char * pe__add_bundle_remote_name(pe_resource_t *rsc, xmlNode *xml, const char *field)
#define crm_trace(fmt, args...)
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
struct pe_node_shared_s * details
#define XML_AGENT_ATTR_PROVIDER
#define XML_RSC_ATTR_ORDERED
#define XML_TAG_META_SETS
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define XML_RSC_ATTR_INCARNATION_NODEMAX
gboolean check_boolean(const char *value)
void free_xml(xmlNode *child)
enum pe_obj_types variant
void(* print)(pe_resource_t *, const char *, long, void *)
#define XML_RSC_ATTR_UNIQUE
void common_print(resource_t *rsc, const char *pre_text, const char *name, node_t *node, long options, void *print_data)
int crm_str_to_boolean(const char *s, int *ret)
#define XML_RSC_ATTR_PROMOTED_MAX
Cluster status and scheduling.
#define XML_CIB_TAG_INCARNATION
void add_hash_param(GHashTable *hash, const char *name, const char *value)
const char * rsc_printable_id(pe_resource_t *rsc)
void crm_xml_set_id(xmlNode *xml, const char *format,...) __attribute__((__format__(__printf__
void(* free)(pe_resource_t *)
#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.
gboolean(* active)(pe_resource_t *, gboolean)
#define safe_str_eq(a, b)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
int pe_bundle_replicas(const pe_resource_t *rsc)
Get the number of configured replicas in a bundle.
gboolean pe__bundle_active(pe_resource_t *rsc, gboolean all)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes