Ejemplo n.º 1
0
def main():

    log_info ("restore_neighbors service is started")
    # Use warmstart python binding to check warmstart information
    warmstart = swsscommon.WarmStart()
    warmstart.initialize("neighsyncd", "swss")
    warmstart.checkWarmStart("neighsyncd", "swss", False)

    # if swss or system warm reboot not enabled, don't run
    if not warmstart.isWarmStart():
        log_info ("restore_neighbors service is skipped as warm restart not enabled")
        return

    # swss restart not system warm reboot, set statedb directly
    if not warmstart.isSystemWarmRebootEnabled():
        set_statedb_neigh_restore_done()
        log_info ("restore_neighbors service is done as system warm reboot not enabled")
        return
    # read the neigh table from appDB to internal map
    try:
        intf_neigh_map = read_neigh_table_to_maps()
    except RuntimeError as e:
        logger.exception(str(e))
        sys.exit(1)

    try:
        restore_update_kernel_neighbors(intf_neigh_map)
    except Exception as e:
        logger.exception(str(e))
        sys.exit(1)

    # set statedb to signal other processes like neighsyncd
    set_statedb_neigh_restore_done()
    log_info ("restore_neighbor service is done for system warmreboot")
    return
Ejemplo n.º 2
0
def main():
    logger.info("restore_nat_entries service is started")

    # Use warmstart python binding to check warmstart information
    warmstart = swsscommon.WarmStart()
    warmstart.initialize("natsyncd", "nat")
    warmstart.checkWarmStart("natsyncd", "nat", False)

    # if swss or system warm reboot not enabled, don't run
    if not warmstart.isWarmStart():
        logger.info("restore_nat_entries service is skipped as warm restart not enabled")
        return

    # NAT restart not system warm reboot, set statedb directly
    if not warmstart.isSystemWarmRebootEnabled():
        set_statedb_nat_restore_done()
        logger.info("restore_nat_entries service is done as system warm reboot not enabled")
        return

    # Program the nat conntrack entries in the kernel by reading the
    # entries from nat_entries.dump
    try:
        restore_update_kernel_nat_entries(WARM_BOOT_FILE_DIR + NAT_WARM_BOOT_FILE)
    except Exception as e:
        logger.exception(str(e))
        sys.exit(1)

    # Remove the dump file after restoration
    os.remove(WARM_BOOT_FILE_DIR + NAT_WARM_BOOT_FILE) 

    # set statedb to signal other processes like natsyncd
    set_statedb_nat_restore_done()
    logger.info("restore_nat_entries service is done for system warmreboot")
    return
#!/usr/bin/env python3

import psutil
import time

from swsscommon import swsscommon

start_time = time.time()

ws = swsscommon.WarmStart()
ws.initialize('cpu-report', 'cpu-report')
is_warm_start = ws.checkWarmStart('cpu-report', 'cpu-report')

if is_warm_start:
    ws.setWarmStartState('cpu-report', ws.INITIALIZED)
else:
    ws.setWarmStartState('cpu-report', ws.WSDISABLED)

while True:
    print(f'Current CPU utilization: {psutil.cpu_percent()}')
    time.sleep(5)
    if is_warm_start and (time.time() - start_time) > 15:
        ws.setWarmStartState('cpu-report', ws.RECONCILED)
Ejemplo n.º 4
0
    print "bgp_eoiu_marker service is started"

    try:
        bgp_state_check = BgpStateCheck()
    except Exception, e:
        syslog.syslog(
            syslog.LOG_ERR,
            "{}: error exit 1, reason {}".format(THIS_MODULE, str(e)))
        exit(1)

    # Always clean the eoiu marker in stateDB first
    bgp_state_check.clean_bgp_eoiu_marker()

    # Use warmstart python binding to check warmstart information
    warmstart = swsscommon.WarmStart()
    warmstart.initialize("bgp", "bgp")
    warmstart.checkWarmStart("bgp", "bgp", False)

    # if bgp or system warm reboot not enabled, don't run
    if not warmstart.isWarmStart():
        print "bgp_eoiu_marker service is skipped as warm restart not enabled"
        return

    bgp_state_check.set_bgp_eoiu_marker("IPv4", "unknown")
    bgp_state_check.set_bgp_eoiu_marker("IPv6", "unknown")
    bgp_state_check.get_all_peers()
    bgp_state_check.init_peers_eor_status()
    try:
        bgp_state_check.wait_for_bgp_eoiu()
    except Exception as e: