Esempio n. 1
0
 def get_hardware(self):
     if self.hardware == None:
         result = self.ssh_command('system resource print; quit')
         for i, line in enumerate(result):
             if "board-name" in line:
                 self.hardware = line.split(':')[1].strip().strip('"')
         if self.hardware == None:
             raise HostControl.HostControlError(
                 ('Error parsing system resource printout'))
     return self.hardware
Esempio n. 2
0
 def get_uptime(self):
     """This thing is a bear to parse"""
     result = self.ssh_command('system resource print; quit')
     line = result[0]
     str = line.split(':')[1].strip()
     parts = {'w': 0, 'd': 0, 'h': 0, 'm': 0, 's': 0}
     sum = 0
     for i in range(len(str)):
         c = str[i]
         if c.isdigit():
             sum = sum * 10 + int(c)
         elif c in parts.keys():
             parts[c] = sum
             sum = 0
         else:
             raise HostControl.HostControlError(
                 ('Error parsing uptime string %s' % str))
     weeks = parts['w']
     days = parts['d'] + weeks * 7
     hours = parts['h'] + days * 24
     mins = parts['m'] + hours * 60
     return parts['s'] + mins * 60