def test_logs():
    """ Test the logs function """
    instance = Action()
    status = instance.logs()
    assert type(status) == tuple
    assert status[0] == True
    status = instance.logs(grep_list=['foo'])
    assert type(status) == tuple
    assert status[0] == True
    status = instance.logs(container_type="core")
    assert type(status) == tuple
    assert status[0] == True
Exemple #2
0
def test_logs():
    """ Test the logs function """
    instance = Action()
    status = instance.logs()
    assert isinstance(status, tuple)
    assert status[0] == True
    status = instance.logs(grep_list=['foo'])
    assert isinstance(status, tuple)
    assert status[0] == True
    status = instance.logs(c_type="core")
    assert isinstance(status, tuple)
    assert status[0] == True
Exemple #3
0
class LogsForm(npyscreen.FormBaseNew):
    """ Logs form for the Vent CLI """
    def quit(self, *args, **kwargs):
        """ Overridden to switch back to MAIN form """
        self.parentApp.switchForm('MAIN')

    def create(self):
        """ Override method for creating FormBaseNew form """
        self.add_handlers({'^T': self.quit, '^Q': self.quit})
        self.add(npyscreen.TitleFixedText, name='Logs:', value='')
        msg = 'Checking for container logs, please wait...'
        self.logs_mle = self.add(npyscreen.Pager, values=[msg])
        self.action = Action()
        response = self.action.logs()
        if response[0]:
            value = 'Logs for each Vent container found:\n'
            logs = response[1]
            for container in logs:
                value += '\n Container: ' + container + '\n'
                for log in logs[container]:
                    value += '    ' + log + '\n'
                value += '\n'
            self.logs_mle.values = value.split('\n')
        else:
            msg = 'There was an issue retrieving logs for Vent containers: '
            self.logs_mle.values = [
                msg,
                str(response[1]), 'Please see vent.log for more details.'
            ]
Exemple #4
0
class LogsForm(npyscreen.FormBaseNew):
    """ Logs form for the Vent CLI """
    action = None
    def while_waiting(self):
        """ Update the text with the logs from containers not logging to syslog """
        if self.action is None:
            self.action = Action()
            response = self.action.logs()
            if response[0]:
                value = "Logs for each Vent container found:\n"
                for container in logs:
                    value += "\n Container: "+container+"\n"
                    for log in logs[container]:
                        value += "    "+log+"\n"
                    value += "\n"
                self.logs_mle.values=value.split("\n")
                self.logs_mle.display()
            else:
                self.logs_mle.values=["There was an issue retrieving logs for Vent containers: ",
                                      str(response[1]),
                                      "Please see vent.log for more details."]
                self.logs_mle.display()
        return

    def create(self):
        """ Override method for creating FormBaseNew form """
        self.add_handlers({"^T": self.change_forms,"^Q": self.exit})
        self.add(npyscreen.TitleFixedText, name='Logs:', value='')
        self.logs_mle = self.add(npyscreen.Pager,
                                      values=['Checking for container logs, please wait...'])

    def exit(self, *args, **keywords):
        self.parentApp.switchForm("MAIN")

    def change_forms(self, *args, **keywords):
        """ Toggles back to main """
        change_to = "MAIN"

        # Tell the VentApp object to change forms.
        self.parentApp.change_form(change_to)