package com.bocloud.ims.entity.installation;

import com.alibaba.fastjson.JSONObject;
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;

import java.util.List;

/**
 * yum源管理
 *
 * @author lkx007
 */
@Table("yum_repo")
public class YumRepo extends Generic {

	@PK(value = PKStrategy.AUTO)
	private Long id; // ID
	@Column("name")
	/**
	 * yum源名称
	 *
	 * lkx_repo
	 */
	private String name;
	/**
	 * yum源种类
	 * <p>
	 * public private iso
	 */
	@Column("type")
	private String type;
	/**
	 * yum源的描述
	 * <p>
	 * LKX YUM REPO
	 */
	@Column("description")
	private String description;
	/**
	 * yum源地址
	 * <p>
	 * http://192.168.1.151/yum
	 */
	@Column("baseurl")
	private String baseurl;

	/**
	 * 多个地址使用mirrorlist
	 * <p>
	 * http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
	 */
	@Column("mirrorlist")
	private String mirrorlist;

	/**
	 * "https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch"
	 */
	@Column("metalink")
	private String metalink;
	/**
	 * if check gpg
	 * <p>
	 * 0 or 1
	 */
	@Column("gpgcheck")
	private Integer gpgcheck;
	/**
	 * "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7"
	 */
	@Column("gpgkey")
	private String gpgkey;
	/**
	 * "priority","roundrobin"二选一 默认为roundrobin
	 */
	@Column("failovermethod")
	private String failovermethod;

	/**
	 * repo文件夹地址
	 */
	@Column("repo_path")
	private String repoPath;

	/**
	 * yum源文件名称
	 */
	@Column("file")
	private String file;

	/**
	 * 私有yum源服务端机器信息
	 */
	@Column("server_info")
	private String serverInfo;
	/**
	 * ISO yum源的镜像id
	 */
	@Column("image_id")
	private Long imageId;

	/**
	 * image service的地址
	 */
	@IgnoreAll
	private String imageServer;
	/**
	 * 配置yum源的server端信息
	 */
	@IgnoreAll
	private JSONObject target;
	/**
	 * 配置yum源的client端信息
	 */
	@IgnoreAll
	private List<JSONObject> targets;
	/**
	 * ISO源的osType
	 * <p>
	 * 暂时支持redhat跟centos
	 */
	@IgnoreAll
	private String osType;
	/**
	 * ISO源的osVersion
	 * <p>
	 * 7.1
	 */
	@IgnoreAll
	private String osVersion;
	/**
	 * ISO源的镜像名称
	 * <p>
	 */
	@Column("image_name")
	@IgnoreAll
	private String imageName;
	/**
	 * ISO源的iso名称
	 * <p>
	 * rhel-server-7.3-x86_64-dvd.iso
	 */
	@IgnoreAll
	private String isoName;

	/**
	 * 给目标机器配置源的时候，是否清理现有目标机器上的yum源
	 */
	@IgnoreAll
	private Boolean clean;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getBaseurl() {
		return baseurl;
	}

	public void setBaseurl(String baseurl) {
		this.baseurl = baseurl;
	}

	public String getMirrorlist() {
		return mirrorlist;
	}

	public void setMirrorlist(String mirrorlist) {
		this.mirrorlist = mirrorlist;
	}

	public String getMetalink() {
		return metalink;
	}

	public void setMetalink(String metalink) {
		this.metalink = metalink;
	}

	public Integer getGpgcheck() {
		return gpgcheck;
	}

	public void setGpgcheck(Integer gpgcheck) {
		this.gpgcheck = gpgcheck;
	}

	public String getGpgkey() {
		return gpgkey;
	}

	public void setGpgkey(String gpgkey) {
		this.gpgkey = gpgkey;
	}

	public String getFailovermethod() {
		return failovermethod;
	}

	public void setFailovermethod(String failovermethod) {
		this.failovermethod = failovermethod;
	}

	public String getRepoPath() {
		return repoPath;
	}

	public void setRepoPath(String repoPath) {
		this.repoPath = repoPath;
	}

	public String getImageServer() {
		return imageServer;
	}

	public void setImageServer(String imageServer) {
		this.imageServer = imageServer;
	}

	public JSONObject getTarget() {
		return target;
	}

	public void setTarget(JSONObject target) {
		this.target = target;
	}

	public List<JSONObject> getTargets() {
		return targets;
	}

	public void setTargets(List<JSONObject> targets) {
		this.targets = targets;
	}

	public String getServerInfo() {
		return serverInfo;
	}

	public void setServerInfo(String serverInfo) {
		this.serverInfo = serverInfo;
	}

	public Long getImageId() {
		return imageId;
	}

	public void setImageId(Long imageId) {
		this.imageId = imageId;
	}

	public String getOsType() {
		return osType;
	}

	public void setOsType(String osType) {
		this.osType = osType;
	}

	public String getOsVersion() {
		return osVersion;
	}

	public void setOsVersion(String osVersion) {
		this.osVersion = osVersion;
	}

	public String getFile() {
		return file;
	}

	public void setFile(String file) {
		this.file = file;
	}

	public Boolean getClean() {
		return clean;
	}

	public void setClean(Boolean clean) {
		this.clean = clean;
	}

	public String getImageName() {
		return imageName;
	}

	public void setImageName(String imageName) {
		this.imageName = imageName;
	}

	public String getIsoName() {
		return isoName;
	}

	public void setIsoName(String isoName) {
		this.isoName = isoName;
	}

	@Override
	public String toString() {
		return JSONObject.toJSONString(this);
	}
}
