package com.bocloud.cmp.model;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Date;
import java.util.List;

/**
 * hmc上的小机信息
 * <p>
 * 存储信息复用该类
 *
 * @author lkx007
 */
public class OsHost {
    /**
     * {
     * "host_display_name": "Server-8203",
     * "hmc_uuids": [],
     * "host_vms": 5,
     * "host_mtms": "8203-E4A 10F8563",
     * "manager_type": null,
     * "host_name": "8203E4A_10F8563",
     * "is_master": true,
     * "host_uuid": "25cc2a4e-b946-3b98-acaa-cdf90628809a",
     * "master_manager_type": "hmc"
     * }
     */
    @JSONField(name = "host_display_name")
    private String nickName;
    @JSONField(name = "hmc_uuids")
    private List<String> hmcUuids;
    @JSONField(name = "host_vms")
    private Integer vmNum;
    @JSONField(name = "host_mtms")
    private String mtms;
    /**
     * hmc
     */
    @JSONField(name = "manager_type")
    private String type;
    @JSONField(name = "host_name")
    private String name;
    @JSONField(name = "is_master")
    private Boolean master;
    @JSONField(name = "host_uuid")
    private String uuid;
    @JSONField(name = "master_manager_type")
    private String managerType;
    /**
     * powervm
     */
    @JSONField(name = "host_type")
    private String hostType;
    /**
     * "2013-10-19T16:06:53Z"
     */
    @JSONField(name = "registered_at", format = "yyyy-mm-dd'T'")
    private Date gmtCreate;
    /**
     * POWER7
     */
    @JSONField(name = "host_proc_level_type")
    private String level;
    /**
     * true
     */
    @JSONField(name = "force_switch")
    private Boolean forceSwitch;
    /**
     * ok
     */
    @JSONField(name = "access_state")
    private String status;
    /**
     * consoleauth
     * <p>
     * ibm-notification
     * <p>
     * rtpolicy
     * <p>
     * scheduler
     * <p>
     * hapolicy
     * <p>
     * health
     * <p>
     * <p>
     * compute（zone为nova时，service为compute）
     */
    @JSONField(name = "service")
    private String service;
    /**
     * zone
     * internal表示powervc本机
     * <p>
     * nova表示小机
     */
    @JSONField(name = "zone")
    private String zone;
    private Integer cpuNumTotal;
    private Integer cpuNumUsed;
    private Integer cpuNumMax;
    private Long memTotal;
    private Double diskTotal;
    private Long memMax;
    private Double diskMax;
    private Long memUsed;
    private Double diskUsed;
    @JSONField(name = "vios_clusters")
    private List<String> viosClusters;
    /**
     * for storage
     */
    @JSONField(name = "access_ip")
    private String ip;
    @JSONField(name = "user_id")
    private String username;
    private String password;
    @JSONField(name = "auto_add_host_key")
    private Boolean addKey;
    @JSONField(name = "volume_pool_name")
    private String volumePool;
    @JSONField(name = "default_volume_type")
    private String defVolumeType;

    public OsHost() {
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public List<String> getHmcUuids() {
        return hmcUuids;
    }

    public void setHmcUuids(List<String> hmcUuids) {
        this.hmcUuids = hmcUuids;
    }

    public Integer getVmNum() {
        return vmNum;
    }

    public void setVmNum(Integer vmNum) {
        this.vmNum = vmNum;
    }

    public String getMtms() {
        return mtms;
    }

    public void setMtms(String mtms) {
        this.mtms = mtms;
    }

    public String getType() {
        return type;
    }

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

    public String getName() {
        return name;
    }

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

    public Boolean getMaster() {
        return master;
    }

    public void setMaster(Boolean master) {
        this.master = master;
    }

    public String getUuid() {
        return uuid;
    }

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

    public String getManagerType() {
        return managerType;
    }

    public void setManagerType(String managerType) {
        this.managerType = managerType;
    }

    public String getHostType() {
        return hostType;
    }

    public void setHostType(String hostType) {
        this.hostType = hostType;
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public Boolean getForceSwitch() {
        return forceSwitch;
    }

    public void setForceSwitch(Boolean forceSwitch) {
        this.forceSwitch = forceSwitch;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getService() {
        return service;
    }

    public void setService(String service) {
        this.service = service;
    }

    public String getZone() {
        return zone;
    }

    public void setZone(String zone) {
        this.zone = zone;
    }

    public Integer getCpuNumTotal() {
        return cpuNumTotal;
    }

    public void setCpuNumTotal(Integer cpuNumTotal) {
        this.cpuNumTotal = cpuNumTotal;
    }

    public Integer getCpuNumUsed() {
        return cpuNumUsed;
    }

    public void setCpuNumUsed(Integer cpuNumUsed) {
        this.cpuNumUsed = cpuNumUsed;
    }

    public Integer getCpuNumMax() {
        return cpuNumMax;
    }

    public void setCpuNumMax(Integer cpuNumMax) {
        this.cpuNumMax = cpuNumMax;
    }

    public Long getMemTotal() {
        return memTotal;
    }

    public void setMemTotal(Long memTotal) {
        this.memTotal = memTotal;
    }

    public Double getDiskTotal() {
        return diskTotal;
    }

    public void setDiskTotal(Double diskTotal) {
        this.diskTotal = diskTotal;
    }

    public Long getMemMax() {
        return memMax;
    }

    public void setMemMax(Long memMax) {
        this.memMax = memMax;
    }

    public Double getDiskMax() {
        return diskMax;
    }

    public void setDiskMax(Double diskMax) {
        this.diskMax = diskMax;
    }

    public Long getMemUsed() {
        return memUsed;
    }

    public void setMemUsed(Long memUsed) {
        this.memUsed = memUsed;
    }

    public Double getDiskUsed() {
        return diskUsed;
    }

    public void setDiskUsed(Double diskUsed) {
        this.diskUsed = diskUsed;
    }

    public List<String> getViosClusters() {
        return viosClusters;
    }

    public void setViosClusters(List<String> viosClusters) {
        this.viosClusters = viosClusters;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Boolean getAddKey() {
        return addKey;
    }

    public void setAddKey(Boolean addKey) {
        this.addKey = addKey;
    }

    public String getVolumePool() {
        return volumePool;
    }

    public void setVolumePool(String volumePool) {
        this.volumePool = volumePool;
    }

    public String getDefVolumeType() {
        return defVolumeType;
    }

    public void setDefVolumeType(String defVolumeType) {
        this.defVolumeType = defVolumeType;
    }

    @Override
    public String toString() {
        try {
            return new ObjectMapper().writeValueAsString(this);
        } catch (JsonProcessingException e) {
            return JSONObject.toJSONString(this);
        }
    }
}
