本文整理汇总了Python中f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper.delete_selfip方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkHelper.delete_selfip方法的具体用法?Python NetworkHelper.delete_selfip怎么用?Python NetworkHelper.delete_selfip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper
的用法示例。
在下文中一共展示了NetworkHelper.delete_selfip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BigipSelfIpManager
# 需要导入模块: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper import NetworkHelper [as 别名]
# 或者: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper import delete_selfip [as 别名]
#.........这里部分代码省略.........
def assure_gateway_on_subnet(self, bigip, subnetinfo, traffic_group):
# Called for every bigip only in replication mode.
# Otherwise called once.
subnet = subnetinfo['subnet']
if subnet['id'] in bigip.assured_gateway_subnets:
return
network = subnetinfo['network']
(network_name, preserve_network_name) = \
self.l2_service.get_network_name(bigip, network)
if self.l2_service.is_common_network(network):
network_folder = 'Common'
network_name = '/Common/' + network_name
else:
network_folder = self.driver.service_adapter.\
get_folder_name(subnet['tenant_id'])
# Select a traffic group for the floating SelfIP
floating_selfip_name = "gw-" + subnet['id']
netmask = netaddr.IPNetwork(subnet['cidr']).netmask
model = {
'name': floating_selfip_name,
'ip_address': subnet['gateway_ip'],
'netmask': netmask,
'vlan_name': network_name,
'floating': True,
'traffic_group': traffic_group,
'partition': network_folder,
'preserve_vlan_name': preserve_network_name
}
self.create_bigip_selfip(bigip, model)
if self.l3_binding:
self.l3_binding.bind_address(subnet_id=subnet['id'],
ip_address=subnet['gateway_ip'])
# Setup a wild card ip forwarding virtual service for this subnet
gw_name = "gw-" + subnet['id']
vs = bigip.ltm.virtuals.virtual
if not vs.exists(name=gw_name, partition=network_folder):
vs.create(
name=gw_name,
partition=network_folder,
destination='0.0.0.0:0',
mask='0.0.0.0',
vlansEnabled=True,
vlans=[network_name],
sourceAddressTranslation={'type': 'automap'},
ipForward=True
)
else:
vs.load(name=gw_name, partition=network_folder)
virtual_address = bigip.ltm.virtual_address_s.virtual_address
virtual_address.load(name='0.0.0.0:0', partition=network_folder)
virtual_address.update(trafficGroup=traffic_group)
bigip.assured_gateway_subnets.append(subnet['id'])
def delete_gateway_on_subnet(self, bigip, subnetinfo):
# Called for every bigip only in replication mode.
# Otherwise called once.
network = subnetinfo['network']
if not network:
LOG.error('Attempted to delete default gateway '
'for network with no id... skipping.')
return
subnet = subnetinfo['subnet']
if self.l2_service.is_common_network(network):
network_folder = 'Common'
else:
network_folder = self.driver.service_adapter.\
get_folder_name(subnet['tenant_id'])
floating_selfip_name = "gw-" + subnet['id']
if self.driver.conf.f5_populate_static_arp:
self.network_helper.arp_delete_by_subnet(
bigip,
partition=network_folder,
subnet=subnetinfo['subnet']['cidr'],
mask=None
)
self.network_helper.delete_selfip(
bigip, floating_selfip_name, network_folder)
if self.l3_binding:
self.l3_binding.unbind_address(subnet_id=subnet['id'],
ip_address=subnet['gateway_ip'])
gw_name = "gw-" + subnet['id']
vs = bigip.ltm.virtuals.virtual
if vs.exists(name=gw_name, partition=network_folder):
vs.load(name=gw_name, partition=network_folder)
vs.delete()
if subnet['id'] in bigip.assured_gateway_subnets:
bigip.assured_gateway_subnets.remove(subnet['id'])
return gw_name