You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(26) |
Dec
(13) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(5) |
Feb
(16) |
Mar
(5) |
Apr
(5) |
May
(13) |
Jun
(12) |
Jul
(1) |
Aug
(2) |
Sep
(13) |
Oct
(6) |
Nov
(1) |
Dec
(29) |
| 2008 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
(57) |
May
(35) |
Jun
(45) |
Jul
(132) |
Aug
(87) |
Sep
(141) |
Oct
(86) |
Nov
(17) |
Dec
(2) |
| 2009 |
Jan
(3) |
Feb
(2) |
Mar
(3) |
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2010 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <ba...@us...> - 2007-12-31 23:22:13
|
Revision: 532
http://omc.svn.sourceforge.net/omc/?rev=532&view=rev
Author: bartw
Date: 2007-12-31 15:22:18 -0800 (Mon, 31 Dec 2007)
Log Message:
-----------
changed CL options. added tests for LogicalFile
Modified Paths:
--------------
test/trunk/omcbase_test.py
Modified: test/trunk/omcbase_test.py
===================================================================
--- test/trunk/omcbase_test.py 2007-12-27 04:28:09 UTC (rev 531)
+++ test/trunk/omcbase_test.py 2007-12-31 23:22:18 UTC (rev 532)
@@ -5,7 +5,10 @@
import pywbem
import os
import commands
+import shutil
+from stat import *
+from tempfile import mkdtemp
from lib import ProviderSanityTest as PST
from time import sleep
from socket import getfqdn
@@ -24,13 +27,10 @@
self.__dict__ = WBEMConn._shared_state
if options:
- proto = 'http'
- if options.secure:
- proto = 'https'
- url = '%s://%s' % (proto, options.host)
- self.conn = pywbem.WBEMConnection(
- url,
- (options.user, options.password),
+ creds = None
+ if options.user is not None:
+ creds = (options.user, options.password)
+ self.conn = pywbem.WBEMConnection(options.url, creds,
default_namespace = options.namespace)
@@ -92,9 +92,11 @@
self._conn = WBEMConn().conn
self._verbose = _globalVerbose
self._dbgPrint()
+ self._tmpdir = mkdtemp()
def tearDown(self):
unittest.TestCase.tearDown(self)
+ shutil.rmtree(self._tmpdir, ignore_errors=True)
def _omc_initdservice_test(self):
svcs = []
@@ -334,16 +336,105 @@
def test_logical_file(self):
'''OMC_LogicalFile'''
- try:
- #TODO Traverse a folder on filesystem and retrieve all of the
- #LinuxDataFiles
- #Get through GetInstance using keybindings since they are
- #non-enumerable
- #self._conn.GetInstance("OMC_LinuxdataFile")
- pass
- except pywbem.CIMError, arg:
- raise
+ inames = self._conn.EnumerateInstanceNames('OMC_LinuxDirectory')
+ inames.sort()
+ names = [x['Name'] for x in inames]
+ gnames = os.listdir('/')
+ isdir = lambda x: S_ISDIR(os.stat(x).st_mode)
+ gnames = ['/'+x for x in gnames]
+ gnames = [x for x in gnames if isdir(x)]
+ gnames.append('/')
+ gnames.sort()
+ self.assertEqual(gnames, names)
+
+ for sock in ['/var/run/tog-pegasus/cimxml.socket',
+ '/tmp/OW@LCL@APIIPC_72859_Xq47Bf_P9r761-5_J-7_Q']:
+ if os.path.exists(sock):
+ iname = pywbem.CIMInstanceName('OMC_LinuxSocketFile',
+ keybindings={'Name':sock})
+ sockinst = self._conn.GetInstance(iname)
+ self.assertEqual(sockinst.classname.lower(),
+ 'omc_linuxsocketfile')
+ self.assertEqual(sockinst['ElementName'],
+ os.path.basename(sock))
+ self.assertEqual(sockinst['CSName'], getfqdn())
+ # TODO check more stuff.
+ break
+ else:
+ self.fail('Failed to find a socket file to test.')
+
+ os.mkdir(self._tmpdir + '/dir')
+ fo = open(self._tmpdir + '/file', 'w')
+ fo.write('1234')
+ fo.close()
+ os.symlink('file', self._tmpdir + '/symlink')
+ iname = pywbem.CIMInstanceName('OMC_LinuxDirectory',
+ keybindings={'Name':self._tmpdir})
+ ccontents = self._conn.Associators(iname,
+ AssocClass='OMC_LinuxDirectoryContainsFile',
+ Role='GroupComponent',
+ ResultRole='PartComponent')
+ self.assertEqual(len(ccontents), 3)
+ ccontents = dict([(os.path.basename(x['Name']), x) for x in ccontents])
+ self.assertEqual(ccontents['file']['FileSize'], 4)
+ self.assertEqual(ccontents['file'].classname.lower(),
+ 'omc_linuxdatafile')
+ self.assertEqual(ccontents['dir'].classname.lower(),
+ 'omc_linuxdirectory')
+ self.assertEqual(ccontents['symlink'].classname.lower(),
+ 'omc_linuxsymboliclink')
+ self.assertEqual(ccontents['symlink']['TargetFile'], 'file')
+
+ parent = self._conn.Associators(ccontents['file'].path,
+ AssocClass='OMC_LinuxDirectoryContainsFile',
+ Role='PartComponent',
+ ResultRole='GroupComponent')
+ self.assertEquals(len(parent), 1)
+ parent = parent[0]
+ self.assertEquals(parent['Name'], self._tmpdir)
+ self.assertEquals(parent.classname.lower(), 'omc_linuxdirectory')
+
+ iname = pywbem.CIMInstanceName('OMC_LinuxDeviceFile',
+ keybindings={'Name':'/dev/null'})
+ null = self._conn.GetInstance(iname, LocalOnly=False)
+ self.assertEquals(null.classname.lower(), 'omc_linuxdevicefile')
+ self.assertEquals(null['DeviceId'], '259') # same on every system?
+ self.assertEquals(null['DeviceMajor'], '1')
+ self.assertEquals(null['DeviceMinor'], '3')
+ self.assertEquals(null['DeviceFileType'], 3)
+
+ os.chmod(self._tmpdir + '/file', 0700)
+
+ iname = pywbem.CIMInstanceName('OMC_LinuxFile',
+ keybindings={'LFName':self._tmpdir + '/file'})
+ lf = self._conn.GetInstance(iname, LocalOnly=False)
+ self.assertTrue(lf['UserReadable'])
+ self.assertTrue(lf['UserWritable'])
+ self.assertTrue(lf['UserExecutable'])
+ self.assertFalse(lf['WorldReadable'])
+ self.assertFalse(lf['WorldWritable'])
+ self.assertFalse(lf['WorldExecutable'])
+ self.assertFalse(lf['GroupReadable'])
+ self.assertFalse(lf['GroupWritable'])
+ self.assertFalse(lf['GroupExecutable'])
+
+ lf['GroupReadable'] = True
+ lf['GroupWritable'] = True
+ lf['GroupExecutable'] = True
+
+ self._conn.ModifyInstance(lf)
+ lf2 = self._conn.GetInstance(iname, LocalOnly=False)
+
+ self.assertEquals(lf, lf2)
+
+ st = os.stat(self._tmpdir + '/file')
+ self.assertTrue(st.st_mode & S_IRGRP)
+ self.assertTrue(st.st_mode & S_IWGRP)
+ self.assertTrue(st.st_mode & S_IXGRP)
+
+ # TODO test chmod/chown/delete
+
def test_operating_system(self):
'''OMC_OperatingSystem'''
if self._isSupportedAssn('OMC_OperatingSystem',
@@ -631,15 +722,13 @@
dest='dbglevel',
help='Indicate the level of debugging statements to display (default=2)',
default=2)
- parser.add_option('', '--host', default='localhost',
- help='Specify the hosting machine of the CIMOM (default=localhost)')
- parser.add_option('-s', '--secure', action='store_true', default=False,
- help='Use the HTTPS protocol. Default is HTTP')
+ parser.add_option('-u', '--url', default='https://localhost',
+ help='Specify the URL to the CIMOM')
parser.add_option('-n', '--namespace', default='root/cimv2',
help='Specify the namespace the test runs against (default=root/cimv2)')
- parser.add_option('', '--user', default='',
+ parser.add_option('', '--user', default=None,
help='Specify the user name used when connection to the CIMOM')
- parser.add_option('', '--password', default='',
+ parser.add_option('', '--password', default=None,
help='Specify the password for the user')
parser.add_option('--verbose', '', action='store_true', default=False,
help='Show verbose output')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-27 04:28:05
|
Revision: 531
http://omc.svn.sourceforge.net/omc/?rev=531&view=rev
Author: bartw
Date: 2007-12-26 20:28:09 -0800 (Wed, 26 Dec 2007)
Log Message:
-----------
added Pegasus registration
Modified Paths:
--------------
pyprofiles/pysoftware/trunk/OMC_InstalledRPMSoftwareIdentity.mof
pyprofiles/pysoftware/trunk/OMC_Software.mof
Added Paths:
-----------
pyprofiles/pysoftware/trunk/OMC_InstalledRPMSoftwareIdentity-peg.reg
pyprofiles/pysoftware/trunk/OMC_RPMContainsFile-peg.reg
pyprofiles/pysoftware/trunk/OMC_RPMSoftwareIdentity-peg.reg
Added: pyprofiles/pysoftware/trunk/OMC_InstalledRPMSoftwareIdentity-peg.reg
===================================================================
--- pyprofiles/pysoftware/trunk/OMC_InstalledRPMSoftwareIdentity-peg.reg (rev 0)
+++ pyprofiles/pysoftware/trunk/OMC_InstalledRPMSoftwareIdentity-peg.reg 2007-12-27 04:28:09 UTC (rev 531)
@@ -0,0 +1,26 @@
+// Pegasus Provider registration for OMC_InstalledRPMSoftwareIdentity
+instance of PG_ProviderModule
+{
+ Name = "/usr/lib/pycim/OMC_InstalledRPMSoftwareIdentity.py";
+ InterfaceType = "Python";
+ InterfaceVersion = "1.0.0";
+ Location = "/usr/lib/pycim/OMC_InstalledRPMSoftwareIdentity.py";
+ UserContext = 2; // Requestor
+ Vendor = "OMC";
+ Version = "1.0";
+};
+instance of PG_Provider
+{
+ Name = "OMC_InstalledRPMSoftwareIdentity";
+ ProviderModuleName = "/usr/lib/pycim/OMC_InstalledRPMSoftwareIdentity.py";
+};
+instance of PG_ProviderCapabilities
+{
+ CapabilityID = "OMC_InstalledRPMSoftwareIdentity";
+ ProviderModuleName = "/usr/lib/pycim/OMC_InstalledRPMSoftwareIdentity.py";
+ ProviderName = "OMC_InstalledRPMSoftwareIdentity";
+ ClassName = "OMC_InstalledRPMSoftwareIdentity";
+ Namespaces = {"root/cimv2"};
+ ProviderType = {2,3}; // Instance, Associator
+};
+
Modified: pyprofiles/pysoftware/trunk/OMC_InstalledRPMSoftwareIdentity.mof
===================================================================
--- pyprofiles/pysoftware/trunk/OMC_InstalledRPMSoftwareIdentity.mof 2007-12-24 23:40:49 UTC (rev 530)
+++ pyprofiles/pysoftware/trunk/OMC_InstalledRPMSoftwareIdentity.mof 2007-12-27 04:28:09 UTC (rev 531)
@@ -1,4 +1,5 @@
+[ Association ]
class OMC_InstalledRPMSoftwareIdentity : CIM_InstalledSoftwareIdentity
{
[Key, Description (
Added: pyprofiles/pysoftware/trunk/OMC_RPMContainsFile-peg.reg
===================================================================
--- pyprofiles/pysoftware/trunk/OMC_RPMContainsFile-peg.reg (rev 0)
+++ pyprofiles/pysoftware/trunk/OMC_RPMContainsFile-peg.reg 2007-12-27 04:28:09 UTC (rev 531)
@@ -0,0 +1,26 @@
+// Pegasus Provider registration for OMC_RPMContainsFile
+instance of PG_ProviderModule
+{
+ Name = "/usr/lib/pycim/OMC_RPMContainsFile.py";
+ InterfaceType = "Python";
+ InterfaceVersion = "1.0.0";
+ Location = "/usr/lib/pycim/OMC_RPMContainsFile.py";
+ UserContext = 2; // Requestor
+ Vendor = "OMC";
+ Version = "1.0";
+};
+instance of PG_Provider
+{
+ Name = "OMC_RPMContainsFile";
+ ProviderModuleName = "/usr/lib/pycim/OMC_RPMContainsFile.py";
+};
+instance of PG_ProviderCapabilities
+{
+ CapabilityID = "OMC_RPMContainsFile";
+ ProviderModuleName = "/usr/lib/pycim/OMC_RPMContainsFile.py";
+ ProviderName = "OMC_RPMContainsFile";
+ ClassName = "OMC_RPMContainsFile";
+ Namespaces = {"root/cimv2"};
+ ProviderType = {2,3}; // Instance, Associator
+};
+
Added: pyprofiles/pysoftware/trunk/OMC_RPMSoftwareIdentity-peg.reg
===================================================================
--- pyprofiles/pysoftware/trunk/OMC_RPMSoftwareIdentity-peg.reg (rev 0)
+++ pyprofiles/pysoftware/trunk/OMC_RPMSoftwareIdentity-peg.reg 2007-12-27 04:28:09 UTC (rev 531)
@@ -0,0 +1,26 @@
+// Pegasus Provider registration for OMC_RPMSoftwareIdentity
+instance of PG_ProviderModule
+{
+ Name = "/usr/lib/pycim/OMC_RPMSoftwareIdentity.py";
+ InterfaceType = "Python";
+ InterfaceVersion = "1.0.0";
+ Location = "/usr/lib/pycim/OMC_RPMSoftwareIdentity.py";
+ UserContext = 2; // Requestor
+ Vendor = "OMC";
+ Version = "1.0";
+};
+instance of PG_Provider
+{
+ Name = "OMC_RPMSoftwareIdentity";
+ ProviderModuleName = "/usr/lib/pycim/OMC_RPMSoftwareIdentity.py";
+};
+instance of PG_ProviderCapabilities
+{
+ CapabilityID = "OMC_RPMSoftwareIdentity";
+ ProviderModuleName = "/usr/lib/pycim/OMC_RPMSoftwareIdentity.py";
+ ProviderName = "OMC_RPMSoftwareIdentity";
+ ClassName = "OMC_RPMSoftwareIdentity";
+ Namespaces = {"root/cimv2"}; // TODO
+ ProviderType = {2}; // Instance
+};
+
Modified: pyprofiles/pysoftware/trunk/OMC_Software.mof
===================================================================
--- pyprofiles/pysoftware/trunk/OMC_Software.mof 2007-12-24 23:40:49 UTC (rev 530)
+++ pyprofiles/pysoftware/trunk/OMC_Software.mof 2007-12-27 04:28:09 UTC (rev 531)
@@ -1,2 +1,4 @@
#pragma include ("OMC_RPMSoftwareIdentity.mof")
+#pragma include ("OMC_InstalledRPMSoftwareIdentity.mof")
+#pragma include ("OMC_RPMContainsFile.mof")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-24 23:41:01
|
Revision: 530
http://omc.svn.sourceforge.net/omc/?rev=530&view=rev
Author: bartw
Date: 2007-12-24 15:40:49 -0800 (Mon, 24 Dec 2007)
Log Message:
-----------
added missing modules
Modified Paths:
--------------
pybase/trunk/setup.py
Modified: pybase/trunk/setup.py
===================================================================
--- pybase/trunk/setup.py 2007-12-24 23:40:14 UTC (rev 529)
+++ pybase/trunk/setup.py 2007-12-24 23:40:49 UTC (rev 530)
@@ -23,7 +23,9 @@
'OMC_LogicalFile',
'OMC_OperatingSystem',
'OMC_UnitaryComputerSystem',
- 'OMC_UnixProcess'],
+ 'OMC_UnixProcess',
+ 'OMC_SyslogNG',
+ 'OMC_TimeService',]
#options={'install':{'--install-lib':'/usr/lib/pycim'}},
)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-24 23:40:35
|
Revision: 529
http://omc.svn.sourceforge.net/omc/?rev=529&view=rev
Author: bartw
Date: 2007-12-24 15:40:14 -0800 (Mon, 24 Dec 2007)
Log Message:
-----------
several fixes to LogicalFile
Modified Paths:
--------------
pybase/trunk/OMC_LogicalFile.py
Modified: pybase/trunk/OMC_LogicalFile.py
===================================================================
--- pybase/trunk/OMC_LogicalFile.py 2007-12-24 23:39:39 UTC (rev 528)
+++ pybase/trunk/OMC_LogicalFile.py 2007-12-24 23:40:14 UTC (rev 529)
@@ -43,6 +43,7 @@
from threading import RLock
import pwd
import grp
+import errno
_mounts = {}
_mountssum = ''
@@ -106,7 +107,7 @@
if S_ISDIR(mode):
ccname = 'OMC_LinuxDirectory'
elif S_ISCHR(mode) or S_ISBLK(mode):
- ccname = 'OMC_LinuxDevice'
+ ccname = 'OMC_LinuxDeviceFile'
elif S_ISREG(mode):
ccname = 'OMC_LinuxDataFile'
elif S_ISFIFO(mode):
@@ -214,7 +215,14 @@
"""
if stat is None:
- stat = os.stat(model['lfname'])
+ try:
+ stat = os.stat(model['lfname'])
+ except OSError, arg:
+ if arg[0] == errno.ENOENT:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ elif arg[0] == errno.EPERM:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
+ get_file_keys(model['lfname'], model, stat, linux_file=True)
statvfs = os.statvfs(model['lfname'])
mode = stat[ST_MODE]
@@ -456,34 +464,50 @@
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' % self.__class__.__name__)
- try:
- if stat is None:
+ if stat is None:
+ try:
stat = os.lstat(model['name'])
- except OSError, arg:
- if arg.errno == 13:
- raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
- raise
+ except OSError, arg:
+ if arg.errno == 13:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
+ raise
+ get_file_keys(model['name'], model, stat)
+ if model.classname.lower() != model['CreationClassName'].lower():
+ print '\n***** ', model['CreationClassName']
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ ux = model.update_existing
mode = stat[ST_MODE]
- model['Writeable'] = bool(mode & S_IWUSR)
- model['HealthState'] = pywbem.Uint16(5)
- #model['StatusDescriptions'] = # TODO (type = string[])
- model['Executable'] = bool(mode & S_IXUSR)
- model['Readable'] = bool(mode & S_IRUSR)
- #model['OperationalStatus'] = # TODO (type = uint16[])
- model['FileSize'] = pywbem.Uint64(stat[ST_SIZE])
- #model['CompressionMethod'] = # TODO (type = string)
- #model['Status'] = # TODO (type = string)
- #model['Description'] = # TODO (type = string)
- #model['InstallDate'] = # TODO (type = datetime)
- model['LastModified'] = pywbem.CIMDateTime.fromtimestamp(stat[ST_MTIME])
- #model['InUseCount'] = # TODO (type = uint64)
- #model['EncryptionMethod'] = # TODO (type = string)
- model['LastAccessed'] = pywbem.CIMDateTime.fromtimestamp(stat[ST_ATIME])
- model['ElementName'] = model['name'] == '/' and '/' or \
- os.path.basename(model['name'])
- #model['Caption'] = # TODO (type = string)
- model['CreationDate'] = pywbem.CIMDateTime.fromtimestamp(stat[ST_CTIME])
+ ux(Writeable= bool(mode & S_IWUSR))
+ ux(HealthState= pywbem.Uint16(5))
+ #ux(StatusDescriptions= # TODO (type = string[]) )
+ ux(Executable= bool(mode & S_IXUSR))
+ ux(Readable= bool(mode & S_IRUSR))
+ #ux(OperationalStatus= # TODO (type = uint16[]) )
+ ux(FileSize= pywbem.Uint64(stat[ST_SIZE]))
+ #ux(CompressionMethod= # TODO (type = string) )
+ #ux(Status= # TODO (type = string) )
+ #ux(Description= # TODO (type = string) )
+ #ux(InstallDate= # TODO (type = datetime) )
+ ux(LastModified= pywbem.CIMDateTime.fromtimestamp(stat[ST_MTIME]))
+ #ux(InUseCount= # TODO (type = uint64) )
+ #ux(EncryptionMethod= # TODO (type = string) )
+ ux(LastAccessed= pywbem.CIMDateTime.fromtimestamp(stat[ST_ATIME]))
+ ux(ElementName= model['name'] == '/' and '/' or \
+ os.path.basename(model['name']))
+ #ux(Caption= # TODO (type = string) )
+ ux(CreationDate= pywbem.CIMDateTime.fromtimestamp(stat[ST_CTIME]))
+ if model.classname.lower() == 'omc_linuxdevicefile':
+ if S_ISCHR(mode):
+ ux(DeviceFileType=3)
+ elif S_ISBLK(mode):
+ ux(DeviceFileType=2)
+ ux(DeviceId=str(stat.st_rdev))
+ ux(DeviceMajor=str(os.major(stat.st_rdev)))
+ ux(DeviceMinor=str(os.minor(stat.st_rdev)))
+ if model.classname.lower() == 'omc_linuxsymboliclink':
+ ux(TargetFile=os.readlink(model['name']))
+
return model
def enum_instances(self, env, model, cim_class, keys_only):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-24 23:39:45
|
Revision: 528
http://omc.svn.sourceforge.net/omc/?rev=528&view=rev
Author: bartw
Date: 2007-12-24 15:39:39 -0800 (Mon, 24 Dec 2007)
Log Message:
-----------
fixed the previous fix
Modified Paths:
--------------
pybase/trunk/OMC_UnixProcess.py
Modified: pybase/trunk/OMC_UnixProcess.py
===================================================================
--- pybase/trunk/OMC_UnixProcess.py 2007-12-24 23:39:00 UTC (rev 527)
+++ pybase/trunk/OMC_UnixProcess.py 2007-12-24 23:39:39 UTC (rev 528)
@@ -479,8 +479,7 @@
model['PercentCPU'] = pywbem.Real32(ps['percent_cpu'])
model['KernelModeTime'] = pywbem.Uint64(ps['kernel_mode_time'])
model['UserModeTime'] = pywbem.Uint64(ps['user_mode_time'])
- modpath = lp.get_module_path()
- model['ModulePath'] = lp.get_module_path()
+ model.update_existing(ModulePath=lp.get_module_path())
model['SharedMemorySize'] = pywbem.Uint64(_bytes2KB(ps['shared_mem_size']))
model['ResidentSetSize'] = pywbem.Uint64(_bytes2KB(ps['resident_set_size']))
cl = lp.get_command_line()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-24 23:39:23
|
Revision: 527
http://omc.svn.sourceforge.net/omc/?rev=527&view=rev
Author: bartw
Date: 2007-12-24 15:39:00 -0800 (Mon, 24 Dec 2007)
Log Message:
-----------
fixed typo
Modified Paths:
--------------
pybase/trunk/OMC_LogicalFile.mof
Modified: pybase/trunk/OMC_LogicalFile.mof
===================================================================
--- pybase/trunk/OMC_LogicalFile.mof 2007-12-24 23:38:11 UTC (rev 526)
+++ pybase/trunk/OMC_LogicalFile.mof 2007-12-24 23:39:00 UTC (rev 527)
@@ -84,7 +84,7 @@
};
//////////////////////////////////////////////////////////////////////////////
-[ Association, Aggregation, Composition, Abstrac, Version("0.0.1"),
+[ Association, Aggregation, Composition, Abstract, Version("0.0.1"),
Description("Specifies the hierarchical arrangement of LogicalFiles in a "
"Directory.")]
class OMC_DirectoryContainsFile : CIM_DirectoryContainsFile
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-24 23:38:26
|
Revision: 526
http://omc.svn.sourceforge.net/omc/?rev=526&view=rev
Author: bartw
Date: 2007-12-24 15:38:11 -0800 (Mon, 24 Dec 2007)
Log Message:
-----------
added UserContext to pegasus registration
Modified Paths:
--------------
pybase/trunk/OMC_InitdService-peg.reg
pybase/trunk/OMC_LogicalFile-peg.reg
pybase/trunk/OMC_OperatingSystem-peg.reg
pybase/trunk/OMC_SyslogNG-peg.reg
pybase/trunk/OMC_TimeService-peg.reg
pybase/trunk/OMC_UnitaryComputerSystem-peg.reg
pybase/trunk/OMC_UnixProcess-peg.reg
Modified: pybase/trunk/OMC_InitdService-peg.reg
===================================================================
--- pybase/trunk/OMC_InitdService-peg.reg 2007-12-21 20:56:40 UTC (rev 525)
+++ pybase/trunk/OMC_InitdService-peg.reg 2007-12-24 23:38:11 UTC (rev 526)
@@ -5,6 +5,7 @@
InterfaceType = "Python";
InterfaceVersion = "1.0.0";
Location = "/usr/lib/pycim/OMC_InitdService.py";
+ UserContext = 2; // Requestor
Vendor = "OMC";
Version = "0.1.0";
};
Modified: pybase/trunk/OMC_LogicalFile-peg.reg
===================================================================
--- pybase/trunk/OMC_LogicalFile-peg.reg 2007-12-21 20:56:40 UTC (rev 525)
+++ pybase/trunk/OMC_LogicalFile-peg.reg 2007-12-24 23:38:11 UTC (rev 526)
@@ -5,6 +5,7 @@
InterfaceType = "Python";
InterfaceVersion = "1.0.0";
Location = "/usr/lib/pycim/OMC_LogicalFile.py";
+ UserContext = 2; // Requestor
Vendor = "OMC";
Version = "0.1.0";
};
@@ -57,6 +58,16 @@
instance of PG_ProviderCapabilities
{
+ CapabilityID = "OMC_LinuxSocketFile";
+ ProviderModuleName = "/usr/lib/pycim/OMC_LogicalFile.py";
+ ProviderName = "OMC_LogicalFile";
+ ClassName = "OMC_LinuxSocketFile";
+ Namespaces = {"root/cimv2"};
+ ProviderType = {2}; // Instance
+};
+
+instance of PG_ProviderCapabilities
+{
CapabilityID = "OMC_LinuxDeviceFile";
ProviderModuleName = "/usr/lib/pycim/OMC_LogicalFile.py";
ProviderName = "OMC_LogicalFile";
Modified: pybase/trunk/OMC_OperatingSystem-peg.reg
===================================================================
--- pybase/trunk/OMC_OperatingSystem-peg.reg 2007-12-21 20:56:40 UTC (rev 525)
+++ pybase/trunk/OMC_OperatingSystem-peg.reg 2007-12-24 23:38:11 UTC (rev 526)
@@ -5,6 +5,7 @@
InterfaceType = "Python";
InterfaceVersion = "1.0.0";
Location = "/usr/lib/pycim/OMC_OperatingSystem.py";
+ UserContext = 2; // Requestor
Vendor = "OMC";
Version = "0.1.0";
};
Modified: pybase/trunk/OMC_SyslogNG-peg.reg
===================================================================
--- pybase/trunk/OMC_SyslogNG-peg.reg 2007-12-21 20:56:40 UTC (rev 525)
+++ pybase/trunk/OMC_SyslogNG-peg.reg 2007-12-24 23:38:11 UTC (rev 526)
@@ -5,6 +5,7 @@
InterfaceType = "Python";
InterfaceVersion = "1.0.0";
Location = "/usr/lib/pycim/OMC_SyslogNG.py";
+ UserContext = 2; // Requestor
Vendor = "OMC";
Version = "1.0";
};
Modified: pybase/trunk/OMC_TimeService-peg.reg
===================================================================
--- pybase/trunk/OMC_TimeService-peg.reg 2007-12-21 20:56:40 UTC (rev 525)
+++ pybase/trunk/OMC_TimeService-peg.reg 2007-12-24 23:38:11 UTC (rev 526)
@@ -4,6 +4,7 @@
InterfaceType = "Python";
InterfaceVersion = "1.0.0";
Location = "/usr/lib/pycim/OMC_TimeService.py";
+ UserContext = 2; // Requestor
Vendor = "OMC";
Version = "1.0";
};
Modified: pybase/trunk/OMC_UnitaryComputerSystem-peg.reg
===================================================================
--- pybase/trunk/OMC_UnitaryComputerSystem-peg.reg 2007-12-21 20:56:40 UTC (rev 525)
+++ pybase/trunk/OMC_UnitaryComputerSystem-peg.reg 2007-12-24 23:38:11 UTC (rev 526)
@@ -5,6 +5,7 @@
InterfaceType = "Python";
InterfaceVersion = "1.0.0";
Location = "/usr/lib/pycim/OMC_UnitaryComputerSystem.py";
+ UserContext = 2; // Requestor
Vendor = "OMC";
Version = "0.1.0";
};
Modified: pybase/trunk/OMC_UnixProcess-peg.reg
===================================================================
--- pybase/trunk/OMC_UnixProcess-peg.reg 2007-12-21 20:56:40 UTC (rev 525)
+++ pybase/trunk/OMC_UnixProcess-peg.reg 2007-12-24 23:38:11 UTC (rev 526)
@@ -5,6 +5,7 @@
InterfaceType = "Python";
InterfaceVersion = "1.0.0";
Location = "/usr/lib/pycim/OMC_UnixProcess.py";
+ UserContext = 2; // Requestor
Vendor = "OMC";
Version = "0.1.0";
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kwo...@us...> - 2007-12-21 20:56:39
|
Revision: 525
http://omc.svn.sourceforge.net/omc/?rev=525&view=rev
Author: kwoodson
Date: 2007-12-21 12:56:40 -0800 (Fri, 21 Dec 2007)
Log Message:
-----------
Updated tests but still needs work
Modified Paths:
--------------
test/trunk/omcbase_test.py
Modified: test/trunk/omcbase_test.py
===================================================================
--- test/trunk/omcbase_test.py 2007-12-21 20:37:06 UTC (rev 524)
+++ test/trunk/omcbase_test.py 2007-12-21 20:56:40 UTC (rev 525)
@@ -4,7 +4,9 @@
import optparse
import pywbem
import os
+import commands
+from lib import ProviderSanityTest as PST
from time import sleep
from socket import getfqdn
@@ -55,6 +57,20 @@
print('\t -- %s --' % msg)
else:
print('')
+
+ def _sanity_check(self, type, classname):
+ try:
+ print self._conn.default_namespace
+ if type == 'instance':
+ PST.instance_sanity_check(self, self._conn,
+ classname,
+ self._verbose)
+ else:
+ PST.association_sanity_check(self, self._conn,
+ classname,
+ self._verbose)
+ except:
+ raise
def _showMissingClassNotice(self, classname, testname):
self._dbgPrint("NOTICE: Skipping all %s tests for test %s: Class not loaded." % (classname, testname))
@@ -312,13 +328,47 @@
self._run_omcbase_component_tests('initd', initdClasses)
def test_syslogd(self):
+ #TODO
+ #FILL IN SYSLOGD test
pass
def test_logical_file(self):
- pass
+ '''OMC_LogicalFile'''
+ try:
+ #TODO Traverse a folder on filesystem and retrieve all of the
+ #LinuxDataFiles
+ #Get through GetInstance using keybindings since they are
+ #non-enumerable
+ #self._conn.GetInstance("OMC_LinuxdataFile")
+ pass
+ except pywbem.CIMError, arg:
+ raise
def test_operating_system(self):
- pass
+ '''OMC_OperatingSystem'''
+ if self._isSupportedAssn('OMC_OperatingSystem',
+ 'OMC_InstalledOS',
+ 'OMC_OSProcess',
+ 'os_test'):
+ os_classes = { 'OMC_InstalledOS': _omc_installed_os,
+ 'OMC_OSProcess': _omc_os_process }
+
+ #TODO Finish Filling out OMC_OperatingSystem
+ try:
+
+ os_list = self._conn.EnumerateInstanceNames("OMC_OperatingSystem")
+ self.failUnless(os_list > 0, \
+ "No instances of OperatingSystem returned")
+
+
+ os_list = self._conn.EnumerateInstances("OMC_OperatingSystem")
+ self.failUnless(os_list > 0, \
+ "No instances of OperatingSystem returned")
+
+ except pywbem.CIMError, arg:
+ raise
+ else:
+ self.fail("OMC_OperatingSystem _isSupportedAssn failed")
def test_unitary_computer_system(self):
ucsClasses = {'OMC_UnitaryComputerSystem' : self._omc_unitarycomputersystem_test,
@@ -326,13 +376,251 @@
'OMC_ComputerSystemHostNameSettingData' : self._omc_computersystemhostnamesettingdata_test}
self._run_omcbase_component_tests('unitary_computer_system', ucsClasses)
+ def _omc_process_executable(self):
+ '''OMC_ProcessExecutable'''
+ try:
+ #Can't do these because of OMC_LinuxDataFile is non-enumerable
+ print "OMC_ProcessExecutable"
+ self._sanity_check(type="association", \
+ classname="OMC_ProcessExecutable")
+ except pywbem.CIMError, arg:
+ raise
+ def _omc_os_process(self):
+ '''OMC_OSProcess'''
+ try:
+ #Can't do these because of OMC_LinuxDataFile is non-enumerable
+ print "OMC_OSProcess"
+ self._sanity_check(type="association", \
+ classname="OMC_OSProcess")
+ except pywbem.CIMError, arg:
+ raise
+
def test_unix_process(self):
- pass
+ '''UnixProcess'''
+ #process_classes = {
+ # 'OMC_ProcessExecutable': self._omc_process_executable,
+ # 'OMC_OSProcess': self._omc_os_process }
+
+ #for classname in process_classes.keys():
+ # if not self._isClassSupported(classname):
+ # #print "Not supported: %s"%str(classname)
+ # self._showMissingClassNotice(classname, 'process_test')
+ # else:
+ # #print "Calling: %s..."%str(time_classes[classname])
+ # process_classes[classname]()
+ #TODO Fill out OMC_UnixProcess
+ try:
+
+ cim_procs = self._conn.EnumerateInstances("OMC_UnixProcess")
+
+ procs = commands.getoutput("ls -d /proc/[0-9]*").split()
+
+ self.failUnless(procs or len(procs) < 1 or len(cim_procs) < 1 or\
+ cim_procs, "No processes returned")
+
+ self.failUnless(len(cim_procs) == len(procs)-1, \
+ "Returned a different number of processes")
+
+ proc_nums = {}
+ ci_proc = []
+ failed = []
+ for proc in procs:
+ proc_nums[proc[6:]]=proc
+ for proc in cim_procs:
+ ci_proc.append(proc['handle'])
+ print proc_nums
+ #Check the PID with cim_instance['handle']
+ for proc in proc_nums.keys():
+ if proc not in ci_proc:
+ failed.append(proc)
+
+ print "failed=",failed
+ #print "percentage=%s"%str(len(failed)/len(cim_procs))
+ print "proc_nums",proc_nums
+
+ for fail in failed:#Getting rid of the 'ls' process
+ del(proc_nums[fail])
+ for ci in cim_procs:#Check that ci['ModulePath'] is correct
+ #print "Checking ModulePath is not none"
+ #print ci['handle']
+ if ci['ModulePath'] and ci['ModulePath'] is not None:
+ path = proc_nums[ci['handle']]
+ #print "ci=",ci['ModulePath']
+ #print "link=",os.readlink(os.path.join(path,"exe"))
+ self.failUnless(ci['ModulePath'] == os.readlink(\
+ os.path.join(path, "exe")), \
+ "ModulePath is incorrect for %s"%str(ci['ModulePath']))
+
+ #TODO
+ #Fill in the following methods
+ #SendSignal
+ #RequestStateChange
+ #KillAll
+
+ except pywbem.CIMError, arg:
+ raise
+
+
+ def _omc_system_time_service(self):
+ '''SystemTimeService Test'''
+ try:
+
+ self._sanity_check(type="association",
+ classname="OMC_SystemTimeService")
+
+ ci = pywbem.CIMInstance("OMC_SystemTimeService")
+ ci['CreationClassName'] = "OMC_SystemTimeService"
+ ci['Name'] = "timeservice_test"
+ ci['SystemCreationClassName'] = "OMC_UnitaryComputerSystem"
+ ci['SystemName'] = "c119.cim.lab.novell.com"
+ ci['AvailableRequestedState'] = [ pywbem.Uint16(2) ]
+ ci['Caption'] = 'test'
+ ci['Description'] = 'test system time service'
+ ci['EnabledDefault'] = pywbem.Uint16(2)
+ ci['EnabledState'] = pywbem.Uint16(2)
+ ci['HealthState'] = pywbem.Uint16(5)
+ ci['StartMode'] = "Automatic"
+ ci['Started'] = True
+ ci['Status'] = "Ok"
+
+ try:
+ ci.path = self._conn.CreateInstance(ci)
+ self.fail("Created Instance when it was supposed to fail")
+ except pywbem.CIMError, arg:
+ #Should fail
+ self.failUnless(pywbem.CIM_ERR_NOT_SUPPORTED == arg[0],\
+ "Unknown Exception: %s"%str(arg))
+ try:
+ sts_list = self._conn.EnumerateInstanceNames(\
+ "OMC_SystemTimeService")
+ self.failUnless(len(sts_list)==1, \
+ "EnumInstNames: OMC_SystemTimeService: No instance returned")
+ ci_name = sts_list[0]
+ try:
+ self._conn.DeleteInstance(ci_name)
+ self.fail("Deleted Instance when it was supposed to fail")
+ except pywbem.CIMError, arg:
+ #Should fail
+ self.failUnless(pywbem.CIM_ERR_NOT_SUPPORTED == arg[0], \
+ "Unknown Exception: %s"%str(arg))
+ except pywbem.CIMError, arg:
+ raise
+ #ManageSystemTime
+ #SetTime/GetTime
+ c_time = pywbem.CIMDateTime.now()
+ test_time=pywbem.CIMDateTime('20121218141923.690382-420')
+ self._conn.InvokeMethod("ManageSystemTime", \
+ "OMC_SystemTimeService", \
+ GetRequest=False, TimeData=test_time.datetime)
+
+ mst_time = self._conn.InvokeMethod("ManageSystemTime", \
+ "OMC_SystemTimeService", \
+ GetRequest=True)
+ delta = mst_time[1]['TimeData'].datetime - test_time.datetime
+ self.failUnless(delta.days == 0, \
+ "ManageSystemTime: Time returned is incorrect")
+ self.failUnless(delta.seconds < _epsilon, \
+ "ManageSystemTime: Time returned is incorrect")
+
+ self._conn.InvokeMethod("ManageSystemTime", \
+ "OMC_SystemTimeService", \
+ GetRequest=False, TimeData=c_time.datetime)
+ #StartService
+ #StopService
+ #ManageTime
+ #ChangeAffectedElementsAssignedSequence
+ #These methods are not implemented under the C++ providers
+ #In the python provider, these throw the "CIM_ERR_NOT_SUPPORTED" exception
+
+ #try:
+ # self._conn.InvokeMethod("StopService", \
+ # "OMC_SystemTimeService")
+ #except pywbem.CIMError, arg:
+ # self.failUnless(pywbem.CIM_ERR_NOT_SUPPORTED == arg[0], \
+ # "Unexpected Exception: %s"%str(arg))
+ #try:
+ # self._conn.InvokeMethod("StartService", \
+ # "OMC_SystemTimeService")
+ #except pywbem.CIMError, arg:
+ # self.failUnless(pywbem.CIM_ERR_NOT_SUPPORTED == arg[0], \
+ # "Unexpected Exception: %s"%str(arg))
+ except pywbem.CIMError, arg:
+ raise
+
+ def _omc_hosted_time_service(self):
+ if self._isSupportedAssn('OMC_HostedTimeService',
+ 'OMC_UnitaryComputerSystem',
+ 'OMC_SystemTimeService',
+ 'h_time_test'):
+ try:
+ self._sanity_check(type="association",
+ classname="OMC_HostedTimeService")
+
+ except pywbem.CIMError, arg:
+ raise
+ else:
+ self.fail("HostedTimeService _isSupportedAssn failed")
+
+ def _omc_time_service_access_by_sap(self):
+ '''TimeServiceAccessBySap'''
+ try:
+ self._sanity_check(type="association",
+ classname="OMC_TimeServiceAccessBySAP")
+ except pywbem.CIMError, arg:
+ raise
+
+ def _omc_time_service_available_to_element(self):
+ '''TimeServiceAvailableToElement'''
+ try:
+ self._sanity_check(type="association",
+ classname="OMC_TimeServiceAvailableToElement")
+ except pywbem.CIMError, arg:
+ raise
+
+ def _omc_time_service_time_zone_setting_data(self):
+ '''TimeServiceTimeZoneSettingData'''
+ try:
+ tsate_nlist = self._conn.EnumerateInstanceNames(\
+ "OMC_TimeZoneSettingData")
+ self.failUnless(len(tsate_nlist) == 1, \
+ "TimeZoneSettingData returned no instance names")
+ tsate_ilist = self._conn.EnumerateInstances(\
+ "OMC_TimeZoneSettingData", LocalOnly=False)
+ self.failUnless(len(tsate_ilist) == 1, \
+ "TimeZoneSettingData returned no instances")
+ ci = tsate_ilist[0]
+ self.failUnless(ci['InstanceID'] == "omc:timezone",\
+ "TimeZoneSettingData InstanceID returned is incorrect")
+ self.failUnless(ci['TimeZone'] == "US/Mountain",\
+ "TimeZoneSettingData TimeZone returned is incorrect")
+
+
+ except pywbem.CIMError, arg:
+ raise
+
+
def test_time_service(self):
- pass
+ '''Test Time Services'''
+ #return
+ time_classes = {
+ 'OMC_SystemTimeService': self._omc_system_time_service,
+ 'OMC_HostedTimeService': self._omc_hosted_time_service, #assoc
+ 'OMC_TimeServiceAccessBySAP': self._omc_time_service_access_by_sap, #assoc
+ 'OMC_TimeServiceAvailableToElement': \
+ self._omc_time_service_available_to_element, #assoc
+ 'OMC_TimeServiceTimeZoneSettingData': \
+ self._omc_time_service_time_zone_setting_data } #assoc
+ for classname in time_classes.keys():
+ if not self._isClassSupported(classname):
+ #print "Not supported: %s"%str(classname)
+ self._showMissingClassNotice(classname, 'h_time_tested')
+ else:
+ #print "Calling: %s..."%str(time_classes[classname])
+ time_classes[classname]()
+
if __name__ == '__main__':
parser = optparse.OptionParser()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-21 20:37:03
|
Revision: 524
http://omc.svn.sourceforge.net/omc/?rev=524&view=rev
Author: bartw
Date: 2007-12-21 12:37:06 -0800 (Fri, 21 Dec 2007)
Log Message:
-----------
some fixes
Modified Paths:
--------------
pybase/trunk/OMC_OperatingSystem.py
pybase/trunk/OMC_UnixProcess.py
pybase/trunk/omc-pybase-providers.spec
Modified: pybase/trunk/OMC_OperatingSystem.py
===================================================================
--- pybase/trunk/OMC_OperatingSystem.py 2007-12-19 00:03:20 UTC (rev 523)
+++ pybase/trunk/OMC_OperatingSystem.py 2007-12-21 20:37:06 UTC (rev 524)
@@ -109,7 +109,7 @@
uex(Description = version)
uex(Caption = version)
fo.close()
- install_time = Popen(['rpm', '-qf','/etc/SuSE-release',
+ install_time = Popen(['/bin/rpm', '-qf','/etc/SuSE-release',
'--queryformat','%{INSTALLTIME}'],
stdout=PIPE).communicate()[0]
uex(InstallDate = pywbem.CIMDateTime.fromtimestamp(int(install_time)))
Modified: pybase/trunk/OMC_UnixProcess.py
===================================================================
--- pybase/trunk/OMC_UnixProcess.py 2007-12-19 00:03:20 UTC (rev 523)
+++ pybase/trunk/OMC_UnixProcess.py 2007-12-21 20:37:06 UTC (rev 524)
@@ -306,7 +306,7 @@
try:
s = os.readlink('/proc/%d/exe' % self.pid)
except:
- return ''
+ return None
return s
def get_exec_name(self):
@@ -479,9 +479,8 @@
model['PercentCPU'] = pywbem.Real32(ps['percent_cpu'])
model['KernelModeTime'] = pywbem.Uint64(ps['kernel_mode_time'])
model['UserModeTime'] = pywbem.Uint64(ps['user_mode_time'])
- modpath = lp.get_module_path();
- if modpath:
- model['ModulePath'] = modpath
+ modpath = lp.get_module_path()
+ model['ModulePath'] = lp.get_module_path()
model['SharedMemorySize'] = pywbem.Uint64(_bytes2KB(ps['shared_mem_size']))
model['ResidentSetSize'] = pywbem.Uint64(_bytes2KB(ps['resident_set_size']))
cl = lp.get_command_line()
@@ -813,7 +812,7 @@
logger.log_debug('Entering %s.enum_instances()' \
% self.__class__.__name__)
for lp in LinuxProcess.procs():
- model['Dependent'] = lp.get_instance_name(cim_class.namespace)
+ model['Dependent'] = lp.get_instance_name(model.path.namespace)
fname = lp.get_module_path()
if fname:
model['Antecedent'] = OMC_LogicalFile.get_file_path(fname)
Modified: pybase/trunk/omc-pybase-providers.spec
===================================================================
--- pybase/trunk/omc-pybase-providers.spec 2007-12-19 00:03:20 UTC (rev 523)
+++ pybase/trunk/omc-pybase-providers.spec 2007-12-21 20:37:06 UTC (rev 524)
@@ -19,9 +19,9 @@
License: BSD
URL: http://omc-project.org/
BuildArch: noarch
-Source0: %{name}-%{version}.tar.gz
-PreReq: /usr/bin/loadmof.sh
-Requires: python-pywbem pyprovifc>=1.0.0
+Source0: %{name}-%{version}.tar.gz
+PreReq: /usr/bin/loadmof.sh
+Requires: python-pywbem, pyprovifc >= 1.0.0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-19 00:03:15
|
Revision: 523
http://omc.svn.sourceforge.net/omc/?rev=523&view=rev
Author: jcarey
Date: 2007-12-18 16:03:20 -0800 (Tue, 18 Dec 2007)
Log Message:
-----------
Operating System finished
Modified Paths:
--------------
pybase/trunk/OMC_OperatingSystem.mof
pybase/trunk/OMC_OperatingSystem.py
pybase/trunk/OMC_UnitaryComputerSystem.mof
pybase/trunk/OMC_UnixProcess.mof
Modified: pybase/trunk/OMC_OperatingSystem.mof
===================================================================
--- pybase/trunk/OMC_OperatingSystem.mof 2007-12-18 23:37:41 UTC (rev 522)
+++ pybase/trunk/OMC_OperatingSystem.mof 2007-12-19 00:03:20 UTC (rev 523)
@@ -34,7 +34,7 @@
"At most one OperatingSystem can execute at any time on a "
"ComputerSystem. 'At most one' is specified, since the Computer "
"System may not be currently booted, or its OperatingSystem may "
- "be unknown.", Version("0.0.1") ]
+ "be unknown."), Version("0.0.1") ]
class OMC_RunningOS : CIM_RunningOS
{
[Override ( "Antecedent" ), Max ( 1 ), Description (
@@ -44,26 +44,26 @@
[Override ( "Dependent" ), Max ( 1 ), Description (
"The ComputerSystem.")]
- CIM_ComputerSystem REF Dependent;
+ OMC_UnitaryComputerSystem REF Dependent;
};
// ===================================================================
// InstalledOS
// ===================================================================
- [Association, Aggregation, Composition, Version ( "2.7.0" ),
+ [Association, Aggregation, Composition, Version ( "0.0.2" ),
Description (
"A link between the ComputerSystem and the OperatingSystem(s) "
"installed or loaded on it. An OperatingSystem is 'installed' "
"on a ComputerSystem, when placed on one of its StorageExtents "
"- for example, copied to a disk drive or downloaded to Memory. "
"Using this definition, an OperatingSystem is 'installed' on a "
- "NetPC when downloaded via the network.", Version("0.0.1") ]
+ "NetPC when downloaded via the network.")]
class OMC_InstalledOS : CIM_InstalledOS
{
[Aggregate, Override ( "GroupComponent" ), Min ( 1 ), Max ( 1 ),
Description (
"The ComputerSystem.")]
- CIM_ComputerSystem REF GroupComponent;
+ OMC_UnitaryComputerSystem REF GroupComponent;
[Override ( "PartComponent" ), Weak, Description (
"The OperatingSystem installed on the ComputerSystem.")]
Modified: pybase/trunk/OMC_OperatingSystem.py
===================================================================
--- pybase/trunk/OMC_OperatingSystem.py 2007-12-18 23:37:41 UTC (rev 522)
+++ pybase/trunk/OMC_OperatingSystem.py 2007-12-19 00:03:20 UTC (rev 523)
@@ -440,29 +440,6 @@
"""
def get_instance(self, env, model, cim_class):
- """Return an instance.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- model -- A template of the pywbem.CIMInstance to be returned. The
- key properties are set on this instance to correspond to the
- instanceName that was requested. The properties of the model
- are already filtered according to the PropertyList from the
- request. Only properties present in the model need to be
- given values. If you prefer, you can set all of the
- values, and the instance will be filtered for you.
- cim_class -- The pywbem.CIMClass
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
- Instance does not exist in the specified namespace)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
% self.__class__.__name__)
@@ -471,29 +448,6 @@
return model
def enum_instances(self, env, model, cim_class, keys_only):
- """Enumerate instances.
-
- The WBEM operations EnumerateInstances and EnumerateInstanceNames
- are both mapped to this method.
- This method is a python generator
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- model -- A template of the pywbem.CIMInstances to be generated.
- The properties of the model are already filtered according to
- the PropertyList from the request. Only properties present in
- the model need to be given values. If you prefer, you can
- always set all of the values, and the instance will be filtered
- for you.
- cim_class -- The pywbem.CIMClass
- keys_only -- A boolean. True if only the key properties should be
- set on the generated instances.
-
- Possible Errors:
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.enum_instances()' \
% self.__class__.__name__)
@@ -514,115 +468,13 @@
raise
def set_instance(self, env, instance, previous_instance, cim_class):
- """Return a newly created or modified instance.
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance -- The new pywbem.CIMInstance. If modifying an existing
- instance, the properties on this instance have been filtered by
- the PropertyList from the request.
- previous_instance -- The previous pywbem.CIMInstance if modifying
- an existing instance. None if creating a new instance.
- cim_class -- The pywbem.CIMClass
-
- Return the new instance. The keys must be set on the new instance.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only
- valid if previous_instance is None, indicating that the operation
- was CreateInstance)
- CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid
- if previous_instance is not None, indicating that the operation
- was ModifyInstance)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
- logger = env.get_logger()
- logger.log_debug('Entering %s.set_instance()' \
- % self.__class__.__name__)
- # TODO create or modify the instance
- raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
- return instance
-
def delete_instance(self, env, instance_name):
- """Delete an instance.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance_name -- A pywbem.CIMInstanceName specifying the instance
- to delete.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_NAMESPACE
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified
- namespace)
- CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
- Instance does not exist in the specified namespace)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
- logger = env.get_logger()
- logger.log_debug('Entering %s.delete_instance()' \
- % self.__class__.__name__)
-
- # TODO delete the resource
- raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
def references(self, env, object_name, model, assoc_class,
result_class_name, role, result_role, keys_only):
- """Instrument Associations.
-
- All four association-related operations (Associators, AssociatorNames,
- References, ReferenceNames) are mapped to this method.
- This method is a python generator
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- object_name -- A pywbem.CIMInstanceName that defines the source
- CIM Object whose associated Objects are to be returned.
- model -- A template pywbem.CIMInstance to serve as a model
- of the objects to be returned. Only properties present on this
- model need to be set.
- assoc_class -- The pywbem.CIMClass.
- result_class_name -- If not None, this string acts as a filter on
- the returned set of Objects by mandating that each returned
- Object MUST be either an Instance of this Class (or one of its
- subclasses) or be this Class (or one of its subclasses).
- role -- If not None, this string acts as a filter on the returned
- set of Objects by mandating that each returned Object MUST be
- associated to the source Object via an Association in which the
- source Object plays the specified role (i.e. the name of the
- Property in the Association Class that refers to the source
- Object MUST match the value of this parameter).
- result_role -- If not None this string acts as a filter on the
- returned set of Objects by mandating that each returned Object
- MUST be associated to the source Object via an Association in
- which the returned Object plays the specified role (i.e. the
- name of the Property in the Association Class that refers to
- the returned Object MUST match the value of this parameter).
- keys_only -- A boolean. True if only the key properties should be
- set on the generated instances.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_NAMESPACE
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.references()' \
% self.__class__.__name__)
Modified: pybase/trunk/OMC_UnitaryComputerSystem.mof
===================================================================
--- pybase/trunk/OMC_UnitaryComputerSystem.mof 2007-12-18 23:37:41 UTC (rev 522)
+++ pybase/trunk/OMC_UnitaryComputerSystem.mof 2007-12-19 00:03:20 UTC (rev 523)
@@ -17,9 +17,9 @@
};
//////////////////////////////////////////////////////////////////////////////
-[ Association, Version ( "2.7.0" ),
+[ Association, Version ( "0.0.1" ),
Description ("OMC_ComputerSystemSettingData is associates "
- " the computer name setting with the computer system"), Version("0.0.1") ]
+ " the computer name setting with the computer system")]
class OMC_ComputerSystemHostNameSettingData : CIM_ElementSettingData
{
[ Override("ManagedElement"), Key,
Modified: pybase/trunk/OMC_UnixProcess.mof
===================================================================
--- pybase/trunk/OMC_UnixProcess.mof 2007-12-18 23:37:41 UTC (rev 522)
+++ pybase/trunk/OMC_UnixProcess.mof 2007-12-19 00:03:20 UTC (rev 523)
@@ -21,7 +21,7 @@
//////////////////////////////////////////////////////////////////////////////
[ Association, Aggregation, Composition, Version ( "2.7.0" ),
Description ("A link between the OperatingSystem and Process(es) "
- "running in the context of this OperatingSystem."), Version("0.0.1") ]
+ "running in the context of this OperatingSystem.")]
class OMC_OSProcess : CIM_OSProcess
{
[Aggregate, Override ( "GroupComponent" ), Min ( 1 ), Max ( 1 ),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-18 23:37:44
|
Revision: 522
http://omc.svn.sourceforge.net/omc/?rev=522&view=rev
Author: jcarey
Date: 2007-12-18 15:37:41 -0800 (Tue, 18 Dec 2007)
Log Message:
-----------
Changed methods to only allow root...
Modified Paths:
--------------
pybase/trunk/OMC_OperatingSystem.py
Modified: pybase/trunk/OMC_OperatingSystem.py
===================================================================
--- pybase/trunk/OMC_OperatingSystem.py 2007-12-18 23:35:00 UTC (rev 521)
+++ pybase/trunk/OMC_OperatingSystem.py 2007-12-18 23:37:41 UTC (rev 522)
@@ -177,60 +177,11 @@
def cim_method_requeststatechange(self, env, object_name, method,
param_requestedstate,
param_timeoutperiod):
- """Implements OMC_OperatingSystem.RequestStateChange()
-
- Requests that the state of the element be changed to the value
- specified in the RequestedState parameter. When the requested
- state change takes place, the EnabledState and RequestedState of
- the element will be the same. Invoking the RequestStateChange
- method multiple times could result in earlier requests being
- overwritten or lost. If 0 is returned, then the task completed
- successfully and the use of ConcreteJob was not required. If 4096
- (0x1000) is returned, then the task will take some time to
- complete, ConcreteJob will be created, and its reference returned
- in the output parameter Job. Any other return code indicates an
- error condition.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName
- specifying the object on which the method RequestStateChange()
- should be invoked.
- method -- A pywbem.CIMMethod representing the method meta-data
- param_requestedstate -- The input parameter RequestedState (type pywbem.Uint16 self.Values.RequestStateChange.RequestedState)
- The state requested for the element. This information will be
- placed into the RequestedState property of the instance if the
- return code of the RequestStateChange method is 0 ('Completed
- with No Error'), 3 ('Timeout'), or 4096 (0x1000) ('Job
- Started'). Refer to the description of the EnabledState and
- RequestedState properties for the detailed explanations of the
- RequestedState values.
-
- param_timeoutperiod -- The input parameter TimeoutPeriod (type pywbem.CIMDateTime)
- A timeout period that specifies the maximum amount of time that
- the client expects the transition to the new state to take.
- The interval format must be used to specify the TimeoutPeriod.
- A value of 0 or a null parameter indicates that the client has
- no time requirements for the transition. If this property
- does not contain 0 or null and the implementation does not
- support this parameter, a return code of 'Use Of Timeout
- Parameter Not Supported' must be returned.
-
-
- Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.RequestStateChange)
- and a dictionary with the out-parameters
-
- Output parameters:
- Job -- (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...))
- Reference to the job (can be null if the task is completed).
-
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.cim_method_requeststatechange()' \
% self.__class__.__name__)
-
+ if os.geteuid() != 0:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
rstate = int(param_requestedstate)
if rstate == 3: # Disable
logger.log_info('OS Disabled State Requested. Shutting Down now...')
@@ -261,32 +212,11 @@
return (pywbem.Uint32(1), {})
def cim_method_reboot(self, env, object_name, method):
- """Implements OMC_OperatingSystem.Reboot()
-
- Requests a reboot of the OperatingSystem. The return value should
- be 0 if the request was successfully executed, 1 if the request is
- not supported and some other value if an error occurred. In a
- subclass, the set of possible return codes could be specified,
- using a ValueMap qualifier on the method. The strings to which the
- ValueMap contents are 'translated' may also be specified in the
- subclass as a Values array qualifier.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName
- specifying the object on which the method Reboot()
- should be invoked.
- method -- A pywbem.CIMMethod representing the method meta-data
-
- Returns a two-tuple containing the return value (type pywbem.Uint32)
- and a dictionary with the out-parameters
-
- Output parameters: none
-
- """
logger = env.get_logger()
logger.log_debug('Entering %s.cim_method_reboot()' \
% self.__class__.__name__)
+ if os.geteuid() != 0:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
logger.log_info('OMC_OperatingSystem.reboot called. '
'Rebooting system now')
if os.system('/sbin/shutdown -r now'):
@@ -294,38 +224,11 @@
return ('Success', {})
def cim_method_shutdown(self, env, object_name, method):
- """Implements OMC_OperatingSystem.Shutdown()
-
- Requests a shutdown of the OperatingSystem. The return value should
- be 0 if the request was successfully executed, 1 if the request is
- not supported and some other value if an error occurred. It is up
- to the implementation or subclass of OperatingSystem to establish
- dependencies between the Shutdown and Reboot methods, and for
- example, to provide more sophisticated capabilities such as
- scheduled shutdown/ reboot, etc. In a subclass, the set of
- possible return codes could be specified, using a ValueMap
- qualifier on the method. The strings to which the ValueMap
- contents are 'translated' may also be specified in the subclass as
- a Values array qualifier.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName
- specifying the object on which the method Shutdown()
- should be invoked.
- method -- A pywbem.CIMMethod representing the method meta-data
-
- Returns a two-tuple containing the return value (type pywbem.Uint32)
- and a dictionary with the out-parameters
-
- Output parameters: none
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.cim_method_shutdown()' \
% self.__class__.__name__)
-
+ if os.geteuid() != 0:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
logger.log_info('OMC_OperatingSystem.shutdown called. '
'shutdown system now')
if os.system('/sbin/shutdown -h now'):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-18 23:35:02
|
Revision: 521
http://omc.svn.sourceforge.net/omc/?rev=521&view=rev
Author: jcarey
Date: 2007-12-18 15:35:00 -0800 (Tue, 18 Dec 2007)
Log Message:
-----------
Filled remaining properties of the Operating system class and implemented the extrinsic methods
Modified Paths:
--------------
pybase/trunk/OMC_OperatingSystem.py
pybase/trunk/OMC_TimeService.mof
Modified: pybase/trunk/OMC_OperatingSystem.py
===================================================================
--- pybase/trunk/OMC_OperatingSystem.py 2007-12-18 20:40:49 UTC (rev 520)
+++ pybase/trunk/OMC_OperatingSystem.py 2007-12-18 23:35:00 UTC (rev 521)
@@ -37,10 +37,21 @@
import pywbem
from pywbem import CIMProvider
from socket import getfqdn
-import os
+import resource
+import os,sys
import time
from subprocess import Popen, PIPE
+import traceback
+def _get_max_number_of_processes():
+ cc = 0
+ try:
+ f = open('/proc/sys/fs/file-max')
+ cc = int(f.readline())
+ except:
+ pass
+ return cc
+
def get_os_path(ns):
return pywbem.CIMInstanceName(classname='OMC_OperatingSystem',
namespace=ns,
@@ -53,33 +64,9 @@
"""Instrument the CIM class OMC_OperatingSystem
OMC Operating System
-
"""
def get_instance(self, env, model, cim_class):
- """Return an instance.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- model -- A template of the pywbem.CIMInstance to be returned. The
- key properties are set on this instance to correspond to the
- instanceName that was requested. The properties of the model
- are already filtered according to the PropertyList from the
- request. Only properties present in the model need to be
- given values. If you prefer, you can set all of the
- values, and the instance will be filtered for you.
- cim_class -- The pywbem.CIMClass
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
- Instance does not exist in the specified namespace)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
% self.__class__.__name__)
@@ -100,11 +87,14 @@
uex(TotalVisibleMemorySize = pywbem.Uint64(meminfo['MemTotal']))
uex(TotalVirtualMemorySize = pywbem.Uint64(meminfo['MemTotal'] +
meminfo['SwapTotal']))
+ uex(FreeSpaceInPagingFiles = pywbem.Uint64(int(meminfo['SwapFree']) / 1024))
+ uex(SizeStoredInPagingFiles = pywbem.Uint64(meminfo['SwapTotal']/1024))
fnames = os.listdir('/proc')
numprocs = len([x for x in fnames if x.isdigit()])
uex(NumberOfProcesses = pywbem.Uint32(numprocs))
- uex(CurrentTimeZone = pywbem.Sint16(time.timezone / 60))
+ uex(CurrentTimeZone = pywbem.Sint16(
+ (time.mktime(time.localtime()) - time.mktime(time.gmtime())) / 60))
uex(LocalDateTime = pywbem.CIMDateTime.now())
fo = open('/proc/uptime', 'r')
@@ -128,48 +118,37 @@
uex(Distributed = True)
#model['EnabledDefault'] = # TODO (type = pywbem.Uint16 self.Values.EnabledDefault) (default=2L)
uex(EnabledState = self.Values.EnabledState.Enabled)
- #model['FreeSpaceInPagingFiles'] = # TODO (type = pywbem.Uint64)
uex(HealthState = self.Values.HealthState.OK)
- #model['MaxNumberOfProcesses'] = # TODO (type = pywbem.Uint32)
- #model['MaxProcessesPerUser'] = # TODO (type = pywbem.Uint32)
- #model['MaxProcessMemorySize'] = # TODO (type = pywbem.Uint64)
- #model['NumberOfLicensedUsers'] = # TODO (type = pywbem.Uint32)
- #model['NumberOfUsers'] = # TODO (type = pywbem.Uint32)
+ model['MaxNumberOfProcesses'] = pywbem.Uint32(_get_max_number_of_processes())
+
+ wk = resource.getrlimit(resource.RLIMIT_DATA)[1]
+ if int(wk) < 0:
+ wk = 0
+ uex(MaxProcessMemorySize = pywbem.Uint64(int(wk)/1024))
+
+ wk = resource.getrlimit(resource.RLIMIT_NPROC)[1]
+ if int(wk) < 0:
+ wk = 0
+ uex(MaxProcessesPerUser = pywbem.Uint32(wk))
+ uex(NumberOfLicensedUsers = pywbem.Uint32(0))
+
+ try:
+ l = Popen([r'/usr/bin/who','-u'], stdout=PIPE).communicate()[0]
+ uex(NumberOfUsers = pywbem.Uint32(len(l.split('\n'))))
+ except:
+ uex(NumberOfUsers = pywbem.Uint32(0))
+
uex(OperationalStatus = [self.Values.OperationalStatus.OK])
uex(OSType = self.Values.OSType.LINUX)
#model['OtherEnabledState'] = # TODO (type = unicode)
#model['OtherTypeDescription'] = # TODO (type = unicode)
#model['RequestedState'] = # TODO (type = pywbem.Uint16 self.Values.RequestedState) (default=12L)
- #model['SizeStoredInPagingFiles'] = # TODO (type = pywbem.Uint64)
#model['Status'] = # TODO (type = unicode self.Values.Status)
#model['StatusDescriptions'] = # TODO (type = [unicode,])
#model['TimeOfLastStateChange'] = # TODO (type = pywbem.CIMDateTime)
return model
def enum_instances(self, env, model, cim_class, keys_only):
- """Enumerate instances.
-
- The WBEM operations EnumerateInstances and EnumerateInstanceNames
- are both mapped to this method.
- This method is a python generator
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- model -- A template of the pywbem.CIMInstances to be generated.
- The properties of the model are already filtered according to
- the PropertyList from the request. Only properties present in
- the model need to be given values. If you prefer, you can
- always set all of the values, and the instance will be filtered
- for you.
- cim_class -- The pywbem.CIMClass
- keys_only -- A boolean. True if only the key properties should be
- set on the generated instances.
-
- Possible Errors:
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.enum_instances()' \
% self.__class__.__name__)
@@ -190,69 +169,10 @@
raise
def set_instance(self, env, instance, previous_instance, cim_class):
- """Return a newly created or modified instance.
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance -- The new pywbem.CIMInstance. If modifying an existing
- instance, the properties on this instance have been filtered by
- the PropertyList from the request.
- previous_instance -- The previous pywbem.CIMInstance if modifying
- an existing instance. None if creating a new instance.
- cim_class -- The pywbem.CIMClass
-
- Return the new instance. The keys must be set on the new instance.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only
- valid if previous_instance is None, indicating that the operation
- was CreateInstance)
- CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid
- if previous_instance is not None, indicating that the operation
- was ModifyInstance)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
- logger = env.get_logger()
- logger.log_debug('Entering %s.set_instance()' \
- % self.__class__.__name__)
- # TODO create or modify the instance
- raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
- return instance
-
def delete_instance(self, env, instance_name):
- """Delete an instance.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance_name -- A pywbem.CIMInstanceName specifying the instance
- to delete.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_NAMESPACE
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified
- namespace)
- CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
- Instance does not exist in the specified namespace)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
- logger = env.get_logger()
- logger.log_debug('Entering %s.delete_instance()' \
- % self.__class__.__name__)
-
- # TODO delete the resource
- raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
def cim_method_requeststatechange(self, env, object_name, method,
param_requestedstate,
@@ -311,12 +231,34 @@
logger.log_debug('Entering %s.cim_method_requeststatechange()' \
% self.__class__.__name__)
- # TODO do something
- raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented
- out_params = {}
- #out_params['job'] = # TODO (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...))
- rval = None # TODO (type pywbem.Uint32 self.Values.RequestStateChange)
- return (rval, out_params)
+ rstate = int(param_requestedstate)
+ if rstate == 3: # Disable
+ logger.log_info('OS Disabled State Requested. Shutting Down now...')
+ if os.system('/sbin/shutdown -h now'):
+ return (pywbem.Uint32(4), {})
+ return (pywbem.Uint32(0), {})
+ elif rstate == 4: # Shutdown
+ logger.log_info('OS Shutdown State Requested. Shutting Down now...')
+ if os.system('/sbin/shutdown -h now'):
+ return (pywbem.Uint32(4), {})
+ return (pywbem.Uint32(0), {})
+ elif rstate == 6: # Offline
+ logger.log_info('OS Offline State Requested. Shutting Down now...')
+ if os.system('/sbin/shutdown -h now'):
+ return (pywbem.Uint32(4), {})
+ return (pywbem.Uint32(0), {})
+ elif rstate == 10: # Reboot
+ logger.log_info('OS Reboot State Requested. Rebooting now...')
+ if os.system('/sbin/shutdown -r now'):
+ return (pywbem.Uint32(4), {})
+ return (pywbem.Uint32(0), {})
+ elif rstate == 11: # Reset
+ logger.log_info('OS Reset State Requested. Rebooting now...')
+ if os.system('/sbin/shutdown -r now'):
+ return (pywbem.Uint32(4), {})
+ return (pywbem.Uint32(0), {})
+ # Return 'not supported'
+ return (pywbem.Uint32(1), {})
def cim_method_reboot(self, env, object_name, method):
"""Implements OMC_OperatingSystem.Reboot()
@@ -342,16 +284,14 @@
Output parameters: none
"""
-
logger = env.get_logger()
logger.log_debug('Entering %s.cim_method_reboot()' \
% self.__class__.__name__)
-
- # TODO do something
- raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented
- out_params = {}
- rval = None # TODO (type pywbem.Uint32)
- return (rval, out_params)
+ logger.log_info('OMC_OperatingSystem.reboot called. '
+ 'Rebooting system now')
+ if os.system('/sbin/shutdown -r now'):
+ return ('Fail', {})
+ return ('Success', {})
def cim_method_shutdown(self, env, object_name, method):
"""Implements OMC_OperatingSystem.Shutdown()
@@ -386,11 +326,11 @@
logger.log_debug('Entering %s.cim_method_shutdown()' \
% self.__class__.__name__)
- # TODO do something
- raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented
- out_params = {}
- rval = None # TODO (type pywbem.Uint32)
- return (rval, out_params)
+ logger.log_info('OMC_OperatingSystem.shutdown called. '
+ 'shutdown system now')
+ if os.system('/sbin/shutdown -h now'):
+ return ('Fail', {})
+ return ('Success', {})
class Values(object):
class Status(object):
Modified: pybase/trunk/OMC_TimeService.mof
===================================================================
--- pybase/trunk/OMC_TimeService.mof 2007-12-18 20:40:49 UTC (rev 520)
+++ pybase/trunk/OMC_TimeService.mof 2007-12-18 23:35:00 UTC (rev 521)
@@ -140,7 +140,7 @@
[ Key, Description(
"InstanceID is the key field inherited from CIM_SettingData. "
"Since there is only one instance of this class, the key "
- "value is 'OMC:SUSE:TIMEZONE'") ]
+ "value is 'omc:timezone'") ]
string InstanceID;
[ Required(true), Description("The time zone"),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-18 20:40:44
|
Revision: 520
http://omc.svn.sourceforge.net/omc/?rev=520&view=rev
Author: jcarey
Date: 2007-12-18 12:40:49 -0800 (Tue, 18 Dec 2007)
Log Message:
-----------
Added version quals to classes
Modified Paths:
--------------
pybase/trunk/OMC_InitdService.mof
pybase/trunk/OMC_LogicalFile.mof
pybase/trunk/OMC_OperatingSystem.mof
pybase/trunk/OMC_TimeService.mof
pybase/trunk/OMC_UnitaryComputerSystem.mof
pybase/trunk/OMC_UnixProcess.mof
Modified: pybase/trunk/OMC_InitdService.mof
===================================================================
--- pybase/trunk/OMC_InitdService.mof 2007-12-18 18:58:52 UTC (rev 519)
+++ pybase/trunk/OMC_InitdService.mof 2007-12-18 20:40:49 UTC (rev 520)
@@ -1,6 +1,6 @@
#pragma locale ("en_US")
-[ Description (
+[ Version("0.0.1"), Description (
"OMC_InitdService represents the function of a system init script "
"found in the /etc/init.d directory. The Name field in this class will "
"be the name of the script. The provider of this class knows nothing "
@@ -98,7 +98,7 @@
};
-[ Description("OMC_Runlevel represents a runlevel on a system, which is a collection of "
+[ Version("0.0.1"), Description("OMC_Runlevel represents a runlevel on a system, which is a collection of "
"init scripts, in this case, a collection of OMC_InitdService objects")]
class OMC_Runlevel : CIM_CollectionOfMSEs
{
@@ -143,7 +143,7 @@
-[ Association,
+[ Association, Version("0.0.1"),
Description(
"OMC_HostedInitdService associates the init.d service to the computer system.") ]
class OMC_HostedInitdService : CIM_HostedService
@@ -158,7 +158,7 @@
};
-[ Association,
+[ Association, Version("0.0.1"),
Description(
"OMC_RunlevelInComputerSystem associates a OMC_Runlevel to its computer system.") ]
class OMC_RunlevelInComputerSystem : CIM_HostedDependency
@@ -173,7 +173,7 @@
};
-[ Association,
+[ Association, Version("0.0.1"),
Description(
"OMC_InitdServiceRunlevel associates a OMC_Runlevel to its services.") ]
class OMC_InitdServiceRunlevel : CIM_CollectedMSEs
Modified: pybase/trunk/OMC_LogicalFile.mof
===================================================================
--- pybase/trunk/OMC_LogicalFile.mof 2007-12-18 18:58:52 UTC (rev 519)
+++ pybase/trunk/OMC_LogicalFile.mof 2007-12-18 20:40:49 UTC (rev 520)
@@ -30,7 +30,7 @@
#pragma locale ("en_US")
//////////////////////////////////////////////////////////////////////////////
-[ Abstract ]
+[ Abstract, Version("0.0.1") ]
class OMC_DataFile : CIM_DataFile
{
sint32 append([IN(true), OUT(false), REQUIRED(true)] string newtext);
@@ -39,37 +39,37 @@
};
//////////////////////////////////////////////////////////////////////////////
-[ Abstract ]
+[ Abstract, Version("0.0.1") ]
class OMC_UnixDeviceFile : CIM_UnixDeviceFile
{
};
//////////////////////////////////////////////////////////////////////////////
-[ Abstract ]
+[ Abstract, Version("0.0.1") ]
class OMC_SymbolicLink : CIM_SymbolicLink
{
};
//////////////////////////////////////////////////////////////////////////////
-[ Abstract ]
+[ Abstract, Version("0.0.1") ]
class OMC_UnixDirectory : CIM_UnixDirectory
{
};
//////////////////////////////////////////////////////////////////////////////
-[ Abstract ]
+[ Abstract, Version("0.0.1") ]
class OMC_UnixSocketFile : CIM_LogicalFile
{
};
//////////////////////////////////////////////////////////////////////////////
-[ Abstract ]
+[ Abstract, Version("0.0.1") ]
class OMC_FIFOPipeFile : CIM_FIFOPipeFile
{
};
//////////////////////////////////////////////////////////////////////////////
-[ Abstract ]
+[ Abstract, Version("0.0.1") ]
class OMC_UnixFile : CIM_UnixFile
{
boolean UserReadable;
@@ -84,7 +84,7 @@
};
//////////////////////////////////////////////////////////////////////////////
-[ Association, Aggregation, Composition, Abstract,
+[ Association, Aggregation, Composition, Abstrac, Version("0.0.1"),
Description("Specifies the hierarchical arrangement of LogicalFiles in a "
"Directory.")]
class OMC_DirectoryContainsFile : CIM_DirectoryContainsFile
@@ -99,7 +99,7 @@
};
//////////////////////////////////////////////////////////////////////////////
-[ Association, Abstract, Description (
+[ Association, Abstract, Version("0.0.1"), Description (
"CIM_FileIdentity indicates that a UnixFile describes Unix-"
"specific aspects of the various subclasses of LogicalFile. "
"The association exists since it forces UnixFile to be "
@@ -119,42 +119,49 @@
};
//////////////////////////////////////////////////////////////////////////////
+[ Version("0.0.1") ]
class OMC_LinuxDataFile : OMC_DataFile
{
};
//////////////////////////////////////////////////////////////////////////////
+[ Version("0.0.1") ]
class OMC_LinuxDeviceFile : OMC_UnixDeviceFile
{
};
//////////////////////////////////////////////////////////////////////////////
+[ Version("0.0.1") ]
class OMC_LinuxSymbolicLink : OMC_SymbolicLink
{
};
//////////////////////////////////////////////////////////////////////////////
+[ Version("0.0.1") ]
class OMC_LinuxDirectory : OMC_UnixDirectory
{
};
//////////////////////////////////////////////////////////////////////////////
+[ Version("0.0.1") ]
class OMC_LinuxFIFOPipeFile : OMC_FIFOPipeFile
{
};
//////////////////////////////////////////////////////////////////////////////
+[ Version("0.0.1") ]
class OMC_LinuxSocketFile : OMC_UnixSocketFile
{
};
//////////////////////////////////////////////////////////////////////////////
+[ Version("0.0.1") ]
class OMC_LinuxFile : OMC_UnixFile
{
};
//////////////////////////////////////////////////////////////////////////////
-[Association, Aggregation, Composition,
+[Association, Aggregation, Composition, Version("0.0.1"),
Description("Specifies the hierarchical arrangement of LogicalFiles in a "
"Directory.")
]
@@ -170,7 +177,7 @@
};
//////////////////////////////////////////////////////////////////////////////
-[Association, Description (
+[Association, Version("0.0.1"), Description (
"CIM_FileIdentity indicates that a UnixFile describes Unix-"
"specific aspects of the various subclasses of LogicalFile. "
"The association exists since it forces UnixFile to be "
Modified: pybase/trunk/OMC_OperatingSystem.mof
===================================================================
--- pybase/trunk/OMC_OperatingSystem.mof 2007-12-18 18:58:52 UTC (rev 519)
+++ pybase/trunk/OMC_OperatingSystem.mof 2007-12-18 20:40:49 UTC (rev 520)
@@ -1,13 +1,13 @@
#pragma locale ("en_US")
//////////////////////////////////////////////////////////////////////////////
-[ Description("OMC Operating System") ]
+[ Description("OMC Operating System"), Version("0.0.1") ]
class OMC_OperatingSystem : CIM_OperatingSystem
{
};
//////////////////////////////////////////////////////////////////////////////
-[ Description("Kernel statistics for the running os kernel") ]
+[ Description("Kernel statistics for the running os kernel"), Version("0.0.1") ]
class OMC_OSStatisticalInformation : CIM_StatisticalInformation
{
};
@@ -16,7 +16,7 @@
[ Association,
Description("OMC_OSStatistics relates "
"OMC_OSStatisticalInformation with "
- "OMC_OperatingSystem") ]
+ "OMC_OperatingSystem"), Version("0.0.1") ]
class OMC_OSStatistics : CIM_Statistics
{
[ Override("Stats"), Weak,
@@ -34,7 +34,7 @@
"At most one OperatingSystem can execute at any time on a "
"ComputerSystem. 'At most one' is specified, since the Computer "
"System may not be currently booted, or its OperatingSystem may "
- "be unknown.")]
+ "be unknown.", Version("0.0.1") ]
class OMC_RunningOS : CIM_RunningOS
{
[Override ( "Antecedent" ), Max ( 1 ), Description (
@@ -57,7 +57,7 @@
"on a ComputerSystem, when placed on one of its StorageExtents "
"- for example, copied to a disk drive or downloaded to Memory. "
"Using this definition, an OperatingSystem is 'installed' on a "
- "NetPC when downloaded via the network.")]
+ "NetPC when downloaded via the network.", Version("0.0.1") ]
class OMC_InstalledOS : CIM_InstalledOS
{
[Aggregate, Override ( "GroupComponent" ), Min ( 1 ), Max ( 1 ),
Modified: pybase/trunk/OMC_TimeService.mof
===================================================================
--- pybase/trunk/OMC_TimeService.mof 2007-12-18 18:58:52 UTC (rev 519)
+++ pybase/trunk/OMC_TimeService.mof 2007-12-18 20:40:49 UTC (rev 520)
@@ -2,7 +2,7 @@
//////////////////////////////////////////////////////////////////////////////
-[ Abstract ]
+[ Abstract, Version("0.0.1") ]
class OMC_TimeService : CIM_TimeService
{
};
@@ -10,7 +10,7 @@
//////////////////////////////////////////////////////////////////////////////
// OMC_SystemTimeService
[ Description("OMC_SystemTimeService represents the configuration "
- " and function of the system time") ]
+ " and function of the system time"), Version("0.0.1") ]
class OMC_SystemTimeService : OMC_TimeService
{
[ Key, Override("SystemCreationClassName") ]
@@ -68,7 +68,7 @@
//////////////////////////////////////////////////////////////////////////////
// OMC_RemoteTimeServicePort
[ Description("OMC_RemoteTimeServicePort represent the NTP "
- "configuration for the time service") ]
+ "configuration for the time service"), Version("0.0.1") ]
class OMC_RemoteTimeServicePort : CIM_RemotePort
{
[ Override("AccessInfo"), Write(true),
@@ -134,7 +134,7 @@
//////////////////////////////////////////////////////////////////////////////
// OMC_TimeZoneSettingData
[ Description("OMC_TimeZoneSettingData represents the "
- "configuration of the system time zone.") ]
+ "configuration of the system time zone."), Version("0.0.1") ]
class OMC_TimeZoneSettingData : CIM_SettingData
{
[ Key, Description(
@@ -158,7 +158,7 @@
// OMC_HostedTimeService
[ Association,
Description("OMC_HostedTimeService associates the time service "
- "to the computer system") ]
+ "to the computer system"), Version("0.0.1") ]
class OMC_HostedTimeService : CIM_HostedService
{
[ Override("Antecedent"), Min(1), Max(1),
@@ -175,7 +175,7 @@
[ Association,
Description("OMC_TimeServiceAccessBySAP is an association "
"that identifies the configuration for NTP access for the "
- "time service") ]
+ "time service"), Version("0.0.1") ]
class OMC_TimeServiceAccessBySAP : CIM_ServiceAccessBySAP
{
[ Override("Antecedent"),
@@ -192,7 +192,7 @@
//
[ Association,
Description("OMC_TimeServiceTimeZoneSettingData associates the time "
- "service with the time zone configuration") ]
+ "service with the time zone configuration"), Version("0.0.1") ]
class OMC_TimeServiceTimeZoneSettingData : CIM_ElementSettingData
{
[ Override("ManagedElement") ]
@@ -207,7 +207,7 @@
// OMC_TimeServiceAvailableToElement
[ Association,
Description("OMC_TimeServiceAvailableToElement indicates that this time "
- "service is available for the use of the managed element") ]
+ "service is available for the use of the managed element"), Version("0.0.1") ]
class OMC_TimeServiceAvailableToElement : CIM_ServiceAvailableToElement
{
[ Override("ServiceProvided") ]
Modified: pybase/trunk/OMC_UnitaryComputerSystem.mof
===================================================================
--- pybase/trunk/OMC_UnitaryComputerSystem.mof 2007-12-18 18:58:52 UTC (rev 519)
+++ pybase/trunk/OMC_UnitaryComputerSystem.mof 2007-12-18 20:40:49 UTC (rev 520)
@@ -2,13 +2,13 @@
//////////////////////////////////////////////////////////////////////////////
-[ Description("OMC Unitary Computer System") ]
+[ Description("OMC Unitary Computer System"), Version("0.0.1") ]
class OMC_UnitaryComputerSystem : CIM_UnitaryComputerSystem
{
};
//////////////////////////////////////////////////////////////////////////////
-[ Description("OMC Host Name Setting Data") ]
+[ Description("OMC Host Name Setting Data"), Version("0.0.1") ]
class OMC_HostNameSettingData : CIM_SettingData
{
[Description ("The name of this computer"),
@@ -19,7 +19,7 @@
//////////////////////////////////////////////////////////////////////////////
[ Association, Version ( "2.7.0" ),
Description ("OMC_ComputerSystemSettingData is associates "
- " the computer name setting with the computer system") ]
+ " the computer name setting with the computer system"), Version("0.0.1") ]
class OMC_ComputerSystemHostNameSettingData : CIM_ElementSettingData
{
[ Override("ManagedElement"), Key,
Modified: pybase/trunk/OMC_UnixProcess.mof
===================================================================
--- pybase/trunk/OMC_UnixProcess.mof 2007-12-18 18:58:52 UTC (rev 519)
+++ pybase/trunk/OMC_UnixProcess.mof 2007-12-18 20:40:49 UTC (rev 520)
@@ -1,7 +1,7 @@
#pragma locale ("en_US")
//////////////////////////////////////////////////////////////////////////////
-[ Description ("A Unix Process") ]
+[ Description ("A Unix Process"), Version("0.0.1") ]
class OMC_UnixProcess : CIM_UnixProcess
{
[ Description("Send a signal to some running processes. Only the "
@@ -21,7 +21,7 @@
//////////////////////////////////////////////////////////////////////////////
[ Association, Aggregation, Composition, Version ( "2.7.0" ),
Description ("A link between the OperatingSystem and Process(es) "
- "running in the context of this OperatingSystem.") ]
+ "running in the context of this OperatingSystem."), Version("0.0.1") ]
class OMC_OSProcess : CIM_OSProcess
{
[Aggregate, Override ( "GroupComponent" ), Min ( 1 ), Max ( 1 ),
@@ -38,7 +38,7 @@
//////////////////////////////////////////////////////////////////////////////
[ Association,
Description("A link between a Process and a DataFile indicating "
- "that the File participates in the execution of the Process.") ]
+ "that the File participates in the execution of the Process."), Version("0.0.1") ]
class OMC_ProcessExecutable : CIM_ProcessExecutable
{
[ Override("Antecedent"),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-18 18:58:52
|
Revision: 519
http://omc.svn.sourceforge.net/omc/?rev=519&view=rev
Author: bartw
Date: 2007-12-18 10:58:52 -0800 (Tue, 18 Dec 2007)
Log Message:
-----------
finished syslog provider
Modified Paths:
--------------
pybase/trunk/OMC_SyslogNG-peg.reg
pybase/trunk/OMC_SyslogNG.mof
pybase/trunk/OMC_SyslogNG.py
Modified: pybase/trunk/OMC_SyslogNG-peg.reg
===================================================================
--- pybase/trunk/OMC_SyslogNG-peg.reg 2007-12-18 18:46:31 UTC (rev 518)
+++ pybase/trunk/OMC_SyslogNG-peg.reg 2007-12-18 18:58:52 UTC (rev 519)
@@ -43,3 +43,33 @@
ProviderType = {2,3}; // Instance, Associator
};
+instance of PG_ProviderCapabilities
+{
+ CapabilityID = "OMC_SyslogNGUseOfLog";
+ ProviderModuleName = "/usr/lib/pycim/OMC_SyslogNG.py";
+ ProviderName = "OMC_SyslogNG";
+ ClassName = "OMC_SyslogNGUseOfLog";
+ Namespaces = {"root/cimv2"}; // TODO
+ ProviderType = {2,3}; // Instance, Associator
+};
+
+instance of PG_ProviderCapabilities
+{
+ CapabilityID = "OMC_SyslogNGRecordLogCapabilities";
+ ProviderModuleName = "/usr/lib/pycim/OMC_SyslogNG.py";
+ ProviderName = "OMC_SyslogNG";
+ ClassName = "OMC_SyslogNGRecordLogCapabilities";
+ Namespaces = {"root/cimv2"}; // TODO
+ ProviderType = {2}; // Instance
+};
+
+instance of PG_ProviderCapabilities
+{
+ CapabilityID = "OMC_SyslogNGRecordLogToCapabilities";
+ ProviderModuleName = "/usr/lib/pycim/OMC_SyslogNG.py";
+ ProviderName = "OMC_SyslogNG";
+ ClassName = "OMC_SyslogNGRecordLogToCapabilities";
+ Namespaces = {"root/cimv2"}; // TODO
+ ProviderType = {2,3}; // Instance, Associator
+};
+
Modified: pybase/trunk/OMC_SyslogNG.mof
===================================================================
--- pybase/trunk/OMC_SyslogNG.mof 2007-12-18 18:46:31 UTC (rev 518)
+++ pybase/trunk/OMC_SyslogNG.mof 2007-12-18 18:58:52 UTC (rev 519)
@@ -51,11 +51,13 @@
[
- Version("0.0.1"),
+ Association, Version("0.0.1"),
Description ("Association that ties ManagedElement (and/or) ComputerSystem to a RecordLog.")
]
class OMC_SyslogNGUseOfLog : CIM_UseOfLog
{
+ [ Override("Antecedent"), Key, Description("The Log.") ]
+ OMC_SyslogNGRecordLog REF Antecedent;
};
Modified: pybase/trunk/OMC_SyslogNG.py
===================================================================
--- pybase/trunk/OMC_SyslogNG.py 2007-12-18 18:46:31 UTC (rev 518)
+++ pybase/trunk/OMC_SyslogNG.py 2007-12-18 18:58:52 UTC (rev 519)
@@ -5,6 +5,7 @@
"""
import pywbem
+from socket import getfqdn
def _get_syslog_list():
rval = []
@@ -52,28 +53,6 @@
# self.filter_results = False
def get_instance(self, env, model, cim_class):
- """Return an instance.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- model -- A template of the pywbem.CIMInstance to be returned. The
- key properties are set on this instance to correspond to the
- instanceName that was requested. The properties of the model
- are already filtered according to the PropertyList from the
- request. Only properties present in the model need to be
- given values. If you prefer, you can set all of the
- values, and the instance will be filtered for you.
- cim_class -- The pywbem.CIMClass
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
- Instance does not exist in the specified namespace)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
@@ -133,29 +112,7 @@
def enum_instances(self, env, model, cim_class, keys_only):
- """Enumerate instances.
- The WBEM operations EnumerateInstances and EnumerateInstanceNames
- are both mapped to this method.
- This method is a python generator
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- model -- A template of the pywbem.CIMInstances to be generated.
- The properties of the model are already filtered according to
- the PropertyList from the request. Only properties present in
- the model need to be given values. If you prefer, you can
- always set all of the values, and the instance will be filtered
- for you.
- cim_class -- The pywbem.CIMClass
- keys_only -- A boolean. True if only the key properties should be
- set on the generated instances.
-
- Possible Errors:
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.enum_instances()' \
% self.__class__.__name__)
@@ -174,34 +131,7 @@
raise
def set_instance(self, env, instance, previous_instance, cim_class):
- """Return a newly created or modified instance.
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance -- The new pywbem.CIMInstance. If modifying an existing
- instance, the properties on this instance have been filtered by
- the PropertyList from the request.
- previous_instance -- The previous pywbem.CIMInstance if modifying
- an existing instance. None if creating a new instance.
- cim_class -- The pywbem.CIMClass
-
- Return the new instance. The keys must be set on the new instance.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only
- valid if previous_instance is None, indicating that the operation
- was CreateInstance)
- CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid
- if previous_instance is not None, indicating that the operation
- was ModifyInstance)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.set_instance()' \
% self.__class__.__name__)
@@ -210,27 +140,7 @@
return instance
def delete_instance(self, env, instance_name):
- """Delete an instance.
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance_name -- A pywbem.CIMInstanceName specifying the instance
- to delete.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_NAMESPACE
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified
- namespace)
- CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
- Instance does not exist in the specified namespace)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.delete_instance()' \
% self.__class__.__name__)
@@ -348,10 +258,19 @@
logger.log_debug('Entering %s.cim_method_clearlog()' \
% self.__class__.__name__)
- # TODO do something
- raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented
+ try:
+ id = object_name['InstanceID']
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ if not id.startswith('OMCSyslogNGRecordLog:'):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ file = id[id.index(':')+1:]
+ if file not in _get_syslog_list():
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ fo = open(file, 'w')
+ fo.close()
out_params = {}
- rval = None # TODO (type pywbem.Uint32 self.Values.ClearLog)
+ rval = self.Values.ClearLog.Completed_with_no_error
return (rval, out_params)
class Values(object):
@@ -588,28 +507,6 @@
# self.filter_results = False
def get_instance(self, env, model, cim_class, line=None):
- """Return an instance.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- model -- A template of the pywbem.CIMInstance to be returned. The
- key properties are set on this instance to correspond to the
- instanceName that was requested. The properties of the model
- are already filtered according to the PropertyList from the
- request. Only properties present in the model need to be
- given values. If you prefer, you can set all of the
- values, and the instance will be filtered for you.
- cim_class -- The pywbem.CIMClass
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
- Instance does not exist in the specified namespace)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
@@ -654,29 +551,7 @@
return model
def enum_instances(self, env, model, cim_class, keys_only):
- """Enumerate instances.
- The WBEM operations EnumerateInstances and EnumerateInstanceNames
- are both mapped to this method.
- This method is a python generator
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- model -- A template of the pywbem.CIMInstances to be generated.
- The properties of the model are already filtered according to
- the PropertyList from the request. Only properties present in
- the model need to be given values. If you prefer, you can
- always set all of the values, and the instance will be filtered
- for you.
- cim_class -- The pywbem.CIMClass
- keys_only -- A boolean. True if only the key properties should be
- set on the generated instances.
-
- Possible Errors:
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.enum_instances()' \
% self.__class__.__name__)
@@ -703,34 +578,7 @@
raise
def set_instance(self, env, instance, previous_instance, cim_class):
- """Return a newly created or modified instance.
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance -- The new pywbem.CIMInstance. If modifying an existing
- instance, the properties on this instance have been filtered by
- the PropertyList from the request.
- previous_instance -- The previous pywbem.CIMInstance if modifying
- an existing instance. None if creating a new instance.
- cim_class -- The pywbem.CIMClass
-
- Return the new instance. The keys must be set on the new instance.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only
- valid if previous_instance is None, indicating that the operation
- was CreateInstance)
- CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid
- if previous_instance is not None, indicating that the operation
- was ModifyInstance)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.set_instance()' \
% self.__class__.__name__)
@@ -739,27 +587,7 @@
return instance
def delete_instance(self, env, instance_name):
- """Delete an instance.
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance_name -- A pywbem.CIMInstanceName specifying the instance
- to delete.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_NAMESPACE
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified
- namespace)
- CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
- Instance does not exist in the specified namespace)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.delete_instance()' \
% self.__class__.__name__)
@@ -785,28 +613,6 @@
# self.filter_results = False
def get_instance(self, env, model, cim_class):
- """Return an instance.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- model -- A template of the pywbem.CIMInstance to be returned. The
- key properties are set on this instance to correspond to the
- instanceName that was requested. The properties of the model
- are already filtered according to the PropertyList from the
- request. Only properties present in the model need to be
- given values. If you prefer, you can set all of the
- values, and the instance will be filtered for you.
- cim_class -- The pywbem.CIMClass
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
- Instance does not exist in the specified namespace)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
@@ -821,29 +627,7 @@
return model
def enum_instances(self, env, model, cim_class, keys_only):
- """Enumerate instances.
- The WBEM operations EnumerateInstances and EnumerateInstanceNames
- are both mapped to this method.
- This method is a python generator
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- model -- A template of the pywbem.CIMInstances to be generated.
- The properties of the model are already filtered according to
- the PropertyList from the request. Only properties present in
- the model need to be given values. If you prefer, you can
- always set all of the values, and the instance will be filtered
- for you.
- cim_class -- The pywbem.CIMClass
- keys_only -- A boolean. True if only the key properties should be
- set on the generated instances.
-
- Possible Errors:
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.enum_instances()' \
% self.__class__.__name__)
@@ -864,34 +648,7 @@
raise
def set_instance(self, env, instance, previous_instance, cim_class):
- """Return a newly created or modified instance.
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance -- The new pywbem.CIMInstance. If modifying an existing
- instance, the properties on this instance have been filtered by
- the PropertyList from the request.
- previous_instance -- The previous pywbem.CIMInstance if modifying
- an existing instance. None if creating a new instance.
- cim_class -- The pywbem.CIMClass
-
- Return the new instance. The keys must be set on the new instance.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only
- valid if previous_instance is None, indicating that the operation
- was CreateInstance)
- CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid
- if previous_instance is not None, indicating that the operation
- was ModifyInstance)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.set_instance()' \
% self.__class__.__name__)
@@ -900,27 +657,7 @@
return instance
def delete_instance(self, env, instance_name):
- """Delete an instance.
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- instance_name -- A pywbem.CIMInstanceName specifying the instance
- to delete.
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_NAMESPACE
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified
- namespace)
- CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
- Instance does not exist in the specified namespace)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.delete_instance()' \
% self.__class__.__name__)
@@ -930,64 +667,7 @@
def references(self, env, object_name, model, assoc_class,
result_class_name, role, result_role, keys_only):
- """Instrument Associations.
- All four association-related operations (Associators, AssociatorNames,
- References, ReferenceNames) are mapped to this method.
- This method is a python generator
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- object_name -- A pywbem.CIMInstanceName that defines the source
- CIM Object whose associated Objects are to be returned.
- model -- A template pywbem.CIMInstance to serve as a model
- of the objects to be returned. Only properties present on this
- model need to be set.
- assoc_class -- The pywbem.CIMClass.
- result_class_name -- If not empty, this string acts as a filter on
- the returned set of Instances by mandating that each returned
- Instances MUST represent an association between object_name
- and an Instance of a Class whose name matches this parameter
- or a subclass.
- role -- If not empty, MUST be a valid Property name. It acts as a
- filter on the returned set of Instances by mandating that each
- returned Instance MUST refer to object_name via a Property
- whose name matches the value of this parameter.
- result_role -- If not empty, MUST be a valid Property name. It acts
- as a filter on the returned set of Instances by mandating that
- each returned Instance MUST represent associations of
- object_name to other Instances, where the other Instances play
- the specified result_role in the association (i.e. the
- name of the Property in the Association Class that refers to
- the Object related to object_name MUST match the value of this
- parameter).
- keys_only -- A boolean. True if only the key properties should be
- set on the generated instances.
-
- The following diagram may be helpful in understanding the role,
- result_role, and result_class_name parameters.
- +------------------------+ +-------------------+
- | object_name.classname | | result_class_name |
- | ~~~~~~~~~~~~~~~~~~~~~ | | ~~~~~~~~~~~~~~~~~ |
- +------------------------+ +-------------------+
- | +-----------------------------------+ |
- | | [Association] assoc_class | |
- | object_name | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
- +--------------+ object_name.classname REF role | |
- (CIMInstanceName) | result_class_name REF result_role +------+
- | |(CIMInstanceName)
- +-----------------------------------+
-
- Possible Errors:
- CIM_ERR_ACCESS_DENIED
- CIM_ERR_NOT_SUPPORTED
- CIM_ERR_INVALID_NAMESPACE
- CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
- or otherwise incorrect parameters)
- CIM_ERR_FAILED (some other unspecified error occurred)
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.references()' \
% self.__class__.__name__)
@@ -1033,13 +713,318 @@
except StopIteration:
break
fo.close()
+## end of class OMC_SyslogNGLogManagesRecordProvider
+class OMC_SyslogNGUseOfLogProvider(pywbem.CIMProvider):
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+ # If you will be filtering instances yourself according to
+ # property_list, role, result_role, and result_class_name
+ # parameters, set self.filter_results to False
+ # self.filter_results = False
+
+ def get_instance(self, env, model, cim_class):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+
+ ux = model.update_existing
+
+ # TODO fetch system resource matching the following keys:
+ # model['Dependent']
+ # model['Antecedent']
+
+ #ux(RecordedData='') # TODO
+ return model
+
+ def enum_instances(self, env, model, cim_class, keys_only):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+
+ for log in _get_syslog_list():
+ model['Dependent'] = pywbem.CIMInstanceName('OMC_UnitaryComputerSystem',
+ keybindings={'CreationClassName':'OMC_UnitaryComputerSystem',
+ 'Name':getfqdn()},
+ namespace=model.path.namespace)
+ model['Antecedent'] = pywbem.CIMInstanceName('OMC_SyslogNGRecordLog',
+ keybindings={'InstanceID':'OMCSyslogNGRecordLog:'+log},
+ namespace=model.path.namespace)
+ if keys_only:
+ yield model
+ else:
+ try:
+ yield self.get_instance(env, model, cim_class)
+ except pywbem.CIMError, (num, msg):
+ if num not in (pywbem.CIM_ERR_NOT_FOUND,
+ pywbem.CIM_ERR_ACCESS_DENIED):
+ raise
+
+ def set_instance(self, env, instance, previous_instance, cim_class):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.set_instance()' \
+ % self.__class__.__name__)
+ # TODO create or modify the instance
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+ return instance
+
+ def delete_instance(self, env, instance_name):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.delete_instance()' \
+ % self.__class__.__name__)
+
+ # TODO delete the resource
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+
+ def references(self, env, object_name, model, assoc_class,
+ result_class_name, role, result_role, keys_only):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.references()' \
+ % self.__class__.__name__)
+ ch = env.get_cimom_handle()
+ if (not role or role.lower() == 'dependent') and \
+ object_name.classname.lower() == 'omc_unitarycomputersystem':
+ model['Dependent'] = object_name
+ for log in _get_syslog_list():
+ model['Antecedent'] = pywbem.CIMInstanceName('OMC_SyslogNGRecordLog',
+ keybindings={'InstanceID':'OMCSyslogNGRecordLog:'+log},
+ namespace=object_name.namespace)
+ yield model
+
+ if (not role or role.lower() == 'antecedent') and \
+ object_name.classname.lower() == 'omc_syslogngrecordlog':
+ model['Antecedent'] = object_name
+ model['Dependent'] = pywbem.CIMInstanceName('OMC_UnitaryComputerSystem',
+ keybindings={'CreationClassName':'OMC_UnitaryComputerSystem',
+ 'Name':getfqdn()},
+ namespace=object_name.namespace)
+ yield model
+
+## end of class OMC_SyslogNGUseOfLogProvider
+class OMC_SyslogNGRecordLogCapabilitiesProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_SyslogNGRecordLogCapabilities
+
+ EnabledLogicalElementCapabilities for SyslogNGRecordLog. This class is
+ here for conformance with the SMASH Record Log Profile. For other
+ details, see parent class.
+
+ """
+
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+ # If you will be filtering instances yourself according to
+ # property_list, role, result_role, and result_class_name
+ # parameters, set self.filter_results to False
+ # self.filter_results = False
+
+ def get_instance(self, env, model, cim_class):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+
+ ux = model.update_existing
+
+ try:
+ id = model['InstanceID']
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ if not id.startswith('OMCSyslogNGRecordLog:'):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ file = id[id.index(':')+1:]
+ if file not in _get_syslog_list():
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+
+ ux(ElementNameEditSupported=False)
+ ux(ElementName=file)
+ #ux(Caption='') # TODO
+ #ux(Description='') # TODO
+ #ux(MaxElementNameLen=pywbem.Uint16()) # TODO
+ #ux(RequestedStatesSupported=[self.Values.RequestedStatesSupported.<VAL>,]) # TODO
+ return model
+
+ def enum_instances(self, env, model, cim_class, keys_only):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+
+ for log in _get_syslog_list():
+ model['InstanceID'] = 'OMCSyslogNGRecordLog:'+log
+ if keys_only:
+ yield model
+ else:
+ try:
+ yield self.get_instance(env, model, cim_class)
+ except pywbem.CIMError, (num, msg):
+ if num not in (pywbem.CIM_ERR_NOT_FOUND,
+ pywbem.CIM_ERR_ACCESS_DENIED):
+ raise
+
+ def set_instance(self, env, instance, previous_instance, cim_class):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.set_instance()' \
+ % self.__class__.__name__)
+ # TODO create or modify the instance
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+ return instance
+
+ def delete_instance(self, env, instance_name):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.delete_instance()' \
+ % self.__class__.__name__)
+
+ # TODO delete the resource
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+
+ class Values(object):
+ class RequestedStatesSupported(object):
+ Enabled = pywbem.Uint16(2)
+ Disabled = pywbem.Uint16(3)
+ Shut_Down = pywbem.Uint16(4)
+ Offline = pywbem.Uint16(6)
+ Test = pywbem.Uint16(7)
+ Defer = pywbem.Uint16(8)
+ Quiesce = pywbem.Uint16(9)
+ Reboot = pywbem.Uint16(10)
+ Reset = pywbem.Uint16(11)
+
+## end of class OMC_SyslogNGRecordLogCapabilitiesProvider
+class OMC_SyslogNGRecordLogToCapabilitiesProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_SyslogNGRecordLogToCapabilities
+
+ Associates OMC_SyslogNGRecordLog to OMC_SyslogNGRecordLogCapabilities.
+
+ """
+
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+ # If you will be filtering instances yourself according to
+ # property_list, role, result_role, and result_class_name
+ # parameters, set self.filter_results to False
+ # self.filter_results = False
+
+ def get_instance(self, env, model, cim_class):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+
+ ux = model.update_existing
+
+ # TODO fetch system resource matching the following keys:
+ # model['Capabilities']
+ # model['ManagedElement']
+
+ return model
+
+ def enum_instances(self, env, model, cim_class, keys_only):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+
+ logname = pywbem.CIMInstanceName('OMC_SyslogNGRecordLog',
+ keybindings={},
+ namespace=model.path.namespace)
+ capname = pywbem.CIMInstanceName('OMC_SyslogNGRecordLogCapabilities',
+ keybindings={},
+ namespace=model.path.namespace)
+ model['Capabilities'] = capname
+ model['ManagedElement'] = logname
+ for log in _get_syslog_list():
+ id = 'OMCSyslogNGRecordLog:' + log
+ capname['InstanceID'] = id
+ logname['InstanceID'] = id
+ if keys_only:
+ yield model
+ else:
+ try:
+ yield self.get_instance(env, model, cim_class)
+ except pywbem.CIMError, (num, msg):
+ if num not in (pywbem.CIM_ERR_NOT_FOUND,
+ pywbem.CIM_ERR_ACCESS_DENIED):
+ raise
+
+ def set_instance(self, env, instance, previous_instance, cim_class):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.set_instance()' \
+ % self.__class__.__name__)
+ # TODO create or modify the instance
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+ return instance
+
+ def delete_instance(self, env, instance_name):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.delete_instance()' \
+ % self.__class__.__name__)
+
+ # TODO delete the resource
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+
+ def references(self, env, object_name, model, assoc_class,
+ result_class_name, role, result_role, keys_only):
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.references()' \
+ % self.__class__.__name__)
+ ch = env.get_cimom_handle()
+ try:
+ id = object_name['InstanceID']
+ except KeyError:
+ return
+ if not id.startswith('OMCSyslogNGRecordLog:'):
+ return
+ file = id[id.index(':')+1:]
+ if file not in _get_syslog_list():
+ return
+ if (not role or role.lower() == 'capabilities') and \
+ object_name.classname.lower() == 'omc_syslogngrecordlogcapabilities':
+ model['Capabilities'] = object_name
+ model['ManagedElement'] = pywbem.CIMInstanceName('OMC_SyslogNGRecordLog',
+ keybindings={'InstanceID':id},
+ namespace=object_name.namespace)
+ yield model
+
+ if (not role or role.lower() == 'managedelement') and \
+ object_name.classname.lower() == 'omc_syslogngrecordlog':
+ model['ManagedElement'] = object_name
+ model['Capabilities'] = pywbem.CIMInstanceName('OMC_SyslogNGRecordLogCapabilities',
+ keybindings={'InstanceID':id},
+ namespace=object_name.namespace)
+ yield model
+
+## end of class OMC_SyslogNGRecordLogToCapabilitiesProvider
+
+
+
def get_providers(env):
omc_syslogngrecordlog_prov = OMC_SyslogNGRecordLogProvider(env)
omc_syslognglogrecord_prov = OMC_SyslogNGLogRecordProvider(env)
omc_syslognglogmanagesrecord_prov = OMC_SyslogNGLogManagesRecordProvider(env)
+ omc_syslognguseoflog_prov = OMC_SyslogNGUseOfLogProvider(env)
+ omc_syslogngrecordlogcapabilities_prov = OMC_SyslogNGRecordLogCapabilitiesProvider(env)
+ omc_syslogngrecordlogtocapabilities_prov = OMC_SyslogNGRecordLogToCapabilitiesProvider(env)
return {'OMC_SyslogNGRecordLog': omc_syslogngrecordlog_prov,
'OMC_SyslogNGLogRecord': omc_syslognglogrecord_prov,
- 'OMC_SyslogNGLogManagesRecord': omc_syslognglogmanagesrecord_prov}
+ 'OMC_SyslogNGLogManagesRecord': omc_syslognglogmanagesrecord_prov,
+ 'OMC_SyslogNGUseOfLog': omc_syslognguseoflog_prov,
+ 'OMC_SyslogNGRecordLogCapabilities': omc_syslogngrecordlogcapabilities_prov,
+ 'OMC_SyslogNGRecordLogToCapabilities': omc_syslogngrecordlogtocapabilities_prov}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-18 18:46:27
|
Revision: 518
http://omc.svn.sourceforge.net/omc/?rev=518&view=rev
Author: jcarey
Date: 2007-12-18 10:46:31 -0800 (Tue, 18 Dec 2007)
Log Message:
-----------
Implemented the time service available to element association. TimeService providers now complete
Modified Paths:
--------------
pybase/trunk/OMC_TimeService-peg.reg
pybase/trunk/OMC_TimeService.py
Modified: pybase/trunk/OMC_TimeService-peg.reg
===================================================================
--- pybase/trunk/OMC_TimeService-peg.reg 2007-12-18 18:15:00 UTC (rev 517)
+++ pybase/trunk/OMC_TimeService-peg.reg 2007-12-18 18:46:31 UTC (rev 518)
@@ -73,7 +73,6 @@
ProviderType = {2,3}; // Instance, Associator
};
-/*
instance of PG_ProviderCapabilities
{
CapabilityID = "OMC_TimeService_Capability7";
@@ -84,7 +83,6 @@
ProviderType = {2,3}; // Instance, Associator
};
-*/
@@ -93,4 +91,3 @@
-
Modified: pybase/trunk/OMC_TimeService.py
===================================================================
--- pybase/trunk/OMC_TimeService.py 2007-12-18 18:15:00 UTC (rev 517)
+++ pybase/trunk/OMC_TimeService.py 2007-12-18 18:46:31 UTC (rev 518)
@@ -563,7 +563,7 @@
return
if result_role and result_role.lower() != 'dependent':
return
- if result_class:
+ if result_class_name:
if not pywbem.is_subclass(env.get_cimom_handle(),
object_name.namespace, sub='omc_systemtimeservice',
super=result_class_name):
@@ -698,14 +698,17 @@
## end of class OMC_RemoteTimeServicePortProvider
+###############################################################################
class OMC_TimeServiceAccessBySAPProvider(pywbem.CIMProvider):
"""Instrument the CIM class OMC_TimeServiceAccessBySAP"""
+ ###########################################################################
def __init__ (self, env):
logger = env.get_logger()
logger.log_debug('Initializing provider %s from %s' \
% (self.__class__.__name__, __file__))
+ ###########################################################################
def get_instance(self, env, model, cim_class):
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
@@ -729,6 +732,7 @@
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
return model
+ ###########################################################################
def enum_instances(self, env, model, cim_class, keys_only):
logger = env.get_logger()
logger.log_debug('Entering %s.enum_instances()' \
@@ -745,12 +749,15 @@
model['Dependent'] = svr.fill_cim_obj(ref, True)
yield model
+ ###########################################################################
def set_instance(self, env, instance, previous_instance, cim_class):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+ ###########################################################################
def delete_instance(self, env, instance_name):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+ ###########################################################################
def references(self, env, object_name, model, assoc_class,
result_class_name, role, result_role, keys_only):
logger = env.get_logger()
@@ -802,14 +809,17 @@
yield model
## end of class OMC_TimeServiceAccessBySAPProvider
+###############################################################################
class OMC_TimeZoneSettingDataProvider(pywbem.CIMProvider):
"""Instrument the CIM class OMC_TimeZoneSettingData"""
+ ###########################################################################
def __init__ (self, env):
logger = env.get_logger()
logger.log_debug('Initializing provider %s from %s' \
% (self.__class__.__name__, __file__))
+ ###########################################################################
def get_instance(self, env, model, cim_class):
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
@@ -830,6 +840,7 @@
model['Description'] = 'Local time zone for the system'
return model
+ ###########################################################################
def enum_instances(self, env, model, cim_class, keys_only):
logger = env.get_logger()
logger.log_debug('Entering %s.enum_instances()' \
@@ -846,6 +857,7 @@
model['Description'] = 'Local time zone for the system'
yield model
+ ###########################################################################
def set_instance(self, env, instance, previous_instance, cim_class):
logger = env.get_logger()
logger.log_debug('Entering %s.set_instance()' \
@@ -903,45 +915,73 @@
raise einst
return instance
+ ###########################################################################
def delete_instance(self, env, instance_name):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
## end of class OMC_TimeZoneSettingDataProvider
+###############################################################################
class OMC_TimeServiceTimeZoneSettingDataProvider(pywbem.CIMProvider):
"""Instrument the CIM class OMC_TimeServiceTimeZoneSettingData"""
+
+ ###########################################################################
def __init__ (self, env):
logger = env.get_logger()
logger.log_debug('Initializing provider %s from %s' \
% (self.__class__.__name__, __file__))
+ ###########################################################################
def get_instance(self, env, model, cim_class):
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
% self.__class__.__name__)
- # TODO
+ try:
+ srvref = model['managedelement']
+ if not _is_service_ref(srvref):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ sdref = model['settingdata']
+ if sdref['InstanceID'].lower() != 'omc:timezone':
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ model['IsDefault'] = pywbem.Uint16(0)
+ model['IsCurrent'] = pywbem.Uint16(1)
return model
+ ###########################################################################
def enum_instances(self, env, model, cim_class, keys_only):
- # TODO
- if False:
- yield None
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+ model['settingdata'] = pywbem.CIMInstanceName(
+ classname='OMC_TimeZoneSettingData',
+ namespace=model.path.namespace,
+ keybindings={'InstanceID':'omc:timezone'})
+ ref = pywbem.CIMInstanceName(classname='OMC_SystemTimeService',
+ namespace=model.path.namespace)
+ model['managedelement'] = _fill_service_instance(ref, True)
+ if not keys_only:
+ model['IsDefault'] = pywbem.Uint16(0)
+ model['IsCurrent'] = pywbem.Uint16(1)
+ yield model
+ ###########################################################################
def set_instance(self, env, instance, previous_instance, cim_class):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+ ###########################################################################
def delete_instance(self, env, instance_name):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+ ###########################################################################
def references(self, env, object_name, model, assoc_class,
result_class_name, role, result_role, keys_only):
- print '#### my references called'
logger = env.get_logger()
logger.log_debug('Entering %s.references()' \
% self.__class__.__name__)
ch = env.get_cimom_handle()
if object_name.classname.lower() == 'omc_systemtimeservice':
- print '#### my references the service!'
if role and role.lower() != 'managedelement':
return
if result_role and result_role.lower() != 'settingdata':
@@ -958,6 +998,8 @@
classname='OMC_TimeZoneSettingData',
namespace=object_name.namespace,
keybindings={'InstanceID':'omc:timezone'})
+ model['IsDefault'] = pywbem.Uint16(0)
+ model['IsCurrent'] = pywbem.Uint16(1)
yield model
elif object_name.classname.lower() == 'omc_timezonesettingdata':
if role and role.lower() != 'settingdata':
@@ -970,22 +1012,119 @@
super=result_class_name):
return
try:
- print '### object_name[instanceid] =',object_name['instanceid']
if object_name['InstanceID'].lower() != 'omc:timezone':
- print '### No match on instance id'
return
except KeyError:
- print '### KeyError on instance id'
return
model['settingdata'] = object_name
ref = pywbem.CIMInstanceName(classname='OMC_SystemTimeService',
namespace=object_name.namespace)
model['managedelement'] = _fill_service_instance(ref, True)
+ model['IsDefault'] = pywbem.Uint16(0)
+ model['IsCurrent'] = pywbem.Uint16(1)
yield model
## end of class OMC_TimeServiceTimeZoneSettingDataProvider
+###############################################################################
+class OMC_TimeServiceAvailableToElementProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_TimeServiceAvailableToElement"""
+
+ ###########################################################################
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+
+ ###########################################################################
+ def get_instance(self, env, model, cim_class):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+ try:
+ tsref = model['serviceprovided']
+ if not _is_service_ref(tsref):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ csref = model['userofservice']
+ if not _is_cs_ref(csref):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ return model
+
+ ###########################################################################
+ def enum_instances(self, env, model, cim_class, keys_only):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+ model['userofservice'] = pywbem.CIMInstanceName(
+ classname='OMC_UnitaryComputerSystem',
+ namespace=model.path.namespace,
+ keybindings={'CreationClassName':'OMC_UnitaryComputerSystem',
+ 'Name':_fqdn})
+ ref = pywbem.CIMInstanceName(classname='OMC_SystemTimeService',
+ namespace=model.path.namespace)
+ model['serviceprovided'] = _fill_service_instance(ref, True)
+ yield model
+
+ ###########################################################################
+ def set_instance(self, env, instance, previous_instance, cim_class):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+
+ ###########################################################################
+ def delete_instance(self, env, instance_name):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+
+ ###########################################################################
+ def references(self, env, object_name, model, assoc_class,
+ result_class_name, role, result_role, keys_only):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.references()' \
+ % self.__class__.__name__)
+ ch = env.get_cimom_handle()
+ if object_name.classname.lower() == 'omc_systemtimeservice':
+ if role and role.lower() != 'serviceprovided':
+ return
+ if result_role and result_role.lower() != 'userofservice':
+ return
+ if result_class_name:
+ if not pywbem.is_subclass(ch, object_name.namespace,
+ sub='omc_unitarycomputersystem',
+ super=result_class_name):
+ return
+ if not _is_service_ref(object_name):
+ return
+ model['serviceprovided'] = object_name
+ model['userofservice'] = pywbem.CIMInstanceName(
+ classname='OMC_UnitaryComputerSystem',
+ namespace=object_name.namespace,
+ keybindings={'CreationClassName':'OMC_UnitaryComputerSystem',
+ 'Name':_fqdn})
+ yield model
+
+ elif object_name.classname.lower() == 'omc_unitarycomputersystem':
+ if role and role.lower() != 'userofservice':
+ return
+ if result_role and result_role.lower() != 'serviceprovided':
+ return
+ if result_class_name:
+ if not pywbem.is_subclass(ch, object_name.namespace,
+ sub='omc_systemtimeservice',
+ super=result_class_name):
+ return
+ if not _is_cs_ref(object_name):
+ return
+ model['userofservice'] = object_name
+ ref = pywbem.CIMInstanceName(classname='OMC_SystemTimeService',
+ namespace=object_name.namespace)
+ model['serviceprovided'] = _fill_service_instance(ref, True)
+ yield model
+
+## end of class OMC_TimeServiceAvailableToElementProvider
+
+###############################################################################
def get_providers(env):
+ omc_timeserviceavailabletoelement_prov = OMC_TimeServiceAvailableToElementProvider(env)
omc_timeservicetimezonesettingdata_prov = OMC_TimeServiceTimeZoneSettingDataProvider(env)
omc_timezonesettingdata_prov = OMC_TimeZoneSettingDataProvider(env)
omc_timeserviceaccessbysap_prov = OMC_TimeServiceAccessBySAPProvider(env)
@@ -997,5 +1136,6 @@
'OMC_RemoteTimeServicePort': omc_remotetimeserviceport_prov,
'OMC_TimeServiceAccessBySAP': omc_timeserviceaccessbysap_prov,
'OMC_TimeZoneSettingData': omc_timezonesettingdata_prov,
- 'OMC_TimeServiceTimeZoneSettingData': omc_timeservicetimezonesettingdata_prov}
+ 'OMC_TimeServiceTimeZoneSettingData': omc_timeservicetimezonesettingdata_prov,
+ 'OMC_TimeServiceAvailableToElement': omc_timeserviceavailabletoelement_prov}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-18 18:14:56
|
Revision: 517
http://omc.svn.sourceforge.net/omc/?rev=517&view=rev
Author: jcarey
Date: 2007-12-18 10:15:00 -0800 (Tue, 18 Dec 2007)
Log Message:
-----------
implemented the time zone setting data and association to service
Modified Paths:
--------------
pybase/trunk/OMC_TimeService-peg.reg
pybase/trunk/OMC_TimeService.py
Modified: pybase/trunk/OMC_TimeService-peg.reg
===================================================================
--- pybase/trunk/OMC_TimeService-peg.reg 2007-12-18 03:34:49 UTC (rev 516)
+++ pybase/trunk/OMC_TimeService-peg.reg 2007-12-18 18:15:00 UTC (rev 517)
@@ -53,7 +53,6 @@
ProviderType = {2,3}; // Instance, Associator
};
-/*
instance of PG_ProviderCapabilities
{
CapabilityID = "OMC_TimeService_Capability3";
@@ -74,6 +73,7 @@
ProviderType = {2,3}; // Instance, Associator
};
+/*
instance of PG_ProviderCapabilities
{
CapabilityID = "OMC_TimeService_Capability7";
Modified: pybase/trunk/OMC_TimeService.py
===================================================================
--- pybase/trunk/OMC_TimeService.py 2007-12-18 03:34:49 UTC (rev 516)
+++ pybase/trunk/OMC_TimeService.py 2007-12-18 18:15:00 UTC (rev 517)
@@ -186,6 +186,7 @@
else:
os.unlink('/etc/ntp.conf')
os.rename(tfname, '/etc/ntp.conf')
+ os.chmod('/etc/ntp.conf', 0644)
return modified
except Exception,einst:
tfile.close()
@@ -232,6 +233,7 @@
else:
os.unlink('/etc/ntp.conf')
os.rename(tfname, '/etc/ntp.conf')
+ os.chmod('/etc/ntp.conf', 0644)
return modified
except Exception,einst:
tfile.close()
@@ -310,6 +312,7 @@
else:
os.unlink('/etc/sysconfig/clock')
os.rename(tfname, '/etc/sysconfig/clock')
+ os.chmod('/etc/sysconfig/clock', 0644)
except Exception,einst:
tfile.close()
cfile.close()
@@ -797,13 +800,194 @@
namespace=object_name.namespace);
model['Antecedent'] = _fill_service_instance(ref, True)
yield model
-
## end of class OMC_TimeServiceAccessBySAPProvider
-def get_providers(env):
- return {'OMC_TimeServiceAccessBySAP': omc_timeserviceaccessbysap_prov}
+class OMC_TimeZoneSettingDataProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_TimeZoneSettingData"""
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+
+ def get_instance(self, env, model, cim_class):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+ try:
+ iid = model['InstanceID']
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ if iid.lower() != 'omc:timezone':
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ tzcc = _clock_conf_get_time_zone()
+ if not tzcc:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ model['ElementName'] = 'omc:timezone'
+ model['UTCHardwareClock'] = tzcc[0]
+ model['TimeZone'] = tzcc[1]
+ model['Caption'] = 'Time Zone Setting'
+ model['Description'] = 'Local time zone for the system'
+ return model
+
+ def enum_instances(self, env, model, cim_class, keys_only):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+ tzcc = _clock_conf_get_time_zone()
+ if not tzcc:
+ return
+ model['InstanceID'] = 'omc:timezone'
+ if not keys_only:
+ model['ElementName'] = 'omc:timezone'
+ model['UTCHardwareClock'] = tzcc[0]
+ model['TimeZone'] = tzcc[1]
+ model['Caption'] = 'Time Zone Setting'
+ model['Description'] = 'Local time zone for the system'
+ yield model
+
+ def set_instance(self, env, instance, previous_instance, cim_class):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.set_instance()' \
+ % self.__class__.__name__)
+ if os.geteuid() != 0:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
+ if previous_instance:
+ for k,v in instance.properties.items():
+ previous_instance[k] = v
+ instance = previous_instance
+ try:
+ iid = instance['InstanceID']
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ if iid.lower() != 'omc:timezone':
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+
+ if 'timezone' not in instance or not instance['timezone']:
+ raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER,
+ "'TimeZone' is a required property")
+ if 'utchardwareclock' not in instance:
+ raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER,
+ "'UTCHardwareClass' is a required property")
+ time_zone = instance['timezone']
+ is_utc = instance['utchardwareclock']
+ tzcc = _clock_conf_get_time_zone()
+ if not tzcc:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ old_time_zone = tzcc[1]
+ # Verify zone info
+ zone_file = '/usr/share/zoneinfo/%s' % time_zone
+ if not os.path.exists(zone_file):
+ raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER,
+ '%s is not a valid time zone specification' % instance['timezone'])
+
+ cmd = '/usr/sbin/zic -l %s' % time_zone
+ cc = os.system(cmd)
+ if cc:
+ try:
+ # Try to revert back to old
+ os.system('/usr/sbin/zic -l %s' % old_time_zone)
+ except:
+ pass
+ raise pywbem.CIMError(pywbem.CIM_ERR_FAILED,
+ 'Failed to execute command %s' % cmd)
+
+ try:
+ _clock_conf_modify(is_utc, time_zone)
+ except Exception,einst:
+ # Try to recover old
+ try:
+ os.system('/usr/sbin/zic -l %s' % old_time_zone)
+ except:
+ pass
+ raise einst
+ return instance
+
+ def delete_instance(self, env, instance_name):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+
+## end of class OMC_TimeZoneSettingDataProvider
+
+class OMC_TimeServiceTimeZoneSettingDataProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_TimeServiceTimeZoneSettingData"""
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+
+ def get_instance(self, env, model, cim_class):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+ # TODO
+ return model
+
+ def enum_instances(self, env, model, cim_class, keys_only):
+ # TODO
+ if False:
+ yield None
+
+ def set_instance(self, env, instance, previous_instance, cim_class):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+
+ def delete_instance(self, env, instance_name):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+
+ def references(self, env, object_name, model, assoc_class,
+ result_class_name, role, result_role, keys_only):
+ print '#### my references called'
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.references()' \
+ % self.__class__.__name__)
+ ch = env.get_cimom_handle()
+ if object_name.classname.lower() == 'omc_systemtimeservice':
+ print '#### my references the service!'
+ if role and role.lower() != 'managedelement':
+ return
+ if result_role and result_role.lower() != 'settingdata':
+ return
+ if result_class_name:
+ if not pywbem.is_subclass(ch, object_name.namespace,
+ sub='omc_timezonesettingdata',
+ super=result_class_name):
+ return
+ if not _is_service_ref(object_name):
+ return
+ model['managedelement'] = object_name
+ model['settingdata'] = pywbem.CIMInstanceName(
+ classname='OMC_TimeZoneSettingData',
+ namespace=object_name.namespace,
+ keybindings={'InstanceID':'omc:timezone'})
+ yield model
+ elif object_name.classname.lower() == 'omc_timezonesettingdata':
+ if role and role.lower() != 'settingdata':
+ return
+ if result_role and result_role.lower() != 'managedelement':
+ return
+ if result_class_name:
+ if not pywbem.is_subclass(ch, object_name.namespace,
+ sub='omc_systemtimeservice',
+ super=result_class_name):
+ return
+ try:
+ print '### object_name[instanceid] =',object_name['instanceid']
+ if object_name['InstanceID'].lower() != 'omc:timezone':
+ print '### No match on instance id'
+ return
+ except KeyError:
+ print '### KeyError on instance id'
+ return
+ model['settingdata'] = object_name
+ ref = pywbem.CIMInstanceName(classname='OMC_SystemTimeService',
+ namespace=object_name.namespace)
+ model['managedelement'] = _fill_service_instance(ref, True)
+ yield model
+
+## end of class OMC_TimeServiceTimeZoneSettingDataProvider
+
def get_providers(env):
+ omc_timeservicetimezonesettingdata_prov = OMC_TimeServiceTimeZoneSettingDataProvider(env)
+ omc_timezonesettingdata_prov = OMC_TimeZoneSettingDataProvider(env)
omc_timeserviceaccessbysap_prov = OMC_TimeServiceAccessBySAPProvider(env)
omc_remotetimeserviceport_prov = OMC_RemoteTimeServicePortProvider(env)
omc_systemtimeservice_prov = OMC_SystemTimeServiceProvider(env)
@@ -811,5 +995,7 @@
return {'OMC_SystemTimeService': omc_systemtimeservice_prov,
'OMC_HostedTimeService': omc_hostedtimeservice_prov,
'OMC_RemoteTimeServicePort': omc_remotetimeserviceport_prov,
- 'OMC_TimeServiceAccessBySAP': omc_timeserviceaccessbysap_prov}
+ 'OMC_TimeServiceAccessBySAP': omc_timeserviceaccessbysap_prov,
+ 'OMC_TimeZoneSettingData': omc_timezonesettingdata_prov,
+ 'OMC_TimeServiceTimeZoneSettingData': omc_timeservicetimezonesettingdata_prov}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-18 03:34:44
|
Revision: 516
http://omc.svn.sourceforge.net/omc/?rev=516&view=rev
Author: bartw
Date: 2007-12-17 19:34:49 -0800 (Mon, 17 Dec 2007)
Log Message:
-----------
added LogManagedRecord association
Modified Paths:
--------------
pybase/trunk/OMC_SyslogNG-peg.reg
pybase/trunk/OMC_SyslogNG.mof
pybase/trunk/OMC_SyslogNG.py
Modified: pybase/trunk/OMC_SyslogNG-peg.reg
===================================================================
--- pybase/trunk/OMC_SyslogNG-peg.reg 2007-12-17 23:44:33 UTC (rev 515)
+++ pybase/trunk/OMC_SyslogNG-peg.reg 2007-12-18 03:34:49 UTC (rev 516)
@@ -33,3 +33,13 @@
ProviderType = {2}; // Instance
};
+instance of PG_ProviderCapabilities
+{
+ CapabilityID = "OMC_SyslogNGLogManagesRecord";
+ ProviderModuleName = "/usr/lib/pycim/OMC_SyslogNG.py";
+ ProviderName = "OMC_SyslogNG";
+ ClassName = "OMC_SyslogNGLogManagesRecord";
+ Namespaces = {"root/cimv2"}; // TODO
+ ProviderType = {2,3}; // Instance, Associator
+};
+
Modified: pybase/trunk/OMC_SyslogNG.mof
===================================================================
--- pybase/trunk/OMC_SyslogNG.mof 2007-12-17 23:44:33 UTC (rev 515)
+++ pybase/trunk/OMC_SyslogNG.mof 2007-12-18 03:34:49 UTC (rev 516)
@@ -33,6 +33,7 @@
#pragma locale ("en_US")
[
+ Version("0.0.1"),
Description ("Class representing a syslog-ng log file")
]
class OMC_SyslogNGRecordLog : CIM_RecordLog
@@ -41,6 +42,7 @@
[
+ Version("0.0.1"),
Description ("Class representing a record in a log file.")
]
class OMC_SyslogNGLogRecord : CIM_LogRecord
@@ -49,6 +51,7 @@
[
+ Version("0.0.1"),
Description ("Association that ties ManagedElement (and/or) ComputerSystem to a RecordLog.")
]
class OMC_SyslogNGUseOfLog : CIM_UseOfLog
@@ -57,19 +60,27 @@
[
+ Association, Aggregation, Version("0.0.1"), Composition,
Description ("Association between a RecordLog and its LogRecords.")
]
class OMC_SyslogNGLogManagesRecord : CIM_LogManagesRecord
{
+ [ Key, Override("Record"),
+ Description("The record managed by the Log.") ]
+ OMC_SyslogNGLogRecord REF Record;
+
+ [ Key, Override("Log"), Max(1), Min(1),
+ Description("The Log.") ]
+ OMC_SyslogNGRecordLog REF Log;
};
// ==================================================================
// OMC_SyslogNGRecordLogCapabilities
// ==================================================================
[Version ( "0.0.1" ), Description (
- "EnabledLogicalElementCapabilities for SyslogNGRecordLog. "
- "This class is here for conformance with the SMASH Record Log Profile. "
- "For other details, see parent class.")]
+ "EnabledLogicalElementCapabilities for SyslogNGRecordLog. "
+ "This class is here for conformance with the SMASH Record Log Profile. "
+ "For other details, see parent class.")]
class OMC_SyslogNGRecordLogCapabilities : CIM_EnabledLogicalElementCapabilities
{
};
@@ -78,8 +89,10 @@
// ==================================================================
// OMC_SyslogNGRecordLogToCapabilities
// ==================================================================
-[Association, Version ( "0.0.1" ), Description ("Associates OMC_SyslogNGRecordLog to "
- "OMC_SyslogNGRecordLogCapabilities.")]
+[ Association, Version ( "0.0.1" ),
+ Description (
+ "Associates OMC_SyslogNGRecordLog to "
+ "OMC_SyslogNGRecordLogCapabilities.")]
class OMC_SyslogNGRecordLogToCapabilities : CIM_ElementCapabilities
{
[Override ( "ManagedElement" ), Min ( 1 ), Max ( 1 ), Description (
Modified: pybase/trunk/OMC_SyslogNG.py
===================================================================
--- pybase/trunk/OMC_SyslogNG.py 2007-12-17 23:44:33 UTC (rev 515)
+++ pybase/trunk/OMC_SyslogNG.py 2007-12-18 03:34:49 UTC (rev 516)
@@ -10,7 +10,7 @@
rval = []
fo = open('/etc/syslog-ng/syslog-ng.conf', 'r')
state = 'i'
- for line in fo.readlines():
+ for line in fo:
line = line.strip()
if line and line[0] == '#':
continue
@@ -96,7 +96,13 @@
ux(MaxNumberOfRecords=pywbem.Uint64(0))
try:
fo = open(file, 'r')
- numlines = len(fo.readlines())
+ numlines = 0
+ while True:
+ try:
+ fo.next()
+ numlines+= 1
+ except StopIteration:
+ break
fo.close()
except:
numlines = 0
@@ -564,14 +570,7 @@
# Vendor_Reserved = 0x8000..
## end of class OMC_SyslogNGRecordLogProvider
-"""Python Provider for OMC_SyslogNGLogRecord
-Instruments the CIM class OMC_SyslogNGLogRecord
-
-"""
-
-import pywbem
-
class OMC_SyslogNGLogRecordProvider(pywbem.CIMProvider):
"""Instrument the CIM class OMC_SyslogNGLogRecord
@@ -625,7 +624,10 @@
# model['LogName']
# model['CreationClassName']
try:
- fname = model['LogName']
+ id = model['LogName']
+ if not id.startswith('OMCSyslogNGRecordLog:'):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ fname = id[id.index(':')+1:]
lineno = int(model['RecordID'])
except KeyError:
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
@@ -683,10 +685,11 @@
model['CreationClassName'] = 'OMC_SyslogNGLogRecord'
for fname in _get_syslog_list():
fo = open(fname, 'r')
- model['LogName'] = fname
+ model['LogName'] = 'OMCSyslogNGRecordLog:' + fname
lineno = 0
for line in fo:
- model['MessageTimestamp'] = pywbem.CIMDateTime.now()
+ #model['MessageTimestamp'] = pywbem.CIMDateTime.now()
+ model['MessageTimestamp'] = pywbem.CIMDateTime('99990101000000.000000+000')
lineno+= 1
model['RecordID'] = str(lineno)
if keys_only:
@@ -765,10 +768,278 @@
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
## end of class OMC_SyslogNGLogRecordProvider
+class OMC_SyslogNGLogManagesRecordProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_SyslogNGLogManagesRecord
+ Association between a RecordLog and its LogRecords.
+
+ """
+
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+ # If you will be filtering instances yourself according to
+ # property_list, role, result_role, and result_class_name
+ # parameters, set self.filter_results to False
+ # self.filter_results = False
+
+ def get_instance(self, env, model, cim_class):
+ """Return an instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ model -- A template of the pywbem.CIMInstance to be returned. The
+ key properties are set on this instance to correspond to the
+ instanceName that was requested. The properties of the model
+ are already filtered according to the PropertyList from the
+ request. Only properties present in the model need to be
+ given values. If you prefer, you can set all of the
+ values, and the instance will be filtered for you.
+ cim_class -- The pywbem.CIMClass
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
+ Instance does not exist in the specified namespace)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+
+ ux = model.update_existing
+
+ # TODO fetch system resource matching the following keys:
+ # model['Record']
+ # model['Log']
+
+ return model
+
+ def enum_instances(self, env, model, cim_class, keys_only):
+ """Enumerate instances.
+
+ The WBEM operations EnumerateInstances and EnumerateInstanceNames
+ are both mapped to this method.
+ This method is a python generator
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ model -- A template of the pywbem.CIMInstances to be generated.
+ The properties of the model are already filtered according to
+ the PropertyList from the request. Only properties present in
+ the model need to be given values. If you prefer, you can
+ always set all of the values, and the instance will be filtered
+ for you.
+ cim_class -- The pywbem.CIMClass
+ keys_only -- A boolean. True if only the key properties should be
+ set on the generated instances.
+
+ Possible Errors:
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+
+ while False: # TODO more instances?
+ # TODO fetch system resource
+ # Key properties
+ #model['Record'] = # TODO (type = REF (pywbem.CIMInstanceName(classname='OMC_SyslogNGLogRecord', ...))
+ #model['Log'] = # TODO (type = REF (pywbem.CIMInstanceName(classname='OMC_SyslogNGRecordLog', ...))
+ if keys_only:
+ yield model
+ else:
+ try:
+ yield self.get_instance(env, model, cim_class)
+ except pywbem.CIMError, (num, msg):
+ if num not in (pywbem.CIM_ERR_NOT_FOUND,
+ pywbem.CIM_ERR_ACCESS_DENIED):
+ raise
+
+ def set_instance(self, env, instance, previous_instance, cim_class):
+ """Return a newly created or modified instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ instance -- The new pywbem.CIMInstance. If modifying an existing
+ instance, the properties on this instance have been filtered by
+ the PropertyList from the request.
+ previous_instance -- The previous pywbem.CIMInstance if modifying
+ an existing instance. None if creating a new instance.
+ cim_class -- The pywbem.CIMClass
+
+ Return the new instance. The keys must be set on the new instance.
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_NOT_SUPPORTED
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only
+ valid if previous_instance is None, indicating that the operation
+ was CreateInstance)
+ CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid
+ if previous_instance is not None, indicating that the operation
+ was ModifyInstance)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.set_instance()' \
+ % self.__class__.__name__)
+ # TODO create or modify the instance
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+ return instance
+
+ def delete_instance(self, env, instance_name):
+ """Delete an instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ instance_name -- A pywbem.CIMInstanceName specifying the instance
+ to delete.
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_NOT_SUPPORTED
+ CIM_ERR_INVALID_NAMESPACE
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified
+ namespace)
+ CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
+ Instance does not exist in the specified namespace)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.delete_instance()' \
+ % self.__class__.__name__)
+
+ # TODO delete the resource
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+
+ def references(self, env, object_name, model, assoc_class,
+ result_class_name, role, result_role, keys_only):
+ """Instrument Associations.
+
+ All four association-related operations (Associators, AssociatorNames,
+ References, ReferenceNames) are mapped to this method.
+ This method is a python generator
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ object_name -- A pywbem.CIMInstanceName that defines the source
+ CIM Object whose associated Objects are to be returned.
+ model -- A template pywbem.CIMInstance to serve as a model
+ of the objects to be returned. Only properties present on this
+ model need to be set.
+ assoc_class -- The pywbem.CIMClass.
+ result_class_name -- If not empty, this string acts as a filter on
+ the returned set of Instances by mandating that each returned
+ Instances MUST represent an association between object_name
+ and an Instance of a Class whose name matches this parameter
+ or a subclass.
+ role -- If not empty, MUST be a valid Property name. It acts as a
+ filter on the returned set of Instances by mandating that each
+ returned Instance MUST refer to object_name via a Property
+ whose name matches the value of this parameter.
+ result_role -- If not empty, MUST be a valid Property name. It acts
+ as a filter on the returned set of Instances by mandating that
+ each returned Instance MUST represent associations of
+ object_name to other Instances, where the other Instances play
+ the specified result_role in the association (i.e. the
+ name of the Property in the Association Class that refers to
+ the Object related to object_name MUST match the value of this
+ parameter).
+ keys_only -- A boolean. True if only the key properties should be
+ set on the generated instances.
+
+ The following diagram may be helpful in understanding the role,
+ result_role, and result_class_name parameters.
+ +------------------------+ +-------------------+
+ | object_name.classname | | result_class_name |
+ | ~~~~~~~~~~~~~~~~~~~~~ | | ~~~~~~~~~~~~~~~~~ |
+ +------------------------+ +-------------------+
+ | +-----------------------------------+ |
+ | | [Association] assoc_class | |
+ | object_name | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
+ +--------------+ object_name.classname REF role | |
+ (CIMInstanceName) | result_class_name REF result_role +------+
+ | |(CIMInstanceName)
+ +-----------------------------------+
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_NOT_SUPPORTED
+ CIM_ERR_INVALID_NAMESPACE
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.references()' \
+ % self.__class__.__name__)
+ ch = env.get_cimom_handle()
+ if (not role or role.lower() == 'record') and \
+ pywbem.is_subclass(ch, object_name.namespace,
+ sub=object_name.classname,
+ super='OMC_SyslogNGLogRecord'):
+ model['Record'] = object_name
+ logfilename = object_name['LogName']
+ if logfilename in _get_syslog_list():
+ model['Log'] = pywbem.CIMInstanceName('OMC_SyslogNGRecordLog',
+ keybindings={'InstanceID':'OMCSyslogNGRecordLog:' + \
+ logfilename})
+ yield model
+
+ if (not role or role.lower() == 'log') and \
+ pywbem.is_subclass(ch, object_name.namespace,
+ sub=object_name.classname,
+ super='OMC_SyslogNGRecordLog'):
+ model['Log'] = object_name
+ id = object_name['InstanceID']
+ if not id.startswith('OMCSyslogNGRecordLog:'):
+ return
+ file = id[id.index(':')+1:]
+ try:
+ fo = open(file, 'r')
+ except:
+ return
+ recordname = pywbem.CIMInstanceName('OMC_SyslogNGLogRecord',
+ keybindings={'LogCreationClassName':'OMC_SyslogNGRecordLog',
+ 'MessageTimestamp':pywbem.CIMDateTime('99990101000000.000000+000'),
+ 'LogName':id,
+ 'CreationClassName':'OMC_SyslogNGLogRecord'})
+ cnt = 0
+ model['Record'] = recordname
+ while True:
+ try:
+ fo.next()
+ cnt+= 1
+ recordname['RecordID'] = str(cnt)
+ yield model
+ except StopIteration:
+ break
+ fo.close()
+
+
def get_providers(env):
omc_syslogngrecordlog_prov = OMC_SyslogNGRecordLogProvider(env)
omc_syslognglogrecord_prov = OMC_SyslogNGLogRecordProvider(env)
+ omc_syslognglogmanagesrecord_prov = OMC_SyslogNGLogManagesRecordProvider(env)
return {'OMC_SyslogNGRecordLog': omc_syslogngrecordlog_prov,
- 'OMC_SyslogNGLogRecord': omc_syslognglogrecord_prov}
+ 'OMC_SyslogNGLogRecord': omc_syslognglogrecord_prov,
+ 'OMC_SyslogNGLogManagesRecord': omc_syslognglogmanagesrecord_prov}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-17 23:44:31
|
Revision: 515
http://omc.svn.sourceforge.net/omc/?rev=515&view=rev
Author: jcarey
Date: 2007-12-17 15:44:33 -0800 (Mon, 17 Dec 2007)
Log Message:
-----------
Implemented the OMC_TimeServiceAccessBySAP association
Modified Paths:
--------------
pybase/trunk/OMC_TimeService-peg.reg
pybase/trunk/OMC_TimeService.py
Modified: pybase/trunk/OMC_TimeService-peg.reg
===================================================================
--- pybase/trunk/OMC_TimeService-peg.reg 2007-12-17 22:51:17 UTC (rev 514)
+++ pybase/trunk/OMC_TimeService-peg.reg 2007-12-17 23:44:33 UTC (rev 515)
@@ -43,25 +43,25 @@
ProviderType = {2,5}; // Instance, Method
};
-/*
instance of PG_ProviderCapabilities
{
- CapabilityID = "OMC_TimeService_Capability3";
+ CapabilityID = "OMC_TimeService_Capability5";
ProviderModuleName = "OMC_TimeServiceProvider_Module";
ProviderName = "OMC_TimeService_Provider";
- ClassName = "OMC_TimeZoneSettingData";
+ ClassName = "OMC_TimeServiceAccessBySAP";
Namespaces = {"root/cimv2"};
- ProviderType = {2}; // Instance
+ ProviderType = {2,3}; // Instance, Associator
};
+/*
instance of PG_ProviderCapabilities
{
- CapabilityID = "OMC_TimeService_Capability5";
+ CapabilityID = "OMC_TimeService_Capability3";
ProviderModuleName = "OMC_TimeServiceProvider_Module";
ProviderName = "OMC_TimeService_Provider";
- ClassName = "OMC_TimeServiceAccessBySAP";
+ ClassName = "OMC_TimeZoneSettingData";
Namespaces = {"root/cimv2"};
- ProviderType = {2,3}; // Instance, Associator
+ ProviderType = {2}; // Instance
};
instance of PG_ProviderCapabilities
Modified: pybase/trunk/OMC_TimeService.py
===================================================================
--- pybase/trunk/OMC_TimeService.py 2007-12-17 22:51:17 UTC (rev 514)
+++ pybase/trunk/OMC_TimeService.py 2007-12-17 23:44:33 UTC (rev 515)
@@ -97,7 +97,7 @@
return server
- def fill_cim_instance(self, model, keys_only=False):
+ def fill_cim_obj(self, model, keys_only=False):
global ntp_inst_date
model['SystemName'] = _fqdn
model['SystemCreationClassName'] = 'OMC_UnitaryComputerSystem'
@@ -599,7 +599,6 @@
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
% self.__class__.__name__)
- global ntp_inst_date
try:
server_name = model['Name']
except KeyError:
@@ -607,7 +606,7 @@
svr = NTPServer.get_server(server_name)
if not svr:
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
- return svr.fill_cim_instance(model, False)
+ return svr.fill_cim_obj(model, False)
###########################################################################
def enum_instances(self, env, model, cim_class, keys_only):
@@ -616,7 +615,7 @@
% self.__class__.__name__)
servers = NTPServer.get_servers()
for svr in servers:
- yield svr.fill_cim_instance(model, keys_only)
+ yield svr.fill_cim_obj(model, keys_only)
###########################################################################
def set_instance(self, env, instance, previous_instance, cim_class):
@@ -696,11 +695,121 @@
## end of class OMC_RemoteTimeServicePortProvider
+class OMC_TimeServiceAccessBySAPProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_TimeServiceAccessBySAP"""
+
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+
+ def get_instance(self, env, model, cim_class):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+ try:
+ antref = model['Antecedent']
+ depref = model['Dependent']
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ # Verify service ref
+ if not _is_service_ref(antref):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+
+ # Verify SAP ref
+ try:
+ server_name = depref['Name']
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ svr = NTPServer.get_server(server_name)
+ if not svr:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ return model
+
+ def enum_instances(self, env, model, cim_class, keys_only):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+ ref = pywbem.CIMInstanceName(
+ classname='OMC_SystemTimeService',
+ namespace=model.path.namespace);
+ model['Antecedent'] = _fill_service_instance(ref, True)
+ ref = pywbem.CIMInstanceName(
+ classname='OMC_RemoteTimeServicePort',
+ namespace=model.path.namespace);
+ servers = NTPServer.get_servers()
+ for svr in servers:
+ model['Dependent'] = svr.fill_cim_obj(ref, True)
+ yield model
+
+ def set_instance(self, env, instance, previous_instance, cim_class):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+
+ def delete_instance(self, env, instance_name):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+
+ def references(self, env, object_name, model, assoc_class,
+ result_class_name, role, result_role, keys_only):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.references()' \
+ % self.__class__.__name__)
+ ch = env.get_cimom_handle()
+ if object_name.classname.lower() == 'omc_systemtimeservice':
+ if not _is_service_ref(object_name):
+ return
+ if role and role.lower() != 'antecedent':
+ return
+ if result_role and result_role.lower() != 'dependent':
+ return
+ if result_class_name and len(result_class_name):
+ if not pywbem.is_subclass(ch, object_name.namespace,
+ sub='OMC_RemoteTimeServicePort',
+ super=result_class_name):
+ return
+ model['Antecedent'] = object_name
+ ref = pywbem.CIMInstanceName(
+ classname='OMC_RemoteTimeServicePort',
+ namespace=object_name.namespace);
+ servers = NTPServer.get_servers()
+ for svr in servers:
+ model['Dependent'] = svr.fill_cim_obj(ref, True)
+ yield model
+ elif object_name.classname.lower() == 'omc_remotetimeserviceport':
+ if role and role.lower() != 'dependent':
+ return
+ if result_role and result_role.lower() != 'antecedent':
+ return
+ if result_class_name and len(result_class_name):
+ if not pywbem.is_subclass(ch, object_name.namespace,
+ sub='OMC_SystemTimeService',
+ super=result_class_name):
+ return
+ try:
+ server_name = object_name['Name']
+ except KeyError:
+ return
+ svr = NTPServer.get_server(server_name)
+ if not svr:
+ return
+ model['Dependent'] = object_name
+ ref = pywbem.CIMInstanceName(
+ classname='OMC_SystemTimeService',
+ namespace=object_name.namespace);
+ model['Antecedent'] = _fill_service_instance(ref, True)
+ yield model
+
+## end of class OMC_TimeServiceAccessBySAPProvider
+
def get_providers(env):
+ return {'OMC_TimeServiceAccessBySAP': omc_timeserviceaccessbysap_prov}
+
+def get_providers(env):
+ omc_timeserviceaccessbysap_prov = OMC_TimeServiceAccessBySAPProvider(env)
omc_remotetimeserviceport_prov = OMC_RemoteTimeServicePortProvider(env)
omc_systemtimeservice_prov = OMC_SystemTimeServiceProvider(env)
omc_hostedtimeservice_prov = OMC_HostedTimeServiceProvider(env)
return {'OMC_SystemTimeService': omc_systemtimeservice_prov,
'OMC_HostedTimeService': omc_hostedtimeservice_prov,
- 'OMC_RemoteTimeServicePort': omc_remotetimeserviceport_prov}
+ 'OMC_RemoteTimeServicePort': omc_remotetimeserviceport_prov,
+ 'OMC_TimeServiceAccessBySAP': omc_timeserviceaccessbysap_prov}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-17 22:51:20
|
Revision: 514
http://omc.svn.sourceforge.net/omc/?rev=514&view=rev
Author: jcarey
Date: 2007-12-17 14:51:17 -0800 (Mon, 17 Dec 2007)
Log Message:
-----------
Implemented the OMC_RemoteTimeServicePort
Modified Paths:
--------------
pybase/trunk/OMC_TimeService-peg.reg
pybase/trunk/OMC_TimeService.py
Modified: pybase/trunk/OMC_TimeService-peg.reg
===================================================================
--- pybase/trunk/OMC_TimeService-peg.reg 2007-12-17 22:35:21 UTC (rev 513)
+++ pybase/trunk/OMC_TimeService-peg.reg 2007-12-17 22:51:17 UTC (rev 514)
@@ -33,7 +33,6 @@
ProviderType = {2,3}; // Instance, Associator
};
-/*
instance of PG_ProviderCapabilities
{
CapabilityID = "OMC_TimeService_Capability2";
@@ -44,6 +43,7 @@
ProviderType = {2,5}; // Instance, Method
};
+/*
instance of PG_ProviderCapabilities
{
CapabilityID = "OMC_TimeService_Capability3";
Modified: pybase/trunk/OMC_TimeService.py
===================================================================
--- pybase/trunk/OMC_TimeService.py 2007-12-17 22:35:21 UTC (rev 513)
+++ pybase/trunk/OMC_TimeService.py 2007-12-17 22:51:17 UTC (rev 514)
@@ -1,12 +1,32 @@
import os
import socket
import tempfile
+from subprocess import Popen, PIPE
+
import pywbem
_fqdn = socket.getfqdn()
+ntp_inst_date = None
+try:
+ _install_time = Popen(['rpm', '-qf','/etc/ntp.conf',
+ '--queryformat','%{INSTALLTIME}'],
+ stdout=PIPE).communicate()[0]
+ ntp_inst_date = pywbem.CIMDateTime.fromtimestamp(int(_install_time))
+except:
+ ntp_inst_date = None
+ pass
+
###############################################################################
+def _isIPV4Address(addr):
+ try:
+ mm = socket.inet_aton(addr)
+ return True
+ except socket.error:
+ return False
+
+###############################################################################
class NTPServer(object):
###########################################################################
def __init__(self):
@@ -54,6 +74,7 @@
utok = toks[i].lower()
if utok == 'prefer':
server.prefer = True
+ i += 1
continue
if i < (tokslen-1):
if utok == 'key':
@@ -71,7 +92,41 @@
elif utok == 'maxpoll':
i += 1
server.max_poll = int(toks[i])
+ i += 1
+
+
return server
+
+ def fill_cim_instance(self, model, keys_only=False):
+ global ntp_inst_date
+ model['SystemName'] = _fqdn
+ model['SystemCreationClassName'] = 'OMC_UnitaryComputerSystem'
+ model['CreationClassName'] = 'OMC_RemoteTimeServicePort'
+ model['Name'] = self.server_name
+ if keys_only:
+ return model
+ model['AccessInfo'] = self.server_name
+ model['InfoFormat'] = _isIPV4Address(self.server_name) \
+ and pywbem.Uint16(3) or pywbem.Uint16(2)
+ model['PortProtocol'] = pywbem.Uint16(2)
+ model['EnabledState'] = pywbem.Uint16(2)
+ model['RequestedState'] = pywbem.Uint16(12)
+ model['EnabledDefault'] = pywbem.Uint16(2)
+ model['InstallDate'] = ntp_inst_date
+ model['OperationalStatus'] = [pywbem.Uint16(2)]
+ model['Status'] = 'OK'
+ model['HealthState'] = pywbem.Uint16(5)
+ model['StartMode'] = 'Automatic'
+ model['Prefer'] = self.prefer and True or False
+ if self.key:
+ model['Key'] = pywbem.Uint32(self.key)
+ if self.ntp_version:
+ model['ntpversion'] = pywbem.Uint32(self.ntp_version)
+ if self.min_poll:
+ model['minpoll'] = pywbem.Uint32(self.min_poll)
+ if self.max_poll:
+ model['maxpoll'] = pywbem.Uint32(self.max_poll)
+ return model
###########################################################################
@classmethod
@@ -82,7 +137,7 @@
f = open('/etc/ntp.conf')
try:
for line in f:
- server = __server_from_conf_line(line)
+ server = NTPServer.__server_from_conf_line(line)
if server is not None:
servers.append(server)
return servers
@@ -98,7 +153,7 @@
try:
usn = server_name.lower()
for line in f:
- server = __server_from_conf_line(line)
+ server = NTPServer.__server_from_conf_line(line)
if server is not None:
if server.server_name.lower() == usn:
return server
@@ -116,7 +171,7 @@
cfile = open('/etc/ntp.conf')
try:
for line in cfile:
- server = __server_from_conf_line(line)
+ server = NTPServer.__server_from_conf_line(line)
if server is None:
tfile.write(line)
continue
@@ -147,13 +202,13 @@
def set_server(cls, ntpserver):
modified = False
server_written = False
- usname = server_name.lower()
+ usname = ntpserver.server_name.lower()
tfd,tfname = tempfile.mkstemp(dir='/etc')
tfile = os.fdopen(tfd, 'w')
cfile = open('/etc/ntp.conf')
try:
for line in cfile:
- server = __server_from_conf_line(line)
+ server = NTPServer.__server_from_conf_line(line)
if server is None:
tfile.write(line)
elif server.server_name.lower() == usname:
@@ -518,9 +573,134 @@
## end of class OMC_HostedTimeServiceProvider
+###############################################################################
+class OMC_RemoteTimeServicePortProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_RemoteTimeServicePort """
+
+ ###########################################################################
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+
+ ###########################################################################
+ @classmethod
+ def __get_ntp_install_date(cls):
+ try:
+ install_time = Popen(['rpm', '-qf','/etc/ntp.conf',
+ '--queryformat','%{INSTALLTIME}'],
+ stdout=PIPE).communicate()[0]
+ return pywbem.CIMDateTime.fromtimestamp(int(install_time))
+ except:
+ return None
+
+ ###########################################################################
+ def get_instance(self, env, model, cim_class):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+ global ntp_inst_date
+ try:
+ server_name = model['Name']
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ svr = NTPServer.get_server(server_name)
+ if not svr:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ return svr.fill_cim_instance(model, False)
+
+ ###########################################################################
+ def enum_instances(self, env, model, cim_class, keys_only):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+ servers = NTPServer.get_servers()
+ for svr in servers:
+ yield svr.fill_cim_instance(model, keys_only)
+
+ ###########################################################################
+ def set_instance(self, env, instance, previous_instance, cim_class):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.set_instance()' \
+ % self.__class__.__name__)
+ if os.geteuid() != 0:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
+ try:
+ sname = previous_instance and previous_instance['Name'] or instance['Name']
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER,
+ "'Name' is a required property")
+ server = NTPServer.get_server(sname)
+ if previous_instance:
+ if not server:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ for k,v in instance.properties.items():
+ previous_instance[k] = v
+ instance = previous_instance
+ else:
+ if server:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ALREADY_EXISTS)
+ server = NTPServer()
+ server.server_name = sname
+
+ if 'prefer' in instance and instance['prefer']:
+ server.prefer = True
+ else:
+ server.prefer = False
+ if 'key' in instance and instance['key']:
+ server.key = int(instance['key'])
+ else:
+ server.key = 0
+
+ if 'ntpversion' in instance and instance['ntpversion']:
+ v = int(instance['ntpversion'])
+ if v < 0 or v > 4:
+ raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER,
+ 'Invalid NTPVersion specified')
+ server.ntp_version = v
+ else:
+ server.ntp_version = 0
+ if 'minpoll' in instance and instance['minpoll']:
+ server.min_poll = int(instance['minpoll'])
+ else:
+ server.min_poll = 0
+ if 'maxpoll' in instance and instance['maxpoll']:
+ server.max_poll = int(instance['maxpoll'])
+ else:
+ server.max_poll = 0
+ NTPServer.set_server(server)
+ return instance
+
+ ###########################################################################
+ def delete_instance(self, env, instance_name):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.delete_instance()' \
+ % self.__class__.__name__)
+ if os.geteuid() != 0:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
+ try:
+ sname = instance_name['Name']
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ server = NTPServer.get_server(sname)
+ if not server:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ NTPServer.delete_server(sname)
+
+ ###########################################################################
+ def cim_method_requeststatechange(self, env, object_name, method,
+ param_requestedstate,
+ param_timeoutperiod):
+ # Not supported
+ return (pywbem.Uint32(1), {})
+
+## end of class OMC_RemoteTimeServicePortProvider
+
def get_providers(env):
+ omc_remotetimeserviceport_prov = OMC_RemoteTimeServicePortProvider(env)
omc_systemtimeservice_prov = OMC_SystemTimeServiceProvider(env)
omc_hostedtimeservice_prov = OMC_HostedTimeServiceProvider(env)
return {'OMC_SystemTimeService': omc_systemtimeservice_prov,
- 'OMC_HostedTimeService': omc_hostedtimeservice_prov}
+ 'OMC_HostedTimeService': omc_hostedtimeservice_prov,
+ 'OMC_RemoteTimeServicePort': omc_remotetimeserviceport_prov}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2007-12-17 22:35:36
|
Revision: 513
http://omc.svn.sourceforge.net/omc/?rev=513&view=rev
Author: mattvryan
Date: 2007-12-17 14:35:21 -0800 (Mon, 17 Dec 2007)
Log Message:
-----------
Added tests for OMC_UnitaryComputerSystem and related.
Modified Paths:
--------------
test/trunk/omcbase_test.py
Modified: test/trunk/omcbase_test.py
===================================================================
--- test/trunk/omcbase_test.py 2007-12-15 06:55:03 UTC (rev 512)
+++ test/trunk/omcbase_test.py 2007-12-17 22:35:21 UTC (rev 513)
@@ -5,6 +5,9 @@
import pywbem
import os
+from time import sleep
+from socket import getfqdn
+
_globalVerbose = False
_globalNamespace = 'root/cimv2'
@@ -112,17 +115,201 @@
def _omc_initdservicerunlevel_test(self):
pass
+ def _omc_unitarycomputersystem_test(self):
+ hostname = getfqdn()
+
+ insts = self._conn.EnumerateInstances('OMC_UnitaryComputerSystem', LocalOnly=False)
+ if 1 < len(insts):
+ self.fail('More than one OMC_UnitaryComputerSystem instance returned from EnumerateInstances')
+ if insts[0]['name'] != hostname:
+ self.fail('EnumerateInstances on OMC_UnitaryComputerSystem returned different instance than expected')
+
+ insts = self._conn.EnumerateInstanceNames('OMC_UnitaryComputerSystem')
+ if 1 < len(insts):
+ self.fail('More than one OMC_UnitaryComputerSystem instance returned from EnumerateInstanceNames')
+ if insts[0]['name'] != hostname:
+ self.fail('EnumerateInstanceNames on OMC_UnitaryComputerSystem returned different instance name than expected')
+
+ inst = self._conn.GetInstance(insts[0], LocalOnly=False)
+ if inst is None:
+ self.fail('Failed to GetInstance of OMC_UnitaryComputerSystem using %s' % insts[0])
+ if inst['name'] != hostname:
+ self.fail('GetInstance on OMC_UnitaryComputerSystem returned different instance than expected')
+
+ try:
+ self._conn.DeleteInstance(insts[0])
+ self.fail('DeleteInstance of OMC_UnitaryComputerSystem succeeded when it should have failed')
+ except pywbem.CIMError, ce:
+ if ce[0] != 7:
+ self.fail('Exception on DeleteInstance of OMC_UnitaryComputerSystem was not "Not Supported" as expected')
+ pass
+
+ try:
+ caption = 'Caption1'
+ if inst['Caption'] == caption:
+ caption = 'Caption2'
+ inst['Caption'] = caption
+ self._conn.ModifyInstance(inst)
+ insts = self._conn.EnumerateInstances('OMC_UnitaryComputerSystem', LocalOnly=False)
+ if insts[0]['Caption'] != caption:
+ self.fail('Attempt to ModifyInstance of OMC_UnitaryComputerSystem failed')
+ except pywbem.CIMError, ce:
+ self.fail('ModifyInstance of OMC_UnitaryComputerSystem failed')
+
+ try:
+ inst = pywbem.CIMInstance('OMC_UnitaryComputerSystem',
+ properties={'CreationClassName' : 'OMC_UnitaryComputerSystem',
+ 'Name':getfqdn()})
+ self._conn.CreateInstance(inst)
+ self.fail('CreateInstance of OMC_UnitaryComputerSystem succeeded when it should have failed')
+ except pywbem.CIMError, ce:
+ if ce[0] != 7:
+ # Should be 7, not supported.
+ self.fail('Exception on CreateInstance of OMC_UnitaryComputerSystem was not "Not Supported" as expected')
+
+ def _omc_hostnamesettingdata_test(self):
+ hostname = getfqdn()
+
+ insts = self._conn.EnumerateInstances('OMC_HostNameSettingData', LocalOnly=False)
+ if 1 < len(insts):
+ self.fail('More than one instance of OMC_HostNameSettingData returned from EnumerateInstances')
+ if insts[0]['ComputerName'] != hostname:
+ self.fail('EnumerateInstances on OMC_HostNameSettingData returned different instance than expected')
+
+ insts = self._conn.EnumerateInstanceNames('OMC_HostNameSettingData')
+ if 1 < len(insts):
+ self.fail('More than one instance name of OMC_HostNameSettingData returned from EnumerateInstanceNames')
+ if insts[0]['InstanceID'] != 'omc:computername':
+ self.fail('EnumerateInstanceNames on OMC_HostNameSettingData returned different instance name than expected')
+
+ inst = self._conn.GetInstance(insts[0], LocalOnly=False)
+ if inst is None:
+ self.fail('Failed to GetInstance of OMC_HostNameSettingData using %s' % insts[0])
+ if inst['ComputerName'] != hostname:
+ self.fail('GetInstance of OMC_HostNameSettingData returned different instance than expected')
+
+ try:
+ self._conn.DeleteInstance(insts[0])
+ self.fail('DeleteInstance of OMC_HostNameSettingData succeeded when it should have failed')
+ except pywbem.CIMError, ce:
+ if ce[0] != 7:
+ # Should be 7, not supported.
+ self.fail('Exception on DeleteInstance of OMC_HostNameSettingData was not "Not Supported" as expected')
+
+ try:
+ elems = hostname.split('.')
+ for elem in elems:
+ if elem == elems[0]:
+ newhostname = 'fakehostname'
+ else:
+ newhostname = newhostname + '.' + elem
+ inst['ComputerName'] = newhostname
+ self._conn.ModifyInstance(inst)
+ insts = self._conn.EnumerateInstances('OMC_HostNameSettingData', LocalOnly=False)
+ failmsg = None
+ if insts[0]['ComputerName'] != newhostname:
+ failmsg = 'Attempt to ModifyInstance of OMC_HostNameSettingData failed'
+ self._dbgPrint('Modified ComputerName of OMC_HostNameSettingData instance, awaiting serialization')
+ ctr = 0
+ while ctr < 100 and newhostname != getfqdn():
+ sleep(1)
+ ctr = ctr + 1
+ if newhostname != getfqdn():
+ failmsg = 'ModifyInstance of OMC_HostNameSettingData successful but hostname not modified on system'
+ else:
+ # Should get here always; try to set the name back to the original
+ self._dbgPrint('New host name setting now applied: %s' % getfqdn())
+ inst['ComputerName'] = hostname
+ self._conn.ModifyInstance(inst)
+ ctr = 0
+ self._dbgPrint('Restored ComputerName of OMC_HostNameSettingData instance, awaiting serialization')
+ while ctr < 100 and hostname != getfqdn():
+ sleep(1)
+ ctr = ctr + 1
+ self._dbgPrint('Previous host name setting now applied: %s' % getfqdn())
+ if failmsg is not None:
+ self.fail(failmsg)
+ except pywbem.CIMError:
+ self.fail('ModifyInstance of OMC_HostNameSettingData failed')
+
+ try:
+ inst = pywbem.CIMInstance('OMC_HostNameSettingData',
+ properties={'InstanceID' : 'omc:computername2',
+ 'ComputerName':getfqdn()})
+ self._conn.CreateInstance(inst)
+ self.fail('CreateInstance of OMC_HostNameSettingData succeeded when it should have failed')
+ except pywbem.CIMError, ce:
+ if ce[0] != 7:
+ # Should be 7, not supported.
+ self.fail('Exception on CreateInstance of OMC_HostNameSettingData was not "Not Supported" as expected')
+
+ def _omc_computersystemhostnamesettingdata_test(self):
+ ucs_op = self._conn.EnumerateInstanceNames('OMC_UnitaryComputerSystem')[0]
+ hnsd_op = self._conn.EnumerateInstanceNames('OMC_HostNameSettingData')[0]
+ insts = self._conn.EnumerateInstances('OMC_ComputerSystemHostNameSettingData', LocalOnly=False)
+ if 1 < len(insts):
+ self.fail('EnumerateInstances of OMC_ComputerSystemHostNameSettingData returned multiple instances when only one was expected')
+ if insts[0]['ManagedElement'] != ucs_op:
+ self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid')
+ if insts[0]['SettingData'] != hnsd_op:
+ self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid')
+
+ insts = self._conn.EnumerateInstanceNames('OMC_ComputerSystemHostNameSettingData')
+ if 1 < len(insts):
+ self.fail('EnumerateInstanceNames of OMC_ComputerSystemHostNameSettingData returned multiple instance names when only one was expected')
+ if insts[0]['ManagedElement'] != ucs_op:
+ self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid')
+ if insts[0]['SettingData'] != hnsd_op:
+ self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid')
+
+ refs = self._conn.References(ucs_op, ResultClass='OMC_ComputerSystemHostNameSettingData')
+ if 1 < len(refs):
+ self.fail('References of OMC_UnitaryComputersystem returned multiple instances when only one was expected')
+ if refs[0]['ManagedElement'] != ucs_op:
+ self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid')
+ if refs[0]['SettingData'] != hnsd_op:
+ self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid')
+
+ refs = self._conn.References(hnsd_op, ResultClass='OMC_ComputerSystemHostNameSettingData')
+ if 1 < len(refs):
+ self.fail('References of OMC_HostNameSettingData returned multiple instances when only one was expected')
+ if refs[0]['ManagedElement'] != ucs_op:
+ self.fail('ManagedElement property of OMC_ComputerSystemHostNameSettingData not valid')
+ if refs[0]['SettingData'] != hnsd_op:
+ self.fail('SettingData property of OMC_ComputerSystemHostNameSettingData not valid')
+
+ assocs = self._conn.AssociatorNames(ucs_op, AssocClass='OMC_ComputerSystemHostNameSettingData')
+ if 1 < len(assocs):
+ self.fail('AssociatorNames of OMC_UnitaryComputerSystem returned multiple instances when only one was expected')
+ qualified_hnsd_op = str(hnsd_op)
+ if not qualified_hnsd_op.startswith('//%s/' % getfqdn()):
+ qualified_hnsd_op = '//%s/%s' % (getfqdn(), str(hnsd_op))
+ if str(assocs[0]) != qualified_hnsd_op:
+ self.fail('AssociatorNames for %s is not valid' % ucs_op)
+
+ assocs = self._conn.AssociatorNames(hnsd_op, AssocClass='OMC_ComputerSystemHostNameSettingData')
+ if 1 < len(assocs):
+ self.fail('AssociatorNames of OMC_HostNameSettingData returned multiple instances when only one was expected')
+ qualified_ucs_op = str(ucs_op)
+ if not qualified_ucs_op.startswith('//%s/' % getfqdn()):
+ qualified_ucs_op = '//%s/%s' % (getfqdn(), str(ucs_op))
+ if str(assocs[0]) != qualified_ucs_op:
+ self.fail('AssociatorNames for %s is not valid' % hnsd_op)
+
+ def _run_omcbase_component_tests(self, testname, testmap):
+ for classname in testmap.keys():
+ if not self._isClassSupported(classname):
+ self._showMissingclassNotice(classname, testname)
+ else:
+ testmap[classname]()
+
def test_initd(self):
initdClasses = {'OMC_InitdService' : self._omc_initdservice_test,
'OMC_Runlevel' : self._omc_runlevel_test,
'OMC_HostedInitdService' : self._omc_hostedinitdservice_test,
'OMC_RunlevelInComputerSystem' : self._omc_runlevelincomputersystem_test,
'OMC_InitdServiceRunLevel' : self._omc_initdservicerunlevel_test}
- for classname in initdClasses.keys():
- if not self._isClassSupported(classname):
- self._showMissingClassNotice(classname, 'initd')
- else:
- initdClasses[classname]()
+ self._run_omcbase_component_tests('initd', initdClasses)
def test_syslogd(self):
pass
@@ -134,7 +321,11 @@
pass
def test_unitary_computer_system(self):
- pass
+ ucsClasses = {'OMC_UnitaryComputerSystem' : self._omc_unitarycomputersystem_test,
+ 'OMC_HostNameSettingData' : self._omc_hostnamesettingdata_test,
+ 'OMC_ComputerSystemHostNameSettingData' : self._omc_computersystemhostnamesettingdata_test}
+ self._run_omcbase_component_tests('unitary_computer_system', ucsClasses)
+
def test_unix_process(self):
pass
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2007-12-15 06:55:00
|
Revision: 512
http://omc.svn.sourceforge.net/omc/?rev=512&view=rev
Author: bartw
Date: 2007-12-14 22:55:03 -0800 (Fri, 14 Dec 2007)
Log Message:
-----------
instumented SysLogNGRecordLog and SysLogNGLogRecord
Modified Paths:
--------------
pybase/trunk/OMC_Base.mof
Added Paths:
-----------
pybase/trunk/OMC_SyslogNG-peg.reg
pybase/trunk/OMC_SyslogNG.mof
pybase/trunk/OMC_SyslogNG.py
Modified: pybase/trunk/OMC_Base.mof
===================================================================
--- pybase/trunk/OMC_Base.mof 2007-12-14 22:54:45 UTC (rev 511)
+++ pybase/trunk/OMC_Base.mof 2007-12-15 06:55:03 UTC (rev 512)
@@ -5,3 +5,4 @@
#pragma include ("OMC_InitdService.mof")
#pragma include ("OMC_InitdService.mof")
#pragma include ("OMC_TimeService.mof")
+#pragma include ("OMC_SyslogNG.mof")
Added: pybase/trunk/OMC_SyslogNG-peg.reg
===================================================================
--- pybase/trunk/OMC_SyslogNG-peg.reg (rev 0)
+++ pybase/trunk/OMC_SyslogNG-peg.reg 2007-12-15 06:55:03 UTC (rev 512)
@@ -0,0 +1,35 @@
+// Pegasus Provider registration for OMC_SyslogNGRecordLog
+instance of PG_ProviderModule
+{
+ Name = "/usr/lib/pycim/OMC_SyslogNG.py";
+ InterfaceType = "Python";
+ InterfaceVersion = "1.0.0";
+ Location = "/usr/lib/pycim/OMC_SyslogNG.py";
+ Vendor = "OMC";
+ Version = "1.0";
+};
+instance of PG_Provider
+{
+ Name = "OMC_SyslogNG";
+ ProviderModuleName = "/usr/lib/pycim/OMC_SyslogNG.py";
+};
+instance of PG_ProviderCapabilities
+{
+ CapabilityID = "OMC_SyslogNGRecordLog";
+ ProviderModuleName = "/usr/lib/pycim/OMC_SyslogNG.py";
+ ProviderName = "OMC_SyslogNG";
+ ClassName = "OMC_SyslogNGRecordLog";
+ Namespaces = {"root/cimv2"};
+ ProviderType = {2,5}; // Instance, Method
+};
+
+instance of PG_ProviderCapabilities
+{
+ CapabilityID = "OMC_SyslogNGLogRecord";
+ ProviderModuleName = "/usr/lib/pycim/OMC_SyslogNG.py";
+ ProviderName = "OMC_SyslogNG";
+ ClassName = "OMC_SyslogNGLogRecord";
+ Namespaces = {"root/cimv2"}; // TODO
+ ProviderType = {2}; // Instance
+};
+
Added: pybase/trunk/OMC_SyslogNG.mof
===================================================================
--- pybase/trunk/OMC_SyslogNG.mof (rev 0)
+++ pybase/trunk/OMC_SyslogNG.mof 2007-12-15 06:55:03 UTC (rev 512)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Novell-syslog-ng provider classes
+ *
+ *
+ * Copyright (C) 2004 Novell, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Novell, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc. OR THE CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ ******************************************************************************/
+#pragma locale ("en_US")
+
+[
+ Description ("Class representing a syslog-ng log file")
+]
+class OMC_SyslogNGRecordLog : CIM_RecordLog
+{
+};
+
+
+[
+ Description ("Class representing a record in a log file.")
+]
+class OMC_SyslogNGLogRecord : CIM_LogRecord
+{
+};
+
+
+[
+ Description ("Association that ties ManagedElement (and/or) ComputerSystem to a RecordLog.")
+]
+class OMC_SyslogNGUseOfLog : CIM_UseOfLog
+{
+};
+
+
+[
+ Description ("Association between a RecordLog and its LogRecords.")
+]
+class OMC_SyslogNGLogManagesRecord : CIM_LogManagesRecord
+{
+};
+
+// ==================================================================
+// OMC_SyslogNGRecordLogCapabilities
+// ==================================================================
+[Version ( "0.0.1" ), Description (
+ "EnabledLogicalElementCapabilities for SyslogNGRecordLog. "
+ "This class is here for conformance with the SMASH Record Log Profile. "
+ "For other details, see parent class.")]
+class OMC_SyslogNGRecordLogCapabilities : CIM_EnabledLogicalElementCapabilities
+{
+};
+
+
+// ==================================================================
+// OMC_SyslogNGRecordLogToCapabilities
+// ==================================================================
+[Association, Version ( "0.0.1" ), Description ("Associates OMC_SyslogNGRecordLog to "
+ "OMC_SyslogNGRecordLogCapabilities.")]
+class OMC_SyslogNGRecordLogToCapabilities : CIM_ElementCapabilities
+{
+ [Override ( "ManagedElement" ), Min ( 1 ), Max ( 1 ), Description (
+ "The RecordLog.")]
+ OMC_SyslogNGRecordLog REF ManagedElement;
+
+ [Override ( "Capabilities" ), Description (
+ "The OMC_SyslogNGRecordLogCapabilities.")]
+ OMC_SyslogNGRecordLogCapabilities REF Capabilities;
+};
+
+
+
+
+
Added: pybase/trunk/OMC_SyslogNG.py
===================================================================
--- pybase/trunk/OMC_SyslogNG.py (rev 0)
+++ pybase/trunk/OMC_SyslogNG.py 2007-12-15 06:55:03 UTC (rev 512)
@@ -0,0 +1,774 @@
+"""Python Provider for OMC_SyslogNGRecordLog
+
+Instruments the CIM class OMC_SyslogNGRecordLog
+
+"""
+
+import pywbem
+
+def _get_syslog_list():
+ rval = []
+ fo = open('/etc/syslog-ng/syslog-ng.conf', 'r')
+ state = 'i'
+ for line in fo.readlines():
+ line = line.strip()
+ if line and line[0] == '#':
+ continue
+ if state == 'i' and line.startswith('destination'):
+ state = 'd'
+ line = line[12:]
+ if state == 'd':
+ idx = line.find('file')
+ if idx >= 0:
+ state = 'f'
+ line = line[idx+4:]
+ if state == 'f':
+ idx = line.find('"')
+ if idx >= 0:
+ line = line[idx+1:]
+ idx = line.find('"')
+ if idx >= 0:
+ line = line[:idx]
+ state = 'i'
+ rval.append(line)
+ fo.close()
+ return rval
+
+
+class OMC_SyslogNGRecordLogProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_SyslogNGRecordLog
+
+ Class representing a syslog-ng log file
+
+ """
+
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+ # If you will be filtering instances yourself according to
+ # property_list, role, result_role, and result_class_name
+ # parameters, set self.filter_results to False
+ # self.filter_results = False
+
+ def get_instance(self, env, model, cim_class):
+ """Return an instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ model -- A template of the pywbem.CIMInstance to be returned. The
+ key properties are set on this instance to correspond to the
+ instanceName that was requested. The properties of the model
+ are already filtered according to the PropertyList from the
+ request. Only properties present in the model need to be
+ given values. If you prefer, you can set all of the
+ values, and the instance will be filtered for you.
+ cim_class -- The pywbem.CIMClass
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
+ Instance does not exist in the specified namespace)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+
+ ux = model.update_existing
+
+ try:
+ id = model['InstanceID']
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ if not id.startswith('OMCSyslogNGRecordLog:'):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ file = id[id.index(':')+1:]
+ if file not in _get_syslog_list():
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+
+ ux(ElementName=file)
+ ux(Name=file)
+ ux(MaxNumberOfRecords=pywbem.Uint64(0))
+ try:
+ fo = open(file, 'r')
+ numlines = len(fo.readlines())
+ fo.close()
+ except:
+ numlines = 0
+ ux(CurrentNumberOfRecords=pywbem.Uint64(numlines))
+
+
+ #ux(AvailableRequestedStates=[self.Values.AvailableRequestedStates.<VAL>,]) # TODO
+ #ux(Caption='') # TODO
+ #ux(CommunicationStatus=self.Values.CommunicationStatus.<VAL>) # TODO
+ #ux(Description='') # TODO
+ #ux(DetailedStatus=self.Values.DetailedStatus.<VAL>) # TODO
+ #ux(EnabledDefault=self.Values.EnabledDefault.Enabled) # TODO
+ #ux(EnabledState=self.Values.EnabledState.Not_Applicable) # TODO
+ #ux(HealthState=self.Values.HealthState.<VAL>) # TODO
+ #ux(InstallDate=pywbem.CIMDateTime()) # TODO
+ #ux(LogState=self.Values.LogState.Not_Applicable) # TODO
+ #ux(OperatingStatus=self.Values.OperatingStatus.<VAL>) # TODO
+ #ux(OperationalStatus=[self.Values.OperationalStatus.<VAL>,]) # TODO
+ #ux(OtherEnabledState='') # TODO
+ #ux(OverwritePolicy=self.Values.OverwritePolicy.Unknown) # TODO
+ #ux(PrimaryStatus=self.Values.PrimaryStatus.<VAL>) # TODO
+ #ux(RequestedState=self.Values.RequestedState.Not_Applicable) # TODO
+ #ux(Status=self.Values.Status.<VAL>) # TODO
+ #ux(StatusDescriptions=['',]) # TODO
+ #ux(TimeOfLastStateChange=pywbem.CIMDateTime()) # TODO
+ #ux(TransitioningToState=self.Values.TransitioningToState.Not_Applicable) # TODO
+ return model
+
+
+ def enum_instances(self, env, model, cim_class, keys_only):
+ """Enumerate instances.
+
+ The WBEM operations EnumerateInstances and EnumerateInstanceNames
+ are both mapped to this method.
+ This method is a python generator
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ model -- A template of the pywbem.CIMInstances to be generated.
+ The properties of the model are already filtered according to
+ the PropertyList from the request. Only properties present in
+ the model need to be given values. If you prefer, you can
+ always set all of the values, and the instance will be filtered
+ for you.
+ cim_class -- The pywbem.CIMClass
+ keys_only -- A boolean. True if only the key properties should be
+ set on the generated instances.
+
+ Possible Errors:
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+
+ for fname in _get_syslog_list():
+ model['InstanceID'] = 'OMCSyslogNGRecordLog:' + fname
+ state = 'i'
+ if keys_only:
+ yield model
+ else:
+ try:
+ yield self.get_instance(env, model, cim_class)
+ except pywbem.CIMError, (num, msg):
+ if num not in (pywbem.CIM_ERR_NOT_FOUND,
+ pywbem.CIM_ERR_ACCESS_DENIED):
+ raise
+
+ def set_instance(self, env, instance, previous_instance, cim_class):
+ """Return a newly created or modified instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ instance -- The new pywbem.CIMInstance. If modifying an existing
+ instance, the properties on this instance have been filtered by
+ the PropertyList from the request.
+ previous_instance -- The previous pywbem.CIMInstance if modifying
+ an existing instance. None if creating a new instance.
+ cim_class -- The pywbem.CIMClass
+
+ Return the new instance. The keys must be set on the new instance.
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_NOT_SUPPORTED
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only
+ valid if previous_instance is None, indicating that the operation
+ was CreateInstance)
+ CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid
+ if previous_instance is not None, indicating that the operation
+ was ModifyInstance)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.set_instance()' \
+ % self.__class__.__name__)
+ # TODO create or modify the instance
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+ return instance
+
+ def delete_instance(self, env, instance_name):
+ """Delete an instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ instance_name -- A pywbem.CIMInstanceName specifying the instance
+ to delete.
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_NOT_SUPPORTED
+ CIM_ERR_INVALID_NAMESPACE
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified
+ namespace)
+ CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
+ Instance does not exist in the specified namespace)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.delete_instance()' \
+ % self.__class__.__name__)
+
+ # TODO delete the resource
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+
+ def cim_method_requeststatechange(self, env, object_name, method,
+ param_requestedstate,
+ param_timeoutperiod):
+ """Implements OMC_SyslogNGRecordLog.RequestStateChange()
+
+ Requests that the state of the element be changed to the value
+ specified in the RequestedState parameter. When the requested
+ state change takes place, the EnabledState and RequestedState of
+ the element will be the same. Invoking the RequestStateChange
+ method multiple times could result in earlier requests being
+ overwritten or lost. If 0 is returned, then the task completed
+ successfully and the use of ConcreteJob was not required. If 4096
+ (0x1000) is returned, then the task will take some time to
+ complete, ConcreteJob will be created, and its reference returned
+ in the output parameter Job. Any other return code indicates an
+ error condition.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName
+ specifying the object on which the method RequestStateChange()
+ should be invoked.
+ method -- A pywbem.CIMMethod representing the method meta-data
+ param_requestedstate -- The input parameter RequestedState (type pywbem.Uint16 self.Values.RequestStateChange.RequestedState)
+ The state requested for the element. This information will be
+ placed into the RequestedState property of the instance if the
+ return code of the RequestStateChange method is 0 ('Completed
+ with No Error'), 3 ('Timeout'), or 4096 (0x1000) ('Job
+ Started'). Refer to the description of the EnabledState and
+ RequestedState properties for the detailed explanations of the
+ RequestedState values.
+
+ param_timeoutperiod -- The input parameter TimeoutPeriod (type pywbem.CIMDateTime)
+ A timeout period that specifies the maximum amount of time that
+ the client expects the transition to the new state to take.
+ The interval format must be used to specify the TimeoutPeriod.
+ A value of 0 or a null parameter indicates that the client has
+ no time requirements for the transition. If this property
+ does not contain 0 or null and the implementation does not
+ support this parameter, a return code of 'Use Of Timeout
+ Parameter Not Supported' must be returned.
+
+
+ Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.RequestStateChange)
+ and a dictionary with the out-parameters
+
+ Output parameters:
+ Job -- (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...))
+ Reference to the job (can be null if the task is completed).
+
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate,
+ unrecognized or otherwise incorrect parameters)
+ CIM_ERR_NOT_FOUND (the target CIM Class or instance does not
+ exist in the specified namespace)
+ CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor
+ the invocation request)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.cim_method_requeststatechange()' \
+ % self.__class__.__name__)
+
+ # TODO do something
+ raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented
+ out_params = {}
+ #out_params['job'] = # TODO (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...))
+ rval = None # TODO (type pywbem.Uint32 self.Values.RequestStateChange)
+ return (rval, out_params)
+
+ def cim_method_clearlog(self, env, object_name, method):
+ """Implements OMC_SyslogNGRecordLog.ClearLog()
+
+ Requests that the Log be cleared of all entries. The return value
+ should be 0 if the request was successfully executed, 1 if the
+ request is not supported, and some other value, as indicated by
+ the ValueMap/Values qualifiers, if an error occurred.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName
+ specifying the object on which the method ClearLog()
+ should be invoked.
+ method -- A pywbem.CIMMethod representing the method meta-data
+
+ Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.ClearLog)
+ and a dictionary with the out-parameters
+
+ Output parameters: none
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate,
+ unrecognized or otherwise incorrect parameters)
+ CIM_ERR_NOT_FOUND (the target CIM Class or instance does not
+ exist in the specified namespace)
+ CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor
+ the invocation request)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.cim_method_clearlog()' \
+ % self.__class__.__name__)
+
+ # TODO do something
+ raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE) # Remove to implemented
+ out_params = {}
+ rval = None # TODO (type pywbem.Uint32 self.Values.ClearLog)
+ return (rval, out_params)
+
+ class Values(object):
+ class DetailedStatus(object):
+ Not_Available = pywbem.Uint16(0)
+ No_Additional_Information = pywbem.Uint16(1)
+ Stressed = pywbem.Uint16(2)
+ Predictive_Failure = pywbem.Uint16(3)
+ Non_Recoverable_Error = pywbem.Uint16(4)
+ Supporting_Entity_in_Error = pywbem.Uint16(5)
+ # DMTF_Reserved = ..
+ # Vendor_Reserved = 0x8000..
+
+ class RequestedState(object):
+ Unknown = pywbem.Uint16(0)
+ Enabled = pywbem.Uint16(2)
+ Disabled = pywbem.Uint16(3)
+ Shut_Down = pywbem.Uint16(4)
+ No_Change = pywbem.Uint16(5)
+ Offline = pywbem.Uint16(6)
+ Test = pywbem.Uint16(7)
+ Deferred = pywbem.Uint16(8)
+ Quiesce = pywbem.Uint16(9)
+ Reboot = pywbem.Uint16(10)
+ Reset = pywbem.Uint16(11)
+ Not_Applicable = pywbem.Uint16(12)
+ # DMTF_Reserved = ..
+ # Vendor_Reserved = 32768..65535
+
+ class HealthState(object):
+ Unknown = pywbem.Uint16(0)
+ OK = pywbem.Uint16(5)
+ Degraded_Warning = pywbem.Uint16(10)
+ Minor_failure = pywbem.Uint16(15)
+ Major_failure = pywbem.Uint16(20)
+ Critical_failure = pywbem.Uint16(25)
+ Non_recoverable_error = pywbem.Uint16(30)
+ # DMTF_Reserved = ..
+
+ class LogState(object):
+ Unknown = pywbem.Uint16(0)
+ Normal = pywbem.Uint16(2)
+ Erasing = pywbem.Uint16(3)
+ Not_Applicable = pywbem.Uint16(4)
+ # DMTF_Reserved = ..
+ # Vendor_Reserved = 32768..65535
+
+ class TransitioningToState(object):
+ Unknown = pywbem.Uint16(0)
+ Enabled = pywbem.Uint16(2)
+ Disabled = pywbem.Uint16(3)
+ Shut_Down = pywbem.Uint16(4)
+ No_Change = pywbem.Uint16(5)
+ Offline = pywbem.Uint16(6)
+ Test = pywbem.Uint16(7)
+ Defer = pywbem.Uint16(8)
+ Quiesce = pywbem.Uint16(9)
+ Reboot = pywbem.Uint16(10)
+ Reset = pywbem.Uint16(11)
+ Not_Applicable = pywbem.Uint16(12)
+
+ class EnabledDefault(object):
+ Enabled = pywbem.Uint16(2)
+ Disabled = pywbem.Uint16(3)
+ Not_Applicable = pywbem.Uint16(5)
+ Enabled_but_Offline = pywbem.Uint16(6)
+ No_Default = pywbem.Uint16(7)
+ Quiesce = pywbem.Uint16(9)
+ # DMTF_Reserved = ..
+ # Vendor_Reserved = 32768..65535
+
+ class EnabledState(object):
+ Unknown = pywbem.Uint16(0)
+ Other = pywbem.Uint16(1)
+ Enabled = pywbem.Uint16(2)
+ Disabled = pywbem.Uint16(3)
+ Shutting_Down = pywbem.Uint16(4)
+ Not_Applicable = pywbem.Uint16(5)
+ Enabled_but_Offline = pywbem.Uint16(6)
+ In_Test = pywbem.Uint16(7)
+ Deferred = pywbem.Uint16(8)
+ Quiesce = pywbem.Uint16(9)
+ Starting = pywbem.Uint16(10)
+ # DMTF_Reserved = 11..32767
+ # Vendor_Reserved = 32768..65535
+
+ class ClearLog(object):
+ Completed_with_no_error = pywbem.Uint32(0)
+ Not_Supported = pywbem.Uint32(1)
+ Unspecified_Error = pywbem.Uint32(2)
+ Timeout = pywbem.Uint32(3)
+ Failed = pywbem.Uint32(4)
+ Invalid_Parameter = pywbem.Uint32(5)
+ # DMTF_Reserved = 6..0x0FFF
+ # Method_Reserved = 0x1000..0x7FFF
+ # Vendor_Reserved = 0x8000..
+
+ class AvailableRequestedStates(object):
+ Enabled = pywbem.Uint16(2)
+ Disabled = pywbem.Uint16(3)
+ Shut_Down = pywbem.Uint16(4)
+ Offline = pywbem.Uint16(6)
+ Test = pywbem.Uint16(7)
+ Defer = pywbem.Uint16(8)
+ Quiesce = pywbem.Uint16(9)
+ Reboot = pywbem.Uint16(10)
+ Reset = pywbem.Uint16(11)
+
+ class Status(object):
+ OK = 'OK'
+ Error = 'Error'
+ Degraded = 'Degraded'
+ Unknown = 'Unknown'
+ Pred_Fail = 'Pred Fail'
+ Starting = 'Starting'
+ Stopping = 'Stopping'
+ Service = 'Service'
+ Stressed = 'Stressed'
+ NonRecover = 'NonRecover'
+ No_Contact = 'No Contact'
+ Lost_Comm = 'Lost Comm'
+ Stopped = 'Stopped'
+
+ class CommunicationStatus(object):
+ Unknown = pywbem.Uint16(0)
+ Not_Available = pywbem.Uint16(1)
+ Communication_OK = pywbem.Uint16(2)
+ Lost_Communication = pywbem.Uint16(3)
+ No_Contact = pywbem.Uint16(4)
+ # DMTF_Reserved = ..
+ # Vendor_Reserved = 0x8000..
+
+ class OperationalStatus(object):
+ Unknown = pywbem.Uint16(0)
+ Other = pywbem.Uint16(1)
+ OK = pywbem.Uint16(2)
+ Degraded = pywbem.Uint16(3)
+ Stressed = pywbem.Uint16(4)
+ Predictive_Failure = pywbem.Uint16(5)
+ Error = pywbem.Uint16(6)
+ Non_Recoverable_Error = pywbem.Uint16(7)
+ Starting = pywbem.Uint16(8)
+ Stopping = pywbem.Uint16(9)
+ Stopped = pywbem.Uint16(10)
+ In_Service = pywbem.Uint16(11)
+ No_Contact = pywbem.Uint16(12)
+ Lost_Communication = pywbem.Uint16(13)
+ Aborted = pywbem.Uint16(14)
+ Dormant = pywbem.Uint16(15)
+ Supporting_Entity_in_Error = pywbem.Uint16(16)
+ Completed = pywbem.Uint16(17)
+ Power_Mode = pywbem.Uint16(18)
+ # DMTF_Reserved = ..
+ # Vendor_Reserved = 0x8000..
+
+ class OperatingStatus(object):
+ Unknown = pywbem.Uint16(0)
+ Not_Available = pywbem.Uint16(1)
+ In_Service = pywbem.Uint16(2)
+ Starting = pywbem.Uint16(3)
+ Stopping = pywbem.Uint16(4)
+ Stopped = pywbem.Uint16(5)
+ Aborted = pywbem.Uint16(6)
+ Dormant = pywbem.Uint16(7)
+ Completed = pywbem.Uint16(8)
+ Migrating = pywbem.Uint16(9)
+ Emigrating = pywbem.Uint16(10)
+ Immigrating = pywbem.Uint16(11)
+ Snapshotting = pywbem.Uint16(12)
+ Shutting_Down = pywbem.Uint16(13)
+ In_Test = pywbem.Uint16(14)
+ # DMTF_Reserved = ..
+ # Vendor_Reserved = 0x8000..
+
+ class OverwritePolicy(object):
+ Unknown = pywbem.Uint16(0)
+ Wraps_When_Full = pywbem.Uint16(2)
+ Never_Overwrites = pywbem.Uint16(7)
+ # DMTF_Reserved = ..
+ # Vendor_Reserved = 32768..65535
+
+ class RequestStateChange(object):
+ Completed_with_No_Error = pywbem.Uint32(0)
+ Not_Supported = pywbem.Uint32(1)
+ Unknown_or_Unspecified_Error = pywbem.Uint32(2)
+ Cannot_complete_within_Timeout_Period = pywbem.Uint32(3)
+ Failed = pywbem.Uint32(4)
+ Invalid_Parameter = pywbem.Uint32(5)
+ In_Use = pywbem.Uint32(6)
+ # DMTF_Reserved = ..
+ Method_Parameters_Checked___Job_Started = pywbem.Uint32(4096)
+ Invalid_State_Transition = pywbem.Uint32(4097)
+ Use_of_Timeout_Parameter_Not_Supported = pywbem.Uint32(4098)
+ Busy = pywbem.Uint32(4099)
+ # Method_Reserved = 4100..32767
+ # Vendor_Specific = 32768..65535
+ class RequestedState(object):
+ Enabled = pywbem.Uint16(2)
+ Disabled = pywbem.Uint16(3)
+ Shut_Down = pywbem.Uint16(4)
+ Offline = pywbem.Uint16(6)
+ Test = pywbem.Uint16(7)
+ Defer = pywbem.Uint16(8)
+ Quiesce = pywbem.Uint16(9)
+ Reboot = pywbem.Uint16(10)
+ Reset = pywbem.Uint16(11)
+ # DMTF_Reserved = ..
+ # Vendor_Reserved = 32768..65535
+
+ class PrimaryStatus(object):
+ Unknown = pywbem.Uint16(0)
+ OK = pywbem.Uint16(1)
+ Degraded = pywbem.Uint16(2)
+ Error = pywbem.Uint16(3)
+ # DMTF_Reserved = ..
+ # Vendor_Reserved = 0x8000..
+
+## end of class OMC_SyslogNGRecordLogProvider
+"""Python Provider for OMC_SyslogNGLogRecord
+
+Instruments the CIM class OMC_SyslogNGLogRecord
+
+"""
+
+import pywbem
+
+class OMC_SyslogNGLogRecordProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_SyslogNGLogRecord
+
+ Class representing a record in a log file.
+
+ """
+
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+ # If you will be filtering instances yourself according to
+ # property_list, role, result_role, and result_class_name
+ # parameters, set self.filter_results to False
+ # self.filter_results = False
+
+ def get_instance(self, env, model, cim_class, line=None):
+ """Return an instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ model -- A template of the pywbem.CIMInstance to be returned. The
+ key properties are set on this instance to correspond to the
+ instanceName that was requested. The properties of the model
+ are already filtered according to the PropertyList from the
+ request. Only properties present in the model need to be
+ given values. If you prefer, you can set all of the
+ values, and the instance will be filtered for you.
+ cim_class -- The pywbem.CIMClass
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
+ Instance does not exist in the specified namespace)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+
+ ux = model.update_existing
+
+ # TODO fetch system resource matching the following keys:
+ # model['LogCreationClassName']
+ # model['MessageTimestamp']
+ # model['RecordID']
+ # model['LogName']
+ # model['CreationClassName']
+ try:
+ fname = model['LogName']
+ lineno = int(model['RecordID'])
+ except KeyError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ except ValueError:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+
+ if line is None:
+ fo = open(fname, 'r')
+ cnt = 0
+ for line in fo:
+ cnt+= 1
+ if cnt == lineno:
+ break
+ else:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ ux(RecordData=line.strip())
+ ux(ElementName=fname)
+
+ #ux(Caption='') # TODO
+ #ux(DataFormat='') # TODO
+ #ux(Description='') # TODO
+ #ux(Locale='') # TODO
+ #ux(RecordFormat='') # TODO
+ return model
+
+ def enum_instances(self, env, model, cim_class, keys_only):
+ """Enumerate instances.
+
+ The WBEM operations EnumerateInstances and EnumerateInstanceNames
+ are both mapped to this method.
+ This method is a python generator
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ model -- A template of the pywbem.CIMInstances to be generated.
+ The properties of the model are already filtered according to
+ the PropertyList from the request. Only properties present in
+ the model need to be given values. If you prefer, you can
+ always set all of the values, and the instance will be filtered
+ for you.
+ cim_class -- The pywbem.CIMClass
+ keys_only -- A boolean. True if only the key properties should be
+ set on the generated instances.
+
+ Possible Errors:
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+
+ model['LogCreationClassName'] = 'OMC_SyslogNGRecordLog'
+ model['CreationClassName'] = 'OMC_SyslogNGLogRecord'
+ for fname in _get_syslog_list():
+ fo = open(fname, 'r')
+ model['LogName'] = fname
+ lineno = 0
+ for line in fo:
+ model['MessageTimestamp'] = pywbem.CIMDateTime.now()
+ lineno+= 1
+ model['RecordID'] = str(lineno)
+ if keys_only:
+ yield model
+ else:
+ try:
+ yield self.get_instance(env, model, cim_class, line)
+ except pywbem.CIMError, (num, msg):
+ if num not in (pywbem.CIM_ERR_NOT_FOUND,
+ pywbem.CIM_ERR_ACCESS_DENIED):
+ raise
+
+ def set_instance(self, env, instance, previous_instance, cim_class):
+ """Return a newly created or modified instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ instance -- The new pywbem.CIMInstance. If modifying an existing
+ instance, the properties on this instance have been filtered by
+ the PropertyList from the request.
+ previous_instance -- The previous pywbem.CIMInstance if modifying
+ an existing instance. None if creating a new instance.
+ cim_class -- The pywbem.CIMClass
+
+ Return the new instance. The keys must be set on the new instance.
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_NOT_SUPPORTED
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only
+ valid if previous_instance is None, indicating that the operation
+ was CreateInstance)
+ CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid
+ if previous_instance is not None, indicating that the operation
+ was ModifyInstance)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.set_instance()' \
+ % self.__class__.__name__)
+ # TODO create or modify the instance
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+ return instance
+
+ def delete_instance(self, env, instance_name):
+ """Delete an instance.
+
+ Keyword arguments:
+ env -- Provider Environment (pycimmb.ProviderEnvironment)
+ instance_name -- A pywbem.CIMInstanceName specifying the instance
+ to delete.
+
+ Possible Errors:
+ CIM_ERR_ACCESS_DENIED
+ CIM_ERR_NOT_SUPPORTED
+ CIM_ERR_INVALID_NAMESPACE
+ CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized
+ or otherwise incorrect parameters)
+ CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified
+ namespace)
+ CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM
+ Instance does not exist in the specified namespace)
+ CIM_ERR_FAILED (some other unspecified error occurred)
+
+ """
+
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.delete_instance()' \
+ % self.__class__.__name__)
+
+ # TODO delete the resource
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) # Remove to implement
+
+## end of class OMC_SyslogNGLogRecordProvider
+
+def get_providers(env):
+ omc_syslogngrecordlog_prov = OMC_SyslogNGRecordLogProvider(env)
+ omc_syslognglogrecord_prov = OMC_SyslogNGLogRecordProvider(env)
+ return {'OMC_SyslogNGRecordLog': omc_syslogngrecordlog_prov,
+ 'OMC_SyslogNGLogRecord': omc_syslognglogrecord_prov}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-14 22:54:40
|
Revision: 511
http://omc.svn.sourceforge.net/omc/?rev=511&view=rev
Author: jcarey
Date: 2007-12-14 14:54:45 -0800 (Fri, 14 Dec 2007)
Log Message:
-----------
added ntp.conf parsing code
Modified Paths:
--------------
pybase/trunk/OMC_TimeService.py
Modified: pybase/trunk/OMC_TimeService.py
===================================================================
--- pybase/trunk/OMC_TimeService.py 2007-12-14 20:10:09 UTC (rev 510)
+++ pybase/trunk/OMC_TimeService.py 2007-12-14 22:54:45 UTC (rev 511)
@@ -7,6 +7,188 @@
_fqdn = socket.getfqdn()
###############################################################################
+class NTPServer(object):
+ ###########################################################################
+ def __init__(self):
+ self.server_name = ''
+ self.prefer = False
+ self.key = 0
+ self.ntp_version = 0
+ self.min_poll = 0
+ self.max_poll = 0
+
+ ###########################################################################
+ def config_line(self):
+ line = 'server %s' % self.server_name
+ if self.prefer:
+ line += ' prefer'
+ if self.key:
+ line += ' key %s' % str(self.key)
+ if self.ntp_version:
+ line += ' version %s' % str(self.ntp_version)
+ if self.min_poll:
+ line += ' minpoll %s' % str(self.min_poll)
+ if self.max_poll:
+ line += ' maxpoll %s' % str(self.max_poll)
+ line += '\n'
+ return line
+
+ ###########################################################################
+ @classmethod
+ def __server_from_conf_line(cls, line):
+ tl = line.strip()
+ if len(tl) < 6:
+ return None
+ if tl[0:6].lower() != 'server':
+ return None
+ toks = tl.split()
+ tokslen = len(toks)
+ if tokslen < 2:
+ return None
+ server = NTPServer()
+ server.server_name = toks[1]
+ if tokslen < 3:
+ return server
+ i = 2
+ while i < tokslen:
+ utok = toks[i].lower()
+ if utok == 'prefer':
+ server.prefer = True
+ continue
+ if i < (tokslen-1):
+ if utok == 'key':
+ i += 1
+ server.key = int(toks[i])
+ elif utok == 'version':
+ i += 1
+ server.ntp_version = int(toks[i])
+ elif utok == 'mode':
+ i += 1
+ # Ignore
+ elif utok == 'minpoll':
+ i += 1
+ server.min_poll = int(toks[i])
+ elif utok == 'maxpoll':
+ i += 1
+ server.max_poll = int(toks[i])
+ return server
+
+ ###########################################################################
+ @classmethod
+ def get_servers(cls):
+ servers = []
+ if not os.path.exists('/etc/ntp.conf'):
+ return None
+ f = open('/etc/ntp.conf')
+ try:
+ for line in f:
+ server = __server_from_conf_line(line)
+ if server is not None:
+ servers.append(server)
+ return servers
+ finally:
+ f.close()
+
+ ###########################################################################
+ @classmethod
+ def get_server(cls, server_name):
+ if not os.path.exists('/etc/ntp.conf'):
+ return None
+ f = open('/etc/ntp.conf')
+ try:
+ usn = server_name.lower()
+ for line in f:
+ server = __server_from_conf_line(line)
+ if server is not None:
+ if server.server_name.lower() == usn:
+ return server
+ return None
+ finally:
+ f.close()
+
+ ###########################################################################
+ @classmethod
+ def delete_server(cls, server_name):
+ modified = False
+ usname = server_name.lower()
+ tfd,tfname = tempfile.mkstemp(dir='/etc')
+ tfile = os.fdopen(tfd, 'w')
+ cfile = open('/etc/ntp.conf')
+ try:
+ for line in cfile:
+ server = __server_from_conf_line(line)
+ if server is None:
+ tfile.write(line)
+ continue
+ if server.server_name.lower() == usname:
+ modified = True
+ else:
+ tfile.write(line)
+ tfile.close()
+ cfile.close()
+ if not modified:
+ os.unlink(tfname)
+ else:
+ os.unlink('/etc/ntp.conf')
+ os.rename(tfname, '/etc/ntp.conf')
+ return modified
+ except Exception,einst:
+ tfile.close()
+ cfile.close()
+ if tfname:
+ try:
+ os.unlink(tfname)
+ except:
+ pass
+ raise einst
+
+ ###########################################################################
+ @classmethod
+ def set_server(cls, ntpserver):
+ modified = False
+ server_written = False
+ usname = server_name.lower()
+ tfd,tfname = tempfile.mkstemp(dir='/etc')
+ tfile = os.fdopen(tfd, 'w')
+ cfile = open('/etc/ntp.conf')
+ try:
+ for line in cfile:
+ server = __server_from_conf_line(line)
+ if server is None:
+ tfile.write(line)
+ elif server.server_name.lower() == usname:
+ modified = True
+ server_written = True
+ tfile.write(ntpserver.config_line())
+ else:
+ if ntpserver.prefer and server.prefer:
+ modified = True
+ server.prefer = False
+ tfile.write(ntpserver.config_line())
+ else:
+ tfile.write(line)
+ if not server_written:
+ modified = True
+ tfile.write(ntpserver.config_line())
+ tfile.close()
+ cfile.close()
+ if not modified:
+ os.unlink(tfname)
+ else:
+ os.unlink('/etc/ntp.conf')
+ os.rename(tfname, '/etc/ntp.conf')
+ return modified
+ except Exception,einst:
+ tfile.close()
+ cfile.close()
+ if tfname:
+ try:
+ os.unlink(tfname)
+ except:
+ pass
+ raise einst
+
+###############################################################################
def _clock_conf_key_value(line):
tline = line.strip(' \n\r')
if not len(tline) or tline.startswith('#'):
@@ -251,27 +433,35 @@
logger = env.get_logger()
logger.log_debug('Initializing provider %s from %s' \
% (self.__class__.__name__, __file__))
- # If you will be filtering instances yourself according to
- # property_list, role, result_role, and result_class_name
- # parameters, set self.filter_results to False
- # self.filter_results = False
###########################################################################
def get_instance(self, env, model, cim_class):
- # TODO
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
% self.__class__.__name__)
+ for nm in ['Dependent', 'Antecedent']:
+ if nm not in model:
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ if not _is_service_ref(model['Dependent']):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
+ if not _is_cs_ref(model['Antecedent']):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
return model
###########################################################################
def enum_instances(self, env, model, cim_class, keys_only):
- # TODO
logger = env.get_logger()
logger.log_debug('Entering %s.enum_instances()' \
% self.__class__.__name__)
- if False:
- yield None
+ model['Antecedent'] = pywbem.CIMInstanceName(
+ classname='OMC_UnitaryComputerSystem',
+ namespace=model.path.namespace,
+ keybindings={'CreationClassName':'OMC_UnitaryComputerSystem',
+ 'Name':_fqdn})
+ ref = pywbem.CIMInstanceName(classname='OMC_SystemTimeService',
+ namespace=model.path.namespace)
+ model['Dependent'] = _fill_service_instance(ref, True)
+ yield model
###########################################################################
def set_instance(self, env, instance, previous_instance, cim_class):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-14 20:10:07
|
Revision: 510
http://omc.svn.sourceforge.net/omc/?rev=510&view=rev
Author: jcarey
Date: 2007-12-14 12:10:09 -0800 (Fri, 14 Dec 2007)
Log Message:
-----------
Implemented the OMC_HostedTimeService association
Modified Paths:
--------------
pybase/trunk/OMC_TimeService-peg.reg
pybase/trunk/OMC_TimeService.py
pybase/trunk/OMC_TimeService.reg
Modified: pybase/trunk/OMC_TimeService-peg.reg
===================================================================
--- pybase/trunk/OMC_TimeService-peg.reg 2007-12-14 16:24:00 UTC (rev 509)
+++ pybase/trunk/OMC_TimeService-peg.reg 2007-12-14 20:10:09 UTC (rev 510)
@@ -18,39 +18,40 @@
CapabilityID = "OMC_TimeService_Capability1";
ProviderModuleName = "OMC_TimeServiceProvider_Module";
ProviderName = "OMC_TimeService_Provider";
- ClassName = "OMC_TimeService";
+ ClassName = "OMC_SystemTimeService";
Namespaces = {"root/cimv2"};
ProviderType = {2,5}; // Instance, Method
};
instance of PG_ProviderCapabilities
{
- CapabilityID = "OMC_TimeService_Capability2";
+ CapabilityID = "OMC_TimeService_Capability4";
ProviderModuleName = "OMC_TimeServiceProvider_Module";
ProviderName = "OMC_TimeService_Provider";
- ClassName = "OMC_RemoteTimeServicePort";
+ ClassName = "OMC_HostedTimeService";
Namespaces = {"root/cimv2"};
- ProviderType = {2,5}; // Instance, Method
+ ProviderType = {2,3}; // Instance, Associator
};
+/*
instance of PG_ProviderCapabilities
{
- CapabilityID = "OMC_TimeService_Capability3";
+ CapabilityID = "OMC_TimeService_Capability2";
ProviderModuleName = "OMC_TimeServiceProvider_Module";
ProviderName = "OMC_TimeService_Provider";
- ClassName = "OMC_TimeZoneSettingData";
+ ClassName = "OMC_RemoteTimeServicePort";
Namespaces = {"root/cimv2"};
- ProviderType = {2}; // Instance
+ ProviderType = {2,5}; // Instance, Method
};
instance of PG_ProviderCapabilities
{
- CapabilityID = "OMC_TimeService_Capability4";
+ CapabilityID = "OMC_TimeService_Capability3";
ProviderModuleName = "OMC_TimeServiceProvider_Module";
ProviderName = "OMC_TimeService_Provider";
- ClassName = "OMC_HostedTimeService";
+ ClassName = "OMC_TimeZoneSettingData";
Namespaces = {"root/cimv2"};
- ProviderType = {2,3}; // Instance, Associator
+ ProviderType = {2}; // Instance
};
instance of PG_ProviderCapabilities
@@ -83,6 +84,7 @@
ProviderType = {2,3}; // Instance, Associator
};
+*/
@@ -92,4 +94,3 @@
-
Modified: pybase/trunk/OMC_TimeService.py
===================================================================
--- pybase/trunk/OMC_TimeService.py 2007-12-14 16:24:00 UTC (rev 509)
+++ pybase/trunk/OMC_TimeService.py 2007-12-14 20:10:09 UTC (rev 510)
@@ -6,6 +6,7 @@
_fqdn = socket.getfqdn()
+###############################################################################
def _clock_conf_key_value(line):
tline = line.strip(' \n\r')
if not len(tline) or tline.startswith('#'):
@@ -17,6 +18,7 @@
return (key,value)
return None
+###############################################################################
def _clock_conf_get_time_zone():
is_utc = False
timezone = ''
@@ -42,6 +44,7 @@
finally:
f.close()
+###############################################################################
def _clock_conf_modify(is_utc, timezone):
modified = False
tfname = None
@@ -80,6 +83,16 @@
pass
raise einst
+###############################################################################
+def _is_cs_ref(model):
+ if 'CreationClassName' not in model \
+ or 'Name' not in model:
+ return False
+ if model['CreationClassName'].lower() != 'omc_unitarycomputersystem':
+ return False
+ return model['Name'].lower() == _fqdn.lower()
+
+###############################################################################
def _is_service_ref(model):
for nm in ['SystemCreationClassName', 'SystemName', 'CreationClassName', 'Name']:
if nm not in model:
@@ -92,6 +105,7 @@
return False
return model['Name'].lower() == 'timeservice'
+###############################################################################
def _fill_service_instance(model, keys_only):
model['SystemCreationClassName'] = 'OMC_UnitaryComputerSystem'
model['SystemName'] = _fqdn
@@ -112,9 +126,11 @@
model['StartMode'] = 'Automatic'
return model
-class OMC_TimeServiceProvider(pywbem.CIMProvider):
- """Instrument the CIM class OMC_TimeService"""
+###############################################################################
+class OMC_SystemTimeServiceProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_SystemTimeService"""
+ ###########################################################################
def __init__ (self, env):
logger = env.get_logger()
logger.log_debug('Initializing provider %s from %s' \
@@ -124,6 +140,7 @@
# parameters, set self.filter_results to False
# self.filter_results = False
+ ###########################################################################
def get_instance(self, env, model, cim_class):
logger = env.get_logger()
logger.log_debug('Entering %s.get_instance()' \
@@ -132,36 +149,40 @@
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
return _fill_service_instance(model, False)
+ ###########################################################################
def enum_instances(self, env, model, cim_class, keys_only):
logger = env.get_logger()
logger.log_debug('Entering %s.enum_instances()' \
% self.__class__.__name__)
yield _fill_service_instance(model, keys_only)
+ ###########################################################################
def set_instance(self, env, instance, previous_instance, cim_class):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+ ###########################################################################
def delete_instance(self, env, instance_name):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+ ###########################################################################
def cim_method_requeststatechange(self, env, object_name, method,
- param_requestedstate,
- param_timeoutperiod):
+ param_requestedstate, param_timeoutperiod):
# Not supported
return (pywbem.Uint32(1), {})
+ ###########################################################################
def cim_method_startservice(self, env, object_name, method):
# Not supported
return (pywbem.Uint32(1), {})
+ ###########################################################################
def cim_method_stopservice(self, env, object_name, method):
# Not supported
return (pywbem.Uint32(1), {})
+ ###########################################################################
def cim_method_managetime(self, env, object_name, method,
- param_timedata,
- param_getrequest,
- param_managedelement):
+ param_timedata, param_getrequest, param_managedelement):
logger = env.get_logger()
logger.log_debug('Entering %s.cim_method_managetime()' \
% self.__class__.__name__)
@@ -219,8 +240,97 @@
'time' % str(inst))
return (pywbem.Uint32(0), {})
-## end of class OMC_TimeServiceProvider
+## end of class OMC_SystemTimeServiceProvider
+###############################################################################
+class OMC_HostedTimeServiceProvider(pywbem.CIMProvider):
+ """Instrument the CIM class OMC_HostedTimeService"""
+
+ ###########################################################################
+ def __init__ (self, env):
+ logger = env.get_logger()
+ logger.log_debug('Initializing provider %s from %s' \
+ % (self.__class__.__name__, __file__))
+ # If you will be filtering instances yourself according to
+ # property_list, role, result_role, and result_class_name
+ # parameters, set self.filter_results to False
+ # self.filter_results = False
+
+ ###########################################################################
+ def get_instance(self, env, model, cim_class):
+ # TODO
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.get_instance()' \
+ % self.__class__.__name__)
+ return model
+
+ ###########################################################################
+ def enum_instances(self, env, model, cim_class, keys_only):
+ # TODO
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.enum_instances()' \
+ % self.__class__.__name__)
+ if False:
+ yield None
+
+ ###########################################################################
+ def set_instance(self, env, instance, previous_instance, cim_class):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+
+ ###########################################################################
+ def delete_instance(self, env, instance_name):
+ raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED)
+
+ ###########################################################################
+ def references(self, env, object_name, model, assoc_class,
+ result_class_name, role, result_role, keys_only):
+ logger = env.get_logger()
+ logger.log_debug('Entering %s.references()' \
+ % self.__class__.__name__)
+ ch = env.get_cimom_handle()
+ if object_name.classname.lower() == 'omc_systemtimeservice':
+ if not _is_service_ref(object_name):
+ return
+ if role and role.lower() != 'dependent':
+ return
+ if result_role and result_role.lower() != 'antecedent':
+ return
+ if result_class_name:
+ if not pywbem.is_subclass(env.get_cimom_handle(),
+ object_name.namespace, sub='omc_unitarycomputersystem',
+ super=result_class_name):
+ return
+ model['Dependent'] = object_name
+ model['Antecedent'] = pywbem.CIMInstanceName(
+ classname='OMC_UnitaryComputerSystem',
+ namespace=object_name.namespace,
+ keybindings={'CreationClassName':'OMC_UnitaryComputerSystem',
+ 'Name':_fqdn})
+ yield model
+
+ elif object_name.classname.lower() == 'omc_unitarycomputersystem':
+ if not _is_cs_ref(object_name):
+ return
+ if role and role.lower() != 'antecedent':
+ return
+ if result_role and result_role.lower() != 'dependent':
+ return
+ if result_class:
+ if not pywbem.is_subclass(env.get_cimom_handle(),
+ object_name.namespace, sub='omc_systemtimeservice',
+ super=result_class_name):
+ return
+ model['Antecedent'] = object_name
+ ref = pywbem.CIMInstanceName(classname='OMC_SystemTimeService',
+ namespace=object_name.namespace)
+ model['Dependent'] = _fill_service_instance(ref, True)
+ yield model
+
+## end of class OMC_HostedTimeServiceProvider
+
def get_providers(env):
- omc_timeservice_prov = OMC_TimeServiceProvider(env)
- return {'OMC_TimeService': omc_timeservice_prov}
+ omc_systemtimeservice_prov = OMC_SystemTimeServiceProvider(env)
+ omc_hostedtimeservice_prov = OMC_HostedTimeServiceProvider(env)
+ return {'OMC_SystemTimeService': omc_systemtimeservice_prov,
+ 'OMC_HostedTimeService': omc_hostedtimeservice_prov}
+
Modified: pybase/trunk/OMC_TimeService.reg
===================================================================
--- pybase/trunk/OMC_TimeService.reg 2007-12-14 16:24:00 UTC (rev 509)
+++ pybase/trunk/OMC_TimeService.reg 2007-12-14 20:10:09 UTC (rev 510)
@@ -3,7 +3,7 @@
{
InstanceID = "OMC_TimeService:0001";
NamespaceNames = {"root/cimv2"};
- ClassName = "OMC_TimeService";
+ ClassName = "OMC_SystemTimeService";
ProviderTypes = {1,6}; // Instance, Method
ModulePath = "/usr/lib/pycim/OMC_TimeService.py";
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jc...@us...> - 2007-12-14 16:24:06
|
Revision: 509
http://omc.svn.sourceforge.net/omc/?rev=509&view=rev
Author: jcarey
Date: 2007-12-14 08:24:00 -0800 (Fri, 14 Dec 2007)
Log Message:
-----------
Got the method on OMC_TimeService working
Modified Paths:
--------------
pybase/trunk/OMC_TimeService.py
Modified: pybase/trunk/OMC_TimeService.py
===================================================================
--- pybase/trunk/OMC_TimeService.py 2007-12-14 00:00:56 UTC (rev 508)
+++ pybase/trunk/OMC_TimeService.py 2007-12-14 16:24:00 UTC (rev 509)
@@ -8,7 +8,7 @@
def _clock_conf_key_value(line):
tline = line.strip(' \n\r')
- if not len(sl) or sl.startswith('#'):
+ if not len(tline) or tline.startswith('#'):
return None
ndx = tline.find('=')
if ndx != -1:
@@ -81,14 +81,14 @@
raise einst
def _is_service_ref(model):
- for nm in ['SystemCreationClassName' 'SystemName', 'CreationClassName', 'Name']:
+ for nm in ['SystemCreationClassName', 'SystemName', 'CreationClassName', 'Name']:
if nm not in model:
return False
if model['SystemCreationClassName'].lower() != 'omc_unitarycomputersystem':
return False
if model['SystemName'].lower() != _fqdn.lower():
return False
- if model['CreationClassName'].lower() = 'omc_systemtimeservice':
+ if model['CreationClassName'].lower() != 'omc_systemtimeservice':
return False
return model['Name'].lower() == 'timeservice'
@@ -130,7 +130,7 @@
% self.__class__.__name__)
if not _is_service_ref(model):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
- return _fill_service_instance(model, false)
+ return _fill_service_instance(model, False)
def enum_instances(self, env, model, cim_class, keys_only):
logger = env.get_logger()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2007-12-14 00:00:52
|
Revision: 508
http://omc.svn.sourceforge.net/omc/?rev=508&view=rev
Author: mattvryan
Date: 2007-12-13 16:00:56 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
Initial checkin of test directory, to house omc base provider test
scripts.
Initial checkin of stubbed-out omcbase_test.py.
Added Paths:
-----------
test/
test/trunk/
test/trunk/omcbase_test.py
Added: test/trunk/omcbase_test.py
===================================================================
--- test/trunk/omcbase_test.py (rev 0)
+++ test/trunk/omcbase_test.py 2007-12-14 00:00:56 UTC (rev 508)
@@ -0,0 +1,175 @@
+#!/usr/bin/env python
+
+import unittest
+import optparse
+import pywbem
+import os
+
+_globalVerbose = False
+_globalNamespace = 'root/cimv2'
+
+class WBEMConn:
+
+ # Borgness
+ _shared_state = {}
+ conn = None
+
+ def __init__(self, options=None):
+ # Borgness
+ self.__dict__ = WBEMConn._shared_state
+
+ if options:
+ proto = 'http'
+ if options.secure:
+ proto = 'https'
+ url = '%s://%s' % (proto, options.host)
+ self.conn = pywbem.WBEMConnection(
+ url,
+ (options.user, options.password),
+ default_namespace = options.namespace)
+
+
+class TestOMCBase(unittest.TestCase):
+
+ _supportedClasses = {}
+
+ def _isClassSupported(self,classname):
+ try:
+ return self._supportedClasses[classname]
+ except KeyError:
+ try:
+ if self._conn.GetClass(classname, _globalNamespace) is not None:
+ self._supportedClasses[classname] = True
+ else:
+ self._supportedClasses[classname] = False
+ except:
+ self._supportedClasses[classname] = False
+ return self._supportedClasses[classname]
+
+ def _dbgPrint(self, msg=''):
+ if self._verbose:
+ if len(msg):
+ print('\t -- %s --' % msg)
+ else:
+ print('')
+
+ def _showMissingClassNotice(self, classname, testname):
+ self._dbgPrint("NOTICE: Skipping all %s tests for test %s: Class not loaded." % (classname, testname))
+
+ def _showUnsupportedAssnNotice(self, assnname, classname, testname):
+ self._dbgPrint('NOTICE: Skipping all %s tests for test %s: Associated class %s not loaded.' % (assnname, classname, testname))
+
+ def _isSupportedAssn(self, assnname, cname1, cname2, testname):
+ if not self._isClassSupported(cname1):
+ self._showUnsupportedAssnNotice(assnname, cname1, testname)
+ return False
+ elif not self._isClassSupported(cname2):
+ self._showUnsupportedAssnNotice(assnname, cname2, testname)
+ return False
+ return True
+
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+ self._conn = WBEMConn().conn
+ self._verbose = _globalVerbose
+ self._dbgPrint()
+
+ def tearDown(self):
+ unittest.TestCase.tearDown(self)
+
+ def _omc_initdservice_test(self):
+ svcs = []
+ for file in os.listdir('/etc/init.d'):
+ if file.startswith('.') or not os.path.isfile('/etc/init.d/%s' % file):
+ continue
+ svcs.append(file)
+ print len(svcs)
+ insts = self._conn.EnumerateInstanceNames('OMC_InitdService') # , LocalOnly=False)
+ print len(insts)
+ for svc in svcs:
+ found = False
+ for i in insts:
+ if i['name'] == svc:
+ found = True
+ if not found:
+ print "Couldn't find a match for %s" % svc
+
+ def _omc_runlevel_test(self):
+ # Do all the runlevel instance tests - check against system
+ pass
+
+ def _omc_hostedinitdservice_test(self):
+ if self._isSupportedAssn('OMC_HostedInitdService',
+ 'OMC_UnitaryComputerSystem',
+ 'OMC_InitdService',
+ 'initd'):
+ # Test the assn
+ pass
+
+ def _omc_runlevelincomputersystem_test(self):
+ pass
+
+ def _omc_initdservicerunlevel_test(self):
+ pass
+
+ def test_initd(self):
+ initdClasses = {'OMC_InitdService' : self._omc_initdservice_test,
+ 'OMC_Runlevel' : self._omc_runlevel_test,
+ 'OMC_HostedInitdService' : self._omc_hostedinitdservice_test,
+ 'OMC_RunlevelInComputerSystem' : self._omc_runlevelincomputersystem_test,
+ 'OMC_InitdServiceRunLevel' : self._omc_initdservicerunlevel_test}
+ for classname in initdClasses.keys():
+ if not self._isClassSupported(classname):
+ self._showMissingClassNotice(classname, 'initd')
+ else:
+ initdClasses[classname]()
+
+ def test_syslogd(self):
+ pass
+
+ def test_logical_file(self):
+ pass
+
+ def test_operating_system(self):
+ pass
+
+ def test_unitary_computer_system(self):
+ pass
+
+ def test_unix_process(self):
+ pass
+
+ def test_time_service(self):
+ pass
+
+
+if __name__ == '__main__':
+ parser = optparse.OptionParser()
+ parser.add_option('--level',
+ '-l',
+ action='store',
+ type='int',
+ dest='dbglevel',
+ help='Indicate the level of debugging statements to display (default=2)',
+ default=2)
+ parser.add_option('', '--host', default='localhost',
+ help='Specify the hosting machine of the CIMOM (default=localhost)')
+ parser.add_option('-s', '--secure', action='store_true', default=False,
+ help='Use the HTTPS protocol. Default is HTTP')
+ parser.add_option('-n', '--namespace', default='root/cimv2',
+ help='Specify the namespace the test runs against (default=root/cimv2)')
+ parser.add_option('', '--user', default='',
+ help='Specify the user name used when connection to the CIMOM')
+ parser.add_option('', '--password', default='',
+ help='Specify the password for the user')
+ parser.add_option('--verbose', '', action='store_true', default=False,
+ help='Show verbose output')
+ options, arguments = parser.parse_args()
+
+ _globalVerbose = options.verbose
+ _globalNamespace = options.namespace
+
+ wconn = WBEMConn(options)
+ suite = unittest.makeSuite(TestOMCBase)
+ unittest.TextTestRunner(verbosity=options.dbglevel).run(suite)
+
Property changes on: test/trunk/omcbase_test.py
___________________________________________________________________
Name: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|