lib/baleen/container.rb in baleen-0.0.10 vs lib/baleen/container.rb in baleen-0.0.11
- old
+ new
@@ -2,46 +2,29 @@
module Container
class DockerClient
Result = Struct.new("Result", :status_code, :container_id, :log)
- def initialize(containers)
- @containers = containers
- end
-
def create_container(params)
- @container = @containers.create([params.shell, params.opt, params.commands], params.image)
+ @container = Docker::Container.create('Cmd' => [params.shell, params.opt, params.commands], 'Image' => params.image)
end
def start_container
- id = @container["Id"]
-
- info "Start container #{id}"
- @containers.start(id)
- @containers.wait(id)
- info "Finish container #{id}"
+ info "Start container #{@container.id}"
+ @container.start
+ @container.wait
+ info "Finish container #{@container.id}"
end
def result
- id = @container["Id"]
- rst = @containers.show(id)
- log = @containers.logs(id)
+ rst = @container.json
+ log = @container.attach(:stream => false, :stdout => true, :stderr => true, :logs => true)
Result.new(
rst["State"]["ExitCode"],
rst["ID"],
log
)
- end
-
- def kill_all
- @containers.list.each do |container|
- @containers.kill(container["Id"])
- end
- end
-
- def status
- info @containers.list
end
end
end
\ No newline at end of file