Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
access-node
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LuFG VR VIS
VR-Group
In Situ Pipeline
access-node
Commits
16a32302
Commit
16a32302
authored
5 years ago
by
Jan Müller
Browse files
Options
Downloads
Patches
Plain Diff
Get SimulationNodes from database
parent
92c0a9ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
Feature/add arbor support
Pipeline
#163336
canceled
5 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
access_node/__main__.py
+22
-16
22 additions, 16 deletions
access_node/__main__.py
with
22 additions
and
16 deletions
access_node/__main__.py
+
22
−
16
View file @
16a32302
...
...
@@ -8,13 +8,16 @@ from flask_cors import CORS
from
access_node.models.nodes
import
nodes
import
json
import
time
import
requests
import
psycopg2
def
ConnectToDatabase
():
return
psycopg2
.
connect
(
database
=
"
postgres
"
,
user
=
postgres_username
,
password
=
postgres_password
,
host
=
"
database
"
,
port
=
str
(
port
))
def
SetupNestTables
(
postgres_username
,
postgres_password
,
port
):
con
=
psycopg2
.
connect
(
database
=
"
postgres
"
,
user
=
postgres_username
,
password
=
postgres_password
,
host
=
"
database
"
,
port
=
str
(
port
))
con
=
ConnectToDatabase
()
print
(
"
Database connection opened successfully!
"
)
cur
=
con
.
cursor
()
...
...
@@ -26,7 +29,7 @@ def SetupNestTables(postgres_username, postgres_password, port):
cur
.
execute
(
'''
CREATE TABLE SIMULATION_NODES (
NODE_ID INT PRIMARY KEY NOT NULL UNIQUE,
ADDRESS VARCHAR(
2
5),
ADDRESS VARCHAR(5
0
),
CURRENT_SIM_TIME FLOAT);
'''
)
cur
.
execute
(
'''
CREATE TABLE MULTIMETERS (
...
...
@@ -51,8 +54,7 @@ def SetupNestTables(postgres_username, postgres_password, port):
print
(
"
Nest tables created successfully!
\n
"
)
def
SetupArborTables
(
postgres_username
,
postgres_password
,
port
):
con
=
psycopg2
.
connect
(
database
=
"
postgres
"
,
user
=
postgres_username
,
password
=
postgres_password
,
host
=
"
database
"
,
port
=
str
(
port
))
con
=
ConnectToDatabase
()
print
(
"
Database connection opened successfully!
"
)
cur
=
con
.
cursor
()
cur
.
execute
(
"
DROP TABLE IF EXISTS PROBES CASCADE
"
)
...
...
@@ -62,7 +64,7 @@ def SetupArborTables(postgres_username, postgres_password, port):
cur
.
execute
(
'''
CREATE TABLE ARBOR_SIMULATION_NODES (
NODE_ID INT PRIMARY KEY NOT NULL UNIQUE,
ADDRESS VARCHAR(
2
5),
ADDRESS VARCHAR(5
0
),
CURRENT_SIM_TIME FLOAT);
'''
)
cur
.
execute
(
'''
CREATE TABLE CELLS (
...
...
@@ -102,19 +104,23 @@ def SetupArborTables(postgres_username, postgres_password, port):
def
main
():
# Connect to the Database and initalize basic Table structure
SetupNestTables
(
'
postgres
'
,
'
docker
'
,
5432
)
#SetupArborTables('postgres', 'docker', 5432)
# Wait for simulation nodes to post to database
time
.
sleep
(
10
)
# get info node
with
open
(
'
access_node//info_node.json
'
,
'
r
'
)
as
f
:
info
=
json
.
load
(
f
)
nodes
.
info_node
=
info
[
'
address
'
]
# get simulation nodes
node_type
=
'
nest_simulation
'
nodes
.
nest_simulation_nodes
=
requests
.
get
(
nodes
.
info_node
+
'
/nodes
'
,
params
=
{
"
node_type
"
:
node_type
}).
json
()
node_type
=
'
arbor_simulation
'
nodes
.
arbor_simulation_nodes
=
requests
.
get
(
nodes
.
info_node
+
'
/nodes
'
,
params
=
{
"
node_type
"
:
node_type
}).
json
()
con
=
ConnectToDatabase
()
cur
=
con
.
cursor
()
# NEST
cur
.
execute
(
"
SELECT ADDRESS FROM SIMULATION_NODES
"
)
nodes
.
nest_simulation_nodes
=
[
i
[
0
]
for
i
in
cur
.
fetchall
()]
# Arbor
#cur.execute("SELECT ADDRESS FROM SIMULATION_NODES")
#nodes.nest_simulation_nodes = [i[0] for i in cur.fetchall()]
con
.
close
()
# run acces_node
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'
./swagger/
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment