def is_tipc_properly_configured():
        tipc_config_cmd = get_tipc_config_cmd()

        tipc_addr = Popen("%s -addr" % tipc_config_cmd)[0]
        tipc_addr = tipc_addr.split(":")[1].strip()[1:-1]

        if tipc_addr != "1.1.%s" % safplus.get_safplus_node_addr():
            log.debug(
                "System configured TIPC address : %s, user configured TIPC address : %s"
                % (tipc_addr, "1.1.%s" % safplus.get_safplus_node_addr())
            )
            return False

        tipc_netid = Popen("%s -netid" % tipc_config_cmd)[0]
        tipc_netid = tipc_netid.split(":")[1].strip()

        if tipc_netid != get_safplus_tipc_netid():
            log.debug(
                "System configured netid : %s, user configured netid : %s" % (tipc_netid, get_safplus_tipc_netid())
            )
            return False

        bearers = Popen("%s -b" % tipc_config_cmd)
        bearers = [e[:-1] for e in bearers[1:]]
        num, link_name = getMultiLink()
        tipc_bearer = "eth:%s" % link_name[0]

        if tipc_bearer not in bearers:
            log.debug("Configured bearer %s not in bearer list %s" % (tipc_bearer, bearers))
            return False

        return True
Example #2
0
    def is_tipc_properly_configured():
        tipc_config_cmd = get_tipc_config_cmd()

        tipc_addr = Popen('%s -addr' % tipc_config_cmd)[0]
        tipc_addr = tipc_addr.split(':')[1].strip()[1:-1]

        if tipc_addr != '1.1.%s' % safplus.get_safplus_node_addr():
            log.debug(
                'System configured TIPC address : %s, user configured TIPC address : %s'
                % (tipc_addr, '1.1.%s' % safplus.get_safplus_node_addr()))
            return False

        tipc_netid = Popen('%s -netid' % tipc_config_cmd)[0]
        tipc_netid = tipc_netid.split(':')[1].strip()

        if tipc_netid != get_safplus_tipc_netid():
            log.debug(
                'System configured netid : %s, user configured netid : %s' %
                (tipc_netid, get_safplus_tipc_netid()))
            return False

        bearers = Popen('%s -b' % tipc_config_cmd)
        bearers = [e[:-1] for e in bearers[1:]]
        num, link_name = getMultiLink()
        tipc_bearer = 'eth:%s' % link_name[0]

        if tipc_bearer not in bearers:
            log.debug('Configured bearer %s not in bearer list %s' %
                      (tipc_bearer, bearers))
            return False

        return True
def config_tipc_module():
    if not is_tipc_build():
        log.warning('Transport protocol : UDP only')
        return
    tipc_netid = get_safplus_tipc_netid()
    node_addr = safplus.get_safplus_node_addr()
    num,link_name = getMultiLink()
    log.info('num of bearer : %d ...' %(num))
    tipcCfg = os.getenv('CL_TIPC_CFG_PARAMS')
    if tipcCfg is None: tipcCfg = ""    
    cmd = '%s -netid=%s -addr=1.1.%s %s -be=eth:%s' % (get_tipc_config_cmd(), tipc_netid, node_addr, tipcCfg, link_name[0])
    log.debug('TIPC command is [%s]' % cmd)
    ret, output, signal, core = system(cmd)
    if ret:
        output_buf = ''.join(output)
        if 'unable to enable bearer' in output_buf:
            msg = ''.join(['Failed to configure the tipc module. ',
                           
                           'System is configured to use %s, but tipc '
                           'cannot use this interface. ' % link_name,
                           
                           'Does it exist? To change the interface, '
                           'edit the LINK_NAME and linkName fields in '
                           '%s/asp.conf and %s/clGmsConfig.xml.' %\
                           (safplus.SAFPLUS_ETC_DIR, safplus.SAFPLUS_ETC_DIR)])
            
            # Try to remove the tipc module if we failed to configure tipc.
            # Otherwise it will work in the next run, but only in "local" mode.
            num,link_name = getMultiLink()    
            cmd = 'tipc-config -bd=eth:%s' %(link_name[0])
            ret, output, signal, core = system(cmd)
            system("rmmod tipc")  
            safplus.fail_and_exit(msg)

        elif 'TIPC module not installed' in output_buf:
            msg = ''.join(['Failed to configure the tipc module. ',                           
                           'The tipc kernel module is not loaded. ',                           
                           'Use \'lsmod | grep tipc\' to see that '
                           'it is not loaded.'])
            safplus.fail_and_exit(msg)

        else:
            msg1 = ''.join(['Failed to configure the tipc module. ',                           
                            'Executed \'%s\'. ' % cmd,                           
                            'Received unknown tipc-config error: %s' % output_buf])

            msg2 = '\n'.join(['Please check that: ',                             
                              '1. The tipc kernel module is loaded. '
                              '(lsmod | grep tipc)',                              
                              '2. The tipc-config command is in your $PATH.',                              
                              '3. Values for TIPC_NETID, DEFAULT_NODEADDR '
                              'and LINK_NAME are correct in %s/asp.conf.' % safplus.SAFPLUS_ETC_DIR])
            safplus.fail_and_exit(msg1 + msg2)
    for x in range(1,num) :       
        cmd = '%s -be=eth:%s' % (get_tipc_config_cmd(),link_name[x])
        log.debug('enable bearer name : %s ...' %(cmd))
        ret, output, signal, core = system(cmd)        
def start_watchdog():
    global TipcSettings
    # check whether watchdog exist 
    watchdog_pid = get_watchdog_pid()
    if not watchdog_pid:
        if TipcSettings=='enforce': 
          safplus_tipc.unload_tipc_module()
        if TipcSettings!='ignore': 
          safplus_tipc.load_config_tipc_module()
        set_ld_library_paths()

        # setsid <prog> & daemonizes...
        cmd = 'setsid %s/safplus_watchdog.py &' % safplus.SAFPLUS_ETC_DIR
        os.system(cmd)
    else:
        safplus.fail_and_exit('SAFplus is already running on node [%s], pid [%s]' % (safplus.get_safplus_node_addr(), watchdog_pid))
Example #5
0
    def is_tipc_properly_configured():
        tipc_config_cmd = get_tipc_config_cmd()

        tipc_addr = ''
        if is_tipc_tool_exist():
            tipc_addr = Popen('%s node get address' % tipc_config_cmd)[0]
            tipc_addr = tipc_addr.strip()[1:-1]
        else:
            tipc_addr = Popen('%s -addr' % tipc_config_cmd)[0]
            tipc_addr = tipc_addr.split(':')[1].strip()[1:-1]

        if tipc_addr != '1.1.%s' % safplus.get_safplus_node_addr():
            log.debug('System configured TIPC address : %s, user configured TIPC address : %s' % (tipc_addr, '1.1.%s' % safplus.get_safplus_node_addr()))
            return False

        tipc_netid = ''
        if is_tipc_tool_exist():
            tipc_netid = Popen('%s node get netid' % tipc_config_cmd)[0]
            tipc_netid = tipc_netid.strip()
        else:
            tipc_netid = Popen('%s -netid' % tipc_config_cmd)[0]
            tipc_netid = tipc_netid.split(':')[1].strip()

        if tipc_netid != get_safplus_tipc_netid():
            log.debug('System configured netid : %s, user configured netid : %s' % (tipc_netid, get_safplus_tipc_netid()))
            return False

        num,link_name= getMultiLink()
        if is_tipc_tool_exist():
            bearers = Popen('%s bearer list' %tipc_config_cmd)
            if not bearers or len(bearers) < 1:
                return False
            bearers = [e.strip().split(':')[1] for e in bearers]
            for x in range(0,num):
                if link_name[x] not in bearers:
                    log.debug('Configured bearer %s not in bearer list %s' % (tipc_bearer, bearers))
                return False
        else:
            bearers = Popen('%s -b' % tipc_config_cmd)
            bearers = [e[:-1] for e in bearers[1:]]
            tipc_bearer = 'eth:%s' % link_name[0]
            if tipc_bearer not in bearers:
                log.debug('Configured bearer %s not in bearer list %s' % (tipc_bearer, bearers))
                return False

        return True
def start_watchdog():
    global TipcSettings
    # check whether watchdog exist
    watchdog_pid = get_watchdog_pid()
    if not watchdog_pid:
        if TipcSettings == 'enforce':
            safplus_tipc.unload_tipc_module()
        if TipcSettings != 'ignore':
            safplus_tipc.load_config_tipc_module()
        set_ld_library_paths()

        # setsid <prog> & daemonizes...
        cmd = 'setsid %s/safplus_watchdog.py &' % safplus.SAFPLUS_ETC_DIR
        os.system(cmd)
    else:
        safplus.fail_and_exit(
            'SAFplus is already running on node [%s], pid [%s]' %
            (safplus.get_safplus_node_addr(), watchdog_pid))
Example #7
0
def start_watchdog():
    global tipc_settings
    # check whether watchdog exist 
    watchdog_pid = get_watchdog_pid()
    if not watchdog_pid:
        if safplus_tipc.has_tipc_plugin() and (safplus_tipc.ignore_tipc_settings() == False):
          if safplus_tipc.enforce_tipc_settings() == True:
            safplus_tipc.unload_tipc_module()
          safplus_tipc.load_config_tipc_module()
        set_ld_library_paths()

        codeBootFile = safplus.SAFPLUS_RUN_DIR + '/' + safplus.SAFPLUS_CODEBOOT_FILE 
        safplus.touch(codeBootFile)    # create 'safplus_codeboot' file to indicate start-up of SAFplus_AMF

        # setsid <prog> & daemonizes...
        cmd = 'setsid %s/safplus_watchdog.py &' % safplus.SAFPLUS_ETC_DIR
        os.system(cmd)
    else:
        safplus.fail_and_exit('SAFplus is already running on node [%s], pid [%s]' % (safplus.get_safplus_node_addr(), watchdog_pid))
def start_watchdog():
    global tipc_settings
    # check whether watchdog exist
    watchdog_pid = get_watchdog_pid()
    if not watchdog_pid:
        if safplus_tipc.has_tipc_plugin() and (
                safplus_tipc.ignore_tipc_settings() == False):
            if safplus_tipc.enforce_tipc_settings() == True:
                safplus_tipc.unload_tipc_module()
            safplus_tipc.load_config_tipc_module()
        set_ld_library_paths()

        codeBootFile = safplus.SAFPLUS_RUN_DIR + '/' + safplus.SAFPLUS_CODEBOOT_FILE
        safplus.touch(
            codeBootFile
        )  # create 'safplus_codeboot' file to indicate start-up of SAFplus_AMF

        # setsid <prog> & daemonizes...
        cmd = 'setsid %s/safplus_watchdog.py &' % safplus.SAFPLUS_ETC_DIR
        os.system(cmd)
    else:
        safplus.fail_and_exit(
            'SAFplus is already running on node [%s], pid [%s]' %
            (safplus.get_safplus_node_addr(), watchdog_pid))
def config_tipc_module():
    if not is_tipc_build():
        log.warning("Transport protocol : UDP only")
        return
    tipc_netid = get_safplus_tipc_netid()
    node_addr = safplus.get_safplus_node_addr()
    num, link_name = getMultiLink()
    log.info("num of bearer : %d ..." % (num))
    tipcCfg = os.getenv("CL_TIPC_CFG_PARAMS")
    if tipcCfg is None:
        tipcCfg = ""
    cmd = "%s -netid=%s -addr=1.1.%s %s -be=eth:%s" % (
        get_tipc_config_cmd(),
        tipc_netid,
        node_addr,
        tipcCfg,
        link_name[0],
    )
    log.debug("TIPC command is [%s]" % cmd)
    ret, output, signal, core = system(cmd)
    if ret:
        output_buf = "".join(output)
        if "unable to enable bearer" in output_buf:
            msg = "".join(
                [
                    "Failed to configure the tipc module. ",
                    "System is configured to use %s, but tipc " "cannot use this interface. " % link_name,
                    "Does it exist? To change the interface, "
                    "edit the LINK_NAME and linkName fields in "
                    "%s/asp.conf and %s/clGmsConfig.xml." % (safplus.SAFPLUS_ETC_DIR, safplus.SAFPLUS_ETC_DIR),
                ]
            )

            # Try to remove the tipc module if we failed to configure tipc.
            # Otherwise it will work in the next run, but only in "local" mode.
            num, link_name = getMultiLink()
            cmd = "tipc-config -bd=eth:%s" % (link_name[0])
            ret, output, signal, core = system(cmd)
            system("rmmod tipc")
            safplus.fail_and_exit(msg)

        elif "TIPC module not installed" in output_buf:
            msg = "".join(
                [
                    "Failed to configure the tipc module. ",
                    "The tipc kernel module is not loaded. ",
                    "Use 'lsmod | grep tipc' to see that " "it is not loaded.",
                ]
            )
            safplus.fail_and_exit(msg)

        else:
            msg1 = "".join(
                [
                    "Failed to configure the tipc module. ",
                    "Executed '%s'. " % cmd,
                    "Received unknown tipc-config error: %s" % output_buf,
                ]
            )

            msg2 = "\n".join(
                [
                    "Please check that: ",
                    "1. The tipc kernel module is loaded. " "(lsmod | grep tipc)",
                    "2. The tipc-config command is in your $PATH.",
                    "3. Values for TIPC_NETID, DEFAULT_NODEADDR "
                    "and LINK_NAME are correct in %s/asp.conf." % safplus.SAFPLUS_ETC_DIR,
                ]
            )
            safplus.fail_and_exit(msg1 + msg2)
    for x in range(1, num):
        cmd = "%s -be=eth:%s" % (get_tipc_config_cmd(), link_name[x])
        log.debug("enable bearer name : %s ..." % (cmd))
        ret, output, signal, core = system(cmd)