def debug(config_id, container_name, action, config, managed_by, labels=None, cont_cmd='docker', default_runtime=None, log_level=None, log_file=None): """Execute supplied container configuration. :param str config_id: Unique config ID, should not be re-used until any running containers with that config ID have been deleted. :param str container_name: Name of the container in the config you wish to manipulate. :param str action: Action to take. :param dict config: Configuration data describing container actions to apply. :param str managed_by: Name of the tool managing the containers. Only containers labeled with this will be modified. :param dict labels: Optional keys/values of labels to apply to containers created with this invocation. :param str cont_cmd: Optional override to the container command to run. :param str default_runtime: (deprecated) does nothing. :param int log_level: optional log level for loggers :param int log_file: optional log file for messages :returns integer return value from running command or failure for any other reason. :rtype: int """ log = common.configure_logging(__name__, log_level, log_file) if default_runtime: log.warning("DEPRECATION: 'default_runtime' does nothing, " "use 'cont_cmd' instead") if cont_cmd == 'docker': r = runner.DockerRunner(managed_by, cont_cmd=cont_cmd, log=log) builder = compose1.ComposeV1Builder( config_id=config_id, config=config, runner=r, labels=labels, log=log ) elif cont_cmd == 'podman': r = runner.PodmanRunner(managed_by, cont_cmd=cont_cmd, log=log) builder = podman.PodmanBuilder( config_id=config_id, config=config, runner=r, labels=labels, log=log ) else: log.error("container runtime not supported: %s" % cont_cmd) if action == 'print-cmd': cmd = [ r.cont_cmd, 'run', '--name', r.unique_container_name(container_name) ] builder.container_run_args(cmd, container_name) print(' '.join(cmd)) elif action == 'run': cmd = [ r.cont_cmd, 'run', '--name', r.unique_container_name(container_name) ] builder.container_run_args(cmd, container_name) return r.execute_interactive(cmd, log) elif action == 'dump-yaml': print(yaml.safe_dump(config, default_flow_style=False)) elif action == 'dump-json': print(json.dumps(config, indent=4)) else: raise ValueError('action should be one of: "dump-json", "dump-yaml"', '"print-cmd", or "run"')
def test_image_exist(self, popen): self.mock_execute(popen, '', '', 0) self.runner = runner.PodmanRunner('tester') self.runner.image_exist('one') self.assert_execute(popen, ['podman', 'image', 'exists', 'one'])
] env = {} # FIXME: add log=log once we have paunch 4.0.1 in Pypi and promoted in RDO RUNNER = containers_runner.DockerRunner('container-puppet', cont_cmd='docker') elif container_cli == 'podman': # podman doesn't allow relabeling content in /usr and # doesn't support named volumes cli_dcmd = [ '--security-opt', 'label=disable', '--volume', '/usr/share/openstack-puppet/modules/:/usr/share/openstack-puppet/modules/:ro' ] # podman need to find dependent binaries that are in environment env = {'PATH': os.environ['PATH']} # FIXME: add log=log once we have paunch 4.0.1 in Pypi and promoted in RDO RUNNER = containers_runner.PodmanRunner('container-puppet', cont_cmd='podman') else: log.error('Invalid container_cli: %s' % container_cli) sys.exit(1) # Controls whether puppet is bind mounted in from the host # NOTE: we require this to support the tarball extracted (Deployment archive) # puppet modules but our containers now also include puppet-tripleo so we # could use either if os.environ.get('MOUNT_HOST_PUPPET', 'true') == 'true': cli_dcmd.extend([ '--volume', '/usr/share/openstack-puppet/modules/:/usr/share/openstack-puppet/modules/:ro' ])
def setUp(self): super(TestBaseRunner, self).setUp() self.runner = runner.DockerRunner('tester') self.podman_runner = runner.PodmanRunner('tester')