2
* hosted_resource_provider.c: HA_HostedResource provider
4
* Author: Jia Ming Pan <jmltc@cn.ibm.com>
5
* Copyright (c) 2005 International Business Machines
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.
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.
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.
23
#include <lha_internal.h>
28
#include <sys/types.h>
32
#include "cluster_info.h"
33
#include "cmpi_utils.h"
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";
43
static int node_host_res(CMPIBroker * broker, char * classname,
44
CMPIContext * ctx, CMPIObjectPath * node_op,
45
CMPIObjectPath * res_op, CMPIStatus * rc);
47
DeclareInstanceFunctions (HostedResource);
48
DeclareAssociationFunctions(HostedResource);
51
/* here resource can be primitive, group, clone and master */
53
node_host_res(CMPIBroker * broker, char * classname, CMPIContext * ctx,
54
CMPIObjectPath * node_op, CMPIObjectPath * res_op,
60
const char * running_node;
63
rsc_id = CMGetKeyString(res_op, "Id", rc);
64
uname = CMGetKeyString(node_op, "Name", rc);
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);
72
running_node = cl_get_string(msg, "host");
73
/* campare running node with uname */
74
if ( strncmp(running_node, uname, MAXLEN) == 0 ) {
83
/**********************************************
84
* Instance Provider Interface
85
**********************************************/
88
HostedResourceCleanup(CMPIInstanceMI * mi, CMPIContext * ctx)
94
HostedResourceEnumInstanceNames(CMPIInstanceMI * mi, CMPIContext* ctx,
95
CMPIResult * rslt, CMPIObjectPath * cop)
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 ) {
104
CMReturn(CMPI_RC_OK);
109
HostedResourceEnumInstances(CMPIInstanceMI * mi, CMPIContext * ctx,
110
CMPIResult * rslt, CMPIObjectPath * cop,
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 ) {
119
CMReturn(CMPI_RC_OK);
125
HostedResourceGetInstance(CMPIInstanceMI * mi, CMPIContext * ctx,
126
CMPIResult * rslt, CMPIObjectPath * cop,
129
CMPIStatus rc = {CMPI_RC_OK, NULL};
130
if (assoc_get_inst(Broker, ClassName, ctx, rslt, cop,
131
Left, Right, &rc) != HA_OK ) {
134
CMReturn(CMPI_RC_OK);
138
HostedResourceCreateInstance(CMPIInstanceMI * mi, CMPIContext * ctx,
139
CMPIResult * rslt, CMPIObjectPath * cop,
142
CMPIStatus rc = {CMPI_RC_OK, NULL};
143
CMSetStatusWithChars(Broker, &rc,
144
CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
150
HostedResourceSetInstance(CMPIInstanceMI * mi, CMPIContext * ctx,
151
CMPIResult * rslt, CMPIObjectPath * cop,
152
CMPIInstance * ci, char ** properties)
154
CMPIStatus rc = {CMPI_RC_OK, NULL};
155
CMSetStatusWithChars(Broker, &rc,
156
CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
163
HostedResourceDeleteInstance(CMPIInstanceMI * mi, CMPIContext * ctx,
164
CMPIResult * rslt, CMPIObjectPath * cop)
166
CMPIStatus rc = {CMPI_RC_OK, NULL};
167
CMSetStatusWithChars(Broker, &rc,
168
CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
173
HostedResourceExecQuery(CMPIInstanceMI * mi, CMPIContext * ctx,
174
CMPIResult * rslt, CMPIObjectPath *ref,
175
char * lang, char * query)
177
CMPIStatus rc = {CMPI_RC_OK, NULL};
178
CMSetStatusWithChars(Broker, &rc,
179
CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
184
/****************************************************
186
****************************************************/
188
HostedResourceAssociationCleanup(CMPIAssociationMI * mi,
191
CMReturn(CMPI_RC_OK);
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,
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,
211
CMReturn(CMPI_RC_OK);
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)
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,
230
CMReturn(CMPI_RC_OK);
234
HostedResourceReferences(CMPIAssociationMI * mi, CMPIContext * ctx,
235
CMPIResult * rslt, CMPIObjectPath * cop,
236
const char * result_class, const char * role,
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,
248
CMReturn(CMPI_RC_OK);
252
HostedResourceReferenceNames(CMPIAssociationMI * mi, CMPIContext * ctx,
253
CMPIResult * rslt, CMPIObjectPath * cop,
254
const char * result_class, const char * role)
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,
265
CMReturn(CMPI_RC_OK);
270
/***********************************************
272
**********************************************/
273
DeclareInstanceMI(HostedResource, HA_HostedResourceProvider, Broker);
274
DeclareAssociationMI(HostedResource, HA_HostedResourceProvider, Broker);