Sha256: e9aafaa2dcb35c8c81bae3d8fd5ddc8555f173be6d58c53e896951d2a7e23028

Contents?: true

Size: 1.24 KB

Versions: 11

Compression:

Stored size: 1.24 KB

Contents

# takelage docker container check module
module DockerContainerCheckModule

  # Backend method for docker container check existing.
  # @return [Boolean] is container existing?
  def docker_container_check_existing(container)
    log.debug "Checking if container \"#{container}\" is existing"

    cmd_docker_existing = 'docker ps ' +
        "--filter name=^#{container}$ " +
        '--quiet'

    stdout_str, stderr_str, status = run_and_check cmd_docker_existing

    if stdout_str.to_s.strip.empty?
      log.debug "Container \"#{container}\" is not existing"
      return false
    end

    log.debug "Container \"#{container}\" is existing"
    true
  end

  # Backend method for docker container check orphaned.
  # @return [Boolean] is container orphaned?
  def docker_container_check_orphaned(container)
    log.debug "Check if container \"#{container}\" is orphaned"

    cmd_docker_orphaned = 'docker exec ' +
        '--interactive ' +
        "#{container} " +
        'ps a'

    stdout_str, stderr_str, status = run_and_check cmd_docker_orphaned

    if stdout_str.include? '/loginpoint.py'
      log.debug "Container \"#{container}\" isn't orphaned"
      return false
    end

    log.debug "Container \"#{container}\" is orphaned"
    true
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
takelage-0.4.1 lib/takelage/docker/container/check/module.rb
takelage-0.4.0 lib/takelage/docker/container/check/module.rb
takelage-0.3.0 lib/takelage/docker/container/check/module.rb
takelage-0.2.1 lib/takelage/docker/container/check/module.rb
takelage-0.2.0 lib/takelage/docker/container/check/module.rb
takelage-0.1.5 lib/takelage/docker/container/check/module.rb
takelage-0.1.4 lib/takelage/docker/container/check/module.rb
takelage-0.1.3 lib/takelage/docker/container/check/module.rb
takelage-0.1.2 lib/takelage/docker/container/check/module.rb
takelage-0.1.1 lib/takelage/docker/container/check/module.rb
takelage-0.1.0 lib/takelage/docker/container/check/module.rb