本文整理汇总了Python中f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper.create_tunnel方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkHelper.create_tunnel方法的具体用法?Python NetworkHelper.create_tunnel怎么用?Python NetworkHelper.create_tunnel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper
的用法示例。
在下文中一共展示了NetworkHelper.create_tunnel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DisconnectedService
# 需要导入模块: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper import NetworkHelper [as 别名]
# 或者: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper import create_tunnel [as 别名]
class DisconnectedService(object):
network_name = "disconnected_network"
def __init__(self):
self.network_name = DisconnectedService.network_name
self.network_helper = NetworkHelper()
# The following method presumes that the plugin driver is aware that we're
# running in hierarchical mode or not and sets segmentation_id correctly.
def is_service_connected(self, service):
networks = service["networks"]
network_id = service["loadbalancer"]["network_id"]
network = networks.get(network_id, {})
if network.get("provider:network_type", "") == "flat":
return True
segmentation_id = network.get("provider:segmentation_id", 0)
return segmentation_id
def is_virtual_connected(self, virtual, bigips):
# check if virtual_server is connected on any of our bigips
connected = True
for bigip in bigips:
vsf = bigip.tm.ltm.virtuals.virtual
if vsf.exists(name=virtual["name"], partition=virtual["partition"]):
vs = vsf.load(name=virtual["name"], partition=virtual["partition"])
if getattr(vs, "vlansDisabled", False) or not getattr(vs, "vlansEnabled", True):
# accommodate quirk of how big-ip returns virtual server
# if vlans are disabled OR vlans are not enabled, then
# we're connected
continue
network_path = "/%s/%s" % (virtual["partition"], self.network_name)
if network_path in getattr(vs, "vlans", []):
connected = False
break
return connected
def network_exists(self, bigip, partition):
t = bigip.tm.net.tunnels.tunnels.tunnel
return t.exists(name=self.network_name, partition=partition)
@log_helpers.log_method_call
def create_network(self, bigip, partition):
model = {
"name": self.network_name,
"partition": partition,
"profile": "ppp",
"description": "Tenant disconnected network",
}
t = self.network_helper.create_tunnel(bigip, model)
return t
@log_helpers.log_method_call
def delete_network(self, bigip, partition):
tf = bigip.tm.net.tunnels.tunnels.tunnel
if tf.exists(name=self.network_name, partition=partition):
tf.load(name=self.network_name, partition=partition).delete()
示例2: DisconnectedService
# 需要导入模块: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper import NetworkHelper [as 别名]
# 或者: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper import create_tunnel [as 别名]
class DisconnectedService(object):
network_name = 'disconnected_network'
def __init__(self):
self.network_name = DisconnectedService.network_name
self.network_helper = NetworkHelper()
# The following method presumes that the plugin driver is aware that we're
# running in hierarchical mode or not and sets segmentation_id correctly.
def is_service_connected(self, service):
networks = service['networks']
network_id = service['loadbalancer']['network_id']
segmentation_id = networks[network_id]['provider:segmentation_id']
return (segmentation_id)
def is_virtual_connected(self, virtual, bigips):
# check if virtual_server is connected on any of our bigips
connected = True
for bigip in bigips:
vsf = bigip.tm.ltm.virtuals.virtual
if vsf.exists(name=virtual['name'],
partition=virtual['partition']):
vs = vsf.load(
name=virtual['name'], partition=virtual['partition'])
if (getattr(vs, 'vlansDisabled', False) or
not getattr(vs, 'vlansEnabled', True)):
# accommodate quirk of how big-ip returns virtual server
# if vlans are disabled OR vlans are not enabled, then
# we're connected
continue
network_path = "/%s/%s" % (virtual['partition'],
self.network_name)
if network_path in getattr(vs, 'vlans', []):
connected = False
break
return connected
def network_exists(self, bigip, partition):
t = bigip.tm.net.tunnels.tunnels.tunnel
return t.exists(name=self.network_name, partition=partition)
@log_helpers.log_method_call
def create_network(self, bigip, partition):
model = {'name': self.network_name,
'partition': partition,
'profile': 'ppp',
'description': 'Tenant disconnected network'}
t = self.network_helper.create_tunnel(bigip, model)
return t
@log_helpers.log_method_call
def delete_network(self, bigip, partition):
tf = bigip.tm.net.tunnels.tunnels.tunnel
if tf.exists(name=self.network_name, partition=partition):
tf.load(name=self.network_name, partition=partition).delete()