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;

@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("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("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("floatingip_uuid")
	private String floatingIpUuid;
	@Column("instance_id")
	private String instanceId;

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

	@IgnoreAll
	private String vpcName;
	@IgnoreAll
	private Long vpcId;
	@IgnoreAll
	private Long serverId;
	@IgnoreAll
	private Long subnetId;
	@IgnoreAll
	private String subnetName;
	@IgnoreAll
	private String serverName;

	@IgnoreAll
	private String floatingIp;

	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);
	}
}
