diff --git a/dragonflow/ovsdb/commands.py b/dragonflow/ovsdb/commands.py index 34fdf2be3..84c36d066 100644 --- a/dragonflow/ovsdb/commands.py +++ b/dragonflow/ovsdb/commands.py @@ -56,11 +56,14 @@ class GetBridgePorts(commands.BaseCommand): class AddVirtualTunnelPort(commands.BaseCommand): - def __init__(self, api, tunnel_type): + def __init__(self, api, tunnel_type, local_ip=None): super(AddVirtualTunnelPort, self).__init__(api) self.tunnel_type = tunnel_type self.integration_bridge = cfg.CONF.df.integration_bridge self.port = tunnel_type + "-vtp" + self.local_ip = local_ip + if local_ip is None: + self.local_ip = cfg.CONF.df.local_ip def run_idl(self, txn): port = idlutils.row_by_value(self.api.idl, 'Port', 'name', @@ -85,7 +88,7 @@ class AddVirtualTunnelPort(commands.BaseCommand): options_dict = getattr(iface, 'options', {}) options_dict['remote_ip'] = 'flow' options_dict['key'] = 'flow' - options_dict['local_ip'] = cfg.CONF.df.local_ip + options_dict['local_ip'] = self.local_ip iface.options = options_dict port.verify('interfaces') ifaces = getattr(port, 'interfaces', []) diff --git a/dragonflow/ovsdb/impl_idl.py b/dragonflow/ovsdb/impl_idl.py index 95b4c03ac..1c4fa9e2d 100644 --- a/dragonflow/ovsdb/impl_idl.py +++ b/dragonflow/ovsdb/impl_idl.py @@ -203,8 +203,8 @@ class DFOvsdbApi(impl_idl.OvsdbIdl): def add_patch_port(self, bridge, port, peer_port): return commands.AddPatchPort(self, bridge, port, peer_port) - def add_virtual_tunnel_port(self, tunnel_type): - return commands.AddVirtualTunnelPort(self, tunnel_type) + def add_virtual_tunnel_port(self, tunnel_type, local_ip=None): + return commands.AddVirtualTunnelPort(self, tunnel_type, local_ip) def create_qos(self, port_id, qos): return commands.CreateQos(self, port_id, qos) diff --git a/dragonflow/ovsdb/vswitch_impl.py b/dragonflow/ovsdb/vswitch_impl.py index 042ddf4cb..2ac8db97c 100644 --- a/dragonflow/ovsdb/vswitch_impl.py +++ b/dragonflow/ovsdb/vswitch_impl.py @@ -111,8 +111,8 @@ class OvsApi(object): return tunnel_ports - def add_virtual_tunnel_port(self, tunnel_type): - self.ovsdb.add_virtual_tunnel_port(tunnel_type).execute() + def add_virtual_tunnel_port(self, tunnel_type, local_ip=None): + self.ovsdb.add_virtual_tunnel_port(tunnel_type, local_ip).execute() def delete_port(self, switch_port): self.ovsdb.del_port(switch_port.name,