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.Generic;
import com.bocloud.entity.meta.PKStrategy;

/**
 * 云主机与云硬盘关系类
 * 
 * @author wangyu
 * @Version 2017年6月28日 上午11:08:13
 */
@Table("server_volume")
public class ServerVolume extends Generic {

	@PK(value = PKStrategy.AUTO)
	private Long id;// ID
	@Column("uuid")
	private String uuid; // uuid
	@Column("server_id")
	private Long serverId;// 云主机ID
	@Column("server_name")
	@IgnoreAll
	private String serverName; // 云主机名称
	@Column("volume_id")
	private Long volumeId;// 云硬盘ID
	@Column("volume_name")
	@IgnoreAll
	private String volumeName;// 云硬盘名称
	@Column("volume_size")
	private Long volumeSize; // 云硬盘容量。在SmartX中，模板中的云硬盘容量有可能不等于该云硬盘的实际容量，所以这里需要一个额外的字段进行记录，而不能从Volume表中关联获取
	@Column("device")
	private String device;// 挂载设备
	@Column("boot_index")
	private Integer bootIndex; // 启动顺序
	@Column("bus")
	private String bus; // 总线
	@Column("disabled")
	private Boolean disabled; // 停用
	@Column("diff_key")
	private Long diffKey;
	@Column("template_uuid")
	private String templateUuid; // 模板uuid

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	/**
	 * 
	 */
	public ServerVolume() {
		super();
	}

	/**
	 * @param serverId
	 * @param volumeId
	 * @param device
	 */
	public ServerVolume(Long serverId, Long volumeId, String device) {
		super();
		this.serverId = serverId;
		this.volumeId = volumeId;
		this.device = device;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the serverId
	 */
	public Long getServerId() {
		return serverId;
	}

	/**
	 * @param serverId
	 *            the serverId to set
	 */
	public void setServerId(Long serverId) {
		this.serverId = serverId;
	}

	/**
	 * @return the volumeId
	 */
	public Long getVolumeId() {
		return volumeId;
	}

	/**
	 * @param volumeId
	 *            the volumeId to set
	 */
	public void setVolumeId(Long volumeId) {
		this.volumeId = volumeId;
	}

	/**
	 * @return the device
	 */
	public String getDevice() {
		return device;
	}

	/**
	 * @param device
	 *            the device to set
	 */
	public void setDevice(String device) {
		this.device = device;
	}

	public String getServerName() {
		return serverName;
	}

	public void setServerName(String serverName) {
		this.serverName = serverName;
	}

	public String getVolumeName() {
		return volumeName;
	}

	public void setVolumeName(String volumeName) {
		this.volumeName = volumeName;
	}

	public Long getVolumeSize() {
		return volumeSize;
	}

	public void setVolumeSize(Long volumeSize) {
		this.volumeSize = volumeSize;
	}

	public Integer getBootIndex() {
		return bootIndex;
	}

	public void setBootIndex(Integer bootIndex) {
		this.bootIndex = bootIndex;
	}

	public String getBus() {
		return bus;
	}

	public void setBus(String bus) {
		this.bus = bus;
	}

	public Boolean getDisabled() {
		return disabled;
	}

	public void setDisabled(Boolean disabled) {
		this.disabled = disabled;
	}

	public Long getDiffKey() {
		return diffKey;
	}

	public void setDiffKey(Long diffKey) {
		this.diffKey = diffKey;
	}

	public String getTemplateUuid() {
		return templateUuid;
	}

	public void setTemplateUuid(String templateUuid) {
		this.templateUuid = templateUuid;
	}

	public Integer getVolumeSizeGB() {
		return this.volumeSize == null ? null : Math.toIntExact(this.volumeSize / 1024L / 1024L / 1024L);
	}

}
