(ifname, dry=False)
Remove the static IP configuration of a given interface
Remove the static IP configuration of a given interface
Remove the static IP configuration of a given interface
def rm_ip(ifname, dry=False):
    """Remove the static IP configuration of a given interface"""
    runner.set_dry(dry)

    # Remove conf file for network interface (next time the interface could
    # have a different number)
    netplan_file = os.path.join("/etc/netplan/",
                                "blocksat-" + ifname + ".yaml")
    net_file = os.path.join("/etc/network/interfaces.d/", ifname + ".conf")
    ifcfg_file = os.path.join("/etc/sysconfig/network-scripts/",
                              "ifcfg-" + ifname)

    if (which("netplan") is not None):
        cfg_file = netplan_file
    elif (os.path.exists(net_file)):
        cfg_file = net_file
    elif (os.path.exists(ifcfg_file)):
        cfg_file = ifcfg_file
    else:
        cfg_file = None

    if (cfg_file is not None and os.path.exists(cfg_file)):
        runner.run(["rm", cfg_file], root=True)
        if (not dry):
            logger.info("Removed configuration file {}".format(cfg_file))
def rm_ip ( ifname , dry = False ) : runner . set_dry ( dry ) # Remove conf file for network interface (next time the interface could # have a different number) netplan_file = os . path . join ( "/etc/netplan/" , "blocksat-" + ifname + ".yaml" ) net_file = os . path . join ( "/etc/network/interfaces.d/" , ifname + ".conf" ) ifcfg_file = os . path . join ( "/etc/sysconfig/network-scripts/" , "ifcfg-" + ifname ) if ( which ( "netplan" ) is not None ) : cfg_file = netplan_file elif ( os . path . exists ( net_file ) ) : cfg_file = net_file elif ( os . path . exists ( ifcfg_file ) ) : cfg_file = ifcfg_file else : cfg_file = None if ( cfg_file is not None and os . path . exists ( cfg_file ) ) : runner . run ( [ "rm" , cfg_file ] , root = True ) if ( not dry ) : logger . info ( "Removed configuration file {}" . format ( cfg_file ) )