本文整理汇总了Python中networkapi.vlan.models.Vlan.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Vlan.delete方法的具体用法?Python Vlan.delete怎么用?Python Vlan.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkapi.vlan.models.Vlan
的用法示例。
在下文中一共展示了Vlan.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remover_vlan_so
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import delete [as 别名]
def remover_vlan_so(user, rack):
nome = "OOB_SO_"+rack.nome
vlan = Vlan()
try:
vlan = vlan.get_by_name(nome)
vlan.delete()
except:
pass
示例2: handle_delete
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import delete [as 别名]
def handle_delete(self, request, user, *args, **kwargs):
"""Treat requests DELETE to deallocate all relationships between Vlan.
URL: vlan/<id_vlan>/deallocate/
"""
self.log.info("Deallocate all relationships between Vlan.")
try:
# User permission
if not has_perm(user, AdminPermission.VLAN_MANAGEMENT, AdminPermission.WRITE_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
# Load URL param
id_vlan = kwargs.get('id_vlan')
# Valid vlan id
if not is_valid_int_greater_zero_param(id_vlan):
self.log.error(
u'The id_vlan parameter is not a valid value: %s.', id_vlan)
raise InvalidValueError(None, 'id_vlan', id_vlan)
# Find Vlan by id to check if it exist
vlan = Vlan().get_by_pk(id_vlan)
# Delete vlan's cache
destroy_cache_function([id_vlan])
# Delete equipment's cache
equip_id_list = []
for netv4 in vlan.networkipv4_set.all():
for ipv4 in netv4.ip_set.all():
server_pool_member_list = ServerPoolMember.objects.filter(ip=ipv4)
if server_pool_member_list.count() != 0:
# IP associated with Server Pool
server_pool_name_list = set()
for member in server_pool_member_list:
item = '{}: {}'.format(member.server_pool.id, member.server_pool.identifier)
server_pool_name_list.add(item)
server_pool_name_list = list(server_pool_name_list)
server_pool_identifiers = ', '.join(server_pool_name_list)
ip_formated = mount_ipv4_string(ipv4)
vlan_name = vlan.nome
network_ip = mount_ipv4_string(netv4)
raise IpCantRemoveFromServerPool({'ip': ip_formated, 'vlan_name': vlan_name, 'network_ip': network_ip, 'server_pool_identifiers': server_pool_identifiers},
"Não foi possível excluir a vlan %s pois ela possui a rede %s e essa rede possui o ip %s contido nela, e esse ip esta sendo usado nos Server Pools (id:identifier) %s" %
(vlan_name, network_ip, ip_formated, server_pool_identifiers))
for ip_equip in ipv4.ipequipamento_set.all():
equip_id_list.append(ip_equip.equipamento_id)
for netv6 in vlan.networkipv6_set.all():
for ip in netv6.ipv6_set.all():
server_pool_member_list = ServerPoolMember.objects.filter(ipv6=ip)
if server_pool_member_list.count() != 0:
# IP associated with Server Pool
server_pool_name_list = set()
for member in server_pool_member_list:
item = '{}: {}'.format(member.server_pool.id, member.server_pool.identifier)
server_pool_name_list.add(item)
server_pool_name_list = list(server_pool_name_list)
server_pool_identifiers = ', '.join(server_pool_name_list)
ip_formated = mount_ipv6_string(ip)
vlan_name = vlan.nome
network_ip = mount_ipv6_string(netv6)
raise IpCantRemoveFromServerPool({'ip': ip_formated, 'vlan_name': vlan_name, 'network_ip': network_ip, 'server_pool_identifiers': server_pool_identifiers},
"Não foi possível excluir a vlan %s pois ela possui a rede %s e essa rede possui o ip %s contido nela, e esse ip esta sendo usado nos Server Pools (id:identifier) %s" %
(vlan_name, network_ip, ip_formated, server_pool_identifiers))
for ip_equip in ip.ipv6equipament_set.all():
equip_id_list.append(ip_equip.equipamento_id)
destroy_cache_function(equip_id_list, True)
with distributedlock(LOCK_VLAN % id_vlan):
# Remove Vlan
vlan.delete(user)
return self.response(dumps_networkapi({}))
#.........这里部分代码省略.........