ia64/xen-unstable

changeset 2723:76c5af12d4aa

bitkeeper revision 1.1159.1.265 (41796a46qnHwXIMDGBF85CbCyNp6Ng)

Remove last reboot, last_reboot, lastboot and rebooted.
author cl349@freefall.cl.cam.ac.uk
date Fri Oct 22 20:15:02 2004 +0000 (2004-10-22)
parents c8a3588babd5
children 2c4a115fcca1
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendRoot.py tools/python/xen/xend/server/SrvServer.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Oct 22 19:47:42 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Fri Oct 22 20:15:02 2004 +0000
     1.3 @@ -58,9 +58,9 @@ class XendDomain:
     1.4          # Table of domain info indexed by domain id.
     1.5          self.db = XendDB.XendDB(self.dbpath)
     1.6          self.domain_db = self.db.fetchall("")
     1.7 -        if xroot.get_rebooted():
     1.8 -            log.info('XendDomain> rebooted: removing all domain info')
     1.9 -            self.rm_all()
    1.10 +        # XXXcl maybe check if there's only dom0 if we _really_ need
    1.11 +        #       to remove the db 
    1.12 +        # self.rm_all()
    1.13          eserver.subscribe('xend.virq', self.onVirq)
    1.14          self.initial_refresh()
    1.15  
     2.1 --- a/tools/python/xen/xend/XendRoot.py	Fri Oct 22 19:47:42 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendRoot.py	Fri Oct 22 20:15:02 2004 +0000
     2.3 @@ -16,24 +16,9 @@ eserver = EventServer.instance()
     2.4  
     2.5  import sxp
     2.6  
     2.7 -def reboots():
     2.8 -    """Get a list of system reboots from wtmp.
     2.9 -    """
    2.10 -    out = os.popen('last reboot', 'r')
    2.11 -    list = [ x.strip() for x in out if x.startswith('reboot') ]
    2.12 -    return list
    2.13 -
    2.14 -def last_reboot():
    2.15 -    """Get the last known system reboot.
    2.16 -    """
    2.17 -    l = reboots()
    2.18 -    return (l and l[-1]) or None
    2.19 -
    2.20  class XendRoot:
    2.21      """Root of the management classes."""
    2.22  
    2.23 -    lastboot_default = "/var/xen/lastboot"
    2.24 -
    2.25      """Default path to the root of the database."""
    2.26      dbroot_default = "/var/xen/xend-db"
    2.27  
    2.28 @@ -56,14 +41,11 @@ class XendRoot:
    2.29      components = {}
    2.30  
    2.31      def __init__(self):
    2.32 -        self.rebooted = 0
    2.33 -        self.last_reboot = None
    2.34          self.dbroot = None
    2.35          self.config_path = None
    2.36          self.config = None
    2.37          self.logger = None
    2.38          self.configure()
    2.39 -        self.check_lastboot()
    2.40          eserver.subscribe('xend.*', self.event_handler)
    2.41          #eserver.subscribe('xend.domain.created', self.event_handler)
    2.42          #eserver.subscribe('xend.domain.died', self.event_handler)
    2.43 @@ -87,7 +69,7 @@ class XendRoot:
    2.44          return self.components.get(name)
    2.45  
    2.46      def start(self):
    2.47 -        eserver.inject('xend.start', self.rebooted)
    2.48 +        eserver.inject('xend.start', 0)
    2.49  
    2.50      def _format(self, msg, args):
    2.51          if args:
    2.52 @@ -145,58 +127,11 @@ class XendRoot:
    2.53      def event_handler(self, event, val):
    2.54          self.logInfo("EVENT> %s %s", str(event), str(val))
    2.55  
    2.56 -    def read_lastboot(self):
    2.57 -        """Read the lastboot file to determine the time of the last boot.
    2.58 -        """
    2.59 -        try:
    2.60 -            val = file(self.lastboot, 'rb').readlines()[0]
    2.61 -        except StandardError, ex:
    2.62 -            self.logWarning('Error reading %s: %s', self.lastboot, str(ex))
    2.63 -            val = None
    2.64 -        return val
    2.65 -
    2.66 -    def write_lastboot(self, val):
    2.67 -        """Write the last boot time to the lastboot file.
    2.68 -        """
    2.69 -        if not val: return
    2.70 -        try:
    2.71 -            fdir = os.path.dirname(self.lastboot)
    2.72 -            if not os.path.isdir(fdir):
    2.73 -                os.makedirs(fdir)
    2.74 -            out = file(self.lastboot, 'wb+')
    2.75 -            out.write(val)
    2.76 -            out.close()
    2.77 -        except IOError, ex:
    2.78 -            self.logWarning('Error writing %s: %s', self.lastboot, str(ex))
    2.79 -
    2.80 -    def check_lastboot(self):
    2.81 -        """Check if there has been a system reboot since we saved lastboot.
    2.82 -        """
    2.83 -        last_val = self.read_lastboot()
    2.84 -        this_val = last_reboot()
    2.85 -        if this_val == last_val:
    2.86 -            self.rebooted = 0
    2.87 -        else:
    2.88 -            self.rebooted = 1
    2.89 -            self.write_lastboot(this_val)
    2.90 -        self.last_reboot = this_val
    2.91 -
    2.92 -    def get_last_reboot(self):
    2.93 -        """Get the last reboot time as a string.
    2.94 -        """
    2.95 -        return self.last_reboot
    2.96 -
    2.97 -    def get_rebooted(self):
    2.98 -        """Get the rebooted flag. The flag is true if the system has
    2.99 -        been rebooted since xend was last run.
   2.100 -        """
   2.101 -        return self.rebooted
   2.102 -
   2.103      def configure(self):
   2.104          self.set_config()
   2.105          self.configure_logger()
   2.106          self.dbroot = self.get_config_value("dbroot", self.dbroot_default)
   2.107 -        self.lastboot = self.get_config_value("lastboot", self.lastboot_default)
   2.108 +
   2.109  
   2.110      def configure_logger(self):
   2.111          logfile = self.get_config_value("logfile", self.logfile_default)
     3.1 --- a/tools/python/xen/xend/server/SrvServer.py	Fri Oct 22 19:47:42 2004 +0000
     3.2 +++ b/tools/python/xen/xend/server/SrvServer.py	Fri Oct 22 20:15:02 2004 +0000
     3.3 @@ -41,7 +41,7 @@ def create(port=None, interface=None, br
     3.4          port = xroot.get_xend_port()
     3.5      if interface is None:
     3.6          interface = xroot.get_xend_address()
     3.7 -    if bridge or xroot.rebooted:
     3.8 +    if bridge:
     3.9          Vifctl.network('start')
    3.10      root = resource.Resource()
    3.11      xend = SrvRoot()