| | |
| | | <div class="ui-top-title">视频分析集群管理</div> |
| | | </div> |
| | | <el-row> |
| | | <el-col :span="12" > |
| | | <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-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> |
| | | <!-- <p>点击将本机创建为存储集群</p> --> |
| | | </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-form-item label="IP地址" style="text-align: left;width: 300px;"> |
| | | <el-input |
| | | v-model="clusterip2" |
| | | v-model="esNodeIp" |
| | | placeholder="请输入集群内任意IP地址" |
| | | size="small" |
| | | autocomplete="off" |
| | | > |
| | | <el-button |
| | | type="text" |
| | | slot="suffix" |
| | | v-show="!searchDis" |
| | | @click="searchColony" |
| | | >搜索集群</el-button> |
| | | </el-input> |
| | | ></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> |
| | |
| | | |
| | | <script> |
| | | import { |
| | | createColony, |
| | | createSerfCluster, |
| | | randomPwd, |
| | | search, |
| | | getSearchNodes, |
| | |
| | | joinCluster, |
| | | leave, |
| | | getVrrp, |
| | | setVrrp |
| | | setVrrp, |
| | | createESNode, |
| | | addESNode, |
| | | getEsClusterInfo |
| | | } from "@/api/clusterManage"; |
| | | |
| | | import { |
| | | getDevInfo |
| | | } from "@/api/system"; |
| | | |
| | | import serfDiagram from "@/components/serfDiagram"; |
| | | import ipInput from "@/components/subComponents/IPInput"; |
| | | |
| | |
| | | serfDiagram, |
| | | ipInput |
| | | }, |
| | | data () { |
| | | data() { |
| | | const checkPwd = (rule, value, callback) => { |
| | | if (!value) { |
| | | return callback(new Error("密码不能为空")); |
| | |
| | | activeName: "1", |
| | | sActiveName: "s-first", |
| | | clusterid: "", |
| | | clusterip2: "", |
| | | esNodeIp: "", |
| | | esNodeType: "", |
| | | clusterpwd2: "", |
| | | sClusterip: "", |
| | | ruleForm: { |
| | |
| | | { 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, |
| | | currentCluster: {}, |
| | |
| | | members: [] |
| | | }; |
| | | }, |
| | | watch: {}, |
| | | mounted() { |
| | | this.findCluster(); |
| | | this.getVrrpInfo(); |
| | | this.getEsClusterNodes(); |
| | | }, |
| | | methods: { |
| | | cleanValue () { |
| | | cleanValue() { |
| | | this.members = []; |
| | | }, |
| | | sHandleClick (tab, event) { |
| | | sHandleClick(tab, event) { |
| | | console.log(tab, event); |
| | | }, |
| | | submitForm (formName) { |
| | | submitForm(formName) { |
| | | this.$refs[formName].validate(valid => { |
| | | if (valid) { |
| | | //alert("submit!"); |
| | |
| | | password: this.ruleForm.clusterpwd, |
| | | //virtualip: this.ruleForm.virtualip |
| | | }; |
| | | this.createColony(json).then(() => { |
| | | this.createCluster(json).then(() => { |
| | | this.findCluster(); |
| | | }); |
| | | } else { |
| | |
| | | } |
| | | }); |
| | | }, |
| | | saveForm (formName) { |
| | | debugger |
| | | saveForm(formName) { |
| | | this.$refs[formName].validate(valid => { |
| | | if (valid) { |
| | | alert("submit!"); |
| | |
| | | } |
| | | }); |
| | | }, |
| | | join (formName) { |
| | | join(formName) { |
| | | this.$refs[formName].validate(valid => { |
| | | if (valid) { |
| | | if (Object.keys(this.currentCluster).length === 0) { |
| | |
| | | } |
| | | }); |
| | | }, |
| | | async createColony (json) { |
| | | let res = await createColony(json); |
| | | async createCluster(json) { |
| | | let res = await createSerfCluster(json); |
| | | console.log(res, "创建集群"); |
| | | this.$notify({ |
| | | title: res.success ? "成功" : "失败", |
| | |
| | | type: res.success ? "success" : "error" |
| | | }); |
| | | }, |
| | | async randomPwd () { |
| | | async randomPwd() { |
| | | let res = await randomPwd(); |
| | | if (res && res.success) { |
| | | this.ruleForm.clusterpwd = res.data; |
| | | } |
| | | }, |
| | | async searchColony () { |
| | | async searchColony() { |
| | | this.$refs["joinForm"].validate(valid => { |
| | | if (valid) { |
| | | this.members = []; |
| | |
| | | } |
| | | }); |
| | | }, |
| | | async search (json) { |
| | | async search(json) { |
| | | let res = await search(json); |
| | | if (res && res.success) { |
| | | console.log(res, "搜索集群"); |
| | |
| | | this.stopSearch(); |
| | | }, 10 * 1000); |
| | | }, |
| | | async getSearchNodes () { |
| | | async getSearchNodes() { |
| | | let res = await getSearchNodes(); |
| | | if (res && res.success) { |
| | | let list = res.data.map(i => { |
| | |
| | | }); |
| | | } |
| | | }, |
| | | setSchedule () { |
| | | setSchedule() { |
| | | this.scheduleId = window.setInterval(() => { |
| | | this.getSearchNodes(); |
| | | }, 1000); |
| | | }, |
| | | async stopSearch () { |
| | | async stopSearch() { |
| | | if (!this.loading) { |
| | | return true; |
| | | } |
| | |
| | | // },2000) |
| | | }) |
| | | }, |
| | | async findCluster () { |
| | | async findCluster() { |
| | | let res = await findCluster(); |
| | | if (res && res.success) { |
| | | if (res.data && res.data.clusterId) { |
| | |
| | | } |
| | | } |
| | | }, |
| | | getVrrpInfo () { |
| | | getVrrpInfo() { |
| | | getVrrp().then(res => { |
| | | if (res.success) { |
| | | this.vrIpForm.virtual_ip = res.data.virtual_ip; |
| | |
| | | console.log(e) |
| | | }) |
| | | }, |
| | | async updateClusterName () { |
| | | async updateClusterName() { |
| | | let res = await updateClusterName({ |
| | | clusterName: this.mangeForm.colonyName |
| | | }); |
| | |
| | | type: res.success ? "success" : "error" |
| | | }); |
| | | }, |
| | | async joinCluster (json) { |
| | | async joinCluster(json) { |
| | | let res = await joinCluster(json); |
| | | if (res.success) { |
| | | this.members = [] |
| | |
| | | type: res.success ? "success" : "error" |
| | | }); |
| | | }, |
| | | leave () { |
| | | leave() { |
| | | this.$confirm(`确定退出集群吗?`, { |
| | | center: true, |
| | | cancelButtonClass: "comfirm-class-cancle", |
| | |
| | | }).catch(() => { }); |
| | | |
| | | }, |
| | | joinNode (event, node) { |
| | | debugger |
| | | joinNode(event, node) { |
| | | this.currentCluster.cluster_id = node.cluster_id; |
| | | if (this.activeName === "3") { |
| | | this.manageForm.clustername = node.clusterName; |
| | |
| | | }); |
| | | } |
| | | }, |
| | | generatePassword () { |
| | | generatePassword() { |
| | | var chars = |
| | | "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
| | | var uuid = []; |
| | |
| | | |
| | | this.ruleForm.clusterpwd = uuid.join(""); |
| | | }, |
| | | onIpBlur (ip) { |
| | | onIpBlur(ip) { |
| | | this.vrIpForm.virtual_ip = ip; |
| | | }, |
| | | 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 |
| | | }); |
| | | }) |
| | | } |
| | | }, |
| | | mounted () { |
| | | this.findCluster(); |
| | | this.getVrrpInfo(); |
| | | }, |
| | | created () { } |
| | | } |
| | | }; |
| | | </script> |
| | | <style lang="scss"> |