constraint
dev_tool.services.docker.constraint
log = logging.getLogger(__name__)
module-attribute
ContainerConstraint
A class that applies resource constraints to Docker containers using docker update.
The constructor for the ContainerConstraint class.
Parameters:
-
client(DockerClient) –The Docker client instance.
-
app_name(str) –The name of the app container.
-
db_name(str) –The name of the database container.
Source code in dev_tool/services/docker/constraint.py
apply
A method that applies resource constraints to both containers.
Parameters:
-
profile(ConstraintProfileType) –A dictionary with 'app' and 'db' keys containing constraint parameters.
Returns:
-
bool–True if all constraints were applied successfully.
Source code in dev_tool/services/docker/constraint.py
create_custom_profile
staticmethod
A method that creates a custom constraint profile.
Parameters:
-
app_memory(str) –The app container memory limit (e.g., '1g', '512m').
-
app_cpu(int) –The app container CPU percentage (e.g., 100 for 1 core).
-
db_memory(str) –The database container memory limit.
-
db_cpu(int) –The database container CPU percentage.
Returns:
-
ConstraintProfileType–The custom constraint profile dictionary.
Source code in dev_tool/services/docker/constraint.py
get_profile
staticmethod
A method that returns a predefined constraint profile.
Parameters:
-
name(ConstraintProfile) –The profile name.
Returns:
-
ConstraintProfileType–The constraint profile dictionary.