~ampelbein/ubuntu/oneiric/heartbeat/lp-770743

« back to all changes in this revision

Viewing changes to cim/hosted_resource_provider.c

  • Committer: Bazaar Package Importer
  • Author(s): Ante Karamatic
  • Date: 2009-08-10 19:29:25 UTC
  • mfrom: (5.2.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20090810192925-9zy2llcbgavbskf7
Tags: 2.99.2+sles11r9-5ubuntu1
* New upstream snapshot
* Adjusted heartbeat.install and rules for documentation path

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * hosted_resource_provider.c: HA_HostedResource provider
3
 
 * 
4
 
 * Author: Jia Ming Pan <jmltc@cn.ibm.com>
5
 
 * Copyright (c) 2005 International Business Machines
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or modify
8
 
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; either version 2 of the License, or
10
 
 * (at your option) any later version.
11
 
 *
12
 
 * This program is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU General Public License
18
 
 * along with this program; if not, write to the Free Software
19
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
 
 *
21
 
 */
22
 
 
23
 
#include <lha_internal.h>
24
 
#include <stdlib.h>
25
 
#include <stdio.h>
26
 
#include <string.h>
27
 
#include <sys/stat.h>
28
 
#include <sys/types.h>
29
 
#include <cmpidt.h>
30
 
#include <cmpift.h>
31
 
#include <cmpimacs.h>
32
 
#include "cluster_info.h"
33
 
#include "cmpi_utils.h"
34
 
 
35
 
static const char *     PROVIDER_ID    = "cim-hosted-res";
36
 
static CMPIBroker *     Broker       = NULL;
37
 
static char             ClassName         [] = "HA_HostedResource"; 
38
 
static char             Left              [] = "Antecedent";
39
 
static char             Right             [] = "Dependent"; 
40
 
static char             LeftClassName     [] = "HA_ClusterNode"; 
41
 
static char             RightClassName    [] = "HA_PrimitiveResource";
42
 
 
43
 
static int              node_host_res(CMPIBroker * broker, char * classname, 
44
 
                                CMPIContext * ctx, CMPIObjectPath * node_op, 
45
 
                                CMPIObjectPath * res_op, CMPIStatus * rc);
46
 
 
47
 
DeclareInstanceFunctions   (HostedResource);
48
 
DeclareAssociationFunctions(HostedResource);
49
 
 
50
 
 
51
 
/* here resource can be primitive, group, clone and master */
52
 
static int
53
 
node_host_res(CMPIBroker * broker, char * classname, CMPIContext * ctx,
54
 
              CMPIObjectPath * node_op, CMPIObjectPath * res_op, 
55
 
              CMPIStatus * rc)
56
 
{
57
 
        char *          rsc_id;
58
 
        char *          uname;
59
 
        int             host = FALSE;
60
 
        const char *    running_node;
61
 
        struct ha_msg * msg;
62
 
 
63
 
        rsc_id = CMGetKeyString(res_op, "Id", rc); 
64
 
        uname  = CMGetKeyString(node_op, "Name", rc);
65
 
 
66
 
        /* get running node */
67
 
        if ((msg = cim_query_dispatch(GET_RSC_HOST, rsc_id, NULL)) == NULL ) {
68
 
                cl_log(LOG_WARNING, "running node of %s is NULL", rsc_id);
69
 
                return FALSE;
70
 
        }
71
 
        
72
 
        running_node = cl_get_string(msg, "host");
73
 
        /* campare running node with uname */
74
 
        if ( strncmp(running_node, uname, MAXLEN) == 0 ) {
75
 
                host = TRUE; 
76
 
        }
77
 
 
78
 
        ha_msg_del(msg);
79
 
        return host;
80
 
}
81
 
 
82
 
 
83
 
/**********************************************
84
 
 * Instance Provider Interface
85
 
 **********************************************/
86
 
 
87
 
static CMPIStatus 
88
 
HostedResourceCleanup(CMPIInstanceMI * mi, CMPIContext * ctx)
89
 
{
90
 
        CMReturn(CMPI_RC_OK);
91
 
}
92
 
 
93
 
static CMPIStatus 
94
 
HostedResourceEnumInstanceNames(CMPIInstanceMI * mi, CMPIContext* ctx, 
95
 
                                CMPIResult * rslt, CMPIObjectPath * cop)
96
 
{
97
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
98
 
        if (assoc_enum_insts(Broker, ClassName, ctx, rslt, cop, 
99
 
                                Left, Right, LeftClassName, RightClassName, 
100
 
                                node_host_res, NULL, 0, &rc) != HA_OK ) {
101
 
                return rc;
102
 
        }
103
 
 
104
 
        CMReturn(CMPI_RC_OK);
105
 
}
106
 
 
107
 
 
108
 
static CMPIStatus 
109
 
HostedResourceEnumInstances(CMPIInstanceMI * mi, CMPIContext * ctx, 
110
 
                            CMPIResult * rslt, CMPIObjectPath * cop, 
111
 
                            char ** properties)
112
 
{
113
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
114
 
        if (assoc_enum_insts(Broker, ClassName, ctx, rslt, cop, 
115
 
                                Left, Right, LeftClassName, RightClassName, 
116
 
                                node_host_res, NULL, 1, &rc) != HA_OK ) {
117
 
                return rc;
118
 
        }
119
 
        CMReturn(CMPI_RC_OK);
120
 
 
121
 
}
122
 
 
123
 
 
124
 
static CMPIStatus 
125
 
HostedResourceGetInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 
126
 
                          CMPIResult * rslt, CMPIObjectPath * cop, 
127
 
                          char ** properties)
128
 
{
129
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
130
 
        if (assoc_get_inst(Broker, ClassName, ctx, rslt, cop, 
131
 
                              Left, Right, &rc) != HA_OK ) {
132
 
                return rc;
133
 
        }
134
 
        CMReturn(CMPI_RC_OK);
135
 
}
136
 
 
137
 
static CMPIStatus 
138
 
HostedResourceCreateInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 
139
 
                             CMPIResult * rslt, CMPIObjectPath * cop, 
140
 
                             CMPIInstance * ci)
141
 
{
142
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
143
 
        CMSetStatusWithChars(Broker, &rc, 
144
 
                        CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
145
 
        return rc;
146
 
}
147
 
 
148
 
 
149
 
static CMPIStatus 
150
 
HostedResourceSetInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 
151
 
                          CMPIResult * rslt, CMPIObjectPath * cop, 
152
 
                          CMPIInstance * ci, char ** properties)
153
 
{
154
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
155
 
        CMSetStatusWithChars(Broker, &rc, 
156
 
                        CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
157
 
        return rc;
158
 
 
159
 
}
160
 
 
161
 
 
162
 
static CMPIStatus 
163
 
HostedResourceDeleteInstance(CMPIInstanceMI * mi, CMPIContext * ctx, 
164
 
                             CMPIResult * rslt, CMPIObjectPath * cop)
165
 
{
166
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
167
 
        CMSetStatusWithChars(Broker, &rc, 
168
 
                        CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
169
 
        return rc;
170
 
}
171
 
 
172
 
static CMPIStatus 
173
 
HostedResourceExecQuery(CMPIInstanceMI * mi, CMPIContext * ctx, 
174
 
                        CMPIResult * rslt, CMPIObjectPath *ref,
175
 
                        char * lang, char * query)
176
 
{
177
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
178
 
        CMSetStatusWithChars(Broker, &rc, 
179
 
                        CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
180
 
        return rc;
181
 
}
182
 
 
183
 
 
184
 
/****************************************************
185
 
 * Association
186
 
 ****************************************************/
187
 
static CMPIStatus 
188
 
HostedResourceAssociationCleanup(CMPIAssociationMI * mi, 
189
 
                                  CMPIContext * ctx)
190
 
{
191
 
        CMReturn(CMPI_RC_OK);
192
 
}
193
 
 
194
 
static CMPIStatus
195
 
HostedResourceAssociators(CMPIAssociationMI * mi, CMPIContext * ctx, 
196
 
                          CMPIResult * rslt, CMPIObjectPath * cop, 
197
 
                          const char * assoc_class,  const char * result_class,
198
 
                          const char * role, const char * result_role, 
199
 
                          char ** properties)
200
 
{
201
 
 
202
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
203
 
        PROVIDER_INIT_LOGGER();
204
 
        if (assoc_enum_associators(Broker, ClassName, ctx, rslt, cop, 
205
 
                                Left, Right, LeftClassName, RightClassName,
206
 
                                assoc_class, result_class, role, 
207
 
                                result_role, node_host_res, NULL, 1, 
208
 
                                &rc) != HA_OK ) {
209
 
                return rc;
210
 
        }
211
 
        CMReturn(CMPI_RC_OK);
212
 
}
213
 
 
214
 
 
215
 
static CMPIStatus
216
 
HostedResourceAssociatorNames(CMPIAssociationMI * mi, CMPIContext * ctx, 
217
 
                              CMPIResult * rslt, CMPIObjectPath * cop, 
218
 
                              const char * assoc_class, const char * result_class,
219
 
                              const char * role, const char * result_role)
220
 
{
221
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
222
 
        PROVIDER_INIT_LOGGER();
223
 
        if (assoc_enum_associators(Broker, ClassName, ctx, rslt, cop, 
224
 
                                Left, Right, LeftClassName, RightClassName,
225
 
                                assoc_class, result_class, role, 
226
 
                                result_role, node_host_res, NULL, 0, 
227
 
                                &rc) != HA_OK ) {
228
 
                return rc;
229
 
        }
230
 
        CMReturn(CMPI_RC_OK);
231
 
}
232
 
 
233
 
static CMPIStatus
234
 
HostedResourceReferences(CMPIAssociationMI * mi, CMPIContext * ctx, 
235
 
                         CMPIResult * rslt, CMPIObjectPath * cop, 
236
 
                         const char * result_class, const char * role, 
237
 
                         char ** properties)
238
 
{
239
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
240
 
        PROVIDER_INIT_LOGGER();
241
 
        if ( assoc_enum_references(Broker, ClassName, ctx, rslt, cop, 
242
 
                                Left, Right, LeftClassName, RightClassName,
243
 
                                result_class, role, node_host_res, NULL, 1, 
244
 
                                &rc) != HA_OK ) {
245
 
                return rc;
246
 
        }
247
 
 
248
 
        CMReturn(CMPI_RC_OK);
249
 
}
250
 
 
251
 
static CMPIStatus
252
 
HostedResourceReferenceNames(CMPIAssociationMI * mi, CMPIContext * ctx, 
253
 
                             CMPIResult * rslt, CMPIObjectPath * cop,
254
 
                             const char * result_class, const char * role)
255
 
{
256
 
        CMPIStatus rc = {CMPI_RC_OK, NULL};
257
 
        PROVIDER_INIT_LOGGER();
258
 
        if ( assoc_enum_references(Broker, ClassName, ctx, rslt, cop, 
259
 
                                Left, Right, LeftClassName, RightClassName,
260
 
                                result_class, role, node_host_res, NULL, 0, 
261
 
                                &rc) != HA_OK ) {
262
 
                return rc;
263
 
        }
264
 
 
265
 
        CMReturn(CMPI_RC_OK);
266
 
 
267
 
}                
268
 
 
269
 
 
270
 
/***********************************************
271
 
 * Install MIs
272
 
 **********************************************/
273
 
DeclareInstanceMI(HostedResource, HA_HostedResourceProvider, Broker);
274
 
DeclareAssociationMI(HostedResource, HA_HostedResourceProvider, Broker);