File Coverage

blib/lib/DMTF/CIM.pm
Criterion Covered Total %
statement 15 265 5.6
branch 0 122 0.0
condition 0 41 0.0
subroutine 5 38 13.1
pod 18 33 54.5
total 38 499 7.6


line stmt bran cond sub pod time code
1             package DMTF::CIM;
2              
3 1     1   25916 use warnings;
  1         2  
  1         33  
4 1     1   6 use strict;
  1         2  
  1         34  
5              
6 1     1   874 use version;
  1         2437  
  1         6  
7             our $VERSION = qv('0.04');
8              
9 1     1   672 use DMTF::CIM::Instance;
  1         5  
  1         25  
10 1     1   6 use Carp;
  1         1  
  1         5249  
11              
12             sub new
13             {
14 0     0 0   my $self={};
15 0           $self->{CLASS} = shift;
16 0           $self->{MODEL} = undef;
17 0           $self->{UFcT} = {
18             authorizedpriv => {class => 'CIM_AuthorizedPrivilege'},
19             configcapacity => {class => 'CIM_ConfigurationCapacity'},
20             location => {class => 'CIM_Location'},
21             record => {class => 'CIM_LogRecord'},
22             namespace => {class => 'CIM_Namespace'},
23             plocation => {class => 'CIM_PhysicalLocation'},
24             product => {class => 'CIM_Product'},
25             profile => {class => 'CIM_RegisteredProfile'},
26             subprofile => {class => 'CIM_RegisteredSubProfile'},
27             mapcap => {class => 'CIM_MAPCapabilities'},
28             sharingcap => {class => 'CIM_DeviceSharingCapabilities'},
29             pwrmgtcap => {class => 'CIM_PowerManagementCapabilities'},
30             swinstallsvccap => {class => 'CIM_SoftwareInstallationServiceCapabilities'},
31             storagecap => {class => 'CIM_StorageCapabilities'},
32             storagecfgcap => {class => 'CIM_StorageConfigurationCapabilities'},
33             dhcpcap => {class => 'CIM_DHCPCapabilities'},
34             bootcfgsetting => {class => 'CIM_BootConfigSetting'},
35             bootsrcsetting => {class => 'CIM_BootSourceSetting'},
36             bootsetting => {class => 'CIM_BootSettingData'},
37             displaysetting => {class => 'CIM_DisplaySetting'},
38             mapsetting => {class => 'CIM_MAPSetting'},
39             nicsetting => {class => 'CIM_NicSetting'},
40             storagesetting => {class => 'CIM_StorageSetting'},
41             ipsettings => {class => 'CIM_IPAssignmentSettingData'},
42             staticipsettings => {class => 'CIM_StaticIPAssignmentSettingData'},
43             dhcpsettings => {class => 'CIM_DHCPSettingData'},
44             dnssettings => {class => 'CIM_DNSSettingData'},
45             dnsgeneralsettings => {class => 'CIM_DNSGeneralSettingData'},
46             group => {class => 'CIM_Group'},
47             redundancyset => {class => 'CIM_RedundancySet'},
48             swrepo => {class => 'CIM_SoftwareRepository'},
49             concretecollection => {class => 'CIM_ConcreteCollection'},
50             hdwr => {class => 'CIM_ConcreteCollection', where=>'ElementName="Hardware"'},
51             capabilities => {class => 'CIM_ConcreteCollection', where=>'ElementName="Capabilities"'},
52             capacities => {class => 'CIM_ConcreteCollection', where=>'ElementName="Capacities"'},
53             consoles => {class => 'CIM_ConcreteCollection', where=>'ElementName="Consoles"'},
54             logs => {class => 'CIM_ConcreteCollection', where=>'ElementName="Logs"'},
55             profiles => {class => 'CIM_ConcreteCollection', where=>'ElementName="Profiles"'},
56             privileges => {class => 'CIM_ConcreteCollection', where=>'ElementName="Privileges"'},
57             products => {class => 'CIM_ConcreteCollection', where=>'ElementName="Products"'},
58             settings => {class => 'CIM_ConcreteCollection', where=>'ElementName="Settings"'},
59             sensors => {class => 'CIM_ConcreteCollection', where=>'ElementName="Sensors"'},
60             swid => {class => 'CIM_SoftwareIdentity'},
61             storagepool => {class => 'CIM_StoragePool'},
62             account => {class => 'CIM_Account'},
63             job => {class => 'CIM_ConcreteJob'},
64             jobq => {class => 'CIM_JobQueue'},
65             log => {class => 'CIM_RecordLog'},
66             os => {class => 'CIM_OperatingSystem'},
67             admin => {class => 'CIM_AdminDomain'},
68             system => {class => 'CIM_ComputerSystem'},
69             modular => {class => 'CIM_ComputerSystem', where=>'OtherDedicatedDescriptions="Modular" and Dedicated="Other"'},
70             storage => {class => 'CIM_ComputerSystem', where=>'Dedicated="Storage"'},
71             router => {class => 'CIM_ComputerSystem', where=>'Dedicated="Router"'},
72             switch => {class => 'CIM_ComputerSystem', where=>'Dedicated="Switch"'},
73             hub => {class => 'CIM_ComputerSystem', where=>'Dedicated="Hub"'},
74             firewall => {class => 'CIM_ComputerSystem', where=>'Dedicated="Firewall"'},
75             printserver => {class => 'CIM_ComputerSystem', where=>'Dedicated="Print"'},
76             accessserver => {class => 'CIM_ComputerSystem', where=>'Dedicated="Access Server"'},
77             ioserver => {class => 'CIM_ComputerSystem', where=>'Dedicated="I/O"'},
78             webcache => {class => 'CIM_ComputerSystem', where=>'Dedicated="Web Caching"'},
79             management => {class => 'CIM_ComputerSystem', where=>'Dedicated="Management"'},
80             blockserver => {class => 'CIM_ComputerSystem', where=>'Dedicated="Block Server"'},
81             fileserver => {class => 'CIM_ComputerSystem', where=>'Dedicated="File Server"'},
82             mobile => {class => 'CIM_ComputerSystem', where=>'Dedicated="Mobile User Device"'},
83             repeater => {class => 'CIM_ComputerSystem', where=>'Dedicated="Repeater"'},
84             bridge => {class => 'CIM_ComputerSystem', where=>'Dedicated="Bridge/Extender"'},
85             extender => {class => 'CIM_ComputerSystem', where=>'Dedicated="Bridge/Extender"'},
86             gateway => {class => 'CIM_ComputerSystem', where=>'Dedicated="Gateway"'},
87             storagevlizer => {class => 'CIM_ComputerSystem', where=>'Dedicated="Storage Virtualizer"'},
88             medialib => {class => 'CIM_ComputerSystem', where=>'Dedicated="Media Library"'},
89             nashead => {class => 'CIM_ComputerSystem', where=>'Dedicated="NAS Head"'},
90             nas => {class => 'CIM_ComputerSystem', where=>'Dedicated="Self-contained NAS"'},
91             ups => {class => 'CIM_ComputerSystem', where=>'Dedicated="UPS"'},
92             ipphone => {class => 'CIM_ComputerSystem', where=>'Dedicated="IP Phone"'},
93             map => {class => 'CIM_ComputerSystem', where=>'Dedicated="Manageability Access Point"'},
94             sp => {class => 'CIM_ComputerSystem', where=>'Dedicated="Management Controller"'},
95             chassismgr => {class => 'CIM_ComputerSystem', where=>'Dedicated="Chassis Manager"'},
96             alarm => {class => 'CIM_AlarmDevice'},
97             battery => {class => 'CIM_Battery'},
98             cd => {class => 'CIM_CDROMDrive'},
99             cooling => {class => 'CIM_CoolingDevice'},
100             daport => {class => 'CIM_DAPort'},
101             diskdrive => {class => 'CIM_DiskDrive'},
102             floppy => {class => 'CIM_DisketteDrive'},
103             diskpartition => {class => 'CIM_DiskPartition'},
104             display => {class => 'CIM_Display'},
105             dvd => {class => 'CIM_DVDDrive'},
106             fan => {class => 'CIM_Fan'},
107             fcport => {class => 'CIM_FCPort'},
108             heatpipe => {class => 'CIM_HeatPipe'},
109             ibport => {class => 'CIM_IBPort'},
110             keyboard => {class => 'CIM_Keyboard'},
111             disk => {class => 'CIM_LogicalDisk'},
112             logicalmodule => {class => 'CIM_LogicalModule'},
113             devicetray => {class => 'CIM_LogicalModule', where=>'LogicalModuleType="Device Tray"'},
114             linecard => {class => 'CIM_LogicalModule', where=>'LogicalModuleType="Line Card"'},
115             blademodule => {class => 'CIM_LogicalModule', where=>'LogicalModuleType="Blade"'},
116             logicalport => {class => 'CIM_LogicalPort'},
117             mediaaccess => {class => 'CIM_MediaAccessDevice'},
118             memory => {class => 'CIM_Memory'},
119             modem => {class => 'CIM_Modem'},
120             netport => {class => 'CIM_NetworkPort'},
121             wifiport => {class => 'CIM_WirelessPort'},
122             enetport => {class => 'CIM_EthernetPort'},
123             pcidev => {class => 'CIM_PCIDevice'},
124             pcibridge => {class => 'CIM_PCIBridge'},
125             pointer => {class => 'CIM_PointingDevice'},
126             mouse => {class => 'CIM_PointingDevice', where=>'PointingType="Mouse"'},
127             trackball => {class => 'CIM_PointingDevice', where=>'PointingType="Track Ball"'},
128             touchpad => {class => 'CIM_PointingDevice', where=>'PointingType="Touch Pad"'},
129             touchscreen => {class => 'CIM_PointingDevice', where=>'PointingType="Touch Screen"'},
130             portctlr => {class => 'CIM_PortController'},
131             nic => {class => 'CIM_PortController', where=>'ControllerType="Ethernet"'},
132             hca => {class => 'CIM_PortController', where=>'ControllerType="IB"'},
133             tca => {class => 'CIM_PortController', where=>'ControllerType="IB"'},
134             hba => {class => 'CIM_PortController', where=>'ControllerType="FC"'},
135             pwrsupply => {class => 'CIM_PowerSupply'},
136             printer => {class => 'CIM_Printer'},
137             cpu => {class => 'CIM_Processor'},
138             refrigeration => {class => 'CIM_Refrigeration'},
139             scsiprotctlr => {class => 'CIM_SCSIProtocolController'},
140             sensor => {class => 'CIM_Sensor'},
141             currentsensor => {class => 'CIM_Sensor', where=>'SensorType="Current"'},
142             tachsensor => {class => 'CIM_Sensor', where=>'SensorType="Tachometer"'},
143             tempsensor => {class => 'CIM_Sensor', where=>'SensorType="Temperature"'},
144             voltsensor => {class => 'CIM_Sensor', where=>'SensorType="Voltage"'},
145             countersensor => {class => 'CIM_Sensor', where=>'SensorType="Counter"'},
146             switchsensor => {class => 'CIM_Sensor', where=>'SensorType="Switch"'},
147             locksensor => {class => 'CIM_Sensor', where=>'SensorType="Lock"'},
148             humiditysensor => {class => 'CIM_Sensor', where=>'SensorType="Humidity"'},
149             airsensor => {class => 'CIM_Sensor', where=>'SensorType="Air Flow"'},
150             presencesensor => {class => 'CIM_Sensor', where=>'SensorType="Presence"'},
151             smokesensor => {class => 'CIM_Sensor', where=>'SensorType="Smoke Detection"'},
152             numsensor => {class => 'CIM_NumericSensor'},
153             ncurrentsensor => {class => 'CIM_NumericSensor', where=>'SensorType="Current"'},
154             ntachsensor => {class => 'CIM_NumericSensor', where=>'SensorType="Tachometer"'},
155             ntempsensor => {class => 'CIM_NumericSensor', where=>'SensorType="Temperature"'},
156             nvoltsensor => {class => 'CIM_NumericSensor', where=>'SensorType="Voltage"'},
157             ncountersensor => {class => 'CIM_NumericSensor', where=>'SensorType="Counter"'},
158             nswitchsensor => {class => 'CIM_NumericSensor', where=>'SensorType="Switch"'},
159             nlocksensor => {class => 'CIM_NumericSensor', where=>'SensorType="Lock"'},
160             nhumiditysensor => {class => 'CIM_NumericSensor', where=>'SensorType="Humidity"'},
161             nairsensor => {class => 'CIM_NumericSensor', where=>'SensorType="Air Flow"'},
162             npresencesensor => {class => 'CIM_NumericSensor', where=>'SensorType="Presence"'},
163             nsmokesensor => {class => 'CIM_NumericSensor', where=>'SensorType="Smoke Detection"'},
164             spiport => {class => 'CIM_SPIPort'},
165             storagevol => {class => 'CIM_StorageVolume'},
166             storageext => {class => 'CIM_StorageExtent'},
167             serialport => {class => 'CIM_SerialPort'},
168             tapedrive => {class => 'CIM_TapeDrive'},
169             usbport => {class => 'CIM_USBPort'},
170             watchdog => {class => 'CIM_WatchDog'},
171             portctrl => {class => 'CIM_PortController'},
172             bootsvc => {class => 'CIM_BootService'},
173             clpsvc => {class => 'CIM_CLPService'},
174             ipcfgsvc => {class => 'CIM_IPConfigurationService'},
175             pwrmgtsvc => {class => 'CIM_PowerManagementService'},
176             shareddevicesvc => {class => 'CIM_SharedDeviceManagementService'},
177             swinstallsvc => {class => 'CIM_SoftwareInstallationService'},
178             sshsvc => {class => 'CIM_SSHService'},
179             storagecfgsvc => {class => 'CIM_StorageConfigurationService'},
180             telnetsvc => {class => 'CIM_TelnetService'},
181             textredirectsvc => {class => 'CIM_TextRedirectionService'},
182             timesvc => {class => 'CIM_TimeService'},
183             protoendpt => {class => 'CIM_ProtocolEndpoint'},
184             ipendpt => {class => 'CIM_IPProtocolEndpoint'},
185             dhcpendpt => {class => 'CIM_DHCPProtocolEndpoint'},
186             dnsendpt => {class => 'CIM_DNSProtocolEndpoint'},
187             remotesap => {class => 'CIM_RemoteServiceAccessPoint'},
188             dnsserver => {class => 'CIM_RemoteServiceAccessPoint', where=>'AccessContext="DNS Server"'},
189             dhcpserver => {class => 'CIM_RemoteServiceAccessPoint', where=>'AccessContext="DHCP Server"'},
190             gateway => {class => 'CIM_RemoteServiceAccessPoint', where=>'AccessContext="Default Gateway"'},
191             lanendpt => {class => 'CIM_LANEndpoint'},
192             remoteport => {class => 'CIM_RemotePort'},
193             scsiendpt => {class => 'CIM_SCSIProtocolEndPoint'},
194             serviceuri => {class => 'CIM_ServiceAccessURI'},
195             textredirectsap => {class => 'CIM_TextRedirectionServiceAccessPoint'},
196             pkg => {class => 'CIM_PhysicalPackage'},
197             bladepkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Blade"'},
198             bladexpkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Blade Expansion"'},
199             diskpkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Storage Media Package"'},
200             fanpkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Fan"'},
201             pwrpkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Power Supply"'},
202             rackpkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Rack"'},
203             chassispkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Chassis/Frame"'},
204             framepkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Chassis/Frame"'},
205             backplanepkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Crossconnect/Backplane"'},
206             sensorpkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Sensor"'},
207             modulepkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Module/Card"'},
208             cardpkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Module/Card"'},
209             batterypkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Battery"'},
210             cpupkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Processor"'},
211             memorypkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Memory"'},
212             storagepkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Storage Media Package"'},
213             pwrsrcpkg => {class => 'CIM_PhysicalPackage', where=>'PackageType="Power Source/Generator"'},
214             frame => {class => 'CIM_PhysicalFrame'},
215             rack => {class => 'CIM_Rack'},
216             chassis => {class => 'CIM_Chassis'},
217             laptop => {class => 'CIM_Chassis', where=>'ChassisPackageType="LapTop"'},
218             desktop => {class => 'CIM_Chassis', where=>'ChassisPackageType="Desktop"'},
219             tower => {class => 'CIM_Chassis', where=>'ChassisPackageType="Tower"'},
220             storagechas => {class => 'CIM_Chassis', where=>'ChassisPackageType="Storage Chassis"'},
221             notebook => {class => 'CIM_Chassis', where=>'ChassisPackageType="Notebook"'},
222             mainchassis => {class => 'CIM_Chassis', where=>'ChassisPackageType="Main System Chassis"'},
223             expansion => {class => 'CIM_Chassis', where=>'ChassisPackageType="Bus Expansion Chassis"'},
224             peripheralchassis => {class => 'CIM_Chassis', where=>'ChassisPackageType="Peripheral Chassis"'},
225             subchassis => {class => 'CIM_Chassis', where=>'ChassisPackageType="SubChassis"'},
226             card => {class => 'CIM_Card'},
227             buscard => {class => 'CIM_SystemBusCard'},
228             pcicard => {class => 'CIM_SystemBusCard', where=>'BusType="PCI"'},
229             eisacard => {class => 'CIM_SystemBusCard', where=>'BusType="EISA"'},
230             vesacard => {class => 'CIM_SystemBusCard', where=>'BusType="VESA"'},
231             pcmciacard => {class => 'CIM_SystemBusCard', where=>'BusType="PCMCIA" or BusType="PCMCIA Type I" or BusType="PCMCIA Type II" or BusType="PCMCIA Type III"'},
232             accesscard => {class => 'CIM_SystemBusCard', where=>'BusType="Access.bus"'},
233             nubuscard => {class => 'CIM_SystemBusCard', where=>'BusType="NuBus"'},
234             agpcard => {class => 'CIM_SystemBusCard', where=>'BusType="AGP"'},
235             vmecard => {class => 'CIM_SystemBusCard', where=>'BusType="VME Bus"'},
236             pccard => {class => 'CIM_SystemBusCard', where=>'BusType="PC-98" or BusType="PC-98-Hireso" or BusType="PC-H98" or BusType="PC-98Note" or BusType="PC-98Full"'},
237             pcixcard => {class => 'CIM_SystemBusCard', where=>'BusType="PCI-X"'},
238             pciecard => {class => 'CIM_SystemBusCard', where=>'BusType="PCI-E"'},
239             sbuscard => {class => 'CIM_SystemBusCard', where=>'BusType="Sbus IEEE 1396-1993 32 bit" or BusType="Sbus IEEE 1396-1993 64 bit"'},
240             isacard => {class => 'CIM_SystemBusCard', where=>'BusType="ISA"'},
241             mcacard => {class => 'CIM_SystemBusCard', where=>'BusType="MCA"'},
242             giocard => {class => 'CIM_SystemBusCard', where=>'BusType="GIO"'},
243             xiocard => {class => 'CIM_SystemBusCard', where=>'BusType="XIO"'},
244             hiocard => {class => 'CIM_SystemBusCard', where=>'BusType="HIO"'},
245             pmccard => {class => 'CIM_SystemBusCard', where=>'BusType="PMC"'},
246             ibcard => {class => 'CIM_SystemBusCard', where=>'BusType="Infiniband"'},
247             component => {class => 'CIM_PhysicalComponent'},
248             chip => {class => 'CIM_Chip'},
249             propchip => {class => 'CIM_Chip', where=>'FormFactor="Proprietary Chip"'},
250             sip => {class => 'CIM_Chip', where=>'FormFactor="SIP"'},
251             dip => {class => 'CIM_Chip', where=>'FormFactor="DIP"'},
252             zip => {class => 'CIM_Chip', where=>'FormFactor="ZIP"'},
253             soj => {class => 'CIM_Chip', where=>'FormFactor="SOJ"'},
254             simm => {class => 'CIM_Chip', where=>'FormFactor="SIMM"'},
255             dimm => {class => 'CIM_Chip', where=>'FormFactor="DIMM"'},
256             tsop => {class => 'CIM_Chip', where=>'FormFactor="TSOP"'},
257             pga => {class => 'CIM_Chip', where=>'FormFactor="PGA"'},
258             rimm => {class => 'CIM_Chip', where=>'FormFactor="RIMM"'},
259             sodimm => {class => 'CIM_Chip', where=>'FormFactor="SODIMM"'},
260             srimm => {class => 'CIM_Chip', where=>'FormFactor="SRIMM"'},
261             smd => {class => 'CIM_Chip', where=>'FormFactor="SMD"'},
262             ssmp => {class => 'CIM_Chip', where=>'FormFactor="SSMP"'},
263             qfp => {class => 'CIM_Chip', where=>'FormFactor="QFP"'},
264             tqfp => {class => 'CIM_Chip', where=>'FormFactor="TQFP"'},
265             soic => {class => 'CIM_Chip', where=>'FormFactor="SOIC"'},
266             lc => {class => 'CIM_Chip', where=>'FormFactor="LCC"'},
267             plcc => {class => 'CIM_Chip', where=>'FormFactor="PLCC"'},
268             bga => {class => 'CIM_Chip', where=>'FormFactor="BGA"'},
269             fpbga => {class => 'CIM_Chip', where=>'FormFactor="FPBGA"'},
270             lga => {class => 'CIM_Chip', where=>'FormFactor="LGA"'},
271             pmem => {class => 'CIM_PhysicalMemory'},
272             ram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="RAM"'},
273             dram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="DRAM"'},
274             synchdram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="Synchronous DRAM"'},
275             cache => {class => 'CIM_PhysicalMemory', where=>'MemoryType="Cache DRAM"'},
276             edo => {class => 'CIM_PhysicalMemory', where=>'MemoryType="EDO"'},
277             edram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="EDRAM"'},
278             vram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="VRAM"'},
279             sram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="SRAM"'},
280             flash => {class => 'CIM_PhysicalMemory', where=>'MemoryType="Flash"'},
281             eeprom => {class => 'CIM_PhysicalMemory', where=>'MemoryType="EEPROM"'},
282             eprom => {class => 'CIM_PhysicalMemory', where=>'MemoryType="EPROM"'},
283             cdram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="CDRAM"'},
284             sdram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="SDRAM"'},
285             sgram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="SGRAM"'},
286             rdram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="RDRAM"'},
287             ddr => {class => 'CIM_PhysicalMemory', where=>'MemoryType="DDR"'},
288             bram => {class => 'CIM_PhysicalMemory', where=>'MemoryType="BRAM"'},
289             connector => {class => 'CIM_PhysicalConnector'},
290             slot => {class => 'CIM_Slot'},
291             };
292 0           $self->{UFContainers}={
293             CIM_AdminDomain => [{association=>'CIM_OwningCollectionElement', contained=>'CIM_ConcreteCollection'}],
294             CIM_ConcreteCollection => [{association=>'CIM_MemberOfCollection', contained=>'CIM_PhysicalPackage'}],
295             CIM_Rack => [{association=>'CIM_ChassisInRack', contained=>'CIM_Chassis'}],
296             CIM_Chassis => [{association=>'CIM_PackageInChassis', contained=>'CIM_PhysicalPackage'}],
297             CIM_PhysicalPackage => [{association=>'CIM_Container', contained=>'CIM_PhysicalElement'},
298             {association=>'CIM_PackagedComponent', contained=>'CIM_PhysicalComponent'},
299             {association=>'CIM_ConnectorOnPackage', contained=>'CIM_PhysicalConnector'}],
300             CIM_PhysicalConnector => [{association=>'CIM_PackageInConnector', contained=>'CIM_PhysicalPackage'}],
301             CIM_Slot => [{association=>'CIM_PackageInSlot', contained=>'CIM_PhysicalPackage'},
302             {association=>'CIM_CardInSlot', contained=>'CIM_Card'}],
303             CIM_Card => [{association=>'CIM_CardOnCard', contained=>'CIM_Card'}],
304             CIM_AdminDomain => [{association=>'CIM_SystemComponent', contained=>'CIM_ComputerSystem'}],
305             CIM_ComputerSystem => [{association=>'CIM_SystemComponent', contained=>'CIM_ComputerSystem'},
306             {association=>'CIM_SystemDevice', contained=>'CIM_LogicalDevice'},
307             {association=>'CIM_HostedService', contained=>'CIM_Service'},
308             {association=>'CIM_HostedAccessPoint', contained=>'CIM_ServiceAccessPoint'},
309             {association=>'CIM_OwningCollectionElement', contained=>'CIM_ConcreteCollection'},
310             {association=>'CIM_HostedPool', contained=>'CIM_StoragePool'}],
311             CIM_ConcreteCollection => [{association=>'CIM_MemberOfCollection', contained=>'CIM_ManagedElement'},
312             {association=>'CIM_OrderedMemberOfCollection', contained=>'CIM_ManagedElement'}],
313             CIM_BootConfigSetting => [{association=>'CIM_ConcreteComponent', contained=>'CIM_SettingData'},
314             {association=>'CIM_OrderedComponent', contained=>'CIM_BootSourceSetting'},
315             {association=>'CIM_ConcreteComponent', contained=>'CIM_SettingData'}],
316             CIM_RecordLog => [{association=>'CIM_LogManagesRecord', contained=>'CIM_LogRecord'}],
317             CIM_ComputerSystem => [{association=>'CIM_HostedJobQueue', contained=>'CIM_JobQueue'}],
318             CIM_JobQueue => [{association=>'CIM_JobDestinationJobs', contained=>'CIM_ConcreteJob'}],
319             CIM_ProtocolEndpoint => [{association=>'CIM_BindsTo', contained=>'CIM_ProtocolEndpoint'},
320             {association=>'CIM_RemoteAccessAvailableToElement', contained=>'CIM_RemoteServiceAccessPoint'}],
321             CIM_EthernetPort => [{association=>'CIM_PortImplementsEndpoint', contained=>'CIM_LANEndpoint'}],
322             CIM_IPAssignmentSettingData => [{association=>'CIM_OrderedComponent', contained=>'CIM_IPAssignmentSettingData'}],
323             # Non-standard...
324             CIM_RegisteredProfile => [{association=>'CIM_ElementConformsToProfile', contained=>'CIM_ComputerSystem'}],
325             };
326 0           $self->{uricache}={};
327              
328 0           bless($self, $self->{CLASS});
329 0           return($self);
330             }
331              
332             sub instance_of
333             {
334 0     0 1   my $self=shift;
335 0           my $class=shift;
336 0           my $lcc=lc($class);
337 0           my $classref;
338            
339 0 0         if(!defined $class) {
340 0           carp("$self->{CLASS}\->instance_of() called without a class name");
341 0           return;
342             }
343              
344 0 0         if(defined $self->{MODEL}{classes}{$lcc}) {
    0          
    0          
345 0           $classref=$self->{MODEL}{classes}{$lcc};
346             }
347             elsif(defined $self->{MODEL}{associations}{$lcc}) {
348 0           $classref=$self->{MODEL}{associations}{$lcc};
349             }
350             elsif(defined $self->{MODEL}{indications}{$lcc}) {
351 0           $classref=$self->{MODEL}{indications}{$lcc};
352             }
353 0 0         if(!defined $classref) {
354             # Now, if there is a GetClass() method, invoke it and add the class to the
355             # model.
356 0           my $cl=$self->GetClass($class);
357 0 0 0       if(defined $cl && $cl->{name} eq lc($class)) {
358 0 0         if($cl->{qualifiers}{association} eq 'true') {
    0          
359 0           $self->{MODEL}{associations}{lc($cl->{name})}=$cl;
360             }
361             elsif($cl->{qualifiers}{indication} eq 'true') {
362 0           $self->{MODEL}{indications}{lc($cl->{name})}=$cl;
363             }
364             else {
365 0           $self->{MODEL}{classes}{lc($cl->{name})}=$cl;
366             }
367 0           return $self->instance_of($cl->{name});
368             }
369             else {
370 0           carp("Unknown class '$class' requested from $self->{CLASS}");
371 0           return;
372             }
373             }
374              
375 0           my $instance=DMTF::CIM::Instance->new(class=>$classref,parent=>$self);
376 0           return($instance);
377             }
378              
379             sub class_tag_alias
380             {
381 0     0 1   my $self=shift;
382 0           my $class=shift;
383 0           my $lcc=lc($class);
384 0           my $alias=shift;
385              
386 0 0         if(defined $self->{MODEL}{classes}{$lcc}) {
    0          
    0          
387 0           $class=$self->{MODEL}{classes}{$lcc}{name};
388             }
389             elsif(defined $self->{MODEL}{associations}{$lcc}) {
390 0           $class=$self->{MODEL}{associations}{$lcc}{name};
391             }
392             elsif(defined $self->{MODEL}{indications}{$lcc}) {
393 0           $class=$self->{MODEL}{indications}{$lcc}{name};
394             }
395 0 0         if(defined $alias) {
396 0           my $lc=lc($alias);
397 0 0 0       if(defined $self->{UFcT}{$lc} && $self->{UFcT}{$lc}{class} ne $class) {
398 0           carp("Illegal attempt to overwrite definition of UFcT $lc ($self->{UFcT}{$lc}{class}) with $class");
399             }
400             else {
401 0           $self->{UFcT}{$lc}{class}=$class;
402             }
403             }
404             else {
405 0           foreach my $check_alias (keys %{$self->{UFcT}}) {
  0            
406 0 0         if($self->{UFcT}{$check_alias}{class} eq $class) {
407 0 0         next if lc($class) eq $check_alias;
408 0 0         next if defined $self->{UFcT}{$check_alias}{where};
409 0           $alias=$check_alias;
410 0           last;
411             }
412             }
413 0 0         $alias = $class unless defined $alias;
414             }
415 0           return $alias;
416             }
417              
418             sub cache_uri_class
419             {
420 0     0 0   my $self=shift;
421 0           my $uri=shift;
422              
423 0 0         if($uri =~ m|(?:(?:[^:/?#]+):)?(?://(?:[^/?#]*))?([^?#]*)(?:\?(?:[^#]*))?(?:#(?:.*))?|) {
424 0           my $path=$1;
425 0 0         if($path=~/^[^:]*?:([^.]+?)\./) {
426 0           my $class=$1;
427 0           $self->class_tag_alias($class, lc($class));
428             }
429             }
430             }
431              
432             sub resolve_class_tag {
433 0     0 0   my $self=shift;
434 0           my %args=@_;
435 0 0         $args{assoc}=0 if(!defined $args{assoc});
436              
437 0 0         if(!defined $args{tag}) {
438 0           carp("$self->{CLASS}\->resolve_class_tag() requires a tag argument.");
439 0           return;
440             }
441              
442 0           my $lcc=lc($args{tag});
443             # First, check the class tag aliases.
444 0 0 0       if(defined $self->{UFcT}{$lcc} && defined $self->{UFcT}{$lcc}{class}) {
445 0           return $self->{UFcT}{$lcc}{class};
446             }
447              
448             # Next, check for an exact model match
449 0 0         if(defined $self->{MODEL}{classes}{$lcc}) {
    0          
    0          
450 0           $self->class_tag_alias($self->{MODEL}{classes}{$lcc}{name}, lc($self->{MODEL}{classes}{$lcc}{name}));
451 0           return $self->{MODEL}{classes}{$lcc}{name};
452             }
453             elsif(defined $self->{MODEL}{associations}{$lcc}) {
454 0           $self->class_tag_alias($self->{MODEL}{associations}{$lcc}{name}, lc($self->{MODEL}{associations}{$lcc}{name}));
455 0           return $self->{MODEL}{associations}{$lcc}{name};
456             }
457             elsif(defined $self->{MODEL}{indications}{$lcc}) {
458 0           $self->class_tag_alias($self->{MODEL}{indications}{$lcc}{name}, lc($self->{MODEL}{indications}{$lcc}{name}));
459 0           return $self->{MODEL}{indications}{$lcc}{name};
460             }
461              
462             # Now we assume we're working with incomplete data... either the model
463             # is missing the specified class, or the class tag alias is undefined.
464             # Since CIM classes are in the SCHEMA_Name format, if there is no
465             # underscore, it is not a missing class, and must be a missing tag.
466 0 0         if($args{tag} !~ /_/) {
467 0           carp("Invalid UFcT $args{tag}");
468 0           return;
469             }
470              
471             # Now, if there is a GetClass() method, invoke it and add the class to the
472             # model.
473 0           my $class=$self->GetClass($args{tag});
474 0 0 0       if(defined $class && $class->{name} eq lc($args{tag})) {
475 0 0         if($class->{qualifiers}{association} eq 'true') {
    0          
476 0           $self->{MODEL}{associations}{lc($class->{name})}=$class;
477             }
478             elsif($class->{qualifiers}{indication} eq 'true') {
479 0           $self->{MODEL}{indications}{lc($class->{name})}=$class;
480             }
481             else {
482 0           $self->{MODEL}{classes}{lc($class->{name})}=$class;
483             }
484 0           $self->class_tag_alias($class->{name}, lc($class->{name}));
485 0           return $class->{name};
486             }
487              
488             # Still don't have the class name. Try to enumerate associated/association
489             # instances to find correct capitalization.
490              
491 0           my @uri_list;
492             my %enum_args;
493 0 0         $enum_args{via}=$args{via} if(defined $args{via});
494 0 0         if(defined $args{uri}) {
495 0           $enum_args{uri}=$args{uri};
496             }
497             else {
498 0           $enum_args{uri}='/interop';
499             }
500 0 0         $enum_args{class}=$args{tag} if(defined $args{tag});
501 0           my $uri_has_instance=0;
502 0 0         $uri_has_instance=1 if($enum_args{uri} =~ /:[^.]+\..*$/);
503 0 0         if($uri_has_instance) {
    0          
504 0 0         if($args{assoc}) {
505 0           delete $enum_args{class};
506 0           @uri_list=$self->GetReferencingInstancePaths(%enum_args);
507             }
508             }
509             elsif($uri_has_instance) {
510 0 0         if(!$args{assoc}) {
511 0           @uri_list=$self->GetAssociatedInstancePaths(%enum_args);
512             }
513             }
514             else {
515 0           @uri_list=$self->GetClassInstancePaths(%enum_args);
516             }
517              
518 0           foreach my $uri (@uri_list) {
519 0           $self->cache_uri_class($uri);
520             }
521 0 0 0       if(defined $self->{UFcT}{lc($args{tag})} && defined $self->{UFcT}{lc($args{tag})}{class}) {
522 0           return $self->{UFcT}{lc($args{tag})}{class};
523             }
524 0           carp("Unable to resolve $args{tag}");
525 0           return;
526             }
527              
528             sub normalize_path
529             {
530 0     0 0   my $self=shift;
531 0           my $path=shift;
532              
533             # Change all sequences of slashes and backslashes to a single slash
534 0           $path=~s/[\/\\]+/\//g;
535              
536             # Remove trailing /
537 0           $path =~ s|/$||g;
538              
539             # Remove /.
540 0           while($path =~ s|(.)/\./|$1/|g){};
541              
542             # Remove /.=
543 0           while($path =~ s|(.)/\.=|$1=|g){};
544              
545             # Remove trailing /.
546 0           $path =~ s|(/\.)+$||g;
547              
548             # Remove /XXX/..
549 0           while($path =~ s|/[^/.]+/\.\./|/|g){};
550              
551             # Remove /Thing.Thing/..
552 0           while($path =~ s|/[^/.]+\.[^/]*/\.\./|/|g){};
553              
554             # Remove /Thing.Thing/..
555 0           while($path =~ s|/[^/]*\.[^/.]*/\.\./|/|g){};
556              
557             # Remove /.../..
558 0           while($path =~ s|/\.{3,}/\.\./|/|g){};
559              
560             # Remove trailing /XXX/..
561 0           while($path =~ s|/[^/]+/\.\.$||g){};
562              
563             # Zero-length becomes root.
564 0 0         if($path eq '') {
565 0           $path='/';
566             }
567              
568 0           return $path;
569             }
570              
571             sub UFiP_to_URI {
572 0     0 1   my $self=shift;
573 0           my $UFP=shift;
574 0           my $rooturi=shift;
575 0 0         if(!defined $rooturi) {
576 0 0         $rooturi=$self->{uricache}{'/'} if(defined $self->{uricache}{'/'});
577             }
578              
579 0 0         if(!defined $rooturi) {
580 0           carp("$self->{CLASS}\->UFiP_to_URI() called with no root URI specified");
581 0           return;
582             }
583 0           my $currenturi=$rooturi;
584 0           my $currentpath='';
585 0           my @repsonse;
586             my @urilist;
587 0           my $loops=0;
588              
589             # Normalize...
590 0           $UFP=$self->normalize_path($UFP);
591 0 0         if($UFP !~ m|^/|) {
592 0           carp "Path error: Path $UFP is not absolute";
593 0           return;
594             }
595              
596             # Now fix up associations (ie: path to association instance)
597 0           $UFP =~ s|=>|/-=|g;
598              
599             # Now, split on slashes...
600 0           my @elements=split(/\//, $UFP);
601             # And remove the root....
602 0           shift @elements;
603              
604 0           while(my $element = shift(@elements)) {
605 0           my $targetclass;
606 0           my $targetisassoc=0;
607 0           my $tag;
608             my $id;
609 0           my $via;
610              
611 0           push @urilist,$currenturi;
612              
613 0 0         if($element =~ /^(-=)?(.+?)([0-9*]*)$/) {
614 0           $tag=$2;
615 0           $id=$3;
616              
617 0 0 0       if(defined $1 && $1 eq '-=') {
618 0           $targetisassoc=1;
619             }
620              
621 0 0 0       if(!defined $id || $id eq '' && $#elements != -1) {
      0        
622             # Really? You expect people to understand that error message?
623 0           carp("Invalid Path - contains non-terminal UFcT");
624 0           return;
625             }
626 0 0 0       if($3 eq '*' && $#elements != -1) {
627             # Really? You expect people to understand that error message?
628 0           carp("Invalid Path - contains non-terminal wildcard");
629 0           return;
630             }
631             }
632             else {
633 0           carp("Impossible error... $element did not match /^(-=)?(.+?)([0-9*]*)\$/");
634 0           return;
635             }
636              
637 0           $targetclass=$self->resolve_class_tag(tag=>$tag, uri=>$currenturi, assoc=>$targetisassoc, via=>$via);
638              
639 0 0         if(!defined $targetclass) {
640 0           return;
641             }
642              
643 0           my $pathelement="$tag$id";
644 0 0         if($targetisassoc) {
645 0           $currentpath .= "=>$pathelement";
646             }
647             else {
648 0 0         if($currentpath =~ /=>[^\/]+$/) {
649 0           $currentpath .= "=>$pathelement";
650             }
651             else {
652 0           $currentpath .= "/$pathelement";
653             }
654             }
655              
656 0           my $nametag=$currentpath;
657 0           $nametag =~ s/[0-9*]+$//;
658 0 0 0       if(!defined $id || $id eq '') {
    0          
659 0           my($scheme, $authority, $path, $query, $fragment) = $currenturi =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|;
660 0           $path =~ s/:.*$//;
661 0           $currenturi='';
662 0 0 0       if(defined $scheme && $scheme ne '' && defined $authority && $authority ne '') {
      0        
      0        
663 0           $currenturi="$scheme://$authority";
664             }
665 0           $currenturi.="$path:$targetclass";
666             }
667             elsif($id eq '*') {
668 0           my @new_urilist;
669 0 0         if($targetisassoc) {
670 0           @new_urilist=$self->GetReferencingInstancePaths(uri=>$currenturi, class=>$targetclass, via=>$via);
671             }
672             else {
673 0           @new_urilist=$self->GetAssociatedInstancePaths(uri=>$currenturi, class=>$targetclass, via=>$via);
674             }
675 0           foreach my $i (0..$#new_urilist) {
676 0           $self->{uricache}{$nametag.($i+1)}=$new_urilist[$i];
677 0           $self->cache_uri_class($new_urilist[$i]);
678             }
679 0           return [@new_urilist];
680             }
681             else {
682             # Now get the nth match.
683 0 0         if(!defined $self->{uricache}{$currentpath}) {
684 0           my @new_urilist;
685              
686 0 0         if($targetisassoc) {
687 0           @new_urilist=$self->GetReferencingInstancePaths(uri=>$currenturi, class=>$targetclass, via=>$via);
688             }
689             else {
690 0           @new_urilist = $self->GetAssociatedInstancePaths(uri=>$currenturi, class=>$targetclass, via=>$via);
691             }
692 0           foreach my $i (0..$#new_urilist) {
693 0           $self->{uricache}{$nametag.($i+1)}=$new_urilist[$i];
694 0           $self->cache_uri_class($new_urilist[$i]);
695             }
696             }
697 0 0         if(!defined $self->{uricache}{$currentpath}) {
698 0           carp("Invalid UFiS specified at end of $currentpath");
699 0           return;
700             }
701 0           $currenturi=$self->{uricache}{$currentpath};
702              
703 0           foreach my $turi (@urilist) {
704 0 0         if($turi eq $currenturi) {
705 0           $loops++;
706             }
707             }
708             }
709             }
710              
711 0 0         carp "Path error: Instance loop detected." if $loops;
712 0           return $currenturi;
713             }
714              
715             sub clear_uri_cache
716             {
717 0     0 1   my $self=shift;
718 0           $self->{uricache}={};
719             }
720              
721             sub cache_uri_path
722             {
723 0     0 1   my $self=shift;
724 0           my $path=shift;
725 0           my $uri=shift;
726 0           $self->{uricache}{$path}=$uri;
727             }
728              
729             sub parse_mof
730             {
731 0     0 1   my $self=shift;
732 0           my $path=shift;
733 0   0       my $clear=shift || 0;
734 0           require DMTF::CIM::MOF;
735              
736 0 0         if(defined $DMTF::CIM::MOF::{parse_MOF}) {
737 0 0         $self->{MODEL} = DMTF::CIM::MOF::parse_MOF($path, $clear?undef:$self->{MODEL});
738             }
739             }
740              
741             ###########################
742             # Generic Operation Stubs #
743             ###########################
744             sub GetClass
745             {
746 0     0 1   return;
747             }
748              
749             sub GetInstance
750             {
751 0     0 1   return;
752             }
753              
754             sub ModifyInstance
755             {
756 0     0 1   return;
757             }
758              
759             sub DeleteInstance
760             {
761 0     0 1   return;
762             }
763              
764             sub CreateInstance
765             {
766 0     0 1   return;
767             }
768              
769             sub GetClassInstancePaths
770             {
771 0     0 1   return;
772             }
773              
774             sub GetReferencingInstancePaths
775             {
776 0     0 1   return;
777             }
778              
779             sub GetAssociatedInstancePaths
780             {
781 0     0 1   return;
782             }
783              
784             sub GetClassInstancesWithPath
785             {
786 0     0 1   return;
787             }
788              
789             sub GetReferencingInstancesWithPath
790             {
791 0     0 1   return;
792             }
793              
794             sub GetAssociatedInstancesWithPath
795             {
796 0     0 1   return;
797             }
798              
799             sub InvokeMethod
800             {
801 0     0 1   return;
802             }
803              
804             #####################
805             # Friendly Wrappers #
806             #####################
807             sub get
808             {
809 0     0 0   my $self=shift;
810 0           return $self->GetInstance(@_);
811             }
812              
813             sub put
814             {
815 0     0 0   my $self=shift;
816 0           return $self->ModifyInstance(@_);
817             }
818              
819             sub delete
820             {
821 0     0 0   my $self=shift;
822 0           return $self->DeleteInstance(@_);
823             }
824              
825             sub create
826             {
827 0     0 0   my $self=shift;
828 0           return $self->CreateInstance(@_);
829             }
830              
831             sub class_uris
832             {
833 0     0 0   my $self=shift;
834 0           return $self->GetClassInstancePaths(@_);
835             }
836              
837             sub associations
838             {
839 0     0 0   my $self=shift;
840 0           return $self->GetReferencingInstancePaths(@_);
841             }
842              
843             sub associated
844             {
845 0     0 0   my $self=shift;
846 0           return $self->GetAssociatedInstancePaths(@_);
847             }
848              
849             sub class_instances
850             {
851 0     0 0   my $self=shift;
852 0           return $self->GetClassInstancesWithPath(@_);
853             }
854              
855             sub association_instances
856             {
857 0     0 0   my $self=shift;
858 0           return $self->GetReferencingInstancesWithPath(@_);
859             }
860              
861             sub associated_instances
862             {
863 0     0 0   my $self=shift;
864 0           return $self->GetAssociatedInstancesWithPath(@_);
865             }
866              
867             sub invoke
868             {
869 0     0 0   my $self=shift;
870 0           return $self->InvokeMethod(@_);
871             }
872              
873             1; # Magic true value required at end of module
874             __END__