This source file includes following definitions.
- pcmk__node_attr_target
- pcmk_promotion_score_name
1
2
3
4
5
6
7
8
9
10 #ifndef _GNU_SOURCE
11 # define _GNU_SOURCE
12 #endif
13
14 #include <crm_internal.h>
15
16 #include <stdio.h>
17
18 #include <crm/msg_xml.h>
19 #include <crm/common/attrd_internal.h>
20
21 #define LRM_TARGET_ENV "OCF_RESKEY_" CRM_META "_" XML_LRM_ATTR_TARGET
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 const char *
39 pcmk__node_attr_target(const char *name)
40 {
41 if (name == NULL || pcmk__strcase_any_of(name, "auto", "localhost", NULL)) {
42 char *target_var = crm_meta_name(XML_RSC_ATTR_TARGET);
43 char *phys_var = crm_meta_name(PCMK__ENV_PHYSICAL_HOST);
44 const char *target = getenv(target_var);
45 const char *host_physical = getenv(phys_var);
46
47
48 if (host_physical && pcmk__str_eq(target, "host", pcmk__str_casei)) {
49 name = host_physical;
50
51 } else {
52 const char *host_pcmk = getenv(LRM_TARGET_ENV);
53
54 if (host_pcmk) {
55 name = host_pcmk;
56 }
57 }
58 free(target_var);
59 free(phys_var);
60
61
62
63 return name;
64 } else {
65 return NULL;
66 }
67 }
68
69
70
71
72
73
74
75
76
77
78
79 char *
80 pcmk_promotion_score_name(const char *rsc_id)
81 {
82 if (rsc_id == NULL) {
83 rsc_id = getenv("OCF_RESOURCE_INSTANCE");
84 if (rsc_id == NULL) {
85 return NULL;
86 }
87 }
88 return crm_strdup_printf("master-%s", rsc_id);
89 }