Exemple #1
0
    def wait_active(self, between_wait=1, max_attempts=5):
        rt_name = self.name
        num_started = len(self.apps_to_start)
        if not num_started:
            raise excp.StartException("No %r programs started, can not wait for them to become active..." % (rt_name))

        def waiter(try_num):
            LOG.info("Waiting %s seconds for component %s programs to start.", between_wait, colorizer.quote(rt_name))
            LOG.info("Please wait...")
            sh.sleep(between_wait)

        for i in range(0, max_attempts):
            statii = self.status()
            if len(statii) == num_started:
                not_worked = []
                for p_status in statii:
                    if p_status.status != STATUS_STARTED:
                        not_worked.append(p_status)
                if len(not_worked) == 0:
                    return
            waiter(i + 1)

        tot_time = max(0, between_wait * max_attempts)
        raise excp.StartException("Failed waiting %s seconds for component %r programs to become active..."
                                  % (tot_time, rt_name))
Exemple #2
0
    def start(self):
        # Perform a check just to make sure said programs aren't already started and bail out
        # so that it we don't unintentionally start new ones and thus causing confusion for all
        # involved...
        what_may_already_be_started = []
        try:
            what_may_already_be_started = self.tracereader.apps_started()
        except excp.NoTraceException:
            pass
        if what_may_already_be_started:
            msg = "%s programs of component %s may already be running, did you forget to stop those?"
            raise excp.StartException(
                msg % (len(what_may_already_be_started), self.name))

        # Select how we are going to start it and get on with the show...
        runner_entry_point = self.get_option("run_type",
                                             default_value=DEFAULT_RUNNER)
        starter_args = [self, runner_entry_point]
        starter = importer.construct_entry_point(runner_entry_point,
                                                 *starter_args)
        amount_started = 0
        for program in self.applications:
            self._start_app(program, starter)
            amount_started += 1
        return amount_started
Exemple #3
0
 def wait_active(self):
     # TODO(harlowja) fix this by using the component wait active...
     started = False
     for _i in range(0, self.wait_attempts):
         (st, output) = self._service_status()
         if st != _ALIVE:
             LOG.info("Please wait %s seconds until libvirt is started.",
                      self.wait_time)
             sh.sleep(self.wait_time)
         else:
             started = True
     if not started:
         raise excp.StartException(
             "Unable to start the libvirt daemon due to: %s" % (output))
Exemple #4
0
 def pre_start(self):
     # Let the parent class do its thing
     comp.PythonRuntime.pre_start(self)
     virt_driver = nhelper.canon_virt_driver(self.get_option('virt_driver'))
     if virt_driver == 'libvirt':
         virt_type = lv.canon_libvirt_type(self.get_option('libvirt_type'))
         LOG.info(
             "Checking that your selected libvirt virtualization type %s is working and running.",
             colorizer.quote(virt_type))
         try:
             self.virsh.check_virt(virt_type)
             self.virsh.restart_service()
             LOG.info(
                 "Libvirt virtualization type %s seems to be working and running.",
                 colorizer.quote(virt_type))
         except excp.ProcessExecutionError as e:
             msg = (
                 "Libvirt type %r does not seem to be active or configured correctly, "
                 "perhaps you should be using %r instead: %s" %
                 (virt_type, lv.DEF_VIRT_TYPE, e))
             raise excp.StartException(msg)