コード例 #1
0
ファイル: background.py プロジェクト: matgalin/v10
def stop_test(id):
    TEST_history = db_get.TEST_history(id)
    TEST_configuration = db_get.TEST_configuration(
        TEST_history[0]['configuration_id'])
    TEST_configuration[0][
        'name'] = TEST_configuration[0]['name'] + '_' + TEST_history[0]['name']
    test_history.stop(TEST_history)
    zabbix.disable_hosts(TEST_configuration, TEST_history)
    #generate_report.generate(TEST_configuration)
    ansible.stop_tasks(TEST_configuration)
コード例 #2
0
ファイル: background.py プロジェクト: matgalin/v10
def report_status(name, status, flag):
    global configuration_status
    content = {
        "id": len(configuration_status[0]['content']),
        "name": name,
        "status": status,
        "flag": flag
    }
    configuration_status[0]['content'].append(content)
    if flag == 1:
        history_id = configuration_status[0]['history_id']
        TEST_history = db_get.TEST_history(history_id)
        test_history.error(TEST_history)
コード例 #3
0
ファイル: startup.py プロジェクト: matgalin/v10
def look_for_finished_tests():
    TEST_history = db_get.TEST_history('all')
    for test in TEST_history:
        if test['is_running'] == 1:
            #print 1
            now = time_conversion.now_date()
            #now=str(now)
            finish = test['data_planned_end']
            now = time_conversion.date_to_readable(now)
            now = time_conversion.date_to_operate(now)
            try:
                time_conversion.date_to_operate(finish)
            except:
                return 0
            else:
                finish = time_conversion.date_to_operate(finish)
                if finish <= now:
                    background.stop_test(test['id'])
コード例 #4
0
ファイル: startup.py プロジェクト: matgalin/v10
def look_for_errors():
    TEST_history = db_get.TEST_history('all')
    for test in TEST_history:
        if test['is_running'] == 3:
            db_update.TEST_history(test['id'], 'change_status', 0)
コード例 #5
0
ファイル: background.py プロジェクト: matgalin/v10
def start_configuration(id, interval):
    global configuration_status
    ##main status
    TEST_history = db_get.TEST_history(id)
    TEST_configuration = db_get.TEST_configuration(
        TEST_history[0]['configuration_id'])
    TEST_configuration[0][
        'name'] = TEST_configuration[0]['name'] + '_' + TEST_history[0]['name']
    ###set test configuration flag to "configuring"
    test_history.start_prepare(TEST_history)
    ###add configuring data to main array
    status_temp = {
        "configuration_id": TEST_configuration[0]['id'],
        "history_id": id,
        "status": 1,
        "content": []
    }
    print status_temp
    configuration_status.append(status_temp)
    time.sleep(2)
    ###report that configuration started
    report_status('Executing Configuration', 'Start', 2)
    time.sleep(2)
    ##prepare hosts data

    ############################################################################ ANSIBLE HOST FILE
    if configuration_status[0]['status'] != 2:
        report_status('Host file', 'Start', 2)
        main_files.prepareHosts(TEST_configuration)
        time.sleep(2)
    ############################################################################ KEA PROV FILE
    if configuration_status[0]['status'] != 2:
        report_status('Host file', 'OK', 0)
        time.sleep(2)
        ##prepare provisioning data
        report_status('Prov file', 'Start', 2)
        cable_modems_ip = prov_files.preparePROVmain(TEST_configuration)
    ############################################################################ CM CFG FILE
    if configuration_status[0]['status'] != 2:
        report_status('Prov file', 'OK', 0)
        time.sleep(2)
        report_status('CM files', 'Start', 2)
        cm_files.createCMconfig(TEST_configuration)
    ############################################################################ ZABBIX
    if configuration_status[0]['status'] != 2:
        report_status('CM files', 'OK', 0)
        time.sleep(2)
        #prepare Zabbix configuration
        report_status('Zabbix', 'Start', 2)
        zabbix_group_id = zabbix.run(TEST_configuration, cable_modems_ip)
    ############################################################################ GRAFANA
    if configuration_status[0]['status'] != 2:
        report_status('Zabbix', 'OK', 0)
        time.sleep(2)
        ###prepare Grafana configureation
        report_status('Grafana', 'Start', 2)
        grafana_dashboard_uid = grafana.run(TEST_configuration)
        time.sleep(2)
        #configuration_status[0]['status']=2
    ############################################################################ ANSIBLE TASKS
    if configuration_status[0]['status'] != 2:
        report_status('Grafana', 'OK', 0)
        time.sleep(2)
        report_status('Ansible', 'Start', 2)
        ansible.run_tasks(TEST_configuration)
        time.sleep(2)
    ############################################################################ CCAP CFG
    if configuration_status[0]['status'] != 2:

        report_status('Ansible', 'OK', 0)
        time.sleep(2)
        report_status('CCAP Clear', 'Start', 2)
        ccap_files_new.clearCCAPconf(TEST_configuration)

    if configuration_status[0]['status'] != 2:
        time.sleep(2)
        report_status('CCAP Clear', 'OK', 0)
        time.sleep(2)
        report_status('CCAP', 'Start', 2)
        ccap_files_new.createCCAPfiles(TEST_configuration)
        ccap_files_new.clearCM(TEST_configuration)
    #print json.dumps(configuration_status[0], indent=4, sort_keys=True)
    if configuration_status[0]['status'] != 2:
        report_status('CCAP', 'OK', 0)
        time.sleep(2)
        report_status('Enabling DHCP', 'Start', 2)
        ansible.enable_kea(TEST_configuration)
    if configuration_status[0]['status'] != 2:
        report_status('DHCP', 'OK', 0)
        time.sleep(2)
        report_status('Executing Configuration', 'OK', 0)
        configuration_status[0]['status'] = 3
        test_history.start(TEST_history, zabbix_group_id,
                           grafana_dashboard_uid, interval)
    if configuration_status[0]['status'] == 2:
        test_logs.insert_log(TEST_history,
                             configuration_status[0]['content'][-1]['name'],
                             configuration_status[0]['content'][-1]['status'])
        test_history.error(TEST_history)
        time.sleep(2)
    configuration_status = []