def init(self): """ Validates the given ``ovsdb_addr`` and connects to OVS instance. If failed to connect to OVS instance or the given ``datapath_id`` does not match with the Datapath ID of the connected OVS instance, raises :py:mod:`ryu.lib.ovs.bridge.OVSBridgeNotFound` exception. """ if not valid_ovsdb_addr(self.ovsdb_addr): raise ValueError('Invalid OVSDB address: %s' % self.ovsdb_addr) if self.br_name is None: self.br_name = self._get_bridge_name()
def init(self): """ Validates the given ``ovsdb_addr`` and connects to OVS instance. If failed to connect to OVS instance or the given ``datapath_id`` does not match with the Datapath ID of the connected OVS instance, raises :py:mod:`ryu.lib.ovs.bridge.OVSBridgeNotFound` exception. """ if not valid_ovsdb_addr(self.ovsdb_addr): raise ValueError('Invalid OVSDB address: %s' % self.ovsdb_addr) if self.br_name is None: self.br_name = self._get_bridge_name()
def test_valid_ovsdb_addr_with_invalid_type(self): eq_(vsctl.valid_ovsdb_addr('invalid:127.0.0.1:6640'), False)
def test_valid_ovsdb_addr_with_ipv6(self): ok_(vsctl.valid_ovsdb_addr('ssl:[::1]:6640'))
def test_valid_ovsdb_addr_with_ipv4(self): ok_(vsctl.valid_ovsdb_addr('tcp:127.0.0.1:6640'))
def test_valid_ovsdb_addr_with_unix(self): ok_(vsctl.valid_ovsdb_addr('unix:/var/run/openvswitch/db.sock'))
def test_valid_ovsdb_addr_with_invalid_type(self): eq_(vsctl.valid_ovsdb_addr('invalid:127.0.0.1:6640'), False)
def test_valid_ovsdb_addr_with_ipv6(self): ok_(vsctl.valid_ovsdb_addr('ssl:[::1]:6640'))
def test_valid_ovsdb_addr_with_ipv4(self): ok_(vsctl.valid_ovsdb_addr('tcp:127.0.0.1:6640'))
def test_valid_ovsdb_addr_with_unix(self): ok_(vsctl.valid_ovsdb_addr('unix:/var/run/openvswitch/db.sock'))
from ryu.lib.ovs import vsctl from ryu.lib.ovs import bridge from oslo_config import cfg opts = [ cfg.StrOpt('switch', default='ovs', help='test switch [ovs|cpqd]'), cfg.StrOpt('protocols', default='OpenFlow13', help='"protocols" option for ovs-vsctl (e.g. OpenFlow13)'), cfg.IntOpt('ovsdb_timeout', default=5, help=' timeout ') ] conf = cfg.ConfigOpts() conf.register_cli_opts(opts) OVSDB_ADDR = 'tcp:192.168.83.132:6640' ret = vsctl.valid_ovsdb_addr(OVSDB_ADDR) ovs_vsctl = vsctl.VSCtl(OVSDB_ADDR) # command1 = vsctl.VSCtlCommand(command='br-exists', args=['br0']) # command2 = vsctl.VSCtlCommand(command='add-br', args=['br0'], options='--may-exist') # # ovs_vsctl.run_command([command2]) # print(command2.result) #ovs_vsctl.run_command([command2]) #print(command2.result) # print(command3.result) br = bridge.OVSBridge(CONF=conf, datapath_id=None, ovsdb_addr=OVSDB_ADDR) br.br_name = 's1' ret = br.get_datapath_id() print(ret)
def init(self): if not valid_ovsdb_addr(self.ovsdb_addr): raise ValueError('Invalid OVSDB address: %s' % self.ovsdb_addr) if self.br_name is None: self.br_name = self._get_bridge_name()