|
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...> - 2008-02-13 20:18:43
|
Revision: 535
http://omc.svn.sourceforge.net/omc/?rev=535&view=rev
Author: bartw
Date: 2008-02-13 12:18:47 -0800 (Wed, 13 Feb 2008)
Log Message:
-----------
minor fix
Modified Paths:
--------------
pybase/trunk/OMC_LogicalFile.py
Modified: pybase/trunk/OMC_LogicalFile.py
===================================================================
--- pybase/trunk/OMC_LogicalFile.py 2008-01-07 17:49:30 UTC (rev 534)
+++ pybase/trunk/OMC_LogicalFile.py 2008-02-13 20:18:47 UTC (rev 535)
@@ -541,6 +541,8 @@
dirs = ['/' + dir for dir in os.listdir('/')]
for dir in ['/'] + dirs:
stat = os.lstat(dir)
+ if not S_ISDIR(stat.st_mode):
+ continue
get_file_keys(dir, model, stat=stat)
if keys_only:
yield model
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2008-02-14 03:50:03
|
Revision: 536
http://omc.svn.sourceforge.net/omc/?rev=536&view=rev
Author: bartw
Date: 2008-02-13 19:50:09 -0800 (Wed, 13 Feb 2008)
Log Message:
-----------
fixed FileIdentity assoc. to not require all of the keys of the target object
Modified Paths:
--------------
pybase/trunk/OMC_LogicalFile.py
Modified: pybase/trunk/OMC_LogicalFile.py
===================================================================
--- pybase/trunk/OMC_LogicalFile.py 2008-02-13 20:18:47 UTC (rev 535)
+++ pybase/trunk/OMC_LogicalFile.py 2008-02-14 03:50:09 UTC (rev 536)
@@ -713,29 +713,39 @@
if object_name.classname.lower() == 'omc_linuxfile':
model['SameElement'] = object_name
+ try:
+ keybindings = {
+ 'Name':object_name['LFName'],
+ 'FSName':object_name['FSName'],
+ 'FSCreationClassName':object_name['FSCreationClassName'],
+ 'CSName':getfqdn(),
+ 'CSCreationClassName':object_name['CSCreationClassName'],
+ 'CreationClassName':object_name['LFCreationClassName']}
+ except KeyError:
+ keybindings = {}
+ get_file_keys(object_name['LFname'], keybindings)
model['SystemElement'] = pywbem.CIMInstanceName(
classname=object_name['LFCreationClassName'],
namespace=object_name.namespace,
- keybindings={
- 'Name':object_name['LFName'],
- 'FSName':object_name['FSName'],
- 'FSCreationClassName':object_name['FSCreationClassName'],
- 'CSName':getfqdn(),
- 'CSCreationClassName':object_name['CSCreationClassName'],
- 'CreationClassName':object_name['LFCreationClassName']})
+ keybindings=keybindings)
yield model
else:
model['SystemElement'] = object_name
- model['SameElement'] = pywbem.CIMInstanceName(
- classname='OMC_LinuxFile',
- namespace=object_name.namespace,
- keybindings={
+ try:
+ keybindings = {
'LFName':object_name['Name'],
'FSName':object_name['FSName'],
'FSCreationClassName':object_name['FSCreationClassName'],
'CSName':getfqdn(),
'CSCreationClassName':object_name['CSCreationClassName'],
- 'LFCreationClassName':object_name['CreationClassName']})
+ 'LFCreationClassName':object_name['CreationClassName']}
+ except KeyError:
+ keybindings = {}
+ get_file_keys(object_name['Name'], keybindings, linux_file=True)
+ model['SameElement'] = pywbem.CIMInstanceName(
+ classname='OMC_LinuxFile',
+ namespace=object_name.namespace,
+ keybindings=keybindings)
yield model
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2008-04-07 20:17:06
|
Revision: 549
http://omc.svn.sourceforge.net/omc/?rev=549&view=rev
Author: bartw
Date: 2008-04-07 13:15:59 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
fixed LinuxFileIdentity.enum_instances
Modified Paths:
--------------
pybase/trunk/OMC_LogicalFile.py
Modified: pybase/trunk/OMC_LogicalFile.py
===================================================================
--- pybase/trunk/OMC_LogicalFile.py 2008-04-07 17:44:16 UTC (rev 548)
+++ pybase/trunk/OMC_LogicalFile.py 2008-04-07 20:15:59 UTC (rev 549)
@@ -664,8 +664,10 @@
"""
- pass
+ if False:
+ yield None
+
def references(self, env, object_name, model, assoc_class,
result_class_name, role, result_role, keys_only):
"""Instrument Associations.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|