Skip to content

Commit 12cde19

Browse files
authored
Merge pull request #411 from fabric-testbed/db-export
Db export
2 parents b8468be + bcdcaea commit 12cde19

21 files changed

+1050
-80
lines changed

Dockerfile-auth

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ COPY docker-entrypoint.sh /usr/src/app/
1717
COPY fabric_cf /usr/src/app/fabric_cf
1818
COPY pyproject.toml /usr/src/app/
1919
COPY README.md /usr/src/app/
20+
COPY LICENSE /usr/src/app/
2021
COPY tools/audit.py /usr/src/app/
22+
COPY tools/export.py /usr/src/app/
23+
COPY export/ /usr/src/app/export/
2124
COPY tools/install.sh /usr/src/app/
2225

2326
RUN pip3 install .

Dockerfile-broker

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ COPY docker-entrypoint.sh /usr/src/app/
1414
COPY fabric_cf /usr/src/app/fabric_cf
1515
COPY pyproject.toml /usr/src/app/
1616
COPY README.md /usr/src/app/
17+
COPY LICENSE /usr/src/app/
1718
COPY tools/audit.py /usr/src/app/
19+
COPY tools/export.py /usr/src/app/
20+
COPY export/ /usr/src/app/export/
1821
COPY tools/install.sh /usr/src/app/
1922

2023
RUN pip3 install .

Dockerfile-cf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ RUN apt-get install cron -y
1313
COPY fabric_cf /usr/src/app/fabric_cf
1414
COPY pyproject.toml /usr/src/app/
1515
COPY README.md /usr/src/app/
16+
COPY LICENSE /usr/src/app/
1617
COPY tools/audit.py /usr/src/app/
18+
COPY tools/export.py /usr/src/app/
19+
COPY export/ /usr/src/app/export/
1720
COPY tools/install.sh /usr/src/app/
1821

1922
RUN pip3 install .

Dockerfile-orchestrator

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ COPY docker-entrypoint.sh /usr/src/app/
1515
COPY fabric_cf /usr/src/app/fabric_cf
1616
COPY pyproject.toml /usr/src/app/
1717
COPY README.md /usr/src/app/
18+
COPY LICENSE /usr/src/app/
1819
COPY tools/audit.py /usr/src/app/
20+
COPY tools/export.py /usr/src/app/
21+
COPY export/ /usr/src/app/export/
1922
COPY tools/install.sh /usr/src/app/
2023

2124
RUN pip3 install .

export/__init__.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
from sqlalchemy import ForeignKey, TIMESTAMP, Index, JSON
2+
from sqlalchemy.orm import declarative_base
3+
from sqlalchemy import Column, String, Integer, Sequence
4+
5+
Base = declarative_base()
6+
7+
8+
class Sites(Base):
9+
__tablename__ = 'sites'
10+
id = Column(Integer, Sequence('sites.id', start=1, increment=1), autoincrement=True, primary_key=True, index=True)
11+
name = Column(String, nullable=False, index=True)
12+
13+
14+
class Hosts(Base):
15+
__tablename__ = 'hosts'
16+
id = Column(Integer, Sequence('hosts.id', start=1, increment=1), autoincrement=True, primary_key=True, index=True)
17+
site_id = Column(Integer, ForeignKey('sites.id'), index=True)
18+
name = Column(String, nullable=False, index=True)
19+
20+
21+
class Projects(Base):
22+
__tablename__ = 'projects'
23+
id = Column(Integer, Sequence('projects.id', start=1, increment=1), autoincrement=True, primary_key=True, index=True)
24+
project_uuid = Column(String, nullable=False, index=True)
25+
project_name = Column(String, nullable=True, index=True)
26+
27+
28+
class Users(Base):
29+
__tablename__ = 'users'
30+
id = Column(Integer, Sequence('users.id', start=1, increment=1), autoincrement=True, primary_key=True, index=True)
31+
user_uuid = Column(String, nullable=False, index=True)
32+
user_email = Column(String, nullable=True, index=True)
33+
34+
35+
class Slices(Base):
36+
__tablename__ = 'slices'
37+
id = Column(Integer, Sequence('slices.id', start=1, increment=1), autoincrement=True, primary_key=True, index=True)
38+
project_id = Column(Integer, ForeignKey('projects.id'), index=True)
39+
user_id = Column(Integer, ForeignKey('users.id'), index=True)
40+
slice_guid = Column(String, nullable=False, index=True)
41+
slice_name = Column(String, nullable=False, index=True)
42+
state = Column(Integer, nullable=False, index=True)
43+
lease_start = Column(TIMESTAMP(timezone=True), nullable=True, index=True)
44+
lease_end = Column(TIMESTAMP(timezone=True), nullable=True, index=True)
45+
46+
__table_args__ = (
47+
Index('idx_slice_lease_range', 'lease_start', 'lease_end'),
48+
)
49+
50+
51+
class Slivers(Base):
52+
__tablename__ = 'slivers'
53+
id = Column(Integer, Sequence('slivers.id', start=1, increment=1), autoincrement=True, primary_key=True, index=True)
54+
project_id = Column(Integer, ForeignKey('projects.id'), index=True)
55+
slice_id = Column(Integer, ForeignKey('slices.id'), index=True)
56+
user_id = Column(Integer, ForeignKey('users.id'), index=True)
57+
host_id = Column(Integer, ForeignKey('hosts.id'), index=True)
58+
site_id = Column(Integer, ForeignKey('sites.id'), index=True)
59+
sliver_guid = Column(String, nullable=False, index=True)
60+
state = Column(Integer, nullable=False, index=True)
61+
sliver_type = Column(String, nullable=False, index=True)
62+
ip_subnet = Column(String, nullable=True, index=True)
63+
image = Column(String, nullable=True)
64+
core = Column(Integer, nullable=True)
65+
ram = Column(Integer, nullable=True)
66+
disk = Column(Integer, nullable=True)
67+
bandwidth = Column(Integer, nullable=True)
68+
error = Column(String, nullable=True)
69+
lease_start = Column(TIMESTAMP(timezone=True), nullable=True, index=True)
70+
lease_end = Column(TIMESTAMP(timezone=True), nullable=True, index=True)
71+
72+
__table_args__ = (
73+
Index('idx_sliver_lease_range', 'lease_start', 'lease_end'),
74+
)
75+
76+
77+
class Components(Base):
78+
__tablename__ = 'components'
79+
sliver_id = Column(Integer, ForeignKey('slivers.id'), primary_key=True)
80+
component_guid = Column(String, primary_key=True, index=True)
81+
type = Column(String, nullable=True, index=True)
82+
model = Column(String, nullable=True, index=True)
83+
bdfs = Column(JSON, nullable=True) # Store BDFs as a JSON list
84+
85+
86+
class Interfaces(Base):
87+
__tablename__ = 'interfaces'
88+
sliver_id = Column(Integer, ForeignKey('slivers.id'), primary_key=True, index=True)
89+
interface_guid = Column(String, primary_key=True, index=True)
90+
vlan = Column(String, nullable=True, index=True)
91+
bdf = Column(String, nullable=True, index=True)
92+
local_name = Column(String, nullable=True, index=True)
93+
device_name = Column(String, nullable=True, index=True)
94+
name = Column(String, nullable=True, index=True)

0 commit comments

Comments
 (0)