Example #1
0
def _create_oobvlans(rack, user):
    log.debug("_create_oobvlans")

    env_oob = models_env.Ambiente.objects.filter(
        dcroom=int(rack.dcroom.id),
        divisao_dc__nome="OOB",
        grupo_l3__nome=str(rack.dcroom.name),
        ambiente_logico__nome="GERENCIA").uniqueResult()
    log.debug("OOB environments: " + str(env_oob))

    vlan = None
    for env in [env_oob]:
        vlan_base = env.min_num_vlan_1
        vlan_number = int(vlan_base) + int(rack.numero)
        vlan_name = "VLAN_" + env.ambiente_logico.nome + "_" + rack.nome

        obj = {
            'name': vlan_name,
            'num_vlan': vlan_number,
            'environment': env.id,
            'default_vrf': env.default_vrf.id,
            'vrf': env.vrf,
            'create_networkv4': None,
            'create_networkv6': None
        }
        vlan = facade_vlan_v3.create_vlan(obj, user)

        log.debug("Vlan allocated: " + str(vlan))

        network = dict()
        for config in env.configs:
            log.debug("Configs: " + str(config))
            new_prefix = config.subnet_mask
            redev4 = IPNetwork(config.network)
            new_v4 = list(redev4.subnet(int(new_prefix)))[int(rack.numero)]
            oct1, oct2, oct3, var = str(new_v4).split('.')
            oct4, prefix = var.split('/')
            netmask = str(new_v4.netmask)
            mask1, mask2, mask3, mask4 = netmask.split('.')
            network = dict(oct1=oct1,
                           oct2=oct2,
                           oct3=oct3,
                           oct4=oct4,
                           prefix=prefix,
                           mask_oct1=mask1,
                           mask_oct2=mask2,
                           mask_oct3=mask3,
                           mask_oct4=mask4,
                           cluster_unit=None,
                           vlan=vlan.id,
                           network_type=config.id_network_type.id,
                           environmentvip=None)
            log.debug("Network allocated: " + str(network))
        facade_redev4_v3.create_networkipv4(network, user)

    return vlan
    def spine_leaf_vlans_save(self):
        log.debug("_create_spnlfvlans")

        spn_lf_envs = models_env.Ambiente.objects.filter(
            dcroom=int(self.rack.dcroom.id),
            grupo_l3__nome=str(self.rack.dcroom.name),
            ambiente_logico__nome__in=[
                "SPINE01LEAF", "SPINE02LEAF", "SPINE03LEAF", "SPINE04LEAF"
            ])
        log.debug("SPN environments" + str(spn_lf_envs))

        tipo_rede = "Ponto a ponto"
        try:
            id_network_type = models_vlan.TipoRede().get_by_name(tipo_rede).id
        except:
            network_type = models_vlan.TipoRede()
            network_type.tipo_rede = tipo_rede
            network_type.save()
            id_network_type = network_type.id
            pass

        for env in spn_lf_envs:

            obj = {
                'name':
                "VLAN_" + env.divisao_dc.nome + "_" +
                env.ambiente_logico.nome + "_" + self.rack.nome,
                'environment':
                env.id,
                'default_vrf':
                env.default_vrf.id,
                'vrf':
                env.vrf,
                'create_networkv4':
                None,
                'create_networkv6':
                None,
                'description':
                "Vlan spinexleaf do rack " + self.rack.nome
            }
            vlan = facade_vlan_v3.create_vlan(obj, self.user)

            log.debug("Vlan allocated: " + str(vlan))

            for config in env.configs:
                log.debug("Configs: " + str(config))
                network = dict(prefix=config.subnet_mask,
                               cluster_unit=None,
                               vlan=vlan.id,
                               network_type=id_network_type,
                               environmentvip=None)
                log.debug("Network allocated: " + str(network))
                if str(config.ip_version)[-1] is "4":
                    facade_redev4_v3.create_networkipv4(network, self.user)
                elif str(config.ip_version)[-1] is "6":
                    facade_redev6_v3.create_networkipv6(network, self.user)
Example #3
0
def _create_oobvlans(rack, user):
    log.debug("_create_oobvlans")

    env_oob = models_env.Ambiente.objects.filter(dcroom=int(rack.dcroom.id),
                                                 divisao_dc__nome="OOB",
                                                 grupo_l3__nome=str(rack.dcroom.name),
                                                 ambiente_logico__nome="GERENCIA").uniqueResult()
    log.debug("OOB environments: "+str(env_oob))

    vlan = None
    for env in [env_oob]:
        vlan_base = env.min_num_vlan_1
        vlan_number = int(vlan_base) + int(rack.numero)
        vlan_name = "VLAN_" + env.ambiente_logico.nome + "_" + rack.nome

        obj = {
            'name': vlan_name,
            'num_vlan': vlan_number,
            'environment': env.id,
            'default_vrf': env.default_vrf.id,
            'vrf': env.vrf,
            'create_networkv4': None,
            'create_networkv6': None
        }
        vlan = facade_vlan_v3.create_vlan(obj, user)

        log.debug("Vlan allocated: "+str(vlan))

        network = dict()
        for config in env.configs:
            log.debug("Configs: "+str(config))
            new_prefix = config.ip_config.new_prefix
            redev4 = IPNetwork(config.ip_config.subnet)
            new_v4 = list(redev4.subnet(int(new_prefix)))[int(rack.numero)]
            oct1, oct2, oct3, var = str(new_v4).split('.')
            oct4, prefix = var.split('/')
            netmask = str(new_v4.netmask)
            mask1, mask2, mask3, mask4 = netmask.split('.')
            network = dict(oct1=oct1, oct2=oct2, oct3=oct3, oct4=oct4, prefix=prefix, mask_oct1=mask1, mask_oct2=mask2,
                           mask_oct3=mask3, mask_oct4=mask4, cluster_unit=None, vlan=vlan.id,
                           network_type=config.ip_config.network_type.id, environmentvip=None)
            log.debug("Network allocated: "+ str(network))
        facade_redev4_v3.create_networkipv4(network, user)

    return vlan
    def manage_vlan_save(self):
        log.debug("_create_oobvlans")

        env_oob = models_env.Ambiente.objects.filter(
            dcroom=int(self.rack.dcroom.id),
            divisao_dc__nome="OOB",
            grupo_l3__nome=str(self.rack.dcroom.name),
            ambiente_logico__nome="GERENCIA").uniqueResult()
        log.debug("OOB environments: " + str(env_oob))

        for env in [env_oob]:

            obj = {
                'name':
                "VLAN_" + env.ambiente_logico.nome + "_" + self.rack.nome,
                'environment': env.id,
                'default_vrf': env.default_vrf.id,
                'vrf': env.vrf,
                'create_networkv4': None,
                'create_networkv6': None,
                'description': "Vlan de gerĂȘncia do rack " + self.rack.nome
            }
            vlan = facade_vlan_v3.create_vlan(obj, self.user)

            log.debug("Vlan allocated: " + str(vlan))

            network = dict()
            for config in env.configs:
                log.debug("Configs: " + str(config))
                network = dict(prefix=config.subnet_mask,
                               cluster_unit=None,
                               vlan=vlan.id,
                               network_type=config.id_network_type.id,
                               environmentvip=None)
                log.debug("Network allocated: " + str(network))
            facade_redev4_v3.create_networkipv4(network, self.user)

        return vlan