# #
###############################################################################
+function switch_start() {
+ local service="openvswitch.service"
+
+ if ! service_is_active "${service}"; then
+ service_start "${service}"
+ fi
+
+ return ${EXIT_OK}
+}
+
function switch_create() {
local device=${1}
assert isset device
+ # Make sure that the openvswitch service is running.
+ switch_start
+
log DEBUG "Creating virtual switch: ${device}"
ovs-vsctl -- --may-exist add-br ${device}
assert isset port
log DEBUG "Attaching port '${port}' to switch '${device}'"
- ovs-vsctl -- --may-exist ${device} ${port}
+ ovs-vsctl -- --may-exist add-port "${device}" "${port}"
return ${EXIT_OK}
}
assert isset port
log DEBUG "Detaching port '${port}' from switch '${device}'"
- ovs-vsctl -- --if-exists ${device} ${port}
+ ovs-vsctl -- --if-exists del-port "${device}" "${port}"
return ${EXIT_OK}
}