Skip to content

Commit 63c3acf

Browse files
author
杨红飞
committed
[Update]基于Tornado重构了CMDB,为Beta0.3做准备
1 parent 4967ae6 commit 63c3acf

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#### 截图
1818

19-
- 放一些简单示例图片,详细的使用可参考[部署文档](http://docs.opendevops.cn/zh/latest/codo-cmdb.html)[Demo体验](https://demo.opendevops.cn/login)、视频示例
19+
- 放一些简单示例图片,详细的使用可参考[部署文档](http://docs.opendevops.cn/zh/latest/codo-cmdb.html)[Demo体验](https://demo.opendevops.cn/login)[视频示例](https://v.youku.com/v_show/id_XNDE5MzEyNTY5Ng==.html?spm=a2hzp.8244740.0.0)
2020

2121
![](./static/images/cmdb_host_list.png)
2222

@@ -60,9 +60,8 @@ docker-compose up -d
6060

6161
```
6262
#若是在本地执行需要安装很多SDK包的依赖,建议进入容器执行
63-
docker exec -ti <CONTAINER ID> /bin/bash
64-
cd /var/www/codo-cmdb/
65-
python3 db_sync.py
63+
#cmdb_codo_cmdb_1:是你的容器名称
64+
docker exec -ti cmdb_codo_cmdb_1 /usr/local/bin/python3 /var/www/codo-cmdb/db_sync.py
6665
```
6766

6867
**日志文件**

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ opssdk
22
pycryptodome
33
boto3==1.9.5
44
ansible==2.7.10
5-
paramiko==2.4.1
5+
paramiko==2.4.2
66
aliyun_python_sdk_ecs==4.16.10

libs/common.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ def remote_upload_file(ip,user,ssh_key,cmd,local_file,remote_file,port=22):
137137

138138

139139

140+
def remote_exec_cmd(ip,user,ssh_key,cmd,port=22):
141+
'''ssh上传并执行bash for key'''
142+
private_key = paramiko.RSAKey.from_private_key_file(ssh_key)
143+
ssh = paramiko.SSHClient()
144+
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
145+
ssh.connect(hostname=ip,port=port,username=user, pkey=private_key, timeout=10)
146+
stdin, stdout, stderr = ssh.exec_command(cmd)
147+
show_log = stdout.read().decode('utf-8').strip()
148+
err_log = stderr.read().decode('utf-8').strip()
149+
#print(show_log,err_log)
150+
ssh.close()
151+
return show_log, err_log
152+
153+
140154
def check_ip(ip_address):
141155
compile_ip=re.compile('^(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)$')
142156
if compile_ip.match(ip_address):

libs/server/sync_public_key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
import paramiko
1212
from settings import PUBLIC_KEY
13-
from models.server import SSHConfigs,model_to_dict
13+
from models.server import SSHConfigs
1414
from libs.db_context import DBContext
1515
from libs.web_logs import ins_log
1616
from libs.common import remote_upload_file, get_key_file, exec_shell, exec_thread
File renamed without changes.

0 commit comments

Comments
 (0)