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
GitLab 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
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!4
Feature/add arbor support
Pipeline
#163336
canceled
5 years ago
Stage: test
Changes
1
Pipelines
1
Show 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
...
@@ -8,13 +8,16 @@ from flask_cors import CORS
from
access_node.models.nodes
import
nodes
from
access_node.models.nodes
import
nodes
import
json
import
json
import
time
import
requests
import
requests
import
psycopg2
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
):
def
SetupNestTables
(
postgres_username
,
postgres_password
,
port
):
con
=
psycopg2
.
connect
(
database
=
"
postgres
"
,
user
=
postgres_username
,
con
=
ConnectToDatabase
()
password
=
postgres_password
,
host
=
"
database
"
,
port
=
str
(
port
))
print
(
"
Database connection opened successfully!
"
)
print
(
"
Database connection opened successfully!
"
)
cur
=
con
.
cursor
()
cur
=
con
.
cursor
()
...
@@ -26,7 +29,7 @@ def SetupNestTables(postgres_username, postgres_password, port):
...
@@ -26,7 +29,7 @@ def SetupNestTables(postgres_username, postgres_password, port):
cur
.
execute
(
'''
CREATE TABLE SIMULATION_NODES (
cur
.
execute
(
'''
CREATE TABLE SIMULATION_NODES (
NODE_ID INT PRIMARY KEY NOT NULL UNIQUE,
NODE_ID INT PRIMARY KEY NOT NULL UNIQUE,
ADDRESS VARCHAR(
2
5),
ADDRESS VARCHAR(5
0
),
CURRENT_SIM_TIME FLOAT);
'''
)
CURRENT_SIM_TIME FLOAT);
'''
)
cur
.
execute
(
'''
CREATE TABLE MULTIMETERS (
cur
.
execute
(
'''
CREATE TABLE MULTIMETERS (
...
@@ -51,8 +54,7 @@ def SetupNestTables(postgres_username, postgres_password, port):
...
@@ -51,8 +54,7 @@ def SetupNestTables(postgres_username, postgres_password, port):
print
(
"
Nest tables created successfully!
\n
"
)
print
(
"
Nest tables created successfully!
\n
"
)
def
SetupArborTables
(
postgres_username
,
postgres_password
,
port
):
def
SetupArborTables
(
postgres_username
,
postgres_password
,
port
):
con
=
psycopg2
.
connect
(
database
=
"
postgres
"
,
user
=
postgres_username
,
con
=
ConnectToDatabase
()
password
=
postgres_password
,
host
=
"
database
"
,
port
=
str
(
port
))
print
(
"
Database connection opened successfully!
"
)
print
(
"
Database connection opened successfully!
"
)
cur
=
con
.
cursor
()
cur
=
con
.
cursor
()
cur
.
execute
(
"
DROP TABLE IF EXISTS PROBES CASCADE
"
)
cur
.
execute
(
"
DROP TABLE IF EXISTS PROBES CASCADE
"
)
...
@@ -62,7 +64,7 @@ def SetupArborTables(postgres_username, postgres_password, port):
...
@@ -62,7 +64,7 @@ def SetupArborTables(postgres_username, postgres_password, port):
cur
.
execute
(
'''
CREATE TABLE ARBOR_SIMULATION_NODES (
cur
.
execute
(
'''
CREATE TABLE ARBOR_SIMULATION_NODES (
NODE_ID INT PRIMARY KEY NOT NULL UNIQUE,
NODE_ID INT PRIMARY KEY NOT NULL UNIQUE,
ADDRESS VARCHAR(
2
5),
ADDRESS VARCHAR(5
0
),
CURRENT_SIM_TIME FLOAT);
'''
)
CURRENT_SIM_TIME FLOAT);
'''
)
cur
.
execute
(
'''
CREATE TABLE CELLS (
cur
.
execute
(
'''
CREATE TABLE CELLS (
...
@@ -102,19 +104,23 @@ def SetupArborTables(postgres_username, postgres_password, port):
...
@@ -102,19 +104,23 @@ def SetupArborTables(postgres_username, postgres_password, port):
def
main
():
def
main
():
# Connect to the Database and initalize basic Table structure
# Connect to the Database and initalize basic Table structure
SetupNestTables
(
'
postgres
'
,
'
docker
'
,
5432
)
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
# get simulation nodes
node_type
=
'
nest_simulation
'
con
=
ConnectToDatabase
()
nodes
.
nest_simulation_nodes
=
requests
.
get
(
cur
=
con
.
cursor
()
nodes
.
info_node
+
'
/nodes
'
,
params
=
{
"
node_type
"
:
node_type
}).
json
()
# NEST
node_type
=
'
arbor_simulation
'
cur
.
execute
(
"
SELECT ADDRESS FROM SIMULATION_NODES
"
)
nodes
.
arbor_simulation_nodes
=
requests
.
get
(
nodes
.
nest_simulation_nodes
=
[
i
[
0
]
for
i
in
cur
.
fetchall
()]
nodes
.
info_node
+
'
/nodes
'
,
params
=
{
"
node_type
"
:
node_type
}).
json
()
# Arbor
#cur.execute("SELECT ADDRESS FROM SIMULATION_NODES")
#nodes.nest_simulation_nodes = [i[0] for i in cur.fetchall()]
con
.
close
()
# run acces_node
# run acces_node
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'
./swagger/
'
)
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