hanbaoshan
2020-12-03 c587fbdad6f75ba05e5440b41be144bd335703aa
src/pages/settings/components/ClusterManagement.vue
@@ -7,33 +7,59 @@
      <el-col :span="12">
        <el-tabs v-model="activeName" id="e-alaycluster" v-if="!isHasColony">
          <el-tab-pane label="创建集群" name="1" :disabled="isHasColony">
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px">
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px">
              <el-form-item label="集群名称" prop="clustername">
                <el-input v-model="ruleForm.clustername" placeholder="手动输入, 如“集群A”" size="small"></el-input>
              </el-form-item>
              <el-form-item label="集群ID">
                <el-input v-model="clusterid" placeholder="不允许输入,保存后回显" disabled size="small"></el-input>
              </el-form-item>
              <el-form-item label="集群密码" prop="clusterpwd" style="width:500px">
              <el-form-item label="集群密码" prop="clusterpwd">
                <el-input v-model="ruleForm.clusterpwd" placeholder="请输入6位密码,或点击生成" size="small">
                  <el-button type="text" slot="suffix" @click="generatePassword">生成密码</el-button>
                </el-input>
              </el-form-item>
              <!-- <el-form-item label="虚拟IP" prop="virtualip">
                <ip-input :ip="ruleForm.virtualip" :on-blur="onIpBlur"></ip-input>
              </el-form-item> -->
              <el-form-item style="width:500px">
              <el-form-item label="集群IP" prop="virtualIp">
                <ip-input :ip="ruleForm.virtualIp" :on-blur="onIpBlur" class="ip-input-comp"></ip-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" size="small" @click="submitForm('ruleForm')">保存</el-button>
              </el-form-item>
            </el-form>
          </el-tab-pane>
          <!-- 加入已有集群 -->
          <el-tab-pane label="加入已有集群" name="3" :disabled="isHasColony">
            <el-form label-width="80px" :model="joinForm" :rules="joinRules" ref="joinForm">
              <el-form-item label="IP地址" style="width:440px">
                <el-input v-model="joinForm.clusterip" placeholder="请输入集群内任意IP地址" size="small">
          <el-tab-pane label="加入已有集群" name="2" :disabled="isHasColony">
            <el-form
              label-width="80px"
              :model="joinForm"
              :rules="joinRules"
              ref="joinForm"
              class="join-form"
              v-loading="joinLoading"
            >
              <el-form-item label="集群ID" style="width:440px" prop="clusterid">
                <el-input v-model="joinForm.clusterid" placeholder size="small"></el-input>
              </el-form-item>
              <el-form-item label="IP地址" style="width:440px" prop="clusterip">
                <el-input
                  v-model="joinForm.clusterip"
                  placeholder="请输入集群内任意IP地址"
                  size="small"
                  autocomplete="new-password"
                ></el-input>
                <!-- <el-button size="mini" :disabled="searchDis" @click="searchColony">搜索集群</el-button>
                <el-button size="mini" @click="stopSearch">停止搜索</el-button>-->
              </el-form-item>
              <el-form-item label="集群密码" prop="clusterpwd" style="width:440px">
                <el-input
                  v-model="joinForm.clusterpwd"
                  placeholder="请输入集群密码"
                  show-password
                  size="small"
                  autocomplete="new-password"
                >
                  <el-button
                    type="text"
                    slot="suffix"
@@ -44,34 +70,24 @@
                    <i class="el-icon-loading"></i>停止搜索
                  </el-button>
                </el-input>
                <!-- <el-button size="mini" :disabled="searchDis" @click="searchColony">搜索集群</el-button>
                <el-button size="mini" @click="stopSearch">停止搜索</el-button>-->
              </el-form-item>
              <el-form-item label="集群密码" prop="clusterpwd" style="width:500px">
                <el-input
                  v-model="joinForm.clusterpwd"
                  placeholder="请输入集群密码"
                  show-password
                  size="small"
                ></el-input>
              </el-form-item>
              <el-form-item style="width:440px">
                <el-button type="primary" @click="join('joinForm')" size="small">加入集群</el-button>
              </el-form-item>
              <div class="form-tip">请输入以上信息加入集群,或者通过集群密码搜索后进行加入</div>
            </el-form>
          </el-tab-pane>
        </el-tabs>
        <!-- 有集群的情况 -->
        <div v-if="isHasColony" id="h-alaycluster">
          <el-form :model="ruleForm" ref="ruleForm" label-width="80px">
          <el-form :model="ruleForm" ref="ruleForm" label-width="100px">
            <el-form-item label="集群名称" prop="clustername">
              <el-input v-model="ruleForm.clustername" placeholder="手动输入, 如“集群A”" size="small"></el-input>
            </el-form-item>
            <el-form-item label="集群ID">
              <el-input v-model="clusterid" placeholder="不允许输入,保存后回显" disabled size="small"></el-input>
            </el-form-item>
            <el-form-item label="集群密码" prop="clusterpwd" style="width:500px">
            <el-form-item label="集群密码" prop="clusterpwd">
              <el-input
                v-model="ruleForm.clusterpwd"
                disabled
@@ -80,95 +96,104 @@
              ></el-input>
            </el-form-item>
            <!-- <el-form-item label="虚拟IP" prop="virtualip">
              <ip-input :ip="ruleForm.virtualip" :on-blur="onIpBlur"></ip-input>
            </el-form-item> -->
            <el-form-item style="width:440px;text-align: right;">
            <el-form-item label="集群IP" prop="virtualIp">
              <ip-input :ip="ruleForm.virtualIp" :on-blur="onIpBlur" class="ip-input-comp"></ip-input>
            </el-form-item>
            <el-form-item style="text-align: right;">
              <el-button size="small" type="danger" @click="leave">退出集群</el-button>
              <el-button
                style="margin-right:10px;"
                type="primary"
                size="small"
                @click="submitForm('manageForm')"
                @click="updateCluster('manageForm')"
              >保存</el-button>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
      <el-col :span="14" style="height: 100%;" v-if="members.length !== 0">
      <el-col
        :span="12"
        style="height: 100%;"
        v-if="members.length !== 0 && isSearch"
        class="node-container"
      >
        <serfDiagram
          ref="diagram"
          :members="members"
          :agent="agentName"
          v-loading="loading"
          :isShowHover="false"
          @selected-node="joinNode"
          class="nodes-svg"
        ></serfDiagram>
      </el-col>
    </el-row>
    <div class="ui-top-view">
      <div class="ui-top-title">漂移IP</div>
    </div>
    <el-row>
      <el-col :span="12">
        <el-form :model="vrIpForm" ref="vrIpForm" :rules="vrIpRules" style="padding:20px 40px;">
          <el-form-item label="虚拟IP" prop="virtual_ip">
            <ip-input :ip="vrIpForm.virtual_ip" :on-blur="onIpBlur"></ip-input>
            <el-switch v-model="vrIpForm.enable" style="margin-left:30px;"></el-switch>
          </el-form-item>
          <el-form-item style="width:500px">
            <el-button type="primary" size="small" @click="saveForm('vrIpForm')">保存</el-button>
          </el-form-item>
        </el-form>
      <el-col
        :span="12"
        style="height: 100%;"
        v-if="innerNodes.length !== 0 && !isSearch"
        class="node-container"
      >
        <cloud-node :nodes="innerNodes"></cloud-node>
      </el-col>
    </el-row>
    <div class="ui-top-view">
    <!-- <div class="ui-top-view">
      <div class="ui-top-title">存储集群管理</div>
    </div>
    <el-row>
      <el-col :span="12">
        <el-tabs id="e-dbcluster" v-model="sActiveName">
          <el-tab-pane label="创建集群" name="s-first">
            <el-button type="primary" style="float: none;margin: 20px 0px;" size="small">创建存储集群</el-button>
            <p>点击将本机创建为存储集群</p>
          <el-tab-pane label="创建集群" name="s-first" v-if="sActiveName != 's-third1'">
            <el-button
              type="primary"
              style="float: left;margin: 20px 0px;"
              size="small"
              @click="createEsCluster()"
            >创建存储集群</el-button>
          </el-tab-pane>
          <el-tab-pane label="加入已有集群" name="s-second">
          <el-tab-pane label="加入已有集群" name="s-second" v-if="sActiveName != 's-third1'">
            <el-form label-width="80px">
              <el-form-item label="IP地址" style="text-align: left;">
                <el-input v-model="clusterip2" placeholder="请输入集群内任意IP地址" size="small">
                  <el-button
                    type="text"
                    slot="suffix"
                    v-show="!searchDis"
                    @click="searchColony"
                  >搜索集群</el-button>
                </el-input>
              <el-form-item label="IP地址" style="text-align: left;width: 300px;">
                <el-input
                  v-model="esNodeIp"
                  placeholder="请输入集群内任意IP地址"
                  size="small"
                  autocomplete="off"
                ></el-input>
                <el-checkbox
                  label="主节点"
                  v-model="esNodeType"
                  style="margin-left: 20px;position: absolute;"
                ></el-checkbox>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="join('joinForm')" size="small">加入集群</el-button>
                <el-button
                  type="primary"
                  @click="joinESCluster()"
                  size="small"
                  style="float: left;"
                >加入集群</el-button>
              </el-form-item>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="管理集群" name="s-third">
            <h3 style="text-align: left;margin: 10px 0px;">
              <b>集群名称</b>
              <span>xxx</span>
            </h3>
            <el-table :data="tableData" style="width: 100%">
          <el-tab-pane label="集群信息" name="s-third">
            <el-table :data="esNodes" style="width: 100%">
              <el-table-column prop="nodeType" label="节点类型"></el-table-column>
              <el-table-column prop="nodeName" label="节点名称"></el-table-column>
              <el-table-column prop="nodeIp" label="节点IP地址"></el-table-column>
              <el-table-column prop="registerTime" label="注册时间"></el-table-column>
              <el-table-column prop="name" label="节点名称"></el-table-column>
              <el-table-column prop="ip" label="节点IP地址" min-width="90px"></el-table-column>
              <el-table-column prop="buildDate" label="注册时间" min-width="120px"></el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
    </el-row>-->
  </div>
</template>
<script>
import {
  createColony,
  createSerfCluster,
  randomPwd,
  search,
  getSearchNodes,
@@ -178,15 +203,24 @@
  joinCluster,
  leave,
  getVrrp,
  setVrrp
  setVrrp,
  createESNode,
  addESNode,
  getEsClusterInfo
} from "@/api/clusterManage";
import {
  getDevInfo
} from "@/api/system";
import cloudNode from "./CloudNode";
import serfDiagram from "@/components/serfDiagram";
import ipInput from "@/components/subComponents/IPInput";
import { isIPv4 } from "@/scripts/validate";
export default {
  components: {
    serfDiagram,
    ipInput
    ipInput,
    cloudNode
  },
  data() {
    const checkPwd = (rule, value, callback) => {
@@ -194,11 +228,6 @@
        return callback(new Error("密码不能为空"));
      }
      setTimeout(() => {
        // if (value.length > 16 || value.length < 6) {
        //   callback(new Error("密码应为6-16位!"));
        // } else {
        //   callback();
        // }
        if (value.length != 6) {
          callback(new Error("密码应为6位!"));
        } else {
@@ -206,17 +235,19 @@
        }
      }, 1000);
    };
    return {
      activeName: "1",
      sActiveName: "s-first",
      clusterid: "",
      clusterip2: "",
      esNodeIp: "",
      esNodeType: "",
      clusterpwd2: "",
      sClusterip: "",
      ruleForm: {
        clustername: "",
        clusterpwd: "",
        //virtualip: ""
        virtualIp: ""
      },
      vrIpForm: {
        enable: true,
@@ -230,6 +261,7 @@
        virtualip: "192.168.1.188"
      },
      joinForm: {
        clusterid: "",
        clusterip: "",
        clusterpwd: ""
      },
@@ -238,53 +270,57 @@
          { required: true, message: "请输入集群名称", trigger: "change" }
        ],
        clusterpwd: [{ validator: checkPwd, trigger: "change" }],
        // virtualip: [
        //   { required: true, message: "请输入虚拟IP", trigger: "change" }
        // ]
      },
      vrIpRules: {
        virtualip: [
          { required: true, message: "请输入虚拟IP", trigger: "change" }
        virtualIp: [
          { required: true, validator: isIPv4, trigger: "change" }
        ]
      },
      // vrIpRules: {
      //   virtualIp: [
      //     { required: true, message: "请输入虚拟IP", trigger: "change" }
      //   ]
      // },
      joinRules: {
        clusterid: [
          { required: true, message: "请输入集群ID", trigger: "change" },
        ],
        clusterip: [
          { required: true, validator: isIPv4, trigger: "change" }
        ],
        clusterpwd: [
          { required: true, message: "请输入集群密码", trigger: "change" },
          { validator: checkPwd, trigger: "change" }
        ]
      },
      tableData: [
        {
          nodeType: "主节点",
          nodeName: "xxxx",
          nodeIp: "192.168.12.102",
          registerTime: "2016-04-04"
        },
        {
          nodeType: "主节点",
          nodeName: "xxxx",
          nodeIp: "192.168.14.122",
          registerTime: "2016-05-04"
        },
        {
          nodeType: "主节点",
          nodeName: "xxxx",
          nodeIp: "192.168.10.132",
          registerTime: "2016-02-12"
        }
      ],
      esNodes: [],
      scheduleId: "",
      isHasColony: false,
      isSearch: false,
      currentCluster: {},
      searchNum: "",
      loading: false,
      searchDis: false,
      agentName: "",
      members: []
      members: [],
      innerNodes: [],
      intervalTimer: null,
      joinLoading: false,
      showJoinConfirm: false
    };
  },
  watch: {},
  mounted() {
    this.findCluster();
    let _this = this;
    this.intervalTimer = setInterval(() => {
      _this.findCluster();
    }, 30000);
    //this.getEsClusterNodes();
  },
  beforeDestroy() {
    clearInterval(this.intervalTimer);
  },
  methods: {
    checkPsd(psd) {
      return psd.trim().length === 6
    },
    cleanValue() {
      this.members = [];
    },
@@ -294,14 +330,14 @@
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("submit!");
          //alert("submit!");
          let json = {
            clusterId: this.clusterid,
            clusterName: this.ruleForm.clustername,
            password: this.ruleForm.clusterpwd,
            //virtualip: this.ruleForm.virtualip
            virtualIp: this.ruleForm.virtualIp
          };
          this.createColony(json).then(() => {
          this.createCluster(json).then(() => {
            this.findCluster();
          });
        } else {
@@ -310,8 +346,8 @@
        }
      });
    },
    saveForm(formName) {
      debugger
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("submit!");
@@ -319,7 +355,7 @@
            enable: this.vrIpForm.enable,
            serve_port: this.vrIpForm.serve_port,
            virtual_ip: this.vrIpForm.virtual_ip,
          };
          setVrrp(json).then(() => {
            this.getVrrpInfo();
@@ -330,27 +366,36 @@
        }
      });
    },
    join(formName) {
      let _this = this;
      this.$refs[formName].validate(valid => {
        if (valid) {
          if (Object.keys(this.currentCluster).length === 0) {
            this.$notify({
              type: "info",
              duration: 1000,
              message: "请先选择一个集群节点"
            });
            return true;
          }
          _this.joinLoading = true;
          // if (Object.keys(this.currentCluster).length === 0) {
          //   this.$notify({
          //     type: "info",
          //     duration: 1000,
          //     message: "请先选择一个集群节点"
          //   });
          //   _this.joinLoading = false;
          //   return true;
          // }
          let nodeIps = this.members.map(i => {
            return i.Address;
          });
          let json = {
            clusterId: this.currentCluster.cluster_id,
            //clusterId: this.currentCluster.cluster_id,
            clusterId: this.joinForm.clusterid,
            password: this.joinForm.clusterpwd,
            nodeIps: nodeIps
            nodeIps: [this.joinForm.clusterip]
          };
          this.joinCluster(json).then(() => {
            _this.joinLoading = false;
            this.findCluster();
          }).catch(e => {
            console.log(e);
            _this.joinLoading = false;
          });
        } else {
          console.log("error submit!!");
@@ -358,8 +403,8 @@
        }
      });
    },
    async createColony(json) {
      let res = await createColony(json);
    async createCluster(json) {
      let res = await createSerfCluster(json);
      console.log(res, "创建集群");
      this.$notify({
        title: res.success ? "成功" : "失败",
@@ -374,29 +419,34 @@
      }
    },
    async searchColony() {
      this.$refs["joinForm"].validate(valid => {
        if (valid) {
          let json = {
            password: this.joinForm.clusterpwd,
            ip: this.joinForm.clusterip
          };
      this.isSearch = true;
      this.$refs["joinForm"].clearValidate();
      this.$refs["joinForm"].validateField('clusterpwd');
      if (this.checkPsd(this.joinForm.clusterpwd)) {
        this.members = [];
        let json = {
          password: this.joinForm.clusterpwd,
          //ip: this.joinForm.clusterip
        };
          this.search(json)
            .then(() => {
              this.setSchedule();
              // this.searchDis = false;
              // this.loading = false;
            })
            .catch(() => {
              this.searchDis = false;
              this.loading = false;
            });
        } else {
          this.searchDis = false;
          this.loading = false;
          return false;
        }
      });
        this.search(json)
          .then(() => {
            this.setSchedule();
            // this.searchDis = false;
            // this.loading = false;
          })
          .catch(() => {
            this.searchDis = false;
            this.loading = false;
            this.isSearch = false;
          });
      } else {
        this.searchDis = false;
        this.loading = false;
        this.isSearch = false;
        return false;
      }
      //});
    },
    async search(json) {
      let res = await search(json);
@@ -410,6 +460,7 @@
        this.stopSearch();
      }, 10 * 1000);
    },
    //搜索集群
    async getSearchNodes() {
      let res = await getSearchNodes();
      if (res && res.success) {
@@ -472,10 +523,15 @@
          this.activeName = "3";
          this.clusterid = res.data.clusterId;
          this.ruleForm.clustername = res.data.clusterName;
          this.ruleForm.clusterpwd = res.data.clusterpwd
          //this.ruleForm.virtualip = res.data.virtualip
          let list = res.data.nodes.map(i => {
          this.ruleForm.clusterpwd = '******';
          this.ruleForm.virtualIp = res.data.virtualIp
          //let list = res.data.nodes.map(i => {
          this.isSearch = false;
          this.innerNodes = res.data.nodes.map(i => {
            let obj = {};
            obj.device_type = i.device_type;
            obj.workType = i.device_type.substr(2, 2);
            obj.hardwareType = i.device_type.substr(4, 2);
            obj.cluster_id = i.cluster_id;
            obj.clusterName = res.data.clusterName;
            obj.create_time = i.create_time;
@@ -484,29 +540,41 @@
            obj.node_ip = i.node_ip;
            obj.nodeName = i.node_name;
            obj.Address = i.node_ip;
            obj.role = i.role ? i.role : "pc";
            obj.role = i.drift_state ? i.drift_state : "pc";
            return obj;
          });
          this.members = this.members.concat(list);
          //this.members = this.members.concat(list);
          console.log(this.members)
        } else {
          this.isHasColony = false;
          // this.activeName = '1'
        }
      }
    },
    getVrrpInfo(){
      getVrrp().then(res=>{
        if(res.success){
    getVrrpInfo() {
      getVrrp().then(res => {
        if (res.success) {
          this.vrIpForm.virtual_ip = res.data.virtual_ip;
          this.vrIpForm.enable = res.data.enable;
        }
      }).catch(e=>{
      }).catch(e => {
        console.log(e)
      })
    },
    async updateClusterName() {
    async updateCluster() {
      if (this.ruleForm.clustername === "") {
        this.$message({
          type: "error",
          message: "集群名称不能为空"
        })
        return
      }
      let res = await updateClusterName({
        clusterName: this.mangeForm.colonyName
        clusterName: this.ruleForm.clustername,
        virtualIp: this.ruleForm.virtualIp
      });
      this.$notify({
        title: res.success ? "成功" : "失败",
@@ -544,11 +612,14 @@
          this.isHasColony = false;
          this.activeName = "1";
          this.members = [];
          this.innerNodes = [];
        }
      }).catch(() => { });
    },
    joinNode(event, node) {
      console.log('join', node)
      let _this = this;
      this.currentCluster.cluster_id = node.cluster_id;
      if (this.activeName === "3") {
        this.manageForm.clustername = node.clusterName;
@@ -556,40 +627,60 @@
        return;
      }
      if (this.activeName === "2") {
        this.$refs["joinForm"].validate(valid => {
          if (valid) {
            this.$confirm("是否要加入节点 " + node.nodeName + "?", "加入集群", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "success"
            })
              .then(() => {
                // this.agentName = 'node' + this.members.length
                // this.members.push({
                //   nodeName: this.agentName,
                //   Address: '172.10.10.26',
                //   role: 'pc'
                // })
                // this.$notify({
                //   type: 'success',
                //   duration: 1000,
                //   message: '加入成功!'
                // })
                console.log(this.currentCluster, '选择的集群节点')
                this.join("joinForm");
              })
              .catch(() => {
                this.$notify({
                  type: "info",
                  duration: 1000,
                  message: "已取消"
                });
              });
          } else {
            console.log("error submit!!");
            return false;
          }
        });
        if (_this.showJoinConfirm) return;
        this.$confirm("是否要加入节点 " + node.nodeName + "?", "加入集群", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "success"
        })
          .then(() => {
            _this.showJoinConfirm = true;
            let json = {
              //clusterId: this.currentCluster.cluster_id,
              clusterId: node.cluster_id,
              password: this.joinForm.clusterpwd,
              nodeIps: [node.Address]
            };
            this.joinCluster(json).then(() => {
              _this.showJoinConfirm = false;
              this.findCluster();
            }).catch(e => {
              console.log(e);
              _this.showJoinConfirm = false;
            });
          }).catch(e => {
            console.log(e)
          });
        // this.$refs["joinForm"].validate(valid => {
        //   if (valid) {
        //     if (_this.showJoinConfirm) return;
        //     _this.showJoinConfirm = true;
        //     this.$confirm("是否要加入节点 " + node.nodeName + "?", "加入集群", {
        //       confirmButtonText: "确定",
        //       cancelButtonText: "取消",
        //       type: "success"
        //     })
        //       .then(() => {
        //         console.log(this.currentCluster, '选择的集群节点')
        //         this.join("joinForm");
        //         _this.showJoinConfirm = false;
        //       })
        //       .catch(() => {
        //         this.$notify({
        //           type: "info",
        //           duration: 1000,
        //           message: "已取消"
        //         });
        //         _this.showJoinConfirm = false;
        //       });
        //   } else {
        //     console.log("error submit!!");
        //     return false;
        //   }
        // });
      }
    },
    generatePassword() {
@@ -603,15 +694,102 @@
      this.ruleForm.clusterpwd = uuid.join("");
    },
    async getEsClusterNodes() {
      let rsp = await getDevInfo();
      let hostIpAddr = "";
      if (rsp && rsp.success) {
        hostIpAddr = rsp.data.ip;
      }
      if (hostIpAddr.length) {
        rsp = await getEsClusterInfo({ ip: hostIpAddr });
        if (rsp && rsp.success) {
          this.esNodes = rsp.data.map(el => {
            return {
              // buildDate: "2018-06-11T23:38:03.357887Z",
              buildDate: el.buildDate.split("T")[0] + " " + el.buildDate.split("T")[1].slice(0, 8),
              ip: el.ip,
              name: el.name,
              nodeType: el.nodeType,
            }
          })
          if (this.esNodes.length) {
            this.sActiveName = 's-third';
          }
        }
      }
    },
    createEsCluster() {
      createESNode().then(rsp => {
        if (rsp && rsp.success) {
          this.$message({
            type: "success",
            duration: 2000,
            message: "创建成功"
          });
          this.getSearchNodes();
        } else {
          this.$message({
            type: "error",
            duration: 2000,
            message: rsp.msg
          });
        }
      }).catch(rsp => {
        this.$message({
          type: "error",
          duration: 2000,
          message: rsp.msg
        });
      })
    },
    joinESCluster() {
      if (!this.esNodeIp.length) {
        this.$message({
          type: "error",
          duration: 2000,
          message: "请输入正确的ip地址"
        });
        return;
      }
      addESNode({ ip: this.esNodeIp, option: this.esNodeType ? "1" : "2" }).then(rsp => {
        if (rsp && rsp.success) {
          this.$message({
            type: "success",
            duration: 2000,
            message: "加入成功"
          });
          this.getSearchNodes();
        } else {
          this.$message({
            type: "error",
            duration: 2000,
            message: rsp.msg
          });
        }
      }).catch(rsp => {
        this.$message({
          type: "error",
          duration: 2000,
          message: rsp.msg
        });
      })
    },
    onIpBlur(ip) {
      this.vrIpForm.virtual_ip = ip;
      //this.vrIpForm.virtual_ip = ip;
      this.ruleForm.virtualIp = ip;
      console.log(this.ruleForm.virtualIp)
    }
  },
  mounted() {
    this.findCluster();
    this.getVrrpInfo();
  },
  created() { }
};
</script>
<style lang="scss">
@@ -619,14 +797,27 @@
  width: 100%;
  height: 100%;
  overflow: auto;
  .el-form-item {
    width: 500px;
  }
  .el-form-item.is-required:not(.is-no-asterisk) > .el-form-item__label:before,
  .el-form-item.is-required:not(.is-no-asterisk)
    .el-form-item__label-wrap
    > .el-form-item__label:before {
    display: none;
  }
  .ip-input-comp {
    width: 400px;
    max-width: 400px;
  }
  .el-button {
    float: right;
  }
  .el-form-item__content {
    text-align: left;
    input {
      max-width: 360px;
      max-width: 400px !important;
    }
  }
@@ -673,9 +864,9 @@
  #h-alaycluster {
    .el-form-item__content {
      text-align: left;
      input {
        max-width: 360px;
      }
      // input {
      //   max-width: 360px;
      // }
    }
  }
}