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
f14e6aa3
Commit
f14e6aa3
authored
May 30, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改连接复用逻辑细节
parent
98027df8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
connection.py
coco/connection.py
+10
-9
No files found.
coco/connection.py
View file @
f14e6aa3
...
...
@@ -101,8 +101,6 @@ class SSHConnection:
if
not
self
.
system_user
.
password
and
not
self
.
system_user
.
private_key
:
self
.
get_system_user_auth
()
logger
.
debug
(
"Password: {} "
.
format
(
self
.
system_user
.
password
))
if
self
.
asset
.
domain
:
sock
=
self
.
get_proxy_sock_v2
(
self
.
asset
)
if
not
sock
:
...
...
@@ -163,8 +161,8 @@ class SSHConnection:
def
get_transport
(
self
):
if
self
.
reconnect_if_need
():
return
None
return
self
.
transport
return
self
.
transport
return
None
def
get_channel
(
self
,
term
=
"xterm"
,
width
=
80
,
height
=
24
):
if
self
.
reconnect_if_need
():
...
...
@@ -186,10 +184,11 @@ class SSHConnection:
def
close
(
self
):
if
self
.
ref
>
1
:
self
.
ref
-=
1
logger
.
debug
(
"Connection ref -1: {}->{}@{}
{}"
.
format
(
msg
=
"Connection ref -1: {}->{}@{}.
{}"
.
format
(
self
.
user
.
username
,
self
.
asset
.
hostname
,
self
.
system_user
.
username
,
self
.
ref
))
)
logger
.
debug
(
msg
)
return
self
.
__class__
.
remove_ssh_connection
(
self
)
try
:
...
...
@@ -198,10 +197,12 @@ class SSHConnection:
self
.
sock
.
close
()
except
Exception
as
e
:
logger
.
error
(
"Close connection error: "
,
e
)
logger
.
debug
(
"Close connection: {}->{}@{}"
.
format
(
self
.
user
.
username
,
self
.
asset
.
ip
,
self
.
system_user
.
username
)
msg
=
"Close connection: {}->{}@{}. Total connections live: {}"
.
format
(
self
.
user
.
username
,
self
.
asset
.
ip
,
self
.
system_user
.
username
,
len
(
self
.
connections
)
)
logger
.
debug
(
"Total connections live: {}"
.
format
(
len
(
self
.
connections
))
)
logger
.
debug
(
msg
)
@staticmethod
def
get_proxy_sock_v2
(
asset
):
...
...
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