Beispiel #1
0
    def do_command(self):
        self.env_id = self.app.pargs.environment_id

        if self.env_id:
            restoreops.restore(self.env_id)
        else:
            self.interactive_restore_environment()
Beispiel #2
0
    def do_command(self):
        self.env_id = self.app.pargs.environment_id

        if self.env_id:
            restoreops.restore(self.env_id)
        else:
            self.interactive_restore_environment()
Beispiel #3
0
    def test_restore_with_good_env(self, mock_common_ops):
        self.mock_beanstalk.get_environment.return_value = self.env_object
        self.mock_beanstalk.rebuild_environment.return_value = self.request_id

        restoreops.restore(self.env_id)

        mock_common_ops.wait_for_success_events.assert_called_with(self.request_id, timeout_in_minutes=None,
                                                                   can_abort=True)
 def restore_environment_num(self, environment_number):
     """Take in user input as a string,
     convert it to a decimal,
     get the environment that the user input matches,
     and attempt to restore that environment.
     """
     environment_number = int(
         environment_number)  # raises InvalidOperation Exception
     environments = self.poller.all_environments
     e_len = len(environments)
     if environment_number > e_len or environment_number < 1:
         raise IndexError
     environment = environments[e_len - environment_number]
     env_id = environment.get(u'EnvironmentId')
     should_exit_display = True
     if env_id:
         try:
             self.flusher(term.get_terminal())
             io.validate_action(
                 prompts['restore.selectedenv'].replace(
                     '{env_id}', env_id).replace(
                         '{app}',
                         utils.encode_to_ascii(
                             environment.get('ApplicationName'))).replace(
                                 '{desc}',
                                 utils.encode_to_ascii(
                                     environment.get('Description'))).
                 replace('{cname}',
                         utils.encode_to_ascii(
                             environment.get('CNAME'))).replace(
                                 '{version}',
                                 utils.encode_to_ascii(
                                     environment.get('VersionLabel'))).
                 replace(
                     '{platform}',
                     utils.encode_to_ascii(
                         environment.get('SolutionStackName'))).replace(
                             '{dat_term}',
                             environment.get('DateUpdated')), 'y')
             from ebcli.operations import restoreops
             # restore specified environment
             self.request_id = restoreops.restore(env_id)
             return should_exit_display
         except ValidationError:
             io.echo(responses['restore.norestore'])
             time.sleep(1)
             should_exit_display = False
             return should_exit_display
     # Exception should never get thrown
     else:
         raise Exception
Beispiel #5
0
    def restore_environment_num(self, environment_number):
        """Take in user input as a string,
        convert it to a decimal,
        get the environment that the user input matches,
        and attempt to restore that environment.
        """
        environment_number = int(environment_number)  # raises InvalidOperation Exception
        environments = self.poller.all_environments
        e_len = len(environments)
        if environment_number > e_len or environment_number < 1:
            raise IndexError
        environment = environments[e_len - environment_number]
        env_id = environment.get(u'EnvironmentId')
        should_exit_display = True
        if env_id:
            self.flusher(term.get_terminal())
            prompt_text = prompts['restore.selectedenv'].format(
                env_id=env_id,
                app=utils.encode_to_ascii(environment.get('ApplicationName')),
                desc=utils.encode_to_ascii(environment.get('Description')),
                cname=utils.encode_to_ascii(environment.get('CNAME')),
                version=utils.encode_to_ascii(environment.get('VersionLabel')),
                platform=utils.encode_to_ascii(environment.get('SolutionStackName')),
                dat_term=environment.get('DateUpdated'))
            should_restore = io.get_boolean_response(prompt_text, default=True)

            if not should_restore:
                io.echo(responses['restore.norestore'])
                time.sleep(1)
                should_exit_display = False
                return should_exit_display

            from ebcli.operations import restoreops
            # restore specified environment
            self.request_id = restoreops.restore(env_id)
            return should_exit_display

        # Exception should never get thrown
        else:
            raise Exception
 def restore_environment_num(self, environment_number):
     """Take in user input as a string,
     convert it to a decimal,
     get the environment that the user input matches,
     and attempt to restore that environment.
     """
     environment_number = int(environment_number)  # raises InvalidOperation Exception
     environments = self.poller.all_environments
     e_len = len(environments)
     if environment_number > e_len or environment_number < 1:
         raise IndexError
     environment = environments[e_len - environment_number]
     env_id = environment.get(u'EnvironmentId')
     should_exit_display = True
     if env_id:
         try:
             self.flusher(term.get_terminal())
             io.validate_action(prompts['restore.selectedenv'].replace('{env_id}', env_id)
                                .replace('{app}', utils.encode_to_ascii(environment.get('ApplicationName')))
                                .replace('{desc}', utils.encode_to_ascii(environment.get('Description')))
                                .replace('{cname}', utils.encode_to_ascii(environment.get('CNAME')))
                                .replace('{version}', utils.encode_to_ascii(environment.get('VersionLabel')))
                                .replace('{platform}', utils.encode_to_ascii(environment.get('SolutionStackName')))
                                .replace('{dat_term}', environment.get('DateUpdated')), 'y')
             from ebcli.operations import restoreops
             # restore specified environment
             self.request_id = restoreops.restore(env_id)
             return should_exit_display
         except ValidationError:
             io.echo(responses['restore.norestore'])
             time.sleep(1)
             should_exit_display = False
             return should_exit_display
     # Exception should never get thrown
     else:
         raise Exception