mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-12 08:06:49 +02:00
ovs: Add API corresponding to ovs-vsctl add-bond command
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
fe83cfd66d
commit
d19e7a3213
@ -172,6 +172,28 @@ class OVSBridge(object):
|
||||
self.run_command([command])
|
||||
return command.result
|
||||
|
||||
def add_bond(self, name, ifaces, bond_mode=None, lacp=None):
|
||||
"""
|
||||
Creates a bonded port.
|
||||
|
||||
:param name: Port name to be created
|
||||
:param ifaces: List of interfaces containing at least 2 interfaces
|
||||
:param bond_mode: Bonding mode (active-backup, balance-tcp
|
||||
or balance-slb)
|
||||
:param lacp: LACP mode (active, passive or off)
|
||||
"""
|
||||
assert len(ifaces) >= 2
|
||||
|
||||
options = ''
|
||||
if bond_mode:
|
||||
options += 'bond_mode=%(bond_mode)s' % locals()
|
||||
if lacp:
|
||||
options += 'lacp=%(lacp)s' % locals()
|
||||
|
||||
command_add = ovs_vsctl.VSCtlCommand(
|
||||
'add-bond', (self.br_name, name, ifaces), options)
|
||||
self.run_command([command_add])
|
||||
|
||||
def add_tunnel_port(self, name, tunnel_type, remote_ip,
|
||||
local_ip=None, key=None, ofport=None):
|
||||
options = 'remote_ip=%(remote_ip)s' % locals()
|
||||
|
||||
@ -1063,7 +1063,7 @@ class VSCtl(object):
|
||||
# Port. commands
|
||||
'list-ports': (self._pre_get_info, self._cmd_list_ports),
|
||||
'add-port': (self._pre_cmd_add_port, self._cmd_add_port),
|
||||
# 'add-bond':
|
||||
'add-bond': (self._pre_cmd_add_bond, self._cmd_add_bond),
|
||||
'del-port': (self._pre_get_info, self._cmd_del_port),
|
||||
# 'port-to-br':
|
||||
|
||||
@ -1338,6 +1338,18 @@ class VSCtl(object):
|
||||
|
||||
self._pre_add_port(ctx, columns)
|
||||
|
||||
def _pre_cmd_add_bond(self, ctx, command):
|
||||
self._pre_get_info(ctx, command)
|
||||
|
||||
if len(command.args) < 3:
|
||||
vsctl_fatal('this command requires at least 3 arguments')
|
||||
|
||||
columns = [
|
||||
ctx.parse_column_key_value(
|
||||
self.schema.tables[vswitch_idl.OVSREC_TABLE_PORT],
|
||||
setting)[0] for setting in command.args[3:]]
|
||||
self._pre_add_port(ctx, columns)
|
||||
|
||||
def _cmd_add_port(self, ctx, command):
|
||||
may_exist = command.has_option('--may_exist')
|
||||
|
||||
@ -1352,6 +1364,20 @@ class VSCtl(object):
|
||||
ctx.add_port(br_name, port_name, may_exist,
|
||||
False, iface_names, settings)
|
||||
|
||||
def _cmd_add_bond(self, ctx, command):
|
||||
may_exist = command.has_option('--may_exist')
|
||||
fake_iface = command.has_option('--fake-iface')
|
||||
|
||||
br_name = command.args[0]
|
||||
port_name = command.args[1]
|
||||
iface_names = list(command.args[2])
|
||||
settings = [
|
||||
ctx.parse_column_key_value(
|
||||
self.schema.tables[vswitch_idl.OVSREC_TABLE_PORT],
|
||||
setting) for setting in command.args[3:]]
|
||||
ctx.add_port(br_name, port_name, may_exist, fake_iface,
|
||||
iface_names, settings)
|
||||
|
||||
def _del_port(self, ctx, br_name=None, target=None,
|
||||
must_exist=False, with_iface=False):
|
||||
assert target is not None
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user