Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
scc-net
netvs
netvs-core
Commits
7f30471e
Commit
7f30471e
authored
Oct 15, 2021
by
janis.streib
🦉
Browse files
FIX: serialize to and from redis
parent
3aa191e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
middleware/net_suite/modules/macfinder/views.py
View file @
7f30471e
...
@@ -61,7 +61,7 @@ def create_job():
...
@@ -61,7 +61,7 @@ def create_job():
created_jobs
.
append
(
job_id
)
created_jobs
.
append
(
job_id
)
pipe
=
r
.
pipeline
()
pipe
=
r
.
pipeline
()
pipe
.
multi
()
pipe
.
multi
()
pipe
.
set
(
job_id
,
MacFinderJob
(
mac
=
request
.
json
[
'mac'
],
job_id
=
job_id
,
vlan
=
vlan
,
bcd
=
vlan
.
bcd
))
pipe
.
set
(
job_id
,
jsonify
(
MacFinderJob
(
mac
=
request
.
json
[
'mac'
],
job_id
=
job_id
,
vlan
=
vlan
,
bcd
=
vlan
.
bcd
))
)
pipe
.
expire
(
job_id
,
60
*
60
*
12
)
pipe
.
expire
(
job_id
,
60
*
60
*
12
)
pipe
.
execute
()
pipe
.
execute
()
return
jsonify
({
'success'
:
True
,
'job_ids'
:
created_jobs
})
return
jsonify
({
'success'
:
True
,
'job_ids'
:
created_jobs
})
...
@@ -71,7 +71,7 @@ def create_job():
...
@@ -71,7 +71,7 @@ def create_job():
@
api_netdb_required
@
api_netdb_required
def
poll
(
job_id
):
def
poll
(
job_id
):
with
redis
.
Redis
(
db
=
int
(
app
.
config
.
get
(
'REDIS_DB_INDEX'
)))
as
r
:
with
redis
.
Redis
(
db
=
int
(
app
.
config
.
get
(
'REDIS_DB_INDEX'
)))
as
r
:
job
=
r
.
get
(
job_id
)
job
=
MacFinderJob
(
**
json
.
loads
(
r
.
get
(
job_id
)
))
session
=
requests
.
session
()
session
=
requests
.
session
()
job
.
poll
(
session
,
db
,
get_db_conn
())
job
.
poll
(
session
,
db
,
get_db_conn
())
pipe
=
r
.
pipeline
()
pipe
=
r
.
pipeline
()
...
...
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