本文整理汇总了Python中networkapi.vlan.models.Vlan.ativada方法的典型用法代码示例。如果您正苦于以下问题:Python Vlan.ativada方法的具体用法?Python Vlan.ativada怎么用?Python Vlan.ativada使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkapi.vlan.models.Vlan
的用法示例。
在下文中一共展示了Vlan.ativada方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: criar_vlan
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import ativada [as 别名]
def criar_vlan(user, variablestochangecore1, ambientes, active=1):
#get environment
ambiente = Ambiente()
divisaodc = DivisaoDc()
divisaodc = divisaodc.get_by_name(ambientes.get('DC'))
ambiente_log = AmbienteLogico()
ambiente_log = ambiente_log.get_by_name(ambientes.get('LOG'))
ambiente = ambiente.search(divisaodc.id, ambiente_log.id)
for amb in ambiente:
if amb.grupo_l3.nome==ambientes.get('L3'):
id_ambiente = amb
# set vlan
vlan = Vlan()
vlan.acl_file_name = None
vlan.acl_file_name_v6 = None
vlan.num_vlan = variablestochangecore1.get("VLAN_NUM")
vlan.nome = variablestochangecore1.get("VLAN_NAME")
vlan.descricao = ""
vlan.ambiente = id_ambiente
vlan.ativada = active
vlan.acl_valida = 0
vlan.acl_valida_v6 = 0
vlan.insert_vlan(user)
return vlan
示例2: handle_post
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import ativada [as 别名]
#.........这里部分代码省略.........
p = re.compile('^[A-Z0-9-_]+$')
m = p.match(acl_file)
if not m:
raise InvalidValueError(None, 'acl_file', acl_file)
# VERIFICA SE VLAN COM MESMO ACL JA EXISTE OU NAO
# commenting acl name check - issue #55
# vlan.get_vlan_by_acl(acl_file)
# Valid acl_file_v6 Vlan
if acl_file_v6 is not None:
if not is_valid_string_minsize(acl_file_v6, 3) or not is_valid_string_maxsize(acl_file_v6, 200):
self.log.error(
u'Parameter acl_file_v6 is invalid. Value: %s', acl_file_v6)
raise InvalidValueError(None, 'acl_file_v6', acl_file_v6)
p = re.compile('^[A-Z0-9-_]+$')
m = p.match(acl_file_v6)
if not m:
raise InvalidValueError(None, 'acl_file_v6', acl_file_v6)
# VERIFICA SE VLAN COM MESMO ACL JA EXISTE OU NAO
# commenting acl name check - issue #55
# vlan.get_vlan_by_acl_v6(acl_file_v6)
ambiente = Ambiente()
ambiente = ambiente.get_by_pk(environment_id)
vlan.acl_file_name = acl_file
vlan.acl_file_name_v6 = acl_file_v6
vlan.num_vlan = number
vlan.nome = name
vlan.descricao = description
vlan.ambiente = ambiente
vlan.ativada = 0
vlan.acl_valida = 0
vlan.acl_valida_v6 = 0
vlan.insert_vlan(user)
if network_ipv4:
network_ipv4 = NetworkIPv4()
vlan_map = network_ipv4.add_network_ipv4(
user, vlan.id, None, None, None)
list_equip_routers_ambient = EquipamentoAmbiente.objects.select_related('equipamento').filter(
ambiente=vlan.ambiente.id, is_router=True)
if list_equip_routers_ambient:
# Add Adds the first available ipv4 on all equipment
# that is configured as a router for the environment related to
# network
ip = Ip.get_first_available_ip(network_ipv4.id)
ip = str(ip).split('.')
ip_model = Ip()
ip_model.oct1 = ip[0]
ip_model.oct2 = ip[1]
ip_model.oct3 = ip[2]
ip_model.oct4 = ip[3]
ip_model.networkipv4_id = network_ipv4.id
ip_model.save(user)
if len(list_equip_routers_ambient) > 1 and network_ipv4.block < 30:
multiple_ips = True
示例3: handle_post
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import ativada [as 别名]
#.........这里部分代码省略.........
network_ipv4 = int(network_ipv4)
network_ipv6 = int(network_ipv6)
if network_ipv4 not in range(0, 2):
self.log.error(
u'Parameter network_ipv4 is invalid. Value: %s.', network_ipv4)
raise InvalidValueError(None, 'network_ipv4', network_ipv4)
if network_ipv6 not in range(0, 2):
self.log.error(
u'Parameter network_ipv6 is invalid. Value: %s.', network_ipv6)
raise InvalidValueError(None, 'network_ipv6', network_ipv6)
p = re.compile("^[A-Z0-9-_]+$")
m = p.match(name)
if not m:
name = name.upper()
m = p.match(name)
if not m:
raise InvalidValueError(None, 'name', name)
# Valid description of Vlan
if not is_valid_string_minsize(description, 3, False) or not is_valid_string_maxsize(description, 200, False):
self.log.error(
u'Parameter description is invalid. Value: %s', description)
raise InvalidValueError(None, 'description', description)
vlan = Vlan()
# Valid acl_file Vlan
if acl_file is not None:
if not is_valid_string_minsize(acl_file, 3) or not is_valid_string_maxsize(acl_file, 200):
self.log.error(
u'Parameter acl_file is invalid. Value: %s', acl_file)
raise InvalidValueError(None, 'acl_file', acl_file)
p = re.compile("^[A-Z0-9-_]+$")
m = p.match(acl_file)
if not m:
raise InvalidValueError(None, 'acl_file', acl_file)
# VERIFICA SE VLAN COM MESMO ACL JA EXISTE OU NAO
vlan.get_vlan_by_acl(acl_file)
# Valid acl_file_v6 Vlan
if acl_file_v6 is not None:
if not is_valid_string_minsize(acl_file_v6, 3) or not is_valid_string_maxsize(acl_file_v6, 200):
self.log.error(
u'Parameter acl_file_v6 is invalid. Value: %s', acl_file_v6)
raise InvalidValueError(None, 'acl_file_v6', acl_file_v6)
p = re.compile("^[A-Z0-9-_]+$")
m = p.match(acl_file_v6)
if not m:
raise InvalidValueError(None, 'acl_file_v6', acl_file_v6)
# VERIFICA SE VLAN COM MESMO ACL JA EXISTE OU NAO
vlan.get_vlan_by_acl_v6(acl_file_v6)
ambiente = Ambiente()
ambiente = ambiente.get_by_pk(environment_id)
vlan.acl_file_name = acl_file
vlan.acl_file_name_v6 = acl_file_v6
vlan.num_vlan = number
vlan.nome = name
vlan.descricao = description
vlan.ambiente = ambiente
vlan.ativada = 0
vlan.acl_valida = 0
vlan.acl_valida_v6 = 0
vlan.insert_vlan(user)
if network_ipv4:
NetworkIPv4().add_network_ipv4(user, vlan.id, None, None, None)
if network_ipv6:
NetworkIPv6().add_network_ipv6(user, vlan.id, None, None, None)
map = dict()
listaVlan = dict()
listaVlan['id'] = vlan.id
listaVlan['nome'] = vlan.nome
listaVlan['acl_file_name'] = vlan.acl_file_name
listaVlan['descricao'] = vlan.descricao
listaVlan['id_ambiente'] = vlan.ambiente.id
listaVlan['ativada'] = vlan.ativada
listaVlan['acl_valida'] = vlan.acl_valida
map['vlan'] = listaVlan
# Delete vlan's cache
# destroy_cache_function()
# Return XML
return self.response(dumps_networkapi(map))
except VlanACLDuplicatedError, e:
return self.response_error(311, acl_file)