def start(params, processes_to_wait_for, retry_interval, daemon_client=None, **_): """ cloudify.docker.container type start lifecycle operation. Any properties and runtime_properties set in the create lifecycle operation also available in start. Similar to the docker start command, but doesn't support attach options. :param daemon_client: optional configuration for client creation :param retry_interval: The number of seconds between retries during the wait_for_processes bit. """ daemon_client = daemon_client or {} client = docker_client.get_client(daemon_client) if ctx.node.properties['use_external_resource']: if utils.get_container_dictionary(client) is None: raise NonRecoverableError('{} does not exist.'.format( ctx.instance.runtime_properties.get('container_id'))) container_id = ctx.instance.runtime_properties['container_id'] arguments = {'container': container_id} arguments.update(params) ctx.logger.info('Start arguments: {0}'.format(arguments)) try: response = client.start(**arguments) except APIError as e: raise NonRecoverableError('Failed to start container: {0}.'.format( str(e))) ctx.logger.info('Container started: {}.'.format(response)) if params.get('processes_to_wait_for'): utils.wait_for_processes(processes_to_wait_for, retry_interval, client) ctx.logger.info('Started container: {0}.'.format( ctx.instance.runtime_properties['container_id'])) if utils.get_container_dictionary(client): inspect_output = utils.inspect_container(client) if inspect_output is not None: ctx.instance.runtime_properties['ports'] = \ inspect_output.get('Ports', None) ctx.instance.runtime_properties['network_settings'] = \ inspect_output.get('NetworkSettings', None) else: ctx.logger.info( 'Failed to get inspect_output: {0}'.format(arguments)) top_info = utils.get_top_info(client) ctx.logger.info('Container: {0} Forwarded ports: {1} Top: {2}.'.format( ctx.instance.runtime_properties['container_id'], 'Ports', top_info))
def start(params, processes_to_wait_for, retry_interval, daemon_client=None, **_): """ cloudify.docker.container type start lifecycle operation. Any properties and runtime_properties set in the create lifecycle operation also available in start. Similar to the docker start command, but doesn't support attach options. :param daemon_client: optional configuration for client creation :param retry_interval: The number of seconds between retries during the wait_for_processes bit. """ daemon_client = daemon_client or {} client = docker_client.get_client(daemon_client) if ctx.node.properties['use_external_resource']: if utils.get_container_dictionary(client) is None: raise NonRecoverableError('{} does not exist.'.format( ctx.instance.runtime_properties.get('container_id'))) container_id = ctx.instance.runtime_properties['container_id'] arguments = {'container': container_id} arguments.update(params) ctx.logger.info('Start arguments: {0}'.format(arguments)) try: response = client.start(**arguments) except APIError as e: raise NonRecoverableError( 'Failed to start container: {0}.'.format(str(e))) ctx.logger.info('Container started: {}.'.format(response)) if params.get('processes_to_wait_for'): utils.wait_for_processes(processes_to_wait_for, retry_interval, client) ctx.logger.info('Started container: {0}.'.format( ctx.instance.runtime_properties['container_id'])) if utils.get_container_dictionary(client): inspect_output = utils.inspect_container(client) if inspect_output is not None: ctx.instance.runtime_properties['ports'] = \ inspect_output.get('Ports', None) ctx.instance.runtime_properties['network_settings'] = \ inspect_output.get('NetworkSettings', None) else: ctx.logger.info('Failed to get inspect_output: {0}'.format(arguments)) top_info = utils.get_top_info(client) ctx.logger.info('Container: {0} Forwarded ports: {1} Top: {2}.'.format( ctx.instance.runtime_properties['container_id'], 'Ports', top_info))