mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-17 09:14:52 +02:00
Prepare resource pools table for future development
This commit is contained in:
parent
170f476733
commit
e72b07bf5c
@ -144,7 +144,7 @@ def get_nodes(project: Project = Depends(dep_project)) -> List[schemas.Node]:
|
|||||||
return [v.asdict() for v in project.nodes.values()]
|
return [v.asdict() for v in project.nodes.values()]
|
||||||
|
|
||||||
|
|
||||||
@router.post("/start", status_code=status.HTTP_204_NO_CONTENT, dependencies=[Depends(has_privilege("Node."))])
|
@router.post("/start", status_code=status.HTTP_204_NO_CONTENT, dependencies=[Depends(has_privilege("Node.PowerMgmt"))])
|
||||||
async def start_all_nodes(project: Project = Depends(dep_project)) -> None:
|
async def start_all_nodes(project: Project = Depends(dep_project)) -> None:
|
||||||
"""
|
"""
|
||||||
Start all nodes belonging to a given project.
|
Start all nodes belonging to a given project.
|
||||||
|
@ -22,6 +22,7 @@ from .roles import Role
|
|||||||
from .privileges import Privilege
|
from .privileges import Privilege
|
||||||
from .computes import Compute
|
from .computes import Compute
|
||||||
from .images import Image
|
from .images import Image
|
||||||
|
from .resource_pools import Resource, ResourcePool
|
||||||
from .templates import (
|
from .templates import (
|
||||||
Template,
|
Template,
|
||||||
CloudTemplate,
|
CloudTemplate,
|
||||||
|
@ -15,28 +15,38 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from sqlalchemy import Column, String, Boolean, ForeignKey
|
from sqlalchemy import Table, Column, String, ForeignKey
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from .base import BaseTable, generate_uuid, GUID
|
from .base import Base, BaseTable, generate_uuid, GUID
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
resource_pool_map = Table(
|
||||||
|
"resource_pool_map",
|
||||||
|
Base.metadata,
|
||||||
|
Column("resource_id", GUID, ForeignKey("resources.resource_id", ondelete="CASCADE")),
|
||||||
|
Column("resource_pool_id", GUID, ForeignKey("resource_pools.resource_pool_id", ondelete="CASCADE"))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Resource(BaseTable):
|
||||||
|
|
||||||
|
__tablename__ = "resources"
|
||||||
|
|
||||||
|
resource_id = Column(GUID, primary_key=True)
|
||||||
|
name = Column(String, unique=True, index=True)
|
||||||
|
resource_type = Column(String)
|
||||||
|
resource_pools = relationship("ResourcePool", secondary=resource_pool_map, back_populates="resources")
|
||||||
|
|
||||||
|
|
||||||
class ResourcePool(BaseTable):
|
class ResourcePool(BaseTable):
|
||||||
|
|
||||||
__tablename__ = "resource_pools"
|
__tablename__ = "resource_pools"
|
||||||
|
|
||||||
resource_id = Column(GUID, primary_key=True)
|
resource_pool_id = Column(GUID, primary_key=True, default=generate_uuid)
|
||||||
resource_type = Column(String)
|
name = Column(String, unique=True, index=True)
|
||||||
|
resources = relationship("Resource", secondary=resource_pool_map, back_populates="resource_pools")
|
||||||
# Create a self-referential relationship to represent a hierarchy of resources
|
|
||||||
parent_id = Column(GUID, ForeignKey("resources.resource_id", ondelete="CASCADE"))
|
|
||||||
children = relationship(
|
|
||||||
"Resource",
|
|
||||||
remote_side=[resource_id],
|
|
||||||
cascade="all, delete-orphan",
|
|
||||||
single_parent=True
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user