Example #1
0
    def __init__(self,alarm_mapping_cfg):
        if(not os.path.exists(alarm_mapping_cfg)):
            test.error("The alarm mapping cfg files: " + alarm_mapping_cfg + " not existed")

        mapping_info = Properties(alarm_mapping_cfg)
        self.dict_mapping_info = {}
        for key in mapping_info.dict_info().keys():
            self.dict_mapping_info[key] = mapping_info.getProperty(key)
Example #2
0
def check_pm_accurate_lic(ne_info_cfg, counter_info_cfg, server_info_path, str_end_time):
    global sep, logger_pm
    ne_info = get_ne_info_from_cfg(ne_info_cfg)
    counters_pm = get_pm_counters_map(counter_info_cfg)
    server_info = Properties(server_info_path)
    dict_browser_chrome = {
        "browser_type": server_info.getProperty('browser_type'),
        "browser_path": server_info.getProperty('browser_path'),
        "driver_path": server_info.getProperty('driver_path')
    }

    dict_browser_firefox = {
        "browser_type": 'firefox',
        "browser_path": 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
        "driver_path": ''
    }

    driver = CommonStatic.login_rsnms(dict_browser_chrome, server_info.getProperty('host'), logger_pm,
                                      server_info.getProperty('username'), server_info.getProperty('password'),
                                      server_info.getProperty('port'), server_info.getProperty('url'))
    if driver:
        try:
            NeCommon.to_ne_management_page_by_url(driver, logger_pm, server_info)
            dict_ne_info = NeCommon.check_and_add_ne(driver, logger_pm, ne_info)

            PmCommon.to_pm_management_page_by_url(driver, logger_pm, ne_info['ne_type'], server_info)
            PmCommon.make_in_correct_tab(driver, logger_pm, ne_info['tab_pre'], '')

            if PmCommon.wait_until_pm_date_show_up(driver, logger_pm, 600, dict_ne_info['ne_name']):
                t_now = datetime.now()
                # minute_delta = t_now.minute % 5
                # end_time = t_now + timedelta(minutes=-(delay_time + minute_delta))
                end_time = datetime.strptime(str_end_time, '%Y-%m-%d %H:%M:%S')
                pm_rounds = len(counters_pm)
                if 'OCGAS' == ne_info['ne_type']:
                    pm_rounds = len(counters_pm) / 2
                elif 'IMSHSS' == ne_info['ne_type']:
                    pm_rounds = len(counters_pm) / 4
                start_time = end_time + timedelta(minutes=-5 * pm_rounds)
                PmCommon.init_and_search(driver, logger_pm, dict_ne_info['ne_name'], end_time, start_time)
                ok = PmCommon.wait_until_rounds_ok(driver, logger_pm, pm_rounds, 10, 5)
                if ok:
                    PmCommon.check_pm_rows(driver, logger_pm, dict_ne_info['ne_type'], counters_pm, 10, None)
                else:
                    logger_pm.error('Timeout ERROR.')
            CommonStatic.logout_rsnms(driver)
            # CommonStatic.quite_driver(driver)
        finally:
            CommonStatic.quite_driver(driver)
Example #3
0
def check_pm_accurate_sbc(ne_info_cfg, counter_info_cfg, server_info_path, rounds):
    global sep, logger_pm
    ne_info = get_ne_info_from_cfg(ne_info_cfg)
    counters_pm = get_pm_counters_map(counter_info_cfg)
    server_info = Properties(server_info_path)
    dict_browser_chrome = {
        "browser_type": server_info.getProperty('browser_type'),
        "browser_path": server_info.getProperty('browser_path'),
        "driver_path": server_info.getProperty('driver_path')
    }

    dict_browser_firefox = {
        "browser_type": 'firefox',
        "browser_path": 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
        "driver_path": ''
    }

    driver = CommonStatic.login_rsnms(dict_browser_chrome, server_info.getProperty('host'), logger_pm,
                                      server_info.getProperty('username'), server_info.getProperty('password'),
                                      server_info.getProperty('port'), server_info.getProperty('url'))
    if driver:
        try:
            NeCommon.to_ne_management_page_by_url(driver, logger_pm, server_info)
            dict_ne_info = NeCommon.check_and_add_ne(driver, logger_pm, ne_info)

            PmCommon.to_pm_management_page_by_url(driver, logger_pm, ne_info['ne_type'], server_info)
            PmCommon.make_in_correct_tab(driver, logger_pm, ne_info['tab_pre'], '')
            if PmCommon.wait_until_pm_date_show_up(driver, logger_pm, 600, dict_ne_info['ne_name']):
                PmCommon.init_and_search(driver, logger_pm, dict_ne_info['ne_name'])

                dict_additional = {"rounds": rounds}

                ok = PmCommon.wait_until_rounds_ok(driver, logger_pm, dict_additional['rounds'], 10, None)
                if ok:
                    PmCommon.check_pm_rows(driver, logger_pm, dict_ne_info['ne_type'], counters_pm, 10, dict_additional)
                else:
                    logger_pm.error('FAILED: Wait for SBC PM timeout.')
            else:
                logger_pm.error('No PM data show up after waiting.')
            CommonStatic.logout_rsnms(driver)
            # CommonStatic.quite_driver(driver)
        finally:
            CommonStatic.quite_driver(driver)
Example #4
0
def check_pm_accurate(ne_info_cfg, counter_info_cfg, server_info_path, str_end_time):
    ne_info = get_ne_info_from_cfg(ne_info_cfg)
    counters_pm = get_pm_counters_map(counter_info_cfg)
    server_info = Properties(server_info_path)
    dict_browser_chrome = {
        "browser_type": server_info.getProperty('browser_type'),
        "browser_path": server_info.getProperty('browser_path'),
        "driver_path": server_info.getProperty('driver_path')
    }

    host = server_info.getProperty('host')
    username = server_info.getProperty('username')
    password = server_info.getProperty('password')
    port = server_info.getProperty('port')
    url = server_info.getProperty('url')
    dict_additinal = {
        'number_of_lic': 4
    }

    driver = CommonStatic.login_rsnms(dict_browser_chrome, host, username, password, port, url)
    if driver:
        try:
            NeCommon.to_ne_management_page_by_url(driver, server_info)
            dict_ne_info = NeCommon.check_and_add_ne(driver, ne_info)

            PmCommon.to_pm_management_page_by_url(driver, ne_info['ne_type'], server_info)
            PmCommon.make_in_correct_tab(driver, ne_info['tab_pre'], '')
            PmCommon.wait_until_pm_date_show_up(driver, dict_ne_info['ne_name'])

            end_time = datetime.strptime(str_end_time, '%Y-%m-%d %H:%M:%S')
            if 0 != len(counters_pm) % dict_additinal['number_of_lic']:
                test.error('Expected couters config file mismatch with the lic number.')
            else:
                start_time = end_time + timedelta(minutes=-5 * len(counters_pm) / dict_additinal['number_of_lic'])
                PmCommon.init_and_search(driver, dict_ne_info['ne_name'], end_time, start_time)
                PmCommon.wait_until_rounds_ok(driver, len(counters_pm), 10, dict_additinal)
                PmCommon.check_pm_rows_updated(driver, dict_ne_info['ne_type'], counters_pm, 10, dict_additinal)
                CommonStatic.logout_rsnms(driver)
        finally:
            CommonStatic.quite_driver(driver)
Example #5
0
def check_pm_accurate_all_ne(dict_all_nes, server_info_path):
    global sep, logger_pm
    server_info = Properties(server_info_path)
    dict_browser_chrome = {
        "browser_type": server_info.getProperty('browser_type'),
        "browser_path": server_info.getProperty('browser_path'),
        "driver_path": server_info.getProperty('driver_path')
    }

    dict_browser_firefox = {
        "browser_type": 'firefox',
        "browser_path": 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
        "driver_path": ''
    }

    driver = CommonStatic.login_rsnms(dict_browser_chrome, server_info.getProperty('host'), logger_pm,
                                      server_info.getProperty('username'), server_info.getProperty('password'),
                                      server_info.getProperty('port'), server_info.getProperty('url'))
    if driver:
        try:
            # check the sbc
            logger_pm.info('******************** Start to check PM for SBC ************************')
            sbc_ne_dict = dict_all_nes['SBC']
            ne_info = get_ne_info_from_cfg(sbc_ne_dict['ne_cfg'])
            counters_pm = get_pm_counters_map(sbc_ne_dict['ct_cfg'])

            NeCommon.to_ne_management_page(driver, logger_pm)
            dict_ne_info = NeCommon.check_and_add_ne(driver, logger_pm, ne_info)

            PmCommon.to_pm_management_page(driver, logger_pm)
            # PmCommon.to_second_page(driver, logger_pm)
            PmCommon.to_tab_by_ne_type(driver, dict_ne_info['ne_type'], logger_pm)
            if PmCommon.wait_until_pm_date_show_up(driver, logger_pm, 600, dict_ne_info['ne_name']):
                PmCommon.init_and_search(driver, logger_pm, dict_ne_info['ne_name'])

                dict_additional = {"rounds": sbc_ne_dict['rounds']}

                ok = PmCommon.wait_until_rounds_ok(driver, logger_pm, dict_additional['rounds'], 10, None)
                if ok:
                    PmCommon.check_pm_rows(driver, logger_pm, dict_ne_info['ne_type'], counters_pm, 10, dict_additional)
                else:
                    logger_pm.error('FAILED: Wait for SBC PM timeout.')

            # check other 5 NEs
            for k, v in dict_all_nes.iteritems:
                if 'SBC' != k:
                    logger_pm.info('******************** Start to check PM for ' + str(k) + ' ************************')
                    ne_info = get_ne_info_from_cfg(v['ne_cfg'])
                    counters_pm = get_pm_counters_map(v['ct_cfg'])

                    NeCommon.to_ne_management_page(driver, logger_pm)
                    dict_ne_info = NeCommon.check_and_add_ne(driver, logger_pm, ne_info)
                    PmCommon.to_pm_management_page(driver, logger_pm)
                    # PmCommon.to_second_page(driver, logger_pm)
                    PmCommon.to_tab_by_ne_type(driver, dict_ne_info['ne_type'], logger_pm)
                    if PmCommon.wait_until_pm_date_show_up(driver, logger_pm, 600, dict_ne_info['ne_name']):
                        # t_now = datetime.now()
                        # minute_delta = t_now.minute % 5
                        # end_time = t_now + timedelta(minutes=-(delay_time + minute_delta))
                        end_time = datetime.strptime(v['end_time'], '%Y-%m-%d %H:%M:%S')
                        pm_rounds = len(counters_pm)
                        if 'OCGAS' == ne_info['ne_type']:
                            pm_rounds = len(counters_pm) / 2

                        check_rounds = len(counters_pm)
                        if 'SGW' == ne_info['ne_type'] or 'PGW' == ne_info['ne_type']:
                            check_rounds

                        start_time = end_time + timedelta(minutes=-5 * pm_rounds)
                        PmCommon.init_and_search(driver, logger_pm, dict_ne_info['ne_name'], end_time, start_time)
                        ok = PmCommon.wait_until_rounds_ok(driver, logger_pm, check_rounds, 10, 5)
                        if ok:
                            PmCommon.check_pm_rows(driver, logger_pm, dict_ne_info['ne_type'], counters_pm, 10, None)
                        else:
                            logger_pm.error('Timeout ERROR.')

            CommonStatic.logout_rsnms(driver)
            # CommonStatic.quite_driver(driver)
        finally:
            CommonStatic.quite_driver(driver)
Example #6
0
from com.ericsson.xn.commons import CommonStatic
from com.ericsson.xn.commons.PyProperties import Properties
from com.ericsson.xn.commons.osutils import get_ne_info_from_cfg, get_pm_counters_map
from com.ericsson.xn.x.ne import NeCommon
from com.ericsson.xn.x.pm.PmCommons import PmCommon

sep = os.sep
root_dir = os.path.dirname(os.path.abspath(__file__)).split(sep + 'com' + sep +
                                                            'ericsson' + sep + 'xn' + sep + 'x' + sep + 'pm')[0]
logger_pm = logging.getLogger('pm_accurate')
log_dir = os.path.normpath(root_dir + sep + 'x' + sep + 'pm' + sep + 'logs')
if not os.path.isdir(log_dir):
    os.mkdir(log_dir)
log_cfg = Properties(os.path.normpath(root_dir + sep + 'x' + sep + 'pm' + sep + 'log_cfg.cfg'))
log_file = os.path.normpath(log_dir + sep + 'pm_accurate.log')
log_level = int(log_cfg.getProperty('log_level'))
log_formatter = logging.Formatter(('%(asctime)s [%(levelname)s] %(module)s %(funcName)s(%(lineno)d) %(message)s'))
log_handler = RotatingFileHandler(log_file, mode='a', maxBytes=1024 * 1024 * int(log_cfg.getProperty('log_maximum')),
                                  backupCount=10, encoding='utf-8', delay=0)
log_handler.setLevel(log_level)
log_handler.setFormatter(log_formatter)
logger_pm.setLevel(10)
logger_pm.addHandler(log_handler)

if 'YES' == log_cfg.getProperty('log_console').strip().upper():
    console_log = logging.StreamHandler()
    console_log.setLevel(log_level)
    console_log.setFormatter(log_formatter)
    logger_pm.addHandler(console_log)

logger_pm.info('Logger of PM part init successfully.')
Example #7
0
def check_alarm_data_accuracy(ne_info_cfg,server_info_cfg,alarm_mapping_cfg):
    
    server_info = Properties(server_info_cfg)
    dict_browser_chrome = {
        "browser_type": server_info.getProperty('browser_type'),
        "browser_path": server_info.getProperty('browser_path'),
        "driver_path": server_info.getProperty('driver_path')
    }
    
    ne_info = Properties(ne_info_cfg)
    dict_ne_info  = {
        "ne_name": ne_info.getProperty("ne_name"),
        "ne_user": ne_info.getProperty("ne_user"),
        "ne_type": ne_info.getProperty("ne_type"),
        "ne_ip" : ne_info.getProperty("ne_ip"),
        "ne_password" : ne_info.getProperty("ne_password"),
        "pm_path": ne_info.getProperty("pm_path"),
        "log_path": ne_info.getProperty("log_path"),
        "alarm_path": ne_info.getProperty("alarm_path"),
        "ne_port": ne_info.getProperty("ne_port"),
        "sftp_port": ne_info.getProperty("sftp_port"),
        "snmp_port": ne_info.getProperty("snmp_port"),
        "usm_user": ne_info.getProperty("usm_user"),
        "auth_password": ne_info.getProperty("auth_password"),
        "priv_password": ne_info.getProperty("priv_password"),
        "app_user": ne_info.getProperty("app_user"),
        "app_password": ne_info.getProperty("app_password"),
        "li_pwd": ne_info.getProperty("li_pwd"),
        "fro_id": ne_info.getProperty("fro_id")
    }

    mappingInstance = AlarmMapping.alarmMapping(alarm_mapping_cfg)

    host = server_info.getProperty("host")
    username = server_info.getProperty("username")
    password = server_info.getProperty("password")
    port = server_info.getProperty("port")
    url = server_info.getProperty("url")
    
    driver = CommonStatic.login_rsnms(dict_browser_chrome,host,username,password,port,url)
    if driver:
        try:
            NeCommon.to_ne_management_page_by_url(driver,server_info)
            new_ne_info=NeCommon.check_and_add_ne(driver, dict_ne_info)
            ne_name = new_ne_info["ne_name"]
            FmCommon.toAlarmManagement_by_url(driver,server_info)
            time.sleep(10)
            FmCommon.init_and_search(driver,ne_name)

            alarmtypes = mappingInstance.dict_mapping_info["alarm_types"]
            alarm_type_list = []
            if type(alarmtypes) is types.StringType:
                alarm_type_list.append(alarmtypes)
            else:
                alarm_type_list = alarmtypes
            if dict_ne_info["ne_type"] == "LTEHSS" or dict_ne_info["ne_type"] == "IMSHSS":
                snmp_auth_info = []
                snmp_auth_info.append(dict_ne_info["usm_user"])
                snmp_auth_info.append(dict_ne_info["auth_password"])
                snmp_auth_info.append(dict_ne_info["priv_password"])
            else:
                snmp_auth_info = None

            for alarm_type in alarm_type_list:
                test_logger.info("send alarm trap: " + dict_ne_info["ne_type"] + ":" + alarm_type + "...")
                alarm_from_ne = base_clint_for_selenium.send_trap(dict_ne_info["ne_ip"], 7070, 'xoambaseserver',dict_ne_info["ne_type"],alarm_type,host,snmp_auth_info)
                error_code = int(alarm_from_ne["code"])
                if error_code==1:
                    alarm_trap=alarm_from_ne["trap"]
                    test_logger.info("alarm sent successfully" + str(alarm_trap))
                    alarm_expected=alarm_converter(dict_ne_info["ne_type"],ne_name,alarm_type,alarm_trap,mappingInstance)
                    alarm_on_gui=FmCommon.fetch_alarm_on_gui(driver,dict_ne_info["ne_type"],alarm_trap,mappingInstance,alarm_type)
                    if alarm_on_gui != None:
                        test_logger.info("start to check alarm type: " + dict_ne_info["ne_type"] + ":" + alarm_type)
                        alarm_compare(alarm_expected,alarm_on_gui)
                    else:
                        test_logger.failed(dict_ne_info["ne_type"] + ":" + alarm_type + " accuracy test failed," + "reason:alarm not received on GUI")
                elif error_code < 0:
                    test_logger.failed(dict_ne_info["ne_type"] + ":" + alarm_type + " accuracy test failed, reason:sending alarm trap failed, the error msg is:" + alarm_from_ne["msg"])

            FmCommon.quitDriver(driver)
        except Exception as e:
            FmCommon.quitDriver(driver)
            test_logger.error(str(e))
Example #8
0
def data_init(ne_info_cfg, server_info_cfg):
    server_info = Properties(server_info_cfg)
    dict_browser_chrome = {
        "browser_type": server_info.getProperty('browser_type'),
        "browser_path": server_info.getProperty('browser_path'),
        "driver_path": server_info.getProperty('driver_path')
    }

    dict_server_info = {
        "host": server_info.getProperty("host"),
        "username": server_info.getProperty("username"),
        "password": server_info.getProperty("password"),
        "port": server_info.getProperty("port"),
        "url": server_info.getProperty("url"),
        "preurl": server_info.getProperty("preurl")
    }

    ne_info = Properties(ne_info_cfg)
    dict_ne_info = {
        "ne_name": ne_info.getProperty("ne_name"),
        "ne_user": ne_info.getProperty("ne_user"),
        "ne_type": ne_info.getProperty("ne_type"),
        "ne_ip": ne_info.getProperty("ne_ip"),
        "ne_password": ne_info.getProperty("ne_password"),
        "pm_path": ne_info.getProperty("pm_path"),
        "log_path": ne_info.getProperty("log_path"),
        "alarm_path": ne_info.getProperty("alarm_path"),
        "ne_port": ne_info.getProperty("ne_port"),
        "sftp_port": ne_info.getProperty("sftp_port"),
        "snmp_port": ne_info.getProperty("snmp_port"),
        "usm_user": ne_info.getProperty("usm_user"),
        "auth_password": ne_info.getProperty("auth_password"),
        "priv_password": ne_info.getProperty("priv_password"),
        "app_user": ne_info.getProperty("app_user"),
        "app_password": ne_info.getProperty("app_password"),
        "li_pwd": ne_info.getProperty("li_pwd"),
        "fro_id": ne_info.getProperty("fro_id")
    }

    return dict_ne_info, dict_server_info, dict_browser_chrome
Example #9
0
def data_init(ne_info_cfg,server_info_cfg):
    server_info = Properties(server_info_cfg)
    dict_browser_chrome = {
        "browser_type": server_info.getProperty('browser_type'),
        "browser_path": server_info.getProperty('browser_path'),
        "driver_path": server_info.getProperty('driver_path')
    }
    
    dict_server_info = {                
    "host":server_info.getProperty("host"),
    "username": server_info.getProperty("username"),
    "password": server_info.getProperty("password"),
    "port" : server_info.getProperty("port"),
    "url" : server_info.getProperty("url"),
    "preurl" : server_info.getProperty("preurl")
    }
    
    ne_info = Properties(ne_info_cfg)
    dict_ne_info  = {
        "ne_name": ne_info.getProperty("ne_name"),
        "ne_user": ne_info.getProperty("ne_user"),
        "ne_type": ne_info.getProperty("ne_type"),
        "ne_ip" : ne_info.getProperty("ne_ip"),
        "ne_password" : ne_info.getProperty("ne_password"),
        "pm_path": ne_info.getProperty("pm_path"),
        "log_path": ne_info.getProperty("log_path"),
        "alarm_path": ne_info.getProperty("alarm_path"),
        "ne_port": ne_info.getProperty("ne_port"),
        "sftp_port": ne_info.getProperty("sftp_port"),
        "snmp_port": ne_info.getProperty("snmp_port"),
        "usm_user": ne_info.getProperty("usm_user"),
        "auth_password": ne_info.getProperty("auth_password"),
        "priv_password": ne_info.getProperty("priv_password"),
        "app_user": ne_info.getProperty("app_user"),
        "app_password": ne_info.getProperty("app_password"),
        "li_pwd": ne_info.getProperty("li_pwd"),
        "fro_id": ne_info.getProperty("fro_id")
    }

    return dict_ne_info,dict_server_info,dict_browser_chrome