Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Introduce --default-runtime parameter
Browse files Browse the repository at this point in the history
Default to 'docker', --default-runtime will allow us to change the
runtime (docker, podman, etc) in the future.
In future patches, we'll add support for LibPod and this patch will
allow to start running "paunch apply" for a specific runtime backend.

Change-Id: I4660f37a3fc231830f4f3a875f63473d68ca7cfc
  • Loading branch information
EmilienM committed Aug 27, 2018
1 parent c19a46b commit c7080ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
21 changes: 14 additions & 7 deletions paunch/__init__.py
Expand Up @@ -25,7 +25,8 @@
LOG = logging.getLogger(__name__)


def apply(config_id, config, managed_by, labels=None, docker_cmd=None):
def apply(config_id, config, managed_by, labels=None, docker_cmd=None,
default_runtime='docker'):
"""Execute supplied container configuration.
:param str config_id: Unique config ID, should not be re-used until any
Expand All @@ -38,19 +39,25 @@ def apply(config_id, config, managed_by, labels=None, docker_cmd=None):
:param dict labels: Optional keys/values of labels to apply to containers
created with this invocation.
:param str docker_cmd: Optional override to the docker command to run.
:param str default_runtime: Optional override to the default runtime used
for containers.
:returns (list, list, int) lists of stdout and stderr for each execution,
and a single return code representing the
overall success of the apply.
:rtype: tuple
"""
# TODO(emilien) Call the right runner based on default_runtime
r = runner.DockerRunner(managed_by, docker_cmd=docker_cmd)
builder = compose1.ComposeV1Builder(
config_id=config_id,
config=config,
runner=r,
labels=labels
)
if default_runtime == 'docker':
builder = compose1.ComposeV1Builder(
config_id=config_id,
config=config,
runner=r,
labels=labels
)
else:
LOG.error("container runtime not supported: %s" % default_runtime)
return builder.apply()


Expand Down
9 changes: 8 additions & 1 deletion paunch/cmd.py
Expand Up @@ -56,6 +56,12 @@ def get_parser(self, prog_name):
required=True,
help=('ID to assign to containers'),
)
parser.add_argument(
'--default-runtime',
dest='default_runtime',
default='docker',
help=('Default runtime for containers. Can be docker or podman.'),
)
return parser

def take_action(self, parsed_args):
Expand All @@ -72,7 +78,8 @@ def take_action(self, parsed_args):
parsed_args.config_id,
config,
managed_by='paunch',
labels=labels
labels=labels,
default_runtime=parsed_args.default_runtime
)

return rc
Expand Down

0 comments on commit c7080ee

Please sign in to comment.