mirror of https://github.com/openspug/spug
parent
1d6f3e66c1
commit
485725d185
|
@ -95,11 +95,16 @@ def exec_host_command():
|
|||
|
||||
|
||||
def hosts_exec(q, ip, port, command):
|
||||
ssh_client = get_ssh_client(ip, port)
|
||||
q.destroyed.append(ssh_client.close)
|
||||
output = ssh_exec_command_with_stream(ssh_client, command)
|
||||
for line in output:
|
||||
q.put({ip: line})
|
||||
q.put({ip: '\n** 执行完成 **'})
|
||||
q.done()
|
||||
|
||||
key = '%s:%s' % (ip, port)
|
||||
try:
|
||||
ssh_client = get_ssh_client(ip, port)
|
||||
q.destroyed.append(ssh_client.close)
|
||||
output = ssh_exec_command_with_stream(ssh_client, command)
|
||||
for line in output:
|
||||
q.put({key: line})
|
||||
q.put({key: '\n** 执行完成 **'})
|
||||
q.done()
|
||||
except Exception as e:
|
||||
q.put({key: '%s\n' % e})
|
||||
q.put({key: '\n** 执行异常结束 **'})
|
||||
q.done()
|
||||
|
|
|
@ -38,6 +38,7 @@ def get_ssh_client(hostname, port):
|
|||
hostname,
|
||||
port=port,
|
||||
username='root',
|
||||
timeout=5,
|
||||
pkey=RSAKey.from_private_key(StringIO(Setting.ssh_private_key)))
|
||||
return ssh_client
|
||||
|
||||
|
|
|
@ -168,11 +168,11 @@
|
|||
<el-collapse>
|
||||
<el-collapse-item v-for="i in multipleSelection" :key="i.ip" :name="i.ip">
|
||||
<template slot="title">
|
||||
<el-tag type="info" style="margin-right: 15px">{{ i.name + '(' + i.ssh_ip + ')'}}</el-tag>
|
||||
<el-tag type="info" style="margin-right: 15px">{{`${i.name}(${i.ssh_ip}:${i.ssh_port})`}}</el-tag>
|
||||
</template>
|
||||
<pre>** 开始执行 **
|
||||
|
||||
<template v-for="line in exec_output"><span v-if="line[i.ssh_ip]">{{line[i.ssh_ip]}}</span></template>
|
||||
<template v-for="line in exec_output"><span v-if="line[`${i.ssh_ip}:${i.ssh_port}`]">{{line[`${i.ssh_ip}:${i.ssh_port}`]}}</span></template>
|
||||
</pre>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
|
@ -313,7 +313,7 @@
|
|||
save_select_host() {
|
||||
let hosts = [], hosts_id = [];
|
||||
for (let v of this.multipleSelection) {
|
||||
hosts.push( v.name + '(' + v.ssh_ip + ')');
|
||||
hosts.push(`${v.name}(${v.ssh_ip}:${v.ssh_port})`);
|
||||
hosts_id.push(v.id);
|
||||
}
|
||||
this.selected_host_id = hosts_id;
|
||||
|
|
Loading…
Reference in New Issue