Beispiel #1
0
    def wait_for_device(self, countdown, poll_delay, msg=None):
        dev = None

        # first we need to wait for the device to be 'reachable' via the API.
        # we'll use the probe error to detect if it is or not

        while not dev:
            new_msg = msg or 'OS installation in progress. Timeout remaining: {} seconds'.format(
                countdown)
            self.post_device_status(message=new_msg, state='AWAIT-ONLINE')
            self.log.info(new_msg)

            try:
                dev = Device(self.target,
                             user=self.user,
                             passwd=self.passwd,
                             timeout=poll_delay)

            except AuthenticationException as e:
                self.log.info(
                    'Authentication exception reported: {} \n args: {}'.format(
                        e, e.args))
                self.exit_results(
                    results=dict(ok=False,
                                 error_type='login',
                                 message='Unauthorized - check user/password'))

            except NoValidConnectionsError as e:
                countdown -= poll_delay
                if countdown <= 0:
                    self.exit_results(results=dict(
                        ok=False,
                        error_type='login',
                        message=
                        'Failed to connect to target %s within reload countdown'
                        % self.target))

            except LoginNotReadyError as e:
                countdown -= poll_delay
                if countdown <= 0:
                    self.exit_results(results=dict(
                        ok=False,
                        error_type='login',
                        message=
                        'Failed to connect to target %s within reload countdown'
                        % self.target))

                time.sleep(poll_delay)

        self.dev = dev
        self.post_device_facts()
def device(mock_con, request):
    dev = Device(args['target'], no_probe=True, no_gather_facts=True)
    dev.facts = request.param
    return dev
Beispiel #3
0
    def wait_for_device(self, countdown, poll_delay, msg=None):
        target = self.cli_args.target
        user = self.cli_args.user or os.getenv(self.cli_args.env_user)
        passwd = os.getenv(self.cli_args.env_passwd)

        if not user:
            errmsg = "login user-name missing"
            self.log.error(errmsg)
            self.exit_results(target=target,
                              results=dict(ok=False,
                                           error_type='login',
                                           message=errmsg))

        if not passwd:
            errmsg = "login user-password missing"
            self.log.error(errmsg)
            self.exit_results(target=target,
                              results=dict(ok=False,
                                           error_type='login',
                                           message=errmsg))

        dev = None

        # first we need to wait for the device to be 'reachable' via the API.
        # we'll use the probe error to detect if it is or not

        while not dev:
            new_msg = msg or 'OS installation in progress. Timeout remaining: {} seconds'.format(
                countdown)
            self.post_device_status(target=target,
                                    state='AWAIT-ONLINE',
                                    message=new_msg)
            self.log.info(new_msg)

            try:
                dev = Device(target,
                             user=user,
                             passwd=passwd,
                             timeout=poll_delay)

            except AuthenticationException as e:
                self.log.info(
                    'Authentication exception reported: {} \n args: {}'.format(
                        e, e.args))
                self.exit_results(
                    target=target,
                    results=dict(ok=False,
                                 error_type='login',
                                 message='Unauthorized - check user/password'))

            except NoValidConnectionsError as e:
                countdown -= poll_delay
                if countdown <= 0:
                    self.exit_results(
                        target=target,
                        results=dict(
                            ok=False,
                            error_type='login',
                            message=
                            'Failed to connect to target %s within reload countdown'
                            % target))

                time.sleep(poll_delay)

        self.post_device_facts(dev)
        return dev