本文整理汇总了Python中ryu.app.client.OFPClient类的典型用法代码示例。如果您正苦于以下问题:Python OFPClient类的具体用法?Python OFPClient怎么用?Python OFPClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OFPClient类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RyuInterfaceDriver
class RyuInterfaceDriver(OVSInterfaceDriver):
"""Driver for creating a Ryu OVS interface."""
def __init__(self, conf):
super(RyuInterfaceDriver, self).__init__(conf)
from ryu.app.client import OFPClient
LOG.debug('ryu rest host %s', self.conf.ryu_api_host)
self.ryu_client = OFPClient(self.conf.ryu_api_host)
def plug(self, network_id, port_id, device_name, mac_address,
bridge=None, namespace=None, prefix=None):
"""Plug in the interface."""
super(RyuInterfaceDriver, self).plug(network_id, port_id, device_name,
mac_address, bridge=bridge,
namespace=namespace,
prefix=prefix)
if not bridge:
bridge = self.conf.ovs_integration_bridge
self.check_bridge_exists(bridge)
ovs_br = ovs_lib.OVSBridge(bridge, self.conf.root_helper)
datapath_id = ovs_br.get_datapath_id()
port_no = ovs_br.get_port_ofport(device_name)
self.ryu_client.create_port(network_id, datapath_id, port_no)
示例2: LibvirtOpenVswitchOFPRyuDriver
class LibvirtOpenVswitchOFPRyuDriver(libvirt_vif.LibvirtOpenVswitchDriver):
def __init__(self, **kwargs):
super(LibvirtOpenVswitchOFPRyuDriver, self).__init__()
LOG.debug('ryu rest host %s', FLAGS.libvirt_ovs_bridge)
self.ryu_client = OFPClient(FLAGS.libvirt_ovs_ryu_api_host)
self.datapath_id = ovs_utils.get_datapath_id(FLAGS.libvirt_ovs_bridge)
def _get_port_no(self, mapping):
iface_id = mapping['vif_uuid']
dev = self.get_dev_name(iface_id)
return ovs_utils.get_port_no(dev)
def plug(self, instance, network, mapping):
result = super(LibvirtOpenVswitchOFPRyuDriver, self).plug(
instance, network, mapping)
port_no = self._get_port_no(mapping)
self.ryu_client.create_port(network['id'],
self.datapath_id, port_no)
return result
def unplug(self, instance, network, mapping):
port_no = self._get_port_no(mapping)
try:
self.ryu_client.delete_port(network['id'],
self.datapath_id, port_no)
except httplib.HTTPException as e:
res = e.args[0]
if res.status != httplib.NOT_FOUND:
raise
super(LibvirtOpenVswitchOFPRyuDriver, self).unplug(instance, network,
mapping)
示例3: __init__
def __init__(self, conf):
super(RyuInterfaceDriver, self).__init__(conf)
from ryu.app.client import OFPClient
LOG.debug("ryu rest host %s", self.conf.ryu_api_host)
self.ryu_client = OFPClient(self.conf.ryu_api_host)
示例4: __init__
def __init__(self, integ_br, db, root_helper):
self.root_helper = root_helper
(ofp_controller_addr, ofp_rest_api_addr) = check_ofp_mode(db)
self.nw_id_external = rest_nw_id.NW_ID_EXTERNAL
self.api = OFPClient(ofp_rest_api_addr)
self._setup_integration_br(integ_br, ofp_controller_addr)
示例5: __init__
def __init__(self, config, integ_br, db):
ret = check_ofp_mode(db)
assert ret
(ofp_controller_addr, ofp_rest_api_addr) = ret
self.nw_id_external = rest_nw_id.NW_ID_EXTERNAL
self.api = OFPClient(ofp_rest_api_addr)
self._setup_integration_br(integ_br, ofp_controller_addr)
示例6: __init__
def __init__(self, conf):
super(RyuInterfaceDriver, self).__init__(conf)
from ryu.app.client import OFPClient
LOG.debug('ryu rest host %s', self.conf.ryu_api_host)
self.ryu_client = OFPClient(self.conf.ryu_api_host)
self.check_bridge_exists(self.conf.ovs_integration_bridge)
self.ovs_br = ovs_lib.OVSBridge(self.conf.ovs_integration_bridge,
self.conf.root_helper)
self.datapath_id = self.ovs_br.get_datapath_id()
示例7: LinuxOVSRyuInterfaceDriver
class LinuxOVSRyuInterfaceDriver(object):
nova_linux_net = None
def __init__(self):
if self.nova_linux_net is None:
self.nova_linux_net = utils.import_object('nova.network.linux_net')
cls = utils.import_class(
'nova.network.linux_net.LinuxOVSInterfaceDriver')
self.parent = cls()
LOG.debug('ryu rest host %s', FLAGS.linuxnet_ovs_ryu_api_host)
self.ryu_client = OFPClient(FLAGS.linuxnet_ovs_ryu_api_host)
self.datapath_id = ovs_utils.get_datapath_id(
FLAGS.linuxnet_ovs_integration_bridge)
if self.nova_linux_net.binary_name == 'nova-network':
for tables in [
self.nova_linux_net.iptables_manager.ipv4,
self.nova_linux_net.iptables_manager.ipv6
]:
tables['filter'].add_rule(
'FORWARD',
'--in-interface gw-+ --out-interface gw-+ -j DROP')
self.nova_linux_net.iptables_manager.apply()
def plug(self, network, mac_address, gateway=True):
LOG.debug("network %s mac_adress %s gateway %s", network, mac_address,
gateway)
ret = self.parent.plug(network, mac_address, gateway)
port_no = ovs_utils.get_port_no(self.get_dev(network))
self.ryu_client.create_port(network['uuid'], self.datapath_id, port_no)
return ret
def unplug(self, network):
return self.parent.unplug(network)
def get_dev(self, network):
return self.parent.get_dev(network)
示例8: __init__
def __init__(self):
super(LinuxOVSRyuInterfaceDriver, self).__init__()
LOG.debug('ryu rest host %s', FLAGS.linuxnet_ovs_ryu_api_host)
self.ryu_client = OFPClient(FLAGS.linuxnet_ovs_ryu_api_host)
self.datapath_id = _get_datapath_id(
FLAGS.linuxnet_ovs_integration_bridge)
if linux_net.binary_name == 'nova-network':
for tables in [linux_net.iptables_manager.ipv4,
linux_net.iptables_manager.ipv6]:
tables['filter'].add_rule('FORWARD',
'--in-interface gw-+ --out-interface gw-+ -j DROP')
linux_net.iptables_manager.apply()
示例9: __init__
def __init__(self):
if self.nova_linux_net is None:
self.nova_linux_net = utils.import_object('nova.network.linux_net')
cls = utils.import_class(
'nova.network.linux_net.LinuxOVSInterfaceDriver')
self.parent = cls()
LOG.debug('ryu rest host %s', FLAGS.linuxnet_ovs_ryu_api_host)
self.ryu_client = OFPClient(FLAGS.linuxnet_ovs_ryu_api_host)
self.datapath_id = ovs_utils.get_datapath_id(
FLAGS.linuxnet_ovs_integration_bridge)
if self.nova_linux_net.binary_name == 'nova-network':
for tables in [self.nova_linux_net.iptables_manager.ipv4,
self.nova_linux_net.iptables_manager.ipv6]:
tables['filter'].add_rule('FORWARD',
'--in-interface gw-+ --out-interface gw-+ -j DROP')
self.nova_linux_net.iptables_manager.apply()
示例10: __init__
def __init__(self, **kwargs):
super(LibvirtOpenVswitchOFPRyuDriver, self).__init__()
LOG.debug('ryu rest host %s', FLAGS.libvirt_ovs_bridge)
self.ryu_client = OFPClient(FLAGS.libvirt_ovs_ryu_api_host)
self.datapath_id = ovs_utils.get_datapath_id(FLAGS.libvirt_ovs_bridge)