Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tdp/cli/commands/plan/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def dag(
from tdp.cli.utils import print_deployment, validate_plan_creation
from tdp.core.dag import Dag
from tdp.core.models import DeploymentModel
from tdp.core.models.enums import FilterTypeEnum
from tdp.core.models.enums import DeploymentStateEnum, FilterTypeEnum
from tdp.dao import Dao

filter_type = None
Expand Down Expand Up @@ -136,6 +136,7 @@ def dag(
with Dao(db_engine, commit_on_exit=True) as dao:
if last_deployment := dao.get_last_deployment():
validate_plan_creation(last_deployment.state, force)
deployment.id = last_deployment.id
if last_deployment.state is DeploymentStateEnum.PLANNED:
deployment.id = last_deployment.id
dao.session.merge(deployment)
click.echo("Deployment plan successfully created.")
5 changes: 3 additions & 2 deletions tdp/cli/commands/plan/import_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def import_file(

from tdp.cli.utils import parse_file, validate_plan_creation
from tdp.core.models.deployment_model import DeploymentModel
from tdp.core.models.enums import DeploymentStateEnum
from tdp.dao import Dao

with Dao(db_engine, commit_on_exit=True) as dao:
Expand All @@ -47,8 +48,8 @@ def import_file(
)
if last_deployment := dao.get_last_deployment():
validate_plan_creation(last_deployment.state, force)
# if a planned deployment is present, update it
deployment.id = last_deployment.id
if last_deployment.state is DeploymentStateEnum.PLANNED:
deployment.id = last_deployment.id
dao.session.merge(deployment)
dao.session.commit()
click.echo("Deployment plan successfully imported.")
4 changes: 3 additions & 1 deletion tdp/cli/commands/plan/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def ops(

from tdp.cli.utils import print_deployment, validate_plan_creation
from tdp.core.models import DeploymentModel
from tdp.core.models.enums import DeploymentStateEnum
from tdp.dao import Dao

click.echo(
Expand All @@ -66,6 +67,7 @@ def ops(
with Dao(db_engine, commit_on_exit=True) as dao:
if last_deployment := dao.get_last_deployment():
validate_plan_creation(last_deployment.state, force)
deployment.id = last_deployment.id
if last_deployment.state is DeploymentStateEnum.PLANNED:
deployment.id = last_deployment.id
dao.session.merge(deployment)
click.echo("Deployment plan successfully created.")
4 changes: 3 additions & 1 deletion tdp/cli/commands/plan/reconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def reconfigure(

from tdp.cli.utils import print_deployment, validate_plan_creation
from tdp.core.models import DeploymentModel
from tdp.core.models.enums import DeploymentStateEnum
from tdp.dao import Dao

click.echo("Creating a deployment plan to reconfigure services.")
Expand All @@ -54,6 +55,7 @@ def reconfigure(
return
if last_deployment := dao.get_last_deployment():
validate_plan_creation(last_deployment.state, force)
deployment.id = last_deployment.id
if last_deployment.state is DeploymentStateEnum.PLANNED:
deployment.id = last_deployment.id
dao.session.merge(deployment)
click.echo("Deployment plan successfully created.")
4 changes: 3 additions & 1 deletion tdp/cli/commands/plan/resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def resume(

from tdp.cli.utils import print_deployment, validate_plan_creation
from tdp.core.models import DeploymentModel
from tdp.core.models.enums import DeploymentStateEnum
from tdp.dao import Dao

with Dao(db_engine, commit_on_exit=True) as dao:
Expand All @@ -51,6 +52,7 @@ def resume(
return
if last_deployment := dao.get_last_deployment():
validate_plan_creation(last_deployment.state)
deployment.id = last_deployment.id
if last_deployment.state is DeploymentStateEnum.PLANNED:
deployment.id = last_deployment.id
dao.session.merge(deployment)
click.echo("Deployment plan successfully created.")