mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 14:31:13 +02:00
Add prune images endpoint.
Use many-to-many relationship between images and templates.
This commit is contained in:
1 parent
078c42f185
commit
4d9e4e1059
5 files changed
+90
-13
No files matched your search
@@ -15,10 +15,18 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from sqlalchemy import Column, String, Integer, BigInteger
|
||||
from sqlalchemy import Table, Column, String, Integer, ForeignKey, BigInteger
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from .base import BaseTable
|
||||
from .base import Base, BaseTable, GUID
|
||||
|
||||
|
||||
image_template_link = Table(
|
||||
"images_templates_link",
|
||||
Base.metadata,
|
||||
Column("image_id", Integer, ForeignKey("images.id", ondelete="CASCADE")),
|
||||
Column("template_id", GUID, ForeignKey("templates.template_id", ondelete="CASCADE"))
|
||||
)
|
||||
|
||||
|
||||
class Image(BaseTable):
|
||||
@@ -32,4 +40,4 @@ class Image(BaseTable):
|
||||
path = Column(String)
|
||||
checksum = Column(String)
|
||||
checksum_algorithm = Column(String)
|
||||
templates = relationship("Template")
|
||||
templates = relationship("Template", secondary=image_template_link, back_populates="images")
|
||||
@@ -17,8 +17,10 @@
|
||||
|
||||
|
||||
from sqlalchemy import Boolean, Column, String, Integer, ForeignKey, PickleType
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from .base import BaseTable, generate_uuid, GUID
|
||||
from .images import image_template_link
|
||||
|
||||
|
||||
class Template(BaseTable):
|
||||
@@ -34,8 +36,7 @@ class Template(BaseTable):
|
||||
compute_id = Column(String)
|
||||
usage = Column(String)
|
||||
template_type = Column(String)
|
||||
|
||||
image_id = Column(Integer, ForeignKey('images.id', ondelete="CASCADE"))
|
||||
images = relationship("Image", secondary=image_template_link, back_populates="templates")
|
||||
|
||||
__mapper_args__ = {
|
||||
"polymorphic_identity": "templates",
|
||||
|
||||
Reference in new issue
Block a user