package com.bocloud.cmp.provider.compute;

import com.bocloud.cmp.model.*;
import com.bocloud.cmp.model.azure.automation.LogAnalyticModel;
import com.bocloud.cmp.model.h3c.H3cMigrateModel;
import com.bocloud.cmp.model.h3c.H3cServerModel;
import com.bocloud.cmp.provider.SuperProvider;
import com.bocloud.common.model.BocloudResult;

import java.util.List;

/**
 * 虚拟机操作服务接口
 *
 * @author weiwei
 */
public interface ServerProvider extends SuperProvider {
    /**
     * 虚拟机列表
     *
     * @return
     */
    public BocloudResult list();

    /**
     * 查询宿主机下的虚拟机列表
     *
     * @param hostId
     * @return
     */
    public BocloudResult list(String hostId);

    /**
     * 创建虚拟机
     *
     * @param server
     * @return
     */
    public BocloudResult create(ServerModel server);

    /**
     * 更新虚拟机
     *
     * @param server
     * @return
     */
    public BocloudResult modify(ServerModel server);

    /**
     * 虚拟机迁移
     *
     * @param server
     * @return
     */
    public BocloudResult migrate(ServerModel server);

    /**
     * 虚拟机迁移
     *
     * @param model
     * @return
     */
    public BocloudResult migrate(OSMigrateModel model);

    /**
     * 删除虚拟机
     *
     * @param instanceId
     * @param name
     * @return
     */
    public BocloudResult remove(String instanceId, String name);

    /**
     * 删除虚拟机
     *
     * @param instanceId
     * @param
     * @return
     */
    default BocloudResult remove(String instanceId, Boolean deletePublicIp, Boolean deleteVolume) {
        return null;
    }

    /**
     * 虚拟机详细
     *
     * @param instanceId
     * @return
     */
    public BocloudResult detail(String instanceId);

    /**
     * 启动虚拟机
     *
     * @param instanceId
     * @return
     */
    public BocloudResult start(String instanceId);

    /**
     * 停止虚拟机
     *
     * @param instanceId
     * @return
     */
    public BocloudResult stop(String instanceId);

    /**
     * 重启虚拟机
     *
     * @param instanceId
     * @return
     */
    public BocloudResult reboot(String instanceId);

    /**
     * 软重启虚拟机
     *
     * @param instanceId
     * @return
     */
    public BocloudResult softReboot(String instanceId);

    /**
     * 休眠虚拟机
     *
     * @param instanceId
     * @return
     */
    public BocloudResult pause(String instanceId);

    /**
     * 取消休眠虚拟机
     *
     * @param instanceId
     * @return
     */
    public BocloudResult unPause(String instanceId);

    /**
     * 挂起虚拟机
     *
     * @param instanceId
     * @return
     */
    public BocloudResult suspend(String instanceId);

    /**
     * 恢复挂起的虚拟机
     *
     * @param instanceId
     * @return
     */
    public BocloudResult resume(String instanceId);

    /**
     * 加入安全组
     *
     * @param instanceId
     * @param group
     * @return
     */
    public BocloudResult joinSGroup(String instanceId, String group);

    /**
     * 离开安全组
     *
     * @param instanceId
     * @param group
     * @return
     */
    public BocloudResult leaveSGroup(String instanceId, String group);

    /**
     * 创建快照
     *
     * @param snapshotModel
     * @return
     */
    public BocloudResult snapshot(SnapshotModel snapshotModel);

    /**
     * console接口
     *
     * @param vncType  novnc and xvpvnc
     * @param serverId
     * @return
     */
    public BocloudResult vncConsole(String vncType, String serverId);

    /**
     * 修改虚拟机密码
     *
     * @param instanceId
     * @param password
     * @return
     */
    public BocloudResult changePassword(String instanceId, String password);

    /**
     * 挂载网卡(openstack)
     *
     * @param server
     * @return
     */
    public BocloudResult attachNetwork(ServerModel server);

    /**
     * 卸载网卡(openstack)
     *
     * @param instanceId
     * @param portUuid
     * @return
     */
    public BocloudResult detachNetwork(String instanceId, String portUuid);

    /**
     * 修改配置
     *
     * @param instanceId
     * @param flavorId
     * @return
     */
    public BocloudResult resize(String instanceId, String flavorId);

    /**
     * 修改配置
     *
     * @param server
     * @param flavor
     * @return
     */
    default public BocloudResult resize(ServerModel server, FlavorModel flavor) {
        return new BocloudResult(false, "don't support");
    }

    /**
     * 确认修改配置
     *
     * @param instanceId
     * @return
     */
    public BocloudResult confirmResize(String instanceId);

    /**
     * 回滚修改配置
     *
     * @param instanceId
     * @return
     */
    public BocloudResult revertResize(String instanceId);

    /**
     * 设置CPU或内存热插拔
     *
     * @param instanceId
     * @param cpuHotEnable
     * @param MemHotEnable
     * @return
     */
    public BocloudResult hotConfigEnable(String instanceId, Boolean cpuHotEnable, Boolean MemHotEnable);

    /**
     * 获得vcenter访问remote console的ticket
     *
     * @param instanceId
     * @return
     */
    public BocloudResult getTicket(String instanceId);

    /**
     * 指定资源池创建虚拟机
     *
     * @param server
     * @return
     */
    public BocloudResult createInResPool(ServerModel server);

    /**
     * 挂载vmware tools安装镜像
     *
     * @param instanceId
     * @return
     */
    public BocloudResult mountToolsInstaller(String instanceId);

    /**
     * 卸载vmware tools安装镜像
     *
     * @param instanceId
     * @return
     */
    public BocloudResult unmountToolsInstaller(String instanceId);

    /**
     * 升级vmware tools
     *
     * @param instanceId
     * @param options
     * @return
     */
    public BocloudResult upgradeToolsTask(String instanceId, String options);

    /**
     * 获取虚拟机或模板下网络适配器
     *
     * @param instanceId
     * @return
     */
    public BocloudResult getNetCard(String instanceId);

    /**
     * 获取虚拟机IP(已安装vmware tools的虚拟机)
     *
     * @param instanceId
     * @return
     */
    default public BocloudResult getVmIps(String instanceId) {
        return null;
    }

    /**
     * 获取虚拟机IP(已安装vmware tools的虚拟机)
     *
     * @param instanceId
     * @param address
     * @return
     */
    default public BocloudResult getVmIps(String instanceId, String address) {
        return null;
    }

    /**
     * 标记为模板(vmware)
     *
     * @param instanceId
     * @return
     */
    public BocloudResult markAsTemplate(String instanceId);

    /**
     * 修改vcenter虚拟机密码
     *
     * @param instanceId
     * @param oldPasswd
     * @param newPasswd
     * @return
     */
    public BocloudResult changeVspVmPasswd(String instanceId, String oldPasswd, String newPasswd);

    /**
     * 初始化vcenter虚拟机密码
     *
     * @param instanceId
     * @param oldPasswd
     * @param newPasswd
     * @return
     */
    default BocloudResult initVspVmPasswd(String instanceId, String oldPasswd, String newPasswd) {
        return null;
    }

    /**
     * vcenter虚拟机磁盘扩容
     *
     * @param instanceId
     * @param diskLabel
     * @param extendSize
     * @return
     */
    public BocloudResult diskExtend(String instanceId, String diskLabel, Integer extendSize);

    /**
     * 获取虚拟机性能数据
     *
     * @param type
     * @return
     */
    public BocloudResult getMetric(String type);

    /**
     * 获取vcenter客户端控制台URL
     *
     * @param instanceId
     * @return
     */
    public BocloudResult vmrcConsole(String instanceId);

    /**
     * 迁移
     *
     * @param model
     * @return
     */
    default BocloudResult migrate(H3cMigrateModel model) {
        return new BocloudResult(false, "don't support");
    }

    /**
     * 创建华三云虚拟机
     *
     * @param server
     * @return
     */
    default BocloudResult create(H3cServerModel server) {
        return new BocloudResult(false, "don't support");
    }

    /**
     * 获取jnlp控制台
     *
     * @param vmId
     * @param address
     * @return
     */
    public BocloudResult getJnlpXml(Long vmId, String address);

    /**
     * 调整网络上限
     *
     * @param instanceId
     * @param internetMaxBandwidthOut
     * @return
     */
    public BocloudResult resetInternetMaxBandwidthOut(String instanceId, Integer internetMaxBandwidthOut);

    /**
     * 重装系统
     *
     * @param serverModel
     * @return
     */
    public BocloudResult resetInstance(ServerModel serverModel);

    /**
     * 切换系统
     *
     * @param serverModel
     * @return
     */
    default public BocloudResult changeInstance(ServerModel serverModel) {
        return null;
    }

    ;

    /**
     * 绑定秘钥
     *
     * @param serverModel
     * @return
     */
    public BocloudResult bindKeypair(ServerModel serverModel);

    /**
     * 解绑秘钥
     *
     * @param serverModel
     * @return
     */
    public BocloudResult unbindKeypair(ServerModel serverModel);

    public BocloudResult resize(String instanceId, String flavorId, Boolean forceStop);

    /**
     * 挂载卷
     *
     * @param instanceId
     * @param volumeModel
     * @return
     */
    default public BocloudResult attachVolume(String instanceId, VolumeModel volumeModel) {
        return null;
    }

    /**
     * 设定卷是否在删除虚拟机的时候也随之删除
     *
     * @param instanceId
     * @param volumeModel
     * @return
     */
    default public BocloudResult retachVolume(String instanceId, VolumeModel volumeModel) {
        return null;
    }

    /**
     * 卸载卷
     *
     * @param instanceId
     * @param volumeModel
     * @return
     */
    default public BocloudResult detachVolume(String instanceId, VolumeModel volumeModel) {
        return null;
    }

    /**
     * 捕获映像前的操作
     *
     * @param instanceId
     * @param imageModel
     * @return
     */
    default BocloudResult beforeCaptureImage(String instanceId, ImageModel imageModel) {
        return null;
    }

    /**
     * 捕获映像
     *
     * @param instanceId
     * @param imageName
     * @param volumes
     * @return
     */
    public BocloudResult createImage(String instanceId, String imageName, List<String> volumes);

    /**
     * 虚拟机vmware tools升级配置
     *
     * @param model
     * @return
     */
    default BocloudResult vmToolsConfig(ServerModel model) {
        return new BocloudResult(true, "success");
    }

    /**
     * 重置状态
     *
     * @param instanceId
     * @return
     */
    default public BocloudResult resetStatus(String instanceId) {
        return null;
    }

    default BocloudResult listByZone(String zone) {
        return null;
    }

    /**
     * 批量分配安全组 aws
     *
     * @param instanceId
     * @param groups
     * @return
     */
    default public BocloudResult allocationSGroups(String instanceId, List<String> groups) {
        return null;
    }

    default public BocloudResult addPortPolicy(String policyId, String portId) {
        return null;
    }

    /**
     * 修改虚拟机名称
     *
     * @param instanceId
     * @return
     */
    default BocloudResult modifyVmName(String instanceId, String newName) {
        return null;
    }

    /**
     * 绑定子网络接口
     *
     * @param model
     * @return
     */
    default public BocloudResult secondBindNics(ServerModel model) {
        return null;
    }

    /**
     * 解绑子网络接口
     *
     * @param model
     * @return
     */
    default public BocloudResult secondUnBindNics(ServerModel model) {
        return null;
    }

    /**
     * 修改系统盘配置
     *
     * @param model
     * @return
     */
    default public BocloudResult osDiskModify(ServerModel model) {
        return null;
    }

    default public BocloudResult serverDetail(ServerModel params) {
        return null;
    }

    /**
     * 查询异常虚拟机的底层报错
     *
     * @param instanceId
     * @return
     */
    default BocloudResult detailFault(String instanceId) {
        return null;
    }

    /**
     * 获取虚拟机创建文件夹
     *
     * @param vmFolder
     * @param vdcName
     * @return
     */
    default BocloudResult getVmFolder(String vmFolder, String vdcName) {
        return null;
    }

    /**
     * 获取虚拟机创建文件夹
     *
     * @param parentFolder
     * @param vmFolder
     * @param vdcName
     * @return
     */
    default BocloudResult getVmFolder(String parentFolder, String vmFolder, String vdcName) {
        return null;
    }

    /**
     * 创建关机状态的虚拟机，后续会对接nsx网络
     *
     * @param server
     * @return
     */
    default BocloudResult createWithoutPowerOff(ServerModel server) {
        return null;
    }

    /**
     * 自定义虚拟机配置
     *
     * @param server
     * @return
     */
    default BocloudResult customize(ServerModel server) {
        return null;
    }

    default BocloudResult listByStack(HeatStackModel stackModel) {
        return null;
    }

    default BocloudResult start(String instanceName, String resourceGroupName) {
        return null;
    }

    default BocloudResult stop(String instanceName, String resourceGroupName) {
        return null;
    }

    default BocloudResult deallocate(String instanceName, String resourceGroupName) {
        return null;
    }

    default BocloudResult reboot(String instanceName, String resourceGroupName) {
        return null;
    }

    /**
     * 克隆为模板
     *
     * @param server
     * @return
     */
    default BocloudResult cloneAsTemplate(ServerModel server) {
        return null;
    }

    /**
     * 整机快照恢复
     *
     * @param snapshotModel
     * @return
     */
    default BocloudResult rebuildServer(SnapshotModel snapshotModel) {
        return null;
    }

    /**
     * 开启disk uuid
     *
     * @param instanceId
     * @return
     */
    default BocloudResult enableDiskUuid(String instanceId) {
        return null;
    }

    /**
     * 设置虚拟机终止保护
     *
     * @param instanceId
     * @return
     */
    default BocloudResult disableApiTermination(String instanceId, Boolean enabled) {
        return null;
    }

    default BocloudResult createTag(ServerModel model) {
        return null;
    }

    default BocloudResult removeTag(ServerModel model) {
        return null;
    }

    /**
     * 删除磁盘
     *
     * @param instanceId
     * @param diskNames
     * @return
     */
    default BocloudResult deleteDisk(String instanceId, List<String> diskNames) {
        return null;
    }

    /**
     * 查询磁盘Uuid
     *
     * @param instanceId
     * @param diskNames
     * @return
     */
    default BocloudResult selectDiskUuid(String instanceId, List<String> diskNames) {
        return null;
    }

    default BocloudResult customizationVm(ServerModel model) {
        return null;
    }

    /**
     * 分配Ipv6
     *
     * @return
     */
    default BocloudResult assignIpv6(String networkInterfaceId, String ipv6) {
        return null;
    }

    default BocloudResult setFields(String instanceId, List<TagModel> tagModels) {
        return null;
    }

    default BocloudResult removeFields(String instanceId, List<String> keys) {
        return null;
    }

    default BocloudResult listByHost(String hostName) {
        return null;
    }

    //azure-虚拟机扩展
    default BocloudResult extension(ServerModel server, String extensionName, LogAnalyticModel analyticModel) {
        return new BocloudResult(false, "need implement");
    }

    // 开启一般化 azure
    default BocloudResult generalize(String instanceId) {
        return new BocloudResult(false, "need implement");
    }

    default BocloudResult availableSizes(String instanceId) {
        return new BocloudResult(false, "need implement");
    }
}
