def delete_net_dev(dev): """Delete a network device only if it exists.""" if ip_lib.exists(dev): try: ip_lib.delete(dev, check_exit_code=[0, 2, 254]) LOG.debug("Net device removed: '%s'", dev) except processutils.ProcessExecutionError: with excutils.save_and_reraise_exception(): LOG.error("Failed removing net device: '%s'", dev)
def delete_bridge(bridge, dev): if ip_lib.exists(bridge): # Note(sean-k-mooney): this will detach all ports on # the bridge before deleting the bridge. ip_lib.delete(bridge, check_exit_code=[0, 2, 254]) # howver it will not set the detached interface down # so we set the dev down if dev is not None and exists. if dev and ip_lib.exists(dev): set_interface_state(dev, "down")
def _ip_cmd_delete(*args, **kwargs): ip_lib.delete(*args, **kwargs)