本文整理汇总了Python中ryu.app.client.OFPClient.create_port方法的典型用法代码示例。如果您正苦于以下问题:Python OFPClient.create_port方法的具体用法?Python OFPClient.create_port怎么用?Python OFPClient.create_port使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ryu.app.client.OFPClient
的用法示例。
在下文中一共展示了OFPClient.create_port方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LibvirtOpenVswitchOFPRyuDriver
# 需要导入模块: from ryu.app.client import OFPClient [as 别名]
# 或者: from ryu.app.client.OFPClient import create_port [as 别名]
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)
示例2: RyuInterfaceDriver
# 需要导入模块: from ryu.app.client import OFPClient [as 别名]
# 或者: from ryu.app.client.OFPClient import create_port [as 别名]
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)
示例3: LinuxOVSRyuInterfaceDriver
# 需要导入模块: from ryu.app.client import OFPClient [as 别名]
# 或者: from ryu.app.client.OFPClient import create_port [as 别名]
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)