SM REF
2013-01-10 15:15:01 UTC
SM REF [http://community.zenoss.org/people/sighBemuch] created the discussion
"how to extend FileSystem class using Migrate method (cutover ..)"
To view the discussion, visit: http://community.zenoss.org/message/70914#70914
--------------------------------------------------------------
Hi,
In order to bypass the usedBlocks problem, i want to extend the FileSystem class by using the migrate method
class FileSystemXXX(Migrate.Step):
   version = Migrate.Version(1, 12, 1)
   def cutover(self,FileSystem,Device):
       pass
   def getDfLine(self):
       hd=self.name()
       hostdev=self.getManageIp()
       #snmpDfCmd="snmpdf -v1 -cpublic "+hostdev+" |grep -w "+'"'+hd+'"'
       snmpDfCmd="ssh SSHUSER http://community.zenoss.org/mailto:SSHUSER@"+hostdev @"+hostdev+" df -k |grep -v \/proc |grep -w "+'"'+hd+'"'
       line="".join(os.popen(snmpDfCmd,"r").readlines())
       if line!="":
               return line
       return None
   #extraction du avalaible
   def getFreeKBytes(self):
       line= self.getDfLine()
       if line is not None:
               #3 pour snmpdf
               fb=int(line.split()[2])
               return fb
       return None
   # extraction du avalaible
   def getTotalKBytes(self):
       line=self.getDfLine()
       if line is not None:
               tb=int(line.split()[1])
               return tb
       return None
   #calcul de used
   def getUsedKBlocks(self):
       tK=self.getTotalKBytes()
       tF=self.getFreeKBytes()
       if tK is not None and tF is not None:
                       ub=int(tK - tF)
                       return ub
       return None
   def capacityBis(self):
       line= self.getDfLine()
       if line is not None:
               c=line.split()[3].split('%')[0]
               return c is None and "unknown" or int(c)
       return None
   def usedBlocks():
       uKbytes=self.getUsedKBlocks()
       return uKbytes is None and "unknown" or uKbytes
   #FinLCL
FileSystemXXX
---------------
for f in DEVICE.os.filesystems():
    print capacityBis()
I have this error:
line 49, in <module>
   print f.capacityBis()
AttributeError: capacityBis
What's wrong extendind FileSystem class ?
Thank's for help

--------------------------------------------------------------
Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70914#70914]
Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
"how to extend FileSystem class using Migrate method (cutover ..)"
To view the discussion, visit: http://community.zenoss.org/message/70914#70914
--------------------------------------------------------------
Hi,
In order to bypass the usedBlocks problem, i want to extend the FileSystem class by using the migrate method
class FileSystemXXX(Migrate.Step):
   version = Migrate.Version(1, 12, 1)
   def cutover(self,FileSystem,Device):
       pass
   def getDfLine(self):
       hd=self.name()
       hostdev=self.getManageIp()
       #snmpDfCmd="snmpdf -v1 -cpublic "+hostdev+" |grep -w "+'"'+hd+'"'
       snmpDfCmd="ssh SSHUSER http://community.zenoss.org/mailto:SSHUSER@"+hostdev @"+hostdev+" df -k |grep -v \/proc |grep -w "+'"'+hd+'"'
       line="".join(os.popen(snmpDfCmd,"r").readlines())
       if line!="":
               return line
       return None
   #extraction du avalaible
   def getFreeKBytes(self):
       line= self.getDfLine()
       if line is not None:
               #3 pour snmpdf
               fb=int(line.split()[2])
               return fb
       return None
   # extraction du avalaible
   def getTotalKBytes(self):
       line=self.getDfLine()
       if line is not None:
               tb=int(line.split()[1])
               return tb
       return None
   #calcul de used
   def getUsedKBlocks(self):
       tK=self.getTotalKBytes()
       tF=self.getFreeKBytes()
       if tK is not None and tF is not None:
                       ub=int(tK - tF)
                       return ub
       return None
   def capacityBis(self):
       line= self.getDfLine()
       if line is not None:
               c=line.split()[3].split('%')[0]
               return c is None and "unknown" or int(c)
       return None
   def usedBlocks():
       uKbytes=self.getUsedKBlocks()
       return uKbytes is None and "unknown" or uKbytes
   #FinLCL
FileSystemXXX
---------------
for f in DEVICE.os.filesystems():
    print capacityBis()
I have this error:
line 49, in <module>
   print f.capacityBis()
AttributeError: capacityBis
What's wrong extendind FileSystem class ?
Thank's for help

--------------------------------------------------------------
Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/70914#70914]
Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]