Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
shared-libs
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pi-Lab
shared-libs
Commits
53fbe7c1
Commit
53fbe7c1
authored
7 months ago
by
Alfred Ashur Oshana
Browse files
Options
Downloads
Patches
Plain Diff
remove legacy and minor fix
parent
9c3eab2f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pilab/crud/Pi.py
+8
-37
8 additions, 37 deletions
pilab/crud/Pi.py
pilab/schemas/Key.py
+0
-5
0 additions, 5 deletions
pilab/schemas/Key.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
9 additions
and
43 deletions
pilab/crud/Pi.py
+
8
−
37
View file @
53fbe7c1
...
@@ -7,6 +7,7 @@ from pilab.crud.Host import Host
...
@@ -7,6 +7,7 @@ from pilab.crud.Host import Host
from
pilab.schemas.Pi
import
PiType
from
pilab.schemas.Pi
import
PiType
from
pilab.schemas.Host
import
HostType
from
pilab.schemas.Host
import
HostType
from
pilab.schemas.Cube
import
CubesType
from
pilab.schemas.Cube
import
CubesType
from
pilab.schemas.ImageBinding
import
ImageBindingType
from
pilab.events
import
meta
from
pilab.events
import
meta
log
.
getLogger
(
'
sqlalchemy.engine
'
).
setLevel
(
log
.
WARNING
)
log
.
getLogger
(
'
sqlalchemy.engine
'
).
setLevel
(
log
.
WARNING
)
...
@@ -31,42 +32,6 @@ class Pi(object):
...
@@ -31,42 +32,6 @@ class Pi(object):
pi
=
meta
.
Pi
(
**
vars
(
db_pi
),
**
host
.
dict
())
pi
=
meta
.
Pi
(
**
vars
(
db_pi
),
**
host
.
dict
())
return
pi
return
pi
@staticmethod
def
update_image
(
db
:
Session
,
pi_id
:
int
,
image_id
:
int
,
user_data_id
:
int
):
db_pi
=
db
.
query
(
PiType
).
filter
(
PiType
.
host_id
==
pi_id
).
first
()
db_pi
.
image_id
=
image_id
db_pi
.
user_data_id
=
user_data_id
db
.
flush
()
@staticmethod
def
update_playbook
(
db
:
Session
,
pi_id
:
int
,
playbook_id
:
int
):
db_pi
=
db
.
query
(
PiType
).
filter
(
PiType
.
host_id
==
pi_id
).
first
()
db_pi
.
playbook_id
=
playbook_id
db
.
flush
()
@staticmethod
def
assign_image
(
db
:
Session
,
pi_id
:
int
,
image_id
:
int
):
db_pi
=
db
.
query
(
PiType
).
filter
(
PiType
.
host_id
==
pi_id
).
first
()
db_pi
.
image_id
=
image_id
db
.
flush
()
@staticmethod
def
assign_host_key
(
db
:
Session
,
pi_id
:
int
,
key_id
:
int
):
db_pi
=
db
.
query
(
PiType
).
filter
(
PiType
.
host_id
==
pi_id
).
first
()
db_pi
.
key_id
=
key_id
db
.
flush
()
@staticmethod
def
assign_data
(
db
:
Session
,
pi_id
:
int
,
user_data_id
:
int
):
db_pi
=
db
.
query
(
PiType
).
filter
(
PiType
.
host_id
==
pi_id
).
first
()
db_pi
.
user_data_id
=
user_data_id
db
.
flush
()
@staticmethod
@staticmethod
def
get
(
db
:
Session
,
id
:
int
=
None
,
serial
:
bytes
=
None
,
mac
:
int
=
None
):
#DONE
def
get
(
db
:
Session
,
id
:
int
=
None
,
serial
:
bytes
=
None
,
mac
:
int
=
None
):
#DONE
if
id
:
if
id
:
...
@@ -127,7 +92,13 @@ class Pi(object):
...
@@ -127,7 +92,13 @@ class Pi(object):
PiType
.
cube_id
==
db_cube
.
id
PiType
.
cube_id
==
db_cube
.
id
).
all
()
).
all
()
elif
image_id
:
elif
image_id
:
ids
=
db
.
query
(
PiType
.
host_id
).
filter
(
PiType
.
image_id
==
image_id
).
all
()
db_image_bindings
=
db
.
query
(
ImageBindingType
).
filter
(
ImageBindingType
.
image_id
==
image_id
).
all
()
pi_ids
=
[
image_binding
.
pi_id
for
image_binding
in
db_image_bindings
]
ids
=
db
.
query
(
PiType
.
host_id
).
filter
(
PiType
.
host_id
in
pi_ids
).
all
()
else
:
else
:
ids
=
db
.
query
(
PiType
.
host_id
).
all
()
ids
=
db
.
query
(
PiType
.
host_id
).
all
()
...
...
This diff is collapsed.
Click to expand it.
pilab/schemas/Key.py
+
0
−
5
View file @
53fbe7c1
...
@@ -9,8 +9,3 @@ class KeyType(Base):
...
@@ -9,8 +9,3 @@ class KeyType(Base):
id
=
Column
(
Integer
,
primary_key
=
True
)
id
=
Column
(
Integer
,
primary_key
=
True
)
owner
=
Column
(
String
)
owner
=
Column
(
String
)
host_key
=
Column
(
String
)
host_key
=
Column
(
String
)
class
KeyBindingType
(
Base
):
__tablename__
=
"
key_bindings
"
key_id
=
Column
(
Integer
,
ForeignKey
(
'
keys.id
'
),
primary_key
=
True
)
pi_id
=
Column
(
Integer
,
ForeignKey
(
'
pis.host_id
'
),
primary_key
=
True
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
53fbe7c1
...
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
...
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup
(
setup
(
name
=
'
pilab
'
,
name
=
'
pilab
'
,
version
=
'
5.
1.4
'
,
version
=
'
5.
2.0
'
,
description
=
'
Shared-Libs for the pi-lab microservices
'
,
description
=
'
Shared-Libs for the pi-lab microservices
'
,
url
=
'
https://code.fbi.h-da.de/api/v4/projects/27896/packages/pypi/pilab
'
,
url
=
'
https://code.fbi.h-da.de/api/v4/projects/27896/packages/pypi/pilab
'
,
author
=
'
Max Reinheimer
'
,
author
=
'
Max Reinheimer
'
,
...
...
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