pacemaker  1.1.17-b36b869ca8
Scalable High-Availability cluster resource manager
remote.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #include <crm_internal.h>
19 #include <crm/msg_xml.h>
20 #include <crm/common/xml.h>
21 #include <crm/pengine/internal.h>
22 #include <glib.h>
23 
24 gboolean
26 {
27  node_t *node;
28 
29  if (rsc == NULL) {
30  return FALSE;
31  } else if (rsc->is_remote_node == FALSE) {
32  return FALSE;
33  }
34 
35  node = pe_find_node(data_set->nodes, rsc->id);
36  if (node == NULL) {
37  return FALSE;
38  }
39 
40  return is_baremetal_remote_node(node);
41 }
42 
43 gboolean
45 {
46  if (is_remote_node(node) && (node->details->remote_rsc == NULL || node->details->remote_rsc->container == FALSE)) {
47  return TRUE;
48  }
49  return FALSE;
50 }
51 
52 gboolean
54 {
55  if (is_remote_node(node) && (node->details->remote_rsc && node->details->remote_rsc->container)) {
56  return TRUE;
57  }
58  return FALSE;
59 }
60 
61 gboolean
63 {
64  if (node && node->details->type == node_remote) {
65  return TRUE;
66  }
67  return FALSE;
68 }
69 
70 resource_t *
72 {
73  if (is_set(data_set->flags, pe_flag_have_remote_nodes) == FALSE) {
74  return NULL;
75  }
76 
77  if (rsc->fillers) {
78  GListPtr gIter = NULL;
79  for (gIter = rsc->fillers; gIter != NULL; gIter = gIter->next) {
80  resource_t *filler = (resource_t *) gIter->data;
81 
82  if (filler->is_remote_node) {
83  return filler;
84  }
85  }
86  }
87  return NULL;
88 }
89 
90 gboolean
92 {
93  const char *class = crm_element_value(xml, XML_AGENT_ATTR_CLASS);
94  const char *provider = crm_element_value(xml, XML_AGENT_ATTR_PROVIDER);
95  const char *agent = crm_element_value(xml, XML_ATTR_TYPE);
96 
97  if (safe_str_eq(agent, "remote") && safe_str_eq(provider, "pacemaker")
99  return TRUE;
100  }
101  return FALSE;
102 }
103 
113 void
115  void (*helper)(const node_t*, void*), void *user_data)
116 {
117  GListPtr iter;
118 
119  CRM_CHECK(data_set && host && host->details && helper, return);
120  if (!is_set(data_set->flags, pe_flag_have_remote_nodes)) {
121  return;
122  }
123  for (iter = host->details->running_rsc; iter != NULL; iter = iter->next) {
124  resource_t *rsc = (resource_t *) iter->data;
125 
126  if (rsc->is_remote_node && (rsc->container != NULL)) {
127  node_t *guest_node = pe_find_node(data_set->nodes, rsc->id);
128 
129  if (guest_node) {
130  (*helper)(guest_node, user_data);
131  }
132  }
133  }
134 }
#define CRM_CHECK(expr, failure_action)
Definition: logging.h:164
GListPtr nodes
Definition: status.h:102
gboolean is_container_remote_node(node_t *node)
Definition: remote.c:53
#define XML_ATTR_TYPE
Definition: msg_xml.h:104
#define pe_flag_have_remote_nodes
Definition: status.h:77
void pe_foreach_guest_node(const pe_working_set_t *data_set, const node_t *host, void(*helper)(const node_t *, void *), void *user_data)
Definition: remote.c:114
GListPtr running_rsc
Definition: status.h:148
node_t * pe_find_node(GListPtr node_list, const char *uname)
Definition: status.c:298
AIS_Host host
Definition: internal.h:52
resource_t * remote_rsc
Definition: status.h:151
gboolean is_remote_node
Definition: status.h:274
char * id
Definition: status.h:252
resource_t * rsc_contains_remote_node(pe_working_set_t *data_set, resource_t *rsc)
Definition: remote.c:71
struct node_shared_s * details
Definition: status.h:173
#define PCMK_RESOURCE_CLASS_OCF
Definition: services.h:56
resource_t * container
Definition: status.h:302
#define XML_AGENT_ATTR_PROVIDER
Definition: msg_xml.h:244
Wrappers for and extensions to libxml2.
const char * crm_element_value(xmlNode *data, const char *name)
Definition: xml.c:5134
gboolean is_remote_node(node_t *node)
Definition: remote.c:62
GListPtr fillers
Definition: status.h:303
gboolean is_baremetal_remote_node(node_t *node)
Definition: remote.c:44
enum node_type type
Definition: status.h:154
Definition: status.h:169
gboolean xml_contains_remote_node(xmlNode *xml)
Definition: remote.c:91
unsigned long long flags
Definition: status.h:92
#define safe_str_eq(a, b)
Definition: util.h:64
GList * GListPtr
Definition: crm.h:202
gboolean is_rsc_baremetal_remote_node(resource_t *rsc, pe_working_set_t *data_set)
Definition: remote.c:25