Beispiel #1
0
 def take_action(self, parsed_args):
     verbose_level = self.app.options.verbose_level
     try:
         job = CLIENT.postdeploy(verbose_level)
         status = job.wait()
         handers_action_result(job, status, verbose_level)
     except Exception:
         raise Exception(traceback.format_exc())
Beispiel #2
0
    def take_action(self, parsed_args):
        verbose_level = self.app.options.verbose_level
        try:
            job = CLIENT.certificate_init(verbose_level)

            # wait for job to complete
            status = job.wait()
            handers_action_result(job, status, verbose_level)
        except Exception:
            raise Exception(traceback.format_exc())
Beispiel #3
0
    def take_action(self, parsed_args):
        hosts = None
        serial_flag = False
        verbose_level = self.app.options.verbose_level
        timeout_target = 0
        services = None
        try:
            if parsed_args.hosts:
                host_list = parsed_args.hosts.strip()
                hosts = host_list.split(',')
            if parsed_args.serial:
                serial_flag = True
            if parsed_args.timeout:
                try:
                    timeout = float(parsed_args.timeout[0])
                except Exception:
                    raise CommandError(u._('Timeout value is not a number.'))
                timeout_target = time.time() + (60 * timeout)
            if parsed_args.services:
                service_list = parsed_args.services.strip()
                services = service_list.split(',')

            # if we are doing a targeted host deploy make sure we are doing it
            # to only compute nodes
            if hosts:
                invalid_host_list = []
                compute_group = CLIENT.group_get(['compute'])[0]
                compute_hosts = compute_group.get_hosts()
                for host in hosts:
                    if host not in compute_hosts:
                        invalid_host_list.append(host)
                if len(invalid_host_list) > 0:
                    raise CommandError(
                        u._('Invalid hosts for host targeted deploy. '
                            'Hosts must be in the compute group only.'
                            'Invalid hosts: {hosts}').format(
                                hosts=invalid_host_list))

            job = CLIENT.deploy(hosts, serial_flag, verbose_level, services)

            # wait for job to complete
            status = None
            while status is None:
                if timeout_target and time.time() > timeout_target:
                    job.kill()
                    raise CommandError(u._('Job timed out and was killed.'))
                time.sleep(1)
                status = job.get_status()

            # job is done
            handers_action_result(job, status, verbose_level)
        except Exception:
            raise Exception(traceback.format_exc())
Beispiel #4
0
 def take_action(self, parsed_args):
     hosts = []
     services = []
     try:
         verbose_level = self.app.options.verbose_level
         if parsed_args.hosts:
             host_list = parsed_args.hosts.strip()
             hosts = host_list.split(',')
         if parsed_args.services:
             service_list = parsed_args.services.strip()
             services = service_list.split(',')
         job = CLIENT.genconfig(verbose_level, hosts, services)
         status = job.wait()
         handers_action_result(job, status, verbose_level)
     except Exception:
         raise Exception(traceback.format_exc())
Beispiel #5
0
    def take_action(self, parsed_args):
        try:
            hostname = parsed_args.hostname.strip()

            hostnames = [hostname]
            if hostname == 'all':
                hostnames = _get_all_hostnames()
                # if there are no hosts, don't bother doing anything
                if not hostnames:
                    return

            destroy_type = 'kill'
            if parsed_args.stop:
                destroy_type = 'stop'
            include_data = False
            if parsed_args.includedata:
                include_data = True
            remove_images = False
            if parsed_args.removeimages:
                remove_images = True

            if include_data and not self._is_ok_to_delete_data():
                LOG.info('Aborting destroy')
                return

            verbose_level = self.app.options.verbose_level

            job = CLIENT.host_destroy(hostnames, destroy_type,
                                      verbose_level, include_data,
                                      remove_images)
            status = job.wait()
            handers_action_result(job, status, verbose_level)
        except ClientException as e:
            raise CommandError(str(e))
        except Exception as e:
            raise Exception(traceback.format_exc())