|
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.
|