def when_i_try_to_log_in_agent_through_xivoagentctl(step, agent, extension): number, context = extension.split('@') command = [ 'xivo-agentctl', '-c', '"login %s %s %s"' % (agent, number, context) ] sysutils.send_command(command)
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)
def then_moh_files_owned_by_asterisk_www_data(step): command = ["apt-get", "install", "-y", "asterisk-moh-opsound-wav"] sysutils.send_command(command) text = sysutils.get_list_file(MOH_PATH) lines = text.split("\n") for line in lines: if line: file = "%s/%s" % (MOH_PATH, line.strip()) assert sysutils.file_owned_by_user(file, "asterisk") assert sysutils.file_owned_by_group(file, "www-data")
def then_moh_files_owned_by_asterisk_www_data(step): command = ['apt-get', 'install', '-y', 'asterisk-moh-opsound-wav'] sysutils.send_command(command) text = sysutils.get_list_file(MOH_PATH) lines = text.split("\n") for line in lines: if line: file = '%s/%s' % (MOH_PATH, line.strip()) assert sysutils.file_owned_by_user(file, 'asterisk') assert sysutils.file_owned_by_group(file, 'www-data')
def given_there_is_a_config_file_group1(step, config_file_name): config_file_full_path = '/etc/asterisk/extensions_extra.d/%s' % config_file_name sysutils.send_command(['touch', config_file_full_path]) sysutils.send_command(['echo', '[section]', '>', config_file_full_path]) sysutils.send_command( ['chown', 'asterisk:www-data', config_file_full_path]) sysutils.send_command(['chmod', '660', config_file_full_path])
def then_backup_files_successfully_rotated(step): command = ['rm', '-f', '%s/*' % BACKUP_DIR] sysutils.send_command(command) command = ['touch', '%s/data.tgz' % BACKUP_DIR] sysutils.send_command(command) command = ['touch', '%s/db.tgz' % BACKUP_DIR] sysutils.send_command(command) command = ['/usr/sbin/logrotate', '-f', '/etc/logrotate.d/xivo-backup'] sysutils.send_command(command) expected_files = ['data.tgz', 'data.tgz.1', 'db.tgz', 'db.tgz.1'] for expected_file in expected_files: assert sysutils.path_exists('%s/%s' % (BACKUP_DIR, expected_file)) command = ['/usr/sbin/logrotate', '-f', '/etc/logrotate.d/xivo-backup'] sysutils.send_command(command) expected_files.extend(['data.tgz.2', 'db.tgz.2']) for expected_file in expected_files: assert sysutils.path_exists('%s/%s' % (BACKUP_DIR, expected_file))
def then_backup_files_successfully_rotated(step): command = ["rm", "-f", "%s/*" % BACKUP_DIR] sysutils.send_command(command) command = ["touch", "%s/data.tgz" % BACKUP_DIR] sysutils.send_command(command) command = ["touch", "%s/db.tgz" % BACKUP_DIR] sysutils.send_command(command) command = ["/usr/sbin/logrotate", "-f", "/etc/logrotate.d/xivo-backup"] sysutils.send_command(command) expected_files = ["data.tgz", "data.tgz.1", "db.tgz", "db.tgz.1"] for expected_file in expected_files: assert sysutils.path_exists("%s/%s" % (BACKUP_DIR, expected_file)) command = ["/usr/sbin/logrotate", "-f", "/etc/logrotate.d/xivo-backup"] sysutils.send_command(command) expected_files.extend(["data.tgz.2", "db.tgz.2"]) for expected_file in expected_files: assert sysutils.path_exists("%s/%s" % (BACKUP_DIR, expected_file))
def when_i_generate_call_logs_using_the_last_unprocessed_1_cel_entries(step, cel_count): command = ['xivo-call-logs', '-c', cel_count] sysutils.send_command(command)
def when_i_generate_call_logs(step): command = ['xivo-call-logs'] sysutils.send_command(command)
def given_the_provisioning_plugin_cache_has_been_cleared(step): sysutils.send_command(['rm', '-f', '/var/cache/xivo-provd/*'])
def then_asterisk_command_group1_return_no_error(step, ast_cmd): command = ['asterisk', '-rx', '"%s"' % ast_cmd] assert sysutils.send_command(command)
def when_i_reload_the_module(step, module): ast_cmd = 'module reload %s' % module command = ['asterisk', '-rx', '"%s"' % ast_cmd] assert sysutils.send_command(command) time.sleep(3)
def when_i_generate_call_logs_using_the_last_unprocessed_1_cel_entries( step, cel_count): command = ['xivo-call-logs', '-c', cel_count] sysutils.send_command(command)
def when_i_stop_asterisk(step): command = ['service', 'asterisk', 'stop'] assert sysutils.send_command(command)
def unlog_all_agents(): sysutils.send_command(['xivo-agentctl', '-c', '"logoff all"'])
def when_i_try_to_log_in_agent_through_xivoagentctl(step, agent, extension): number, context = extension.split('@') command = ['xivo-agentctl', '-c', '"login %s %s %s"' % (agent, number, context)] sysutils.send_command(command)
def unpause_agent(agent_number): command = ['xivo-agentctl', '-c', '"unpause %s"' % agent_number] sysutils.send_command(command)
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)
def when_i_try_to_log_off_agent_through_xivoagentctl(step, agent): command = ['xivo-agentctl', '-c', '"logoff %s"' % agent] sysutils.send_command(command)
def given_there_is_a_config_file_group1(step, config_file_name): config_file_full_path = '/etc/asterisk/extensions_extra.d/%s' % config_file_name sysutils.send_command(['touch', config_file_full_path]) sysutils.send_command(['echo', '[section]', '>', config_file_full_path]) sysutils.send_command(['chown', 'asterisk:www-data', config_file_full_path]) sysutils.send_command(['chmod', '660', config_file_full_path])