package com.bocloud.ims.entity.resource;

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.Data;

import java.util.List;

@Table("network_card")
@Data
public class NetworkCard extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id;
	@Column("used")
	private Boolean used;// 网卡在某一台物理机上是否被使用
	@Column("host_id")
	private Long hostId;
    @Column("host_name")
    @IgnoreAll
    private String hostName;
	@Column("vendor_id")
	private Long vendorId;
	@Column("mac")
	private String mac;
	/**
	 * VM or PM
	 */
	@Column("category")
	private String category;
	/**
	 * for vm, label is 'Network adapter 1' for pm, label is null
	 */
	@Column("label")
	private String label;
    @Column("model")
    private String model;
	@Column("switcher_id")
	private Long switcherId;
	/**
	 * for vm, portType is 'VIRTUAL' for pm, portType is eth....
	 */
	@Column("port_type")
	private String portType;// 端口类型
	@Column("pci_id")
	private Long pciId;
	@IgnoreAll
	private String switcher;
	@Column("region_id")
	private String regionId;
	@IgnoreAll
	private String regionName;

    @Column("zone")
    private String zone;
    @IgnoreAll
    private String zoneName;
    @Column("vpc_uuid")
    private String vpcUuid;

	@Column("subnet_uuid")
	private String subnetUuid;
	@Column("networkcard_uuid")
	private String networkcardUuid;
	@Column("is_primary")
	private Boolean isPrimary;
	@Column("ip_address")
	private String ipAddress;
    @Column("netmask")
    private String netmask;
    @Column("gateway")
    private String gateway;
    @Column("vlan")
    private Integer vlan;

    @Column("floatingip_uuid")
    private String floatingIpUuid;
    @Column("instance_id")
    private String instanceId;

	/**
	 * 网卡mtu数据
	 * <p>
	 * 1500
	 */
	@Column("mtu")
	private Integer mtu;
    /**
     * 网卡速率
     */
    @Column("speed")
    private Long speed;
	/**
	 * 网卡下表编号 0，1，2，3
	 */
	@Column("number")
	private Integer number;
    @Column("switcher_available")
    private Boolean switcherAvailable;

	@IgnoreAll
	private String vpcName;
	@IgnoreAll
	private Long vpcId;
	@IgnoreAll
    @Column("subnet_id")
	private Long subnetId;
    @IgnoreAll
    @Column("network_id")
    private Long networkId;
	@IgnoreAll
    @Column("subnet_name")
	private String subnetName;
    @IgnoreAll
    @Column("network_name")
    private String networkName;
	@IgnoreAll
	private String serverName;

    @IgnoreAll
    private String floatingIp;
    @IgnoreAll
    private List<String> securityGroupIds;
	//fc 纳管
	@Column("uri")
	private String uri;
	@Column("port_group_id")
	private Long portGroupId;
	@Column("type")
	private String type;
	@Column("enable_security_group")
	private  Boolean enableSecurityGroup;//云主机网卡是否开启安全组
	@Column("security_group_id")
	private Long securityGroupId;//安全组Id
	@Column("vringbuf")
	private Integer vringbuf;//IO环大小，默认为256，取值范围为256、512、1024、2048、4096
	@Column("queues")
	private Integer queues;//队列数，默认为1，取值范围为[1,8]
	@Column("server_id")
	private Long serverId;
	@IgnoreAll
	private String portGroupUuid;
	@IgnoreAll
	private String securityGroupUuid;
	@IgnoreAll
	private String portGroupName;
	//fc 纳管

    public void preSave(Long creatorId, Long menderId, Long vendorId, Long hostId, String category) {
        this.setCreatorId(creatorId);
        this.setMenderId(menderId);
        this.setVendorId(vendorId);
        this.setHostId(hostId);
        this.setCategory(category);
    }
}
