當前位置: 首頁>>代碼示例>>Python>>正文


Python Vlan.get_vlan_by_acl_v6方法代碼示例

本文整理匯總了Python中networkapi.vlan.models.Vlan.get_vlan_by_acl_v6方法的典型用法代碼示例。如果您正苦於以下問題:Python Vlan.get_vlan_by_acl_v6方法的具體用法?Python Vlan.get_vlan_by_acl_v6怎麽用?Python Vlan.get_vlan_by_acl_v6使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在networkapi.vlan.models.Vlan的用法示例。


在下文中一共展示了Vlan.get_vlan_by_acl_v6方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: handle_post

# 需要導入模塊: from networkapi.vlan.models import Vlan [as 別名]
# 或者: from networkapi.vlan.models.Vlan import get_vlan_by_acl_v6 [as 別名]

#.........這裏部分代碼省略.........
            vlan = Vlan()
            vlan = vlan.get_by_pk(id_vlan)

            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)
開發者ID:itnihao,項目名稱:GloboNetworkAPI,代碼行數:69,代碼來源:VlanEditResource.py

示例2: handle_post

# 需要導入模塊: from networkapi.vlan.models import Vlan [as 別名]
# 或者: from networkapi.vlan.models.Vlan import get_vlan_by_acl_v6 [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)
開發者ID:andrewsmedina,項目名稱:GloboNetworkAPI,代碼行數:104,代碼來源:VlanInsertResource.py

示例3: handle_post

# 需要導入模塊: from networkapi.vlan.models import Vlan [as 別名]
# 或者: from networkapi.vlan.models.Vlan import get_vlan_by_acl_v6 [as 別名]

#.........這裏部分代碼省略.........
            # 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:
                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(".")
開發者ID:marcelometal,項目名稱:GloboNetworkAPI,代碼行數:69,代碼來源:VlanInsertResource.py


注:本文中的networkapi.vlan.models.Vlan.get_vlan_by_acl_v6方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。