~ubuntu-branches/ubuntu/precise/opendrim-lmp-ssh/precise

« back to all changes in this revision

Viewing changes to OpenDRIM_SSHServiceAccessBySAP/assocOpenDRIM_SSHServiceAccessBySAP.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Guillaume BOTTEX
  • Date: 2010-07-07 11:04:10 UTC
  • Revision ID: james.westby@ubuntu.com-20100707110410-2bojrtqjp582wiy8
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*###############################################################################
 
2
# Linux Management Providers (LMP), SSH provider package
 
3
# Copyright (C) 2010 Feng Zhanlei, REDFLAG <fengzhanlei@redflag-linux.com>
 
4
 
5
# This program is being developed under the "OpenDRIM" project.
 
6
# The "OpenDRIM" project web page: http://opendrim.sourceforge.net
 
7
# The "OpenDRIM" project mailing list: opendrim@googlegroups.com
 
8
 
9
# This program is free software; you can redistribute it and/or
 
10
# modify it under the terms of the GNU General Public License
 
11
# as published by the Free Software Foundation; version 2
 
12
# of the License.
 
13
 
14
# This program is distributed in the hope that it will be useful,
 
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
# GNU General Public License for more details.
 
18
 
19
# You should have received a copy of the GNU General Public License
 
20
# along with this program; if not, write to the Free Software
 
21
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
22
#################################################################################
 
23
 
 
24
#################################################################################
 
25
# To contributors, please leave your contact information in this section
 
26
# AND comment your changes in the source code.
 
27
 
28
# Modified by Guillaume BOTTEX <guillaumebottex@uxsystem.net>, UXSystem, 2010
 
29
###############################################################################*/
 
30
 
 
31
#include "assocOpenDRIM_SSHServiceAccessBySAP.h"
 
32
 
 
33
int SSH_OpenDRIM_SSHServiceAccessBySAP_associatorFilter(const CMPIBroker* broker, const CMPIContext* ctx, const CMPIObjectPath* cop, Instance& knownInstance, const char* assocClass, const char* resultClass, const char* role, const char* resultRole, bool& leftToRight, string& errorMessage) {
 
34
        _E_;
 
35
        string _assocClass, _resultClass, _resultRole, _role;
 
36
        assocClass == NULL ? _assocClass = "null" : _assocClass = assocClass;
 
37
        resultClass == NULL ? _resultClass = "null" : _resultClass = resultClass;
 
38
        resultRole == NULL ?  _resultRole = "null" :  _resultRole = resultRole;
 
39
        role == NULL ?  _role = "null" :  _role = role;
 
40
        
 
41
        for (unsigned int i=0; i<sizeof(OpenDRIM_SSHServiceAccessBySAP_classnames)/sizeof(char*); i++) {
 
42
                if (CF_strCmpNoCase(_assocClass, OpenDRIM_SSHServiceAccessBySAP_classnames[i])) {
 
43
                        _assocClass=OpenDRIM_SSHServiceAccessBySAP_classnames[0];
 
44
                        break;
 
45
                }
 
46
        }
 
47
        if (!CF_strCmpNoCase(_assocClass, "null") && !CF_strCmpNoCase(_assocClass, OpenDRIM_SSHServiceAccessBySAP_classnames[0]))
 
48
                return OK;
 
49
        
 
50
        Objectpath known(broker, (CMPIObjectPath*) cop);
 
51
        int errorCode = CA_associatorResolveDirection(broker, Antecedent_classnames, Dependent_classnames, Antecedent_NAMESPACE, Dependent_NAMESPACE, Antecedent_role, Dependent_role, known, _resultClass, _role, _resultRole, leftToRight);
 
52
        if (errorCode != OK)
 
53
                return -1;
 
54
        
 
55
        if (leftToRight) {
 
56
                CF_assert(SSH_OpenDRIM_SSHServiceAccessBySAP_getAntecedent(broker, ctx, known, knownInstance, NULL, errorMessage));
 
57
        } else {
 
58
                CF_assert(SSH_OpenDRIM_SSHServiceAccessBySAP_getDependent(broker, ctx, known, knownInstance, NULL, errorMessage));
 
59
        }
 
60
        _L_;
 
61
        return OK;
 
62
}
 
63
 
 
64
int SSH_OpenDRIM_SSHServiceAccessBySAP_associator(const CMPIBroker* broker, const CMPIContext* ctx, const CMPIObjectPath* cop, Instance& knownInstance, const char* assocClass, const char* resultClass, const char* role, const char* resultRole, const char** properties, vector<Instance>& associatedInstances, bool& leftToRight, string& errorMessage, const string& dicriminant) {
 
65
        _E_;
 
66
        int errorCode = SSH_OpenDRIM_SSHServiceAccessBySAP_associatorFilter(broker, ctx, cop, knownInstance, assocClass, resultClass, role, resultRole, leftToRight, errorMessage);
 
67
        if (errorCode == -1)
 
68
                return OK;
 
69
        if (errorCode != OK)
 
70
                return errorCode;
 
71
        
 
72
        if (leftToRight) {
 
73
                if (role != NULL && strcasecmp(role, "Antecedent") != 0) return OK;
 
74
                if (resultRole != NULL && strcasecmp(resultRole, "Dependent") != 0) return OK;
 
75
                CF_assert(SSH_OpenDRIM_SSHServiceAccessBySAP_associatorAntecedentToDependent(broker, ctx, knownInstance, properties, associatedInstances, errorMessage, dicriminant));
 
76
        } else {
 
77
                if (role != NULL && strcasecmp(role, "Dependent") != 0) return OK;
 
78
                if (resultRole != NULL && strcasecmp(resultRole, "Antecedent") != 0) return OK;
 
79
                CF_assert(SSH_OpenDRIM_SSHServiceAccessBySAP_associatorDependentToAntecedent(broker, ctx, knownInstance, properties, associatedInstances, errorMessage, dicriminant));
 
80
        }
 
81
        _L_;
 
82
        return OK;
 
83
}
 
84
 
 
85
int SSH_OpenDRIM_SSHServiceAccessBySAP_enumerateAntecedents(const CMPIBroker* broker, const CMPIContext* ctx, vector<Instance>& instances, const char** properties, bool onlyNames, string& errorMessage) {
 
86
        _E_;
 
87
        /*
 
88
         * CMPI broker version
 
89
         */
 
90
        if (onlyNames) {
 
91
                vector<Objectpath> objectpaths;
 
92
                CF_assert(CB_enumerateInstanceNames(broker, ctx, Antecedent_NAMESPACE, Antecedent_classnames[0], objectpaths, errorMessage));
 
93
                for (size_t i=0; i<objectpaths.size(); i++)
 
94
                        instances.push_back(Instance(broker, objectpaths[i]));
 
95
        } else {
 
96
                CF_assert(CB_enumerateInstances(broker,ctx, Antecedent_NAMESPACE, Antecedent_classnames[0], properties, instances, errorMessage));
 
97
        }
 
98
        /*
 
99
         * Direct Invocation version
 
100
         */
 
101
        /*
 
102
        vector<CIM_Service> _instances;
 
103
        if (onlyNames) {
 
104
                CF_assert(SSH_CIM_Service_retrieve(broker, ctx, _instances, properties, errorMessage, "ein"));
 
105
        } else {
 
106
                CF_assert(SSH_CIM_Service_retrieve(broker, ctx, _instances, properties, errorMessage, "ei"));
 
107
        }
 
108
 
 
109
        for (size_t i=0; i<_instances.size(); i++)
 
110
                instances.push_back(Instance(broker, SSH_CIM_Service_toCMPIInstance(broker, _instances[i])));
 
111
        */
 
112
        _L_;
 
113
        return OK;
 
114
}
 
115
 
 
116
int SSH_OpenDRIM_SSHServiceAccessBySAP_getAntecedent(const CMPIBroker* broker, const CMPIContext* ctx, const Objectpath& objectpath, Instance& instance, const char** properties, string& errorMessage) {
 
117
        _E_;
 
118
        if (!CF_strCmpNoCase(objectpath.getClassname(), Antecedent_classnames[0]))
 
119
                return INVALID_CLASS;
 
120
        //if (!CF_strCmpNoCase(objectpath.getNamespace(), Antecedent_NAMESPACE))
 
121
        //      return INVALID_NAMESPACE;
 
122
        /*
 
123
         * CMPI broker version
 
124
         */
 
125
        CF_assert(CB_getInstance(broker, ctx, objectpath, properties, instance, errorMessage));
 
126
        
 
127
        /*
 
128
         * Direct Invocation version
 
129
         */
 
130
        /*
 
131
        CIM_Service _instance;
 
132
        SSH_CIM_Service_toCPP(broker, objectpath.getHdl(), _instance);
 
133
        CF_assert(SSH_CIM_Service_getInstance(broker, ctx, _instance, properties, errorMessage));
 
134
        instance = Instance(broker, SSH_CIM_Service_toCMPIInstance(broker, _instance));
 
135
        */
 
136
        _L_;
 
137
        return OK;
 
138
}
 
139
 
 
140
int SSH_OpenDRIM_SSHServiceAccessBySAP_enumerateDependents(const CMPIBroker* broker, const CMPIContext* ctx, vector<Instance>& instances, const char** properties, bool onlyNames, string& errorMessage) {
 
141
        _E_;
 
142
        /*
 
143
         * CMPI broker version
 
144
         */
 
145
        if (onlyNames) {
 
146
                vector<Objectpath> objectpaths;
 
147
                CF_assert(CB_enumerateInstanceNames(broker, ctx, Dependent_NAMESPACE, Dependent_classnames[0], objectpaths, errorMessage));
 
148
                for (size_t i=0; i<objectpaths.size(); i++)
 
149
                        instances.push_back(Instance(broker, objectpaths[i]));
 
150
        } else {
 
151
                CF_assert(CB_enumerateInstances(broker,ctx, Dependent_NAMESPACE, Dependent_classnames[0], properties, instances, errorMessage));
 
152
        }
 
153
        /*
 
154
         * Direct Invocation version
 
155
         */
 
156
        /*
 
157
        vector<CIM_ServiceAccessPoint> _instances;
 
158
        if (onlyNames) {
 
159
                CF_assert(SSH_CIM_ServiceAccessPoint_retrieve(broker, ctx, _instances, properties, errorMessage, "ein"));
 
160
        } else {
 
161
                CF_assert(SSH_CIM_ServiceAccessPoint_retrieve(broker, ctx, _instances, properties, errorMessage, "ei"));
 
162
        }
 
163
 
 
164
        for (size_t i=0; i<_instances.size(); i++)
 
165
                instances.push_back(Instance(broker, SSH_CIM_ServiceAccessPoint_toCMPIInstance(broker, _instances[i])));
 
166
        */
 
167
        _L_;
 
168
        return OK;
 
169
}
 
170
 
 
171
int SSH_OpenDRIM_SSHServiceAccessBySAP_getDependent(const CMPIBroker* broker, const CMPIContext* ctx, const Objectpath& objectpath, Instance& instance, const char** properties, string& errorMessage) {
 
172
        _E_;
 
173
        if (!CF_strCmpNoCase(objectpath.getClassname(), Dependent_classnames[0]))
 
174
                return INVALID_CLASS;
 
175
        //if (!CF_strCmpNoCase(objectpath.getNamespace(), Dependent_NAMESPACE))
 
176
        //      return INVALID_NAMESPACE;
 
177
        /*
 
178
         * CMPI broker version
 
179
         */
 
180
        CF_assert(CB_getInstance(broker, ctx, objectpath, properties, instance, errorMessage));
 
181
 
 
182
        /*
 
183
         * Direct Invocation version
 
184
         */
 
185
        /*
 
186
        CIM_ServiceAccessPoint _instance;
 
187
        SSH_CIM_ServiceAccessPoint_toCPP(broker, objectpath.getHdl(), _instance);
 
188
        CF_assert(SSH_CIM_ServiceAccessPoint_getInstance(broker, ctx, _instance, properties, errorMessage));
 
189
        instance = Instance(broker, SSH_CIM_ServiceAccessPoint_toCMPIInstance(broker, _instance));
 
190
        */
 
191
        _L_;
 
192
        return OK;
 
193
}