Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
install.api
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
Script
install.api
Commits
b2fd772e
Commit
b2fd772e
authored
Apr 08, 2020
by
金凯强
🎨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
远程服务器配置 增加车间
parent
5232a74f
Pipeline
#22272
failed with stage
in 11 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
+16
-13
conncetion_api.py
app/conncetion/conncetion_api.py
+3
-3
conncetion_service.py
app/conncetion/conncetion_service.py
+12
-10
db_tools.py
app/utils/db_tools.py
+1
-0
No files found.
app/conncetion/conncetion_api.py
View file @
b2fd772e
...
...
@@ -42,13 +42,13 @@ class ConnectionAPI(ApiController):
'''
return
ConnectionService
()
.
test_connection
(
request
.
json
)
@
api
(
'remote_server/<string:project_no>/'
)
def
get_remote_server
(
self
,
project_no
):
@
api
(
'remote_server/<string:project_no>/
<string:work_shop_no>
'
)
def
get_remote_server
(
self
,
project_no
,
work_shop_no
):
'''
获取远程服务器连接
:return:
'''
return
ConnectionService
()
.
get_remote_server_info
(
project_no
)
return
ConnectionService
()
.
get_remote_server_info
(
project_no
,
work_shop_no
)
@
api
(
'remote_server'
)
def
post_set_remote_server_info
(
self
):
...
...
app/conncetion/conncetion_service.py
View file @
b2fd772e
...
...
@@ -141,14 +141,14 @@ values
else
:
return
{
'message'
:
'连接失败'
}
def
get_remote_server_info
(
self
,
project_no
):
def
get_remote_server_info
(
self
,
project_no
,
work_shop_no
):
'''
获取远端服务器信息
:return:
'''
with
db_driver
as
session
:
remote_server_info
=
session
.
retrive_sql
(
f
"select * from remote_server_info where project_no='{project_no}'"
)
f
"select * from remote_server_info where project_no='{project_no}'
and work_shop_no='{work_shop_no}'
"
)
return
remote_server_info
...
...
@@ -161,46 +161,48 @@ values
id
=
json_data
.
get
(
'id'
)
project_no
=
json_data
.
get
(
'project_no'
)
work_shop_no
=
json_data
.
get
(
'work_shop_no'
)
server_ip
=
json_data
.
get
(
'server_ip'
)
server_ssh_port
=
json_data
.
get
(
'server_ssh_port'
)
server_user
=
json_data
.
get
(
'server_user'
)
server_password
=
json_data
.
get
(
'server_password'
)
if
project_no
is
None
or
server_ip
is
None
or
server_ssh_port
is
None
or
\
server_user
is
None
or
server_password
is
None
:
server_user
is
None
or
server_password
is
None
or
work_shop_no
is
None
:
raise
HSException
(
'以上参数全部必填'
)
project_no
=
project_no
.
strip
()
server_ip
=
server_ip
.
strip
()
server_user
=
server_user
.
strip
()
server_password
=
server_password
.
strip
()
work_shop_no
=
work_shop_no
.
strip
()
with
db_driver
as
session
:
if
id
:
validate_sql
=
f
"select * from remote_server_info where project_no='{project_no}' and id<>'{id}' "
validate_sql
=
f
"select * from remote_server_info where project_no='{project_no}' and
work_shop_no='{work_shop_no}' and
id<>'{id}' "
validate_data
=
session
.
retrive_sql
(
validate_sql
)
if
validate_data
:
raise
HSException
(
f
'{project_no}已经存在'
)
raise
HSException
(
f
'{project_no}
-{work_shop_no}
已经存在'
)
update_sql
=
f
'''update remote_server_info
set project_no='{project_no}',server_ip='{server_ip}',server_ssh_port='{server_ssh_port}',server_user='{server_user}'
,server_password='{server_password}'
,server_password='{server_password}'
,work_shop_no='{work_shop_no}'
where id='{id}' '''
session
.
exec_sql
(
update_sql
,
json_data
)
else
:
project_no_sql
=
f
"select project_no from remote_server_info where project_no='{project_no}'"
project_no_sql
=
f
"select project_no from remote_server_info where project_no='{project_no}'
and work_shop_no='{work_shop_no}'
"
project_no_data
=
session
.
retrive_sql
(
project_no_sql
)
if
project_no_data
:
raise
HSException
(
f
"{project_no}已经存在"
)
raise
HSException
(
f
"{project_no}
-{work_shop_no}
已经存在"
)
id
=
new_id
()
json_data
[
'id'
]
=
id
insert_sql
=
f
'''insert into remote_server_info
(id,project_no,server_ip,server_ssh_port,server_user
,server_password)
,server_password
,work_shop_no
)
values
('{id}','{project_no}','{server_ip}','{server_ssh_port}','{server_user}','{server_password}') '''
('{id}','{project_no}','{server_ip}','{server_ssh_port}','{server_user}','{server_password}'
,'{work_shop_no}'
) '''
session
.
exec_sql
(
insert_sql
,
json_data
)
return
{
'message'
:
"保存成功"
}
...
...
app/utils/db_tools.py
View file @
b2fd772e
...
...
@@ -35,6 +35,7 @@ create_table_sql_list = ['''create table if not exists project_info
,
'''create table if not exists remote_server_info
(id bigint
, project_no varchar(50) unique
, work_shop_no varchar(50)
, server_ip varchar(50)
, server_ssh_port varchar(50)
, server_user varchar(50)
...
...
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