Ejemplo n.º 1
0
    def rebootwholeappliance(self):
        #reboot after a minute. On a cluster, reboot all other nodes first.
        cmd = E.nonblocking_cmd('shutdown -r +1 &')
        machines = self.cfg.getGlobalParam("MACHINES")
        logging.info("List of machines : %s" % machines)
        my_hostname = []
        out = []
        E.execute(['localhost'], 'hostname', my_hostname, E.true, 1, 0,
                  self.cfg.getGlobalParam('ENTERPRISE_HOME'))
        logging.info('My hostname is : ' + str(my_hostname[0]))
        #shallow copy is okay because list is not nested
        machines_other = machines[:]
        machines_other.remove(my_hostname[0])
        logging.info(
            'Removed myself from the list of nodes because I will reboot myself at the end. List now is : '
            + str(machines_other))
        if len(machines_other) > 0:
            E.execute(machines_other, cmd, out, E.true, 1, 0,
                      self.cfg.getGlobalParam('ENTERPRISE_HOME'))
            logging.info('Output of command is : ' + str(out))
            out = []
        else:
            logging.info('There are no other nodes. This must be a oneway')

        logging.info('Running the command on myself : ' + str(my_hostname))
        E.execute(my_hostname, cmd, out, E.true, 1, 0,
                  self.cfg.getGlobalParam('ENTERPRISE_HOME'))
        logging.info('Output of command is : ' + str(out))

        return 0
Ejemplo n.º 2
0
  def rebootwholeappliance(self):
    #reboot after a minute. On a cluster, reboot all other nodes first.
    cmd = E.nonblocking_cmd('shutdown -r +1 &')
    machines = self.cfg.getGlobalParam("MACHINES")
    logging.info("List of machines : %s" % machines)
    my_hostname=[]
    out = []
    E.execute(['localhost'],'hostname',my_hostname,E.true,1,0,self.cfg.getGlobalParam('ENTERPRISE_HOME'))
    logging.info('My hostname is : '+ str(my_hostname[0]) )
    #shallow copy is okay because list is not nested
    machines_other=machines[:]
    machines_other.remove(my_hostname[0])
    logging.info('Removed myself from the list of nodes because I will reboot myself at the end. List now is : '+ str(machines_other) )
    if len(machines_other) > 0 :
      E.execute(machines_other, cmd, out, E.true, 1, 0,self.cfg.getGlobalParam('ENTERPRISE_HOME'))
      logging.info('Output of command is : '+ str(out) )
      out = []
    else:
      logging.info('There are no other nodes. This must be a oneway')

    logging.info('Running the command on myself : '+ str(my_hostname) )
    E.execute(my_hostname, cmd, out, E.true, 1, 0,self.cfg.getGlobalParam('ENTERPRISE_HOME'))
    logging.info('Output of command is : '+ str(out) )

    return 0
Ejemplo n.º 3
0
 def start_service(self, service):
   """
   Activates and starts the given service on the given machine
   """
   logging.info("ACTIVATE: %s service %s on %s" % (
     service, self.version_, self.machine_))
   cmd = E.nonblocking_cmd(
     "/etc/rc.d/init.d/%s_%s activate" % (service, self.version_))
   ret = E.exe("ssh %s %s" % (self.machine_, commands.mkarg(cmd)))
   if ret == 0:
     logging.info("START: %s service %s on %s" % (
         service, self.version_, self.machine_))
     cmd = E.nonblocking_cmd(
         "/etc/rc.d/init.d/%s_%s start" % (service, self.version_))
     ret = E.exe("ssh %s %s" % (self.machine_, commands.mkarg(cmd)))
   return ret
Ejemplo n.º 4
0
 def start_service(self, service):
     """
 Activates and starts the given service on the given machine
 """
     logging.info("ACTIVATE: %s service %s on %s" %
                  (service, self.version_, self.machine_))
     cmd = E.nonblocking_cmd("/etc/rc.d/init.d/%s_%s activate" %
                             (service, self.version_))
     ret = E.exe("ssh %s %s" % (self.machine_, commands.mkarg(cmd)))
     if ret == 0:
         logging.info("START: %s service %s on %s" %
                      (service, self.version_, self.machine_))
         cmd = E.nonblocking_cmd("/etc/rc.d/init.d/%s_%s start" %
                                 (service, self.version_))
         ret = E.exe("ssh %s %s" % (self.machine_, commands.mkarg(cmd)))
     return ret