package com.bocloud.ims.entity.resource;

import java.math.BigInteger;
import java.util.List;

import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 
 * @description IP池管理
 * @version 5.1.0
 * @author wangyu
 * @date: 2020-11-30
 *
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@Table("ip_pool")
public class IpPool extends GenericEntity {

    /**
     * idn
     */
    @PK(value = PKStrategy.AUTO)
    private Long id;
    /**
     * 网关
     */
    @Column("gateway")
    private String gateway;
    /**
     * cidr
     */
    @Column("cidr")
    private String cidr;
    /**
     * IP池范围
     */
    @Column("pools")
    private String pools;
    /**
     * DNS
     */
    @Column("dns_names")
    private String dnsNames;
    /**
     * 子网ID
     */
    @Column("subnet_id")
    private Long subnetId;

    /**
     * 平台id
     */
    @Column("vendor_id")
    private Long vendorId;
    /**
     * 网络ID
     */
    @Column("network_id")
    private Long networkId;
    /**
     * vlan id
     */
    @Column("vlan_id")
    private Integer vlanId;
    /**
     * IP协议版本:V4/V6s
     */
    @Column("version")
    private String version;
    /**
     * nsx路由器端口id
     */
    @Column("router_port_id")
    private Long routerPortId;
    /**
     * 关联的vc端口组id
     */
    @Column("port_group_id")
    private Long portGroupId;
    /**
     * nsx分段id
     */
    @Column("segment_id")
    private Long segmentId;
    /**
     * 子网名称
     */
    @IgnoreAll
    private String subnetName;
    /**
     * 平台类型
     */
    @IgnoreAll
    private String vendorType;
    /**
     * ip总数
     */
    @IgnoreAll
    private BigInteger ipTotal;
    /**
     * ip使用数
     */
    @IgnoreAll
    private BigInteger ipUsed;
    /**
     * ip空闲数
     */
    @IgnoreAll
    private BigInteger ipFree;
    /**
     * ip锁定
     */
    @IgnoreAll
    private BigInteger ipLock;
    /**
     * ip预占数
     */
    @IgnoreAll
    private BigInteger ipPreempt;
    /**
     * 平台名称
     */
    @IgnoreAll
    private String vendorName;

    /**
     * ip列表详情
     */
    @IgnoreAll
    private List<AddressSection> addressSections;

    public IpPool(String gateway, String cidr, String pools, String dnsNames, Long subnetId, Long networkId,
        Long vendorId) {
        this.gateway = gateway;
        this.cidr = cidr;
        this.pools = pools;
        this.dnsNames = dnsNames;
        this.subnetId = subnetId;
        this.networkId = networkId;
        this.vendorId = vendorId;
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class AddressSection {
        /**
         * 当前值
         */
        private Integer value;
        /**
         * 最小值
         */
        private Integer min;
        /**
         * 最大值
         */
        private Integer max;
    }

}
