1 karl 1.7 //%2006////////////////////////////////////////////////////////////////////////
|
2 chip 1.1 //
|
3 karl 1.5 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.3 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.5 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.6 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.7 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 chip 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.3 //
|
21 chip 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Chip Vincent (cvincent@us.ibm.com)
33 //
34 // Modified By:
35 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
38 #include "ProviderRegistrarInitializer.h"
39
40 #include <Pegasus/Repository/CIMRepository.h>
41 #include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
42 chip 1.1
43 #include <Pegasus/Common/Constants.h>
44 #include <Pegasus/Common/Tracer.h>
45 #include <Pegasus/Common/Logger.h>
46
47 PEGASUS_NAMESPACE_BEGIN
48
|
49 chip 1.2 Array<RegistrationRecord> _globalRegistrationTable;
|
50 chip 1.1
51 ProviderRegistrarInitializer::ProviderRegistrarInitializer(void)
52 {
53 }
54
55 ProviderRegistrarInitializer::~ProviderRegistrarInitializer(void)
56 {
57 }
58
59 void ProviderRegistrarInitializer::initialize(CIMRepository * repository)
60 {
61 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderRegistrarInitializer::initialize()");
62
63 Array<RegistrationRecord> records;
64
65 //
66 // get all relevant registration instances from the repository and cache them locally.
67 //
68 // validate instances and remove any that have dangling (incomplete) references. the simplest way to do this with
69 // the current schema is to ensure that each provider capabilities instance has an associated provider module instance and
70 // provider instance. Keep in mind that each class must have an entry. The provider capability instance is one-to-one
71 chip 1.1 // correlated to a class, so it makes sense to start there.
72 //
73
74 Array<CIMInstance> providerCapabilityInstances;
75 Array<CIMInstance> providerInstances;
76 Array<CIMInstance> providerModuleInstances;
77
78 try
79 {
80 providerCapabilityInstances = repository->enumerateInstances("root/PG_interop", "PG_ProviderCapabilities");
81 providerInstances = repository->enumerateInstances("root/PG_Interop", "PG_Provider");
82 providerModuleInstances = repository->enumerateInstances("root/PG_Interop", "PG_ProviderModule");
83 }
84 catch(...)
85 {
86 // suppress exceptions
87 }
88
89 //
90 // create registration records for each class entry
91 //
92 chip 1.1
93 for(Uint32 i = 0, n = providerCapabilityInstances.size(); i < n; i++)
94 {
95 RegistrationRecord record;
96
97 Uint32 pos = 0;
98
99 // get class name
100 if((pos = providerInstances[i].findProperty("Name")) != PEG_NOT_FOUND)
101 {
|
102 chip 1.2 providerInstances[i].getProperty(pos).getValue().get(record.className);
|
103 chip 1.1 }
104
105 // get namespace
106 if((pos = providerInstances[i].findProperty("NameSpace")) != PEG_NOT_FOUND)
107 {
108 // ATTN: must create duplicate entries for each namespace. for now, only
109 // one namespace is support (0 is invalid).
110
|
111 chip 1.2 //Array<String> temp;
|
112 chip 1.1
|
113 chip 1.2 //providerInstances[i].getProperty(pos).getValue().get(temp);
|
114 chip 1.1
|
115 chip 1.2 //record._namespace = temp[0];
|
116 chip 1.1 }
117
118 // get provider name
119 if((pos = providerInstances[i].findProperty("ProviderName")) != PEG_NOT_FOUND)
120 {
|
121 chip 1.2 providerInstances[i].getProperty(pos).getValue().get(record.providerName);
|
122 chip 1.1 }
123
124 // get provider module name
125 if((pos = providerInstances[i].findProperty("ProviderModuleName")) != PEG_NOT_FOUND)
126 {
|
127 chip 1.2 providerInstances[i].getProperty(pos).getValue().get(record.moduleName);
|
128 chip 1.1 }
129 }
130
131 // validate current registration records using cached instances.
132
133 for(Uint32 i = 0, n = records.size(); i < n; i++)
134 {
135 Uint32 pos = 0;
136
137 // find the provider for this record.
138 for(Uint32 i = 0, n = providerInstances.size(); i < n; i++)
139 {
140 String s;
141
142 // get name
143 if((pos = providerInstances[i].findProperty("Name")) != PEG_NOT_FOUND)
144 {
145 providerInstances[i].getProperty(pos).getValue().get(s);
146 }
147
148 // compare record._providerName to PG_Provider.Name
|
149 chip 1.2 if(String::equalNoCase(s, records[i].providerName))
|
150 chip 1.1 {
151 break;
152 }
153 }
154
155 if(i == n)
156 {
157 // not found: must be an invalid entry
158
159 // drop record and log
160 }
161
162 // find the provider module for this record.
163 for(Uint32 i = 0, n = providerModuleInstances.size(); i < n; i++)
164 {
165 String s;
166
167 // get name
168 if((pos = providerModuleInstances[i].findProperty("Name")) != PEG_NOT_FOUND)
169 {
170 providerModuleInstances[i].getProperty(pos).getValue().get(s);
171 chip 1.1 }
172
173 // compare record._moduleName to PG_ProviderModule.Name
|
174 chip 1.2 if(String::equalNoCase(s, records[i].moduleName))
|
175 chip 1.1 {
176 break;
177 }
178 }
179
180 if(i == n)
181 {
182 // not found: must be an invalid entry
183
184 // drop record and log
185 }
186
187 // extract the location property, fully qualify and update the record._moduleName;
188 }
189
190 PEG_METHOD_EXIT();
191 }
192
193 PEGASUS_NAMESPACE_END
|