Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /snap/lxd/38688/share/openvswitch/python/ovstest/ |
Upload File : |
# Copyright (c) 2012 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
vswitch module allows its callers to interact with OVS DB.
"""
from . import util
def ovs_vsctl_add_bridge(bridge):
"""
This function creates an OVS bridge.
"""
ret, _out, _err = util.start_process(["ovs-vsctl", "add-br", bridge])
return ret
def ovs_vsctl_del_bridge(bridge):
"""
This function deletes the OVS bridge.
"""
ret, _out, _err = util.start_process(["ovs-vsctl", "del-br", bridge])
return ret
def ovs_vsctl_del_pbridge(bridge, iface):
"""
This function deletes the OVS bridge and assigns the bridge IP address
back to the iface.
"""
(ip_addr, mask) = util.interface_get_ip(bridge)
util.interface_assign_ip(iface, ip_addr, mask)
util.interface_up(iface)
util.move_routes(bridge, iface)
return ovs_vsctl_del_bridge(bridge)
def ovs_vsctl_is_ovs_bridge(bridge):
"""
This function verifies whether given port is an OVS bridge. If it is an
OVS bridge then it will return True.
"""
ret, _out, _err = util.start_process(["ovs-vsctl", "br-exists", bridge])
return ret == 0
def ovs_vsctl_add_port_to_bridge(bridge, iface):
"""
This function adds given interface to the bridge.
"""
ret, _out, _err = util.start_process(["ovs-vsctl", "add-port", bridge,
iface])
return ret
def ovs_vsctl_del_port_from_bridge(port):
"""
This function removes given port from a OVS bridge.
"""
ret, _out, _err = util.start_process(["ovs-vsctl", "del-port", port])
return ret
def ovs_vsctl_set(table, record, column, key, value):
"""
This function allows to alter the OVS database. If column is a map, then
caller should also set the key, otherwise the key should be left as an
empty string.
"""
if key is None:
index = column
else:
index = "%s:%s" % (column, key)
index_value = "%s=%s" % (index, value)
ret, _out, _err = util.start_process(["ovs-vsctl", "set", table, record,
index_value])
return ret
def ovs_get_physical_interface(bridge):
"""
This function tries to figure out which is the physical interface that
belongs to the bridge. If there are multiple physical interfaces assigned
to this bridge then it will return the first match.
"""
ret, out, _err = util.start_process(["ovs-vsctl", "list-ifaces", bridge])
if ret == 0:
ifaces = out.splitlines()
for iface in ifaces:
ret, out, _err = util.start_process(["ovs-vsctl", "get",
"Interface", iface, "type"])
if ret == 0:
if ('""' in out) or ('system' in out):
return iface # this should be the physical interface
return None