def delete_net_dev(dev): """Delete a network device only if it exists.""" if device_exists(dev): try: processutils.execute('ip', 'link', 'delete', dev, check_exit_code=[0, 2, 254], run_as_root=True) LOG.debug("Net device removed: '%s'", dev) except processutils.ProcessExecutionError: with excutils.save_and_reraise_exception(): LOG.error(_LE("Failed removing net device: '%s'"), dev)
def _ovs_vsctl(args, timeout=timeout): full_args = ['ovs-vsctl', '--timeout=%s' % timeout] + args try: return processutils.execute(*full_args, run_as_root=True) except Exception as e: LOG.error(_LE("Unable to execute %(cmd)s. Exception: %(exception)s"), {'cmd': full_args, 'exception': e}) raise exception.AgentError(method=full_args)
def _set_device_mtu(dev, mtu): """Set the device MTU.""" processutils.execute('ip', 'link', 'set', dev, 'mtu', mtu, check_exit_code=[0, 2, 254])