Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
coco
Commits
4eaea983
Commit
4eaea983
authored
Sep 11, 2018
by
广宏伟
Browse files
Options
Browse Files
Download
Plain Diff
Merged in dev (pull request #92)
Dev
parents
37cc25d9
80826161
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
15 deletions
+32
-15
config.py
coco/config.py
+9
-4
connection.py
coco/connection.py
+9
-0
httpd.py
coco/httpd.py
+3
-2
interactive.py
coco/interactive.py
+2
-0
models.py
coco/models.py
+0
-4
sftp.py
coco/sftp.py
+7
-3
requirements.txt
requirements/requirements.txt
+2
-2
No files found.
coco/config.py
View file @
4eaea983
...
...
@@ -23,6 +23,9 @@ from werkzeug.utils import import_string
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
root_path
=
os
.
environ
.
get
(
"COCO_PATH"
)
if
not
root_path
:
root_path
=
BASE_DIR
class
ConfigAttribute
(
object
):
...
...
@@ -270,11 +273,7 @@ class Config(dict):
return
'<
%
s
%
s>'
%
(
self
.
__class__
.
__name__
,
dict
.
__repr__
(
self
))
root_path
=
os
.
environ
.
get
(
"COCO_PATH"
)
if
not
root_path
:
root_path
=
BASE_DIR
access_key_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
root_path
,
'keys'
,
'.access_key'
))
default_config
=
{
'NAME'
:
socket
.
gethostname
(),
'CORE_HOST'
:
'http://127.0.0.1:8080'
,
...
...
@@ -306,3 +305,9 @@ default_config = {
config
=
Config
(
root_path
,
default_config
)
config
.
from_pyfile
(
'conf.py'
)
try
:
from
conf
import
config
as
_conf
config
.
from_object
(
_conf
)
except
ImportError
:
pass
coco/connection.py
View file @
4eaea983
...
...
@@ -43,6 +43,7 @@ class SSHConnection:
if
asset
.
domain
:
sock
=
self
.
get_proxy_sock_v2
(
asset
)
try
:
try
:
ssh
.
connect
(
asset
.
ip
,
port
=
asset
.
port
,
username
=
system_user
.
username
,
...
...
@@ -51,6 +52,14 @@ class SSHConnection:
compress
=
True
,
auth_timeout
=
config
[
'SSH_TIMEOUT'
],
look_for_keys
=
False
,
sock
=
sock
)
except
paramiko
.
AuthenticationException
:
# 思科设备不支持秘钥登陆,提供秘钥,必然失败
ssh
.
connect
(
asset
.
ip
,
port
=
asset
.
port
,
username
=
system_user
.
username
,
password
=
system_user
.
password
,
timeout
=
config
[
'SSH_TIMEOUT'
],
compress
=
True
,
auth_timeout
=
config
[
'SSH_TIMEOUT'
],
look_for_keys
=
False
,
sock
=
sock
,
allow_agent
=
False
,
)
transport
=
ssh
.
get_transport
()
transport
.
set_keepalive
(
300
)
except
(
paramiko
.
AuthenticationException
,
...
...
coco/httpd.py
View file @
4eaea983
...
...
@@ -184,9 +184,10 @@ class ProxyNamespace(BaseNamespace):
connection
=
Connection
.
get_connection
(
request
.
sid
)
if
not
connection
:
return
for
client
in
connection
.
clients
:
clients_copy
=
list
(
connection
.
clients
.
keys
())
for
client_id
in
clients_copy
:
try
:
self
.
on_logout
(
client
.
id
)
self
.
on_logout
(
client
_
id
)
except
Exception
as
e
:
logger
.
warn
(
e
)
Connection
.
remove_connection
(
connection
.
id
)
...
...
coco/interactive.py
View file @
4eaea983
...
...
@@ -155,6 +155,8 @@ class InteractiveServer:
self
.
client
.
send
(
wr
(
_
(
"Total: {}"
)
.
format
(
len
(
self
.
nodes
)),
before
=
1
))
def
display_node_assets
(
self
,
_id
):
if
self
.
nodes
is
None
:
self
.
get_user_nodes
()
if
_id
>
len
(
self
.
nodes
)
or
_id
<=
0
:
msg
=
wr
(
warning
(
_
(
"There is no matched node, please re-enter"
)))
self
.
client
.
send
(
msg
)
...
...
coco/models.py
View file @
4eaea983
...
...
@@ -333,15 +333,11 @@ class WSProxy:
def
closed
(
self
):
return
self
.
sock
.
_closed
def
session_close
(
self
):
self
.
ws
.
on_logout
(
self
.
client_id
)
def
write
(
self
,
data
):
self
.
proxy
.
send
(
data
.
encode
())
def
close
(
self
):
self
.
proxy
.
close
()
self
.
sock
.
close
()
def
__getattr__
(
self
,
item
):
return
getattr
(
self
.
sock
,
item
)
...
...
coco/sftp.py
View file @
4eaea983
...
...
@@ -98,11 +98,11 @@ class SFTPServer(paramiko.SFTPServerInterface):
asset
=
self
.
hosts
.
get
(
host
)
date_start
=
datetime
.
utcnow
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
+
" +0000"
,
data
=
{
"user"
:
self
.
server
.
request
.
user
.
username
,
"user"
:
self
.
server
.
connection
.
user
.
username
,
"asset"
:
host
,
"org_id"
:
asset
.
org_id
,
"system_user"
:
su
,
"remote_addr"
:
self
.
server
.
request
.
addr
[
0
],
"remote_addr"
:
self
.
server
.
connection
.
addr
[
0
],
"operate"
:
operate
,
"filename"
:
filename
or
rpath
,
"date_start"
:
date_start
,
...
...
@@ -160,7 +160,11 @@ class SFTPServer(paramiko.SFTPServerInterface):
return
attr
else
:
sftp
=
self
.
get_host_sftp
(
host
,
su
)
return
sftp
.
stat
(
rpath
)
try
:
stat
=
sftp
.
stat
(
rpath
)
return
stat
except
FileNotFoundError
as
e
:
return
paramiko
.
SFTPServer
.
convert_errno
(
e
.
errno
)
def
lstat
(
self
,
path
):
host
,
su
,
rpath
=
self
.
parse_path
(
path
)
...
...
requirements/requirements.txt
View file @
4eaea983
...
...
@@ -8,7 +8,7 @@ cffi==1.11.2
chardet==3.0.4
click==6.7
crcmod==1.7
cryptography==2.
1.4
cryptography==2.
3.1
docutils==0.14
dotmap==1.2.20
elasticsearch==6.1.1
...
...
@@ -40,5 +40,5 @@ six==1.11.0
tornado==4.5.2
urllib3==1.22
wcwidth==0.1.7
eventlet==0.2
2
.1
eventlet==0.2
4
.1
Werkzeug==0.14.1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment