本文整理汇总了Python中networkapi.vlan.models.Vlan.ambiente方法的典型用法代码示例。如果您正苦于以下问题:Python Vlan.ambiente方法的具体用法?Python Vlan.ambiente怎么用?Python Vlan.ambiente使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkapi.vlan.models.Vlan
的用法示例。
在下文中一共展示了Vlan.ambiente方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: criar_vlan
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import ambiente [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 ambiente [as 别名]
def handle_post(self, request, user, *args, **kwargs):
"""
Handles POST requests to allocate a new VLAN.
URL: vlan/
"""
self.log.info('Allocate new VLAN')
try:
# Commons Validations
# 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.')
return self.not_authorized()
# Business Validations
# Load XML data
xml_map, attrs_map = loads(request.raw_post_data)
# XML data format
networkapi_map = xml_map.get('networkapi')
if networkapi_map is None:
msg = u'There is no value to the networkapi tag of XML request.'
self.log.error(msg)
return self.response_error(3, msg)
vlan_map = networkapi_map.get('vlan')
if vlan_map is None:
msg = u'There is no value to the vlan tag of XML request.'
self.log.error(msg)
return self.response_error(3, msg)
# Get XML data
environment = vlan_map.get('id_ambiente')
network_type = vlan_map.get('id_tipo_rede')
name = vlan_map.get('nome')
description = vlan_map.get('descricao')
environment_vip = vlan_map.get('id_ambiente_vip')
vrf = vlan_map.get('vrf')
# Name must NOT be none and 50 is the maxsize
if not is_valid_string_minsize(name, 3) or not is_valid_string_maxsize(name, 50):
self.log.error(u'Parameter nome is invalid. Value: %s.', name)
raise InvalidValueError(None, 'nome', name)
# Description can NOT be greater than 200
if not is_valid_string_minsize(description, 3, False) or not is_valid_string_maxsize(description, 200, False):
self.log.error(
u'Parameter descricao is invalid. Value: %s.', description)
raise InvalidValueError(None, 'descricao', description)
# vrf can NOT be greater than 100
if not is_valid_string_maxsize(vrf, 100, False):
self.log.error(
u'Parameter vrf is invalid. Value: %s.', vrf)
raise InvalidValueError(None, 'vrf', vrf)
# Environment
# Valid environment ID
if not is_valid_int_greater_zero_param(environment):
self.log.error(
u'Parameter id_ambiente is invalid. Value: %s.', environment)
raise InvalidValueError(None, 'id_ambiente', environment)
# Find environment by ID to check if it exist
env = Ambiente.get_by_pk(environment)
# Environment Vip
if environment_vip is not None:
# Valid environment_vip ID
if not is_valid_int_greater_zero_param(environment_vip):
self.log.error(
u'Parameter id_ambiente_vip is invalid. Value: %s.', environment_vip)
raise InvalidValueError(
None, 'id_ambiente_vip', environment_vip)
# Find Environment VIP by ID to check if it exist
evip = EnvironmentVip.get_by_pk(environment_vip)
else:
evip = None
# Network Type
# Valid network_type ID
if not is_valid_int_greater_zero_param(network_type):
self.log.error(
u'Parameter id_tipo_rede is invalid. Value: %s.', network_type)
raise InvalidValueError(None, 'id_tipo_rede', network_type)
# Find network_type by ID to check if it exist
net = TipoRede.get_by_pk(network_type)
# Business Rules
# New Vlan
#.........这里部分代码省略.........
示例3: handle_post
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import ambiente [as 别名]
#.........这里部分代码省略.........
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
# 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]
示例4: handle_post
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import ambiente [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)
示例5: handle_post
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import ambiente [as 别名]
def handle_post(self, request, user, *args, **kwargs):
"""Handles POST requests to create new VLAN without add NetworkIPv4.
URLs: /vlan/no-network/
"""
self.log.info('Create new VLAN without add NetworkIPv4')
try:
# Commons Validations
# 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.')
return self.not_authorized()
# Business Validations
# Load XML data
xml_map, attrs_map = loads(request.raw_post_data)
# XML data format
networkapi_map = xml_map.get('networkapi')
if networkapi_map is None:
msg = u'There is no value to the networkapi tag of XML request.'
self.log.error(msg)
return self.response_error(3, msg)
vlan_map = networkapi_map.get('vlan')
if vlan_map is None:
msg = u'There is no value to the vlan tag of XML request.'
self.log.error(msg)
return self.response_error(3, msg)
# Get XML data
environment = vlan_map.get('environment_id')
name = vlan_map.get('name')
description = vlan_map.get('description')
vrf = vlan_map.get('vrf')
# Name must NOT be none and 50 is the maxsize
if not is_valid_string_minsize(name, 3) or not is_valid_string_maxsize(name, 50):
self.log.error(u'Parameter name is invalid. Value: %s.', name)
raise InvalidValueError(None, 'name', name)
# Description can NOT be greater than 200
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)
# vrf can NOT be greater than 100
if not is_valid_string_maxsize(vrf, 100, False):
self.log.error(
u'Parameter vrf is invalid. Value: %s.', vrf)
raise InvalidValueError(None, 'vrf', vrf)
# Environment
try:
# Valid environment ID
if not is_valid_int_greater_zero_param(environment):
self.log.error(
u'Parameter environment_id is invalid. Value: %s.', environment)
raise InvalidValueError(
None, 'environment_id', environment)
# Find environment by ID to check if it exist
env = Ambiente.get_by_pk(environment)
except AmbienteNotFoundError, e:
self.log.error(u'The environment parameter does not exist.')
return self.response_error(112)
# Business Rules
# New Vlan
vlan = Vlan()
vlan.nome = name
vlan.descricao = description
vlan.ambiente = env
# Check if environment has min/max num_vlan value or use the value
# thas was configured in settings
if (vlan.ambiente.min_num_vlan_1 and vlan.ambiente.max_num_vlan_1) or (vlan.ambiente.min_num_vlan_2 and vlan.ambiente.max_num_vlan_2):
min_num_01 = vlan.ambiente.min_num_vlan_1 if vlan.ambiente.min_num_vlan_1 and vlan.ambiente.max_num_vlan_1 else vlan.ambiente.min_num_vlan_2
max_num_01 = vlan.ambiente.max_num_vlan_1 if vlan.ambiente.min_num_vlan_1 and vlan.ambiente.max_num_vlan_1 else vlan.ambiente.max_num_vlan_2
min_num_02 = vlan.ambiente.min_num_vlan_2 if vlan.ambiente.min_num_vlan_2 and vlan.ambiente.max_num_vlan_2 else vlan.ambiente.min_num_vlan_1
max_num_02 = vlan.ambiente.max_num_vlan_2 if vlan.ambiente.min_num_vlan_2 and vlan.ambiente.max_num_vlan_2 else vlan.ambiente.max_num_vlan_1
else:
min_num_01 = settings.MIN_VLAN_NUMBER_01
max_num_01 = settings.MAX_VLAN_NUMBER_01
min_num_02 = settings.MIN_VLAN_NUMBER_02
max_num_02 = settings.MAX_VLAN_NUMBER_02
# Persist
vlan.create_new(user,
min_num_01,
max_num_01,
#.........这里部分代码省略.........
示例6: handle_post
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import ambiente [as 别名]
#.........这里部分代码省略.........
with distributedlock(LOCK_VLAN % id_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)
change_name = False
change_number_environment = False
redes4 = vlan.networkipv4_set.all()
redes6 = vlan.networkipv6_set.all()
listaIpsv4 = []
listaIpsv6 = []
listaEquips4 = []
listaEquips6 = []
for rede in redes4:
for ip in rede.ip_set.all():
listaIpsv4.append(ip)
for rede in redes6:
for ip in rede.ipv6_set.all():
listaIpsv6.append(ip)
for ip in listaIpsv4:
for ipequip in ip.ipequipamento_set.all():
listaEquips4.append(ipequip.equipamento)
for ip in listaIpsv6:
for ipequip in ip.ipv6equipament_set.all():
listaEquips6.append(ipequip.equipamento)
listaDeIps4DoEquip = []
listaDeIps6DoEquip = []
示例7: handle_get
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import ambiente [as 别名]
def handle_get(self, request, user, *args, **kwargs):
"""Handle GET requests to check if environment has a number available.
URLs: /vlan/check_number_available/<environment>/<num_vlan>/
"""
try:
id_env = kwargs.get('id_environment')
num_vlan = kwargs.get('num_vlan')
id_vlan = kwargs.get('id_vlan')
# User permission
if not has_perm(user, AdminPermission.VLAN_MANAGEMENT, AdminPermission.READ_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
raise UserNotAuthorizedError(None)
# Valid env ID
if not is_valid_int_greater_zero_param(id_env):
self.log.error(
u'The id_env parameter is not a valid value: %s.', id_env)
raise InvalidValueError(None, 'env_id', id_env)
# Valid num Vlan
if not is_valid_int_greater_zero_param(num_vlan):
self.log.error(
u'The num_vlan parameter is not a valid value: %s.', num_vlan)
raise InvalidValueError(None, 'num_vlan', id_env)
else:
num_vlan = int(num_vlan)
if is_valid_int_greater_zero_param(id_vlan):
vlan_to_edit = Vlan().get_by_pk(id_vlan)
if vlan_to_edit.num_vlan == num_vlan:
return self.response(dumps_networkapi({'has_numbers_availables': True}))
environment = Ambiente().get_by_pk(id_env)
vlan = Vlan()
vlan.ambiente = environment
# Check if environment has min/max num_vlan value or use the value
# that was configured in settings
if (vlan.ambiente.min_num_vlan_1 and vlan.ambiente.max_num_vlan_1) or (vlan.ambiente.min_num_vlan_2 and vlan.ambiente.max_num_vlan_2):
min_num_01 = vlan.ambiente.min_num_vlan_1 if vlan.ambiente.min_num_vlan_1 and vlan.ambiente.max_num_vlan_1 else vlan.ambiente.min_num_vlan_2
max_num_01 = vlan.ambiente.max_num_vlan_1 if vlan.ambiente.min_num_vlan_1 and vlan.ambiente.max_num_vlan_1 else vlan.ambiente.max_num_vlan_2
min_num_02 = vlan.ambiente.min_num_vlan_2 if vlan.ambiente.min_num_vlan_2 and vlan.ambiente.max_num_vlan_2 else vlan.ambiente.min_num_vlan_1
max_num_02 = vlan.ambiente.max_num_vlan_2 if vlan.ambiente.min_num_vlan_2 and vlan.ambiente.max_num_vlan_2 else vlan.ambiente.max_num_vlan_1
else:
min_num_01 = MIN_VLAN_NUMBER_01
max_num_01 = MAX_VLAN_NUMBER_01
min_num_02 = MIN_VLAN_NUMBER_02
max_num_02 = MAX_VLAN_NUMBER_02
has_numbers_availables = False
availables_numbers = vlan.calculate_vlan_number(
min_num_01, max_num_01, True)
if num_vlan not in availables_numbers:
availables_numbers = vlan.calculate_vlan_number(
min_num_02, max_num_02, True)
if num_vlan in availables_numbers:
has_numbers_availables = True
else:
has_numbers_availables = True
if Vlan.objects.filter(num_vlan=num_vlan, ambiente=environment):
has_numbers_availables = True
return self.response(dumps_networkapi({'has_numbers_availables': has_numbers_availables}))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
示例8: handle_post
# 需要导入模块: from networkapi.vlan.models import Vlan [as 别名]
# 或者: from networkapi.vlan.models.Vlan import ambiente [as 别名]
def handle_post(self, request, user, *args, **kwargs):
"""Handles POST requests to create new VLAN without add NetworkIPv4.
URLs: /vlan/no-network/
"""
self.log.info('Create new VLAN without add NetworkIPv4')
try:
# Commons Validations
# 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.')
return self.not_authorized()
# Business Validations
# Load XML data
xml_map, attrs_map = loads(request.raw_post_data)
# XML data format
networkapi_map = xml_map.get('networkapi')
if networkapi_map is None:
msg = u'There is no value to the networkapi tag of XML request.'
self.log.error(msg)
return self.response_error(3, msg)
vlan_map = networkapi_map.get('vlan')
if vlan_map is None:
msg = u'There is no value to the vlan tag of XML request.'
self.log.error(msg)
return self.response_error(3, msg)
# Get XML data
environment = vlan_map.get('environment_id')
name = vlan_map.get('name')
description = vlan_map.get('description')
vrf = vlan_map.get('vrf')
# Name must NOT be none and 50 is the maxsize
if not is_valid_string_minsize(name, 3) or not is_valid_string_maxsize(name, 50):
self.log.error(u'Parameter name is invalid. Value: %s.', name)
raise InvalidValueError(None, 'name', name)
# Description can NOT be greater than 200
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)
# vrf can NOT be greater than 100
if not is_valid_string_maxsize(vrf, 100, False):
self.log.error(
u'Parameter vrf is invalid. Value: %s.', vrf)
raise InvalidValueError(None, 'vrf', vrf)
# Environment
try:
# Valid environment ID
if not is_valid_int_greater_zero_param(environment):
self.log.error(
u'Parameter environment_id is invalid. Value: %s.', environment)
raise InvalidValueError(
None, 'environment_id', environment)
# Find environment by ID to check if it exist
env = Ambiente.get_by_pk(environment)
except AmbienteNotFoundError, e:
self.log.error(u'The environment parameter does not exist.')
return self.response_error(112)
# Business Rules
# New Vlan
vlan = Vlan()
vlan.nome = name
vlan.descricao = description
vlan.ambiente = env
# Check if environment has min/max num_vlan value or use the value
# thas was configured in settings
if (vlan.ambiente.min_num_vlan_1 and vlan.ambiente.max_num_vlan_1) or (vlan.ambiente.min_num_vlan_2 and vlan.ambiente.max_num_vlan_2):
min_num_01 = vlan.ambiente.min_num_vlan_1 if vlan.ambiente.min_num_vlan_1 and vlan.ambiente.max_num_vlan_1 else vlan.ambiente.min_num_vlan_2
max_num_01 = vlan.ambiente.max_num_vlan_1 if vlan.ambiente.min_num_vlan_1 and vlan.ambiente.max_num_vlan_1 else vlan.ambiente.max_num_vlan_2
min_num_02 = vlan.ambiente.min_num_vlan_2 if vlan.ambiente.min_num_vlan_2 and vlan.ambiente.max_num_vlan_2 else vlan.ambiente.min_num_vlan_1
max_num_02 = vlan.ambiente.max_num_vlan_2 if vlan.ambiente.min_num_vlan_2 and vlan.ambiente.max_num_vlan_2 else vlan.ambiente.max_num_vlan_1
else:
min_num_01 = settings.MIN_VLAN_NUMBER_01
max_num_01 = settings.MAX_VLAN_NUMBER_01
min_num_02 = settings.MIN_VLAN_NUMBER_02
max_num_02 = settings.MAX_VLAN_NUMBER_02
#To avoid allocation same vlan number twice for different environments in same equipments
#Lock all environments related to this environment when allocating vlan number
#select all equipments from this environment that are not part of a filter
# and them selects all environments from all these equipments and lock them out
#.........这里部分代码省略.........