Exemplo n.º 1
0
def is_agent_logged_in(agent_number):
    command = ['xivo-agentctl', '-c', '"status %s"' % agent_number]
    output = sysutils.output_command(command)

    log_line = output.split("\n")[1]
    log_status = log_line.split(": ")[1].strip()

    return log_status == "True"
Exemplo n.º 2
0
def _configure_ca_certificate():
    command = ['grep', 'TLS_CACERT', '/etc/ldap/ldap.conf']
    output = sysutils.output_command(command)
    if not output.strip():
        command = [
            "echo 'TLS_CACERT /etc/ssl/certs/ca-certificates.crt' >> /etc/ldap/ldap.conf"
        ]
        sysutils.send_command(command)
Exemplo n.º 3
0
def when_i_generate_a_core_dump_and_remember_the_pid_as_group1_and_the_epoch_as_group2(step, pid_var_name, epoch_var_name):
    assets.copy_asset_to_server('core_dump', '/tmp')
    res = sysutils.output_command(['ulimit -c 1024 && /tmp/core_dump'])
    separator = ': '
    for line in res.split('\n'):
        if separator not in line:
            continue
        name, value = line.split(separator, 1)
        if name == 'PID':
            setattr(world, pid_var_name, value)
        elif name == 'Epoch time':
            setattr(world, epoch_var_name, value)
Exemplo n.º 4
0
def when_i_generate_a_core_dump_and_remember_the_pid_as_group1_and_the_epoch_as_group2(
        step, pid_var_name, epoch_var_name):
    assets.copy_asset_to_server('core_dump', '/tmp')
    res = sysutils.output_command(['ulimit -c 1024 && /tmp/core_dump'])
    separator = ': '
    for line in res.split('\n'):
        if separator not in line:
            continue
        name, value = line.split(separator, 1)
        if name == 'PID':
            setattr(world, pid_var_name, value)
        elif name == 'Epoch time':
            setattr(world, epoch_var_name, value)
Exemplo n.º 5
0
def _configure_ca_certificate():
    command = ['grep', 'TLS_CACERT', '/etc/ldap/ldap.conf']
    output = sysutils.output_command(command)
    if not output.strip():
        command = ["echo 'TLS_CACERT /etc/ssl/certs/ca-certificates.crt' >> /etc/ldap/ldap.conf"]
        sysutils.send_command(command)
Exemplo n.º 6
0
def _asterisk_queue_show(queue_name):
    command = ['asterisk', '-rx', '"queue show %s"' % queue_name]
    output = sysutils.output_command(command)
    return output
Exemplo n.º 7
0
def _match_on_mirror_list(regex):
    output = sysutils.output_command(["apt-cache", "policy"])
    return re.search(regex, output)
Exemplo n.º 8
0
def then_max_open_file_descriptors_are_equals_to_8192(step):
    pid = _get_asterisk_pid().strip()
    cmd = ["grep", "'Max open files'", "/proc/%s/limits" % pid]
    string_limit = sysutils.output_command(cmd)
    limit = re.sub("\s+", " ", string_limit).split()[3]
    assert_that(int(limit), equal_to(8192))
Exemplo n.º 9
0
def _match_on_mirror_list(regex):
    output = sysutils.output_command(['apt-cache', 'policy'])
    return re.search(regex, output)
Exemplo n.º 10
0
def then_max_open_file_descriptors_are_equals_to_8192(step):
    pid = _get_asterisk_pid().strip()
    cmd = ['grep', '\'Max open files\'', '/proc/%s/limits' % pid]
    string_limit = sysutils.output_command(cmd)
    limit = re.sub('\s+', ' ', string_limit).split()[3]
    assert_that(int(limit), equal_to(8192))
Exemplo n.º 11
0
def when_i_generate_call_logs_twice_in_parallel(step):
    command = ['xivo-call-logs', '&', 'xivo-call-logs']
    world.command_output = sysutils.output_command(command)
Exemplo n.º 12
0
def xivo_current_datetime():
    command = ['date', '+%s']
    output = sysutils.output_command(command).strip()
    return datetime.fromtimestamp(float(output))
Exemplo n.º 13
0
def _find_all_lines_in_log_file(loginfo):
    command = ['tail', '-n', '30', loginfo.logfile]
    result = sysutils.output_command(command)
    lines = result.split("\n")
    return lines
Exemplo n.º 14
0
def when_i_generate_call_logs_twice_in_parallel(step):
    command = ['xivo-call-logs', '&', 'xivo-call-logs']
    world.command_output = sysutils.output_command(command)
Exemplo n.º 15
0
def xivo_current_datetime():
    command = ['date', '+%s']
    output = sysutils.output_command(command).strip()
    return datetime.fromtimestamp(float(output))
Exemplo n.º 16
0
def _find_all_lines_in_log_file(loginfo):
    command = ['tail', '-n', '30', loginfo.logfile]
    result = sysutils.output_command(command)
    lines = result.split("\n")
    return lines