Permalink
Browse files

Merge branch 'protocol'

  • Loading branch information...
2 parents d8e6dd7 + ee2befd commit f7de02ea10d85e69007b749d3b8027c8f6b24d90 Kowshik Prakasam and Pieter Noordhuis committed Feb 26, 2013
Showing with 1,256 additions and 1,022 deletions.
  1. +1 −2 warden-client/lib/warden/client.rb
  2. +1 −1 warden-client/lib/warden/client/version.rb
  3. +1 −2 warden-client/spec/support/mock_warden_server.rb
  4. +1 −1 warden-client/warden-client.gemspec
  5. +1 −31 warden-protocol/lib/warden/protocol.rb
  6. +34 −103 warden-protocol/lib/warden/protocol/base.rb
  7. +2 −2 warden-protocol/lib/warden/protocol/buffer.rb
  8. +13 −0 warden-protocol/lib/warden/protocol/build.sh
  9. +0 −20 warden-protocol/lib/warden/protocol/copy_in.rb
  10. +0 −21 warden-protocol/lib/warden/protocol/copy_out.rb
  11. +0 −34 warden-protocol/lib/warden/protocol/create.rb
  12. +0 −18 warden-protocol/lib/warden/protocol/destroy.rb
  13. +0 −19 warden-protocol/lib/warden/protocol/echo.rb
  14. +0 −13 warden-protocol/lib/warden/protocol/error.rb
  15. +0 −81 warden-protocol/lib/warden/protocol/info.rb
  16. +0 −18 warden-protocol/lib/warden/protocol/limit_bandwidth.rb
  17. +0 −50 warden-protocol/lib/warden/protocol/limit_disk.rb
  18. +0 −20 warden-protocol/lib/warden/protocol/limit_memory.rb
  19. +0 −22 warden-protocol/lib/warden/protocol/link.rb
  20. +0 −17 warden-protocol/lib/warden/protocol/list.rb
  21. +50 −0 warden-protocol/lib/warden/protocol/message.rb
  22. +0 −22 warden-protocol/lib/warden/protocol/net_in.rb
  23. +0 −20 warden-protocol/lib/warden/protocol/net_out.rb
  24. +494 −0 warden-protocol/lib/warden/protocol/pb.rb
  25. +10 −0 warden-protocol/lib/warden/protocol/pb/copy_in.proto
  26. +11 −0 warden-protocol/lib/warden/protocol/pb/copy_out.proto
  27. +28 −0 warden-protocol/lib/warden/protocol/pb/create.proto
  28. +8 −0 warden-protocol/lib/warden/protocol/pb/destroy.proto
  29. +9 −0 warden-protocol/lib/warden/protocol/pb/echo.proto
  30. +7 −0 warden-protocol/lib/warden/protocol/pb/error.proto
  31. +71 −0 warden-protocol/lib/warden/protocol/pb/info.proto
  32. +13 −0 warden-protocol/lib/warden/protocol/pb/limit_bandwidth.proto
  33. +39 −0 warden-protocol/lib/warden/protocol/pb/limit_disk.proto
  34. +11 −0 warden-protocol/lib/warden/protocol/pb/limit_memory.proto
  35. +13 −0 warden-protocol/lib/warden/protocol/pb/link.proto
  36. +8 −0 warden-protocol/lib/warden/protocol/pb/list.proto
  37. +34 −0 warden-protocol/lib/warden/protocol/pb/message.proto
  38. +13 −0 warden-protocol/lib/warden/protocol/pb/net_in.proto
  39. +11 −0 warden-protocol/lib/warden/protocol/pb/net_out.proto
  40. +7 −0 warden-protocol/lib/warden/protocol/pb/ping.proto
  41. +19 −0 warden-protocol/lib/warden/protocol/pb/resource_limits.proto
  42. +15 −0 warden-protocol/lib/warden/protocol/pb/run.proto
  43. +13 −0 warden-protocol/lib/warden/protocol/pb/spawn.proto
  44. +11 −0 warden-protocol/lib/warden/protocol/pb/stop.proto
  45. +13 −0 warden-protocol/lib/warden/protocol/pb/stream.proto
  46. +0 −16 warden-protocol/lib/warden/protocol/ping.rb
  47. +0 −25 warden-protocol/lib/warden/protocol/resource_limits.rb
  48. +0 −25 warden-protocol/lib/warden/protocol/run.rb
  49. +0 −23 warden-protocol/lib/warden/protocol/spawn.rb
  50. +0 −20 warden-protocol/lib/warden/protocol/stop.rb
  51. +0 −22 warden-protocol/lib/warden/protocol/stream.rb
  52. +1 −1 warden-protocol/lib/warden/protocol/version.rb
  53. +12 −12 warden-protocol/spec/base_spec.rb
  54. +0 −1 warden-protocol/spec/buffer_spec.rb
  55. +0 −3 warden-protocol/spec/copy_in_spec.rb
  56. +0 −3 warden-protocol/spec/copy_out_spec.rb
  57. +0 −3 warden-protocol/spec/create_spec.rb
  58. +0 −3 warden-protocol/spec/destroy_spec.rb
  59. +0 −4 warden-protocol/spec/echo_spec.rb
  60. +0 −1 warden-protocol/spec/error_spec.rb
  61. +0 −3 warden-protocol/spec/info_spec.rb
  62. +0 −3 warden-protocol/spec/limit_bandwidth_spec.rb
  63. +0 −3 warden-protocol/spec/limit_disk_spec.rb
  64. +0 −3 warden-protocol/spec/limit_memory_spec.rb
  65. +0 −3 warden-protocol/spec/link_spec.rb
  66. +0 −1 warden-protocol/spec/list_spec.rb
  67. +0 −3 warden-protocol/spec/net_in_spec.rb
  68. +0 −3 warden-protocol/spec/net_out_spec.rb
  69. +0 −3 warden-protocol/spec/ping_spec.rb
  70. +0 −4 warden-protocol/spec/resource_limits_spec.rb
  71. +0 −3 warden-protocol/spec/run_spec.rb
  72. +0 −3 warden-protocol/spec/spawn_spec.rb
  73. +0 −3 warden-protocol/spec/stop_spec.rb
  74. +0 −3 warden-protocol/spec/stream_spec.rb
  75. +0 −7 warden-protocol/spec/support/examples/documented_request.rb
  76. +3 −3 warden-protocol/spec/support/examples/wrappable_reply.rb
  77. +3 −3 warden-protocol/spec/support/examples/wrappable_request.rb
  78. +2 −2 warden/Gemfile
  79. +5 −5 warden/Gemfile.lock
  80. +2 −2 warden/bin/warden
  81. +31 −23 warden/lib/warden/{ → repl}/commands_manager.rb
  82. +12 −5 warden/lib/warden/{ → repl}/repl_v2.rb
  83. +6 −6 warden/lib/warden/{ → repl}/repl_v2_runner.rb
  84. +71 −100 warden/spec/{ → repl}/commands_manager_spec.rb
  85. +8 −8 warden/spec/{ → repl}/repl_v2_runner_spec.rb
  86. +29 −18 warden/spec/{ → repl}/repl_v2_spec.rb
  87. +0 −120 warden/spec/spec_helper.rb
  88. +109 −0 warden/spec/support/helpers/repl.rb
View
3 warden-client/lib/warden/client.rb
@@ -53,8 +53,7 @@ def read
# Discard \r\n
io { @sock.read(2) }
- wrapped_response = Warden::Protocol::WrappedResponse.decode(data)
- response = wrapped_response.response
+ response = Warden::Protocol::Message.decode(data).response
# Raise error replies
if response.is_a?(Warden::Protocol::ErrorResponse)
View
2 warden-client/lib/warden/client/version.rb
@@ -1,5 +1,5 @@
module Warden
class Client
- VERSION = "0.0.7"
+ VERSION = "0.1.0"
end
end
View
3 warden-client/spec/support/mock_warden_server.rb
@@ -37,8 +37,7 @@ def run!
# Discard \r\n
@sock.read(2)
- wrapped_request = Warden::Protocol::WrappedRequest.decode(data)
- handle(wrapped_request.request)
+ handle(Warden::Protocol::Message.decode(data).request)
end
end
end
View
2 warden-client/warden-client.gemspec
@@ -16,5 +16,5 @@ Gem::Specification.new do |s|
s.executables = []
s.require_paths = ["lib"]
- s.add_runtime_dependency "warden-protocol"
+ s.add_runtime_dependency "warden-protocol", "~> 0.1.0"
end
View
32 warden-protocol/lib/warden/protocol.rb
@@ -1,34 +1,4 @@
# coding: UTF-8
require "warden/protocol/version"
-
-require "warden/protocol/error"
-
-require "warden/protocol/create"
-require "warden/protocol/stop"
-require "warden/protocol/destroy"
-require "warden/protocol/info"
-
-require "warden/protocol/spawn"
-require "warden/protocol/link"
-require "warden/protocol/run"
-require "warden/protocol/stream"
-
-require "warden/protocol/net_in"
-require "warden/protocol/net_out"
-
-require "warden/protocol/copy_in"
-require "warden/protocol/copy_out"
-
-require "warden/protocol/limit_memory"
-require "warden/protocol/limit_disk"
-require "warden/protocol/limit_bandwidth"
-
-require "warden/protocol/ping"
-require "warden/protocol/list"
-require "warden/protocol/echo"
-
-module Warden
- module Protocol
- end
-end
+require "warden/protocol/message"
View
137 warden-protocol/lib/warden/protocol/base.rb
@@ -18,61 +18,6 @@ def append_string(s)
module Warden
module Protocol
- module Type
- Error = 1
-
- Create = 11
- Stop = 12
- Destroy = 13
- Info = 14
-
- Spawn = 21
- Link = 22
- Run = 23
- Stream = 24
-
- NetIn = 31
- NetOut = 32
-
- CopyIn = 41
- CopyOut = 42
-
- LimitMemory = 51
- LimitDisk = 52
- LimitBandwidth = 53
-
- Ping = 91
- List = 92
- Echo = 93
-
- def self.generate_klass_map(suffix)
- map = Hash[self.constants.map do |name|
- klass_name = "#{name}#{suffix}"
- if Protocol.const_defined?(klass_name)
- [const_get(name), Protocol.const_get(klass_name)]
- end
- end]
-
- if map.respond_to?(:default_proc=)
- map.default_proc = lambda do |h, k|
- raise "Unknown request type: #{k}"
- end
- end
-
- map
- end
-
- def self.to_request_klass(type)
- @request_klass_map ||= generate_klass_map("Request")
- @request_klass_map[type]
- end
-
- def self.to_response_klass(type)
- @response_klass_map ||= generate_klass_map("Response")
- @response_klass_map[type]
- end
- end
-
TypeConverter = {
:bool => lambda do |arg|
return true if arg.downcase == "true"
@@ -131,13 +76,28 @@ def self.to_ruby_type(str, protocol_type)
raise TypeError, "Non-existent protocol type passed: '#{protocol_type}'."
end
- class BaseMessage
- include Beefcake::Message
+ module BaseMessage
+ def self.included(base)
+ base.send(:include, Beefcake::Message)
+
+ if base.name =~ /(Request|Response)$/
+ base.extend(ClassMethods)
+
+ case $1
+ when "Request"
+ base.send(:include, BaseRequest)
+ when "Response"
+ base.send(:include, BaseResponse)
+ end
+ end
+ end
def safe
- yield
- rescue WrongTypeError, InvalidValueError, RequiredFieldNotSetError => e
- raise ProtocolError, e
+ yield
+ rescue Beefcake::Message::WrongTypeError,
+ Beefcake::Message::InvalidValueError,
+ Beefcake::Message::RequiredFieldNotSetError => e
+ raise ProtocolError, e
end
def reload
@@ -146,6 +106,12 @@ def reload
end
end
+ def wrap
+ safe do
+ Message.new(:type => self.class.type, :payload => encode)
+ end
+ end
+
def to_hash
fields.values.inject({}) do |h, fld|
if v = self[fld.name]
@@ -156,9 +122,9 @@ def to_hash
end
end
- class << self
+ module ClassMethods
def type
- Type.const_get(type_name)
+ Message::Type.const_get(type_name)
end
def type_camelized
@@ -177,61 +143,26 @@ def type_name
end
end
- class BaseRequest < BaseMessage
+ module BaseRequest
def create_response(attributes = {})
klass_name = self.class.name.gsub(/Request$/, "Response")
klass_name = klass_name.split("::").last
klass = Protocol.const_get(klass_name)
klass.new(attributes)
end
-
- def wrap
- safe do
- WrappedRequest.new(:type => self.class.type, :payload => encode)
- end
- end
-
- def self.description
- type_underscored.gsub("_", " ").capitalize
- end
end
- class BaseResponse < BaseMessage
+ module BaseResponse
def ok?
!error?
end
def error?
- self.class.type == Type::Error
- end
-
- def wrap
- safe do
- WrappedResponse.new(:type => self.class.type, :payload => encode)
- end
- end
- end
-
- class WrappedRequest < BaseRequest
- required :type, Type, 1
- required :payload, :string, 2
-
- def request
- safe do
- Type.to_request_klass(type).decode(payload)
- end
- end
- end
-
- class WrappedResponse < BaseResponse
- required :type, Type, 1
- required :payload, :string, 2
-
- def response
- safe do
- Type.to_response_klass(type).decode(payload)
- end
+ self.class.type == Message::Type::Error
end
end
end
end
+
+require "warden/protocol/pb"
+require "warden/protocol/message"
View
4 warden-protocol/lib/warden/protocol/buffer.rb
@@ -31,13 +31,13 @@ def <<(data)
def each_request(&blk)
each do |payload|
- yield(Warden::Protocol::WrappedRequest.decode(payload).request)
+ yield(Warden::Protocol::Message.decode(payload).request)
end
end
def each_response(&blk)
each do |payload|
- yield(Warden::Protocol::WrappedResponse.decode(payload).response)
+ yield(Warden::Protocol::Message.decode(payload).response)
end
end
View
13 warden-protocol/lib/warden/protocol/build.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+set -e
+
+cd pb
+
+export BEEFCAKE_NAMESPACE=Warden::Protocol
+
+out=bundle
+(echo "package protocol;" && (find . -name '*.proto' | sort | xargs cat | sed /^package/d)) > $out
+protoc --beefcake_out=. $out
+sed -e "s/Beefcake::Message/Warden::Protocol::BaseMessage/" $out.pb.rb > ../pb.rb
+rm -f $out*
View
20 warden-protocol/lib/warden/protocol/copy_in.rb
@@ -1,20 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class CopyInRequest < BaseRequest
- required :handle, :string, 1
- required :src_path, :string, 2
- required :dst_path, :string, 3
-
- def self.description
- "Copy files/directories into the container."
- end
- end
-
- class CopyInResponse < BaseResponse
- end
- end
-end
View
21 warden-protocol/lib/warden/protocol/copy_out.rb
@@ -1,21 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class CopyOutRequest < BaseRequest
- required :handle, :string, 1
- required :src_path, :string, 2
- required :dst_path, :string, 3
- optional :owner, :string, 4
-
- def self.description
- "Copy files/directories out of the container."
- end
- end
-
- class CopyOutResponse < BaseResponse
- end
- end
-end
View
34 warden-protocol/lib/warden/protocol/create.rb
@@ -1,34 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class CreateRequest < BaseRequest
- class BindMount < BaseMessage
- module Mode
- RO = 0
- RW = 1
- end
-
- required :src_path, :string, 1
- required :dst_path, :string, 2
- required :mode, BindMount::Mode, 3
- end
-
- repeated :bind_mounts, BindMount, 1
- optional :grace_time, :uint32, 2
- optional :handle, :string, 3
- optional :network, :string, 4
- optional :rootfs, :string, 5
-
- def self.description
- "Create a container, optionally pass options."
- end
- end
-
- class CreateResponse < BaseResponse
- required :handle, :string, 1
- end
- end
-end
View
18 warden-protocol/lib/warden/protocol/destroy.rb
@@ -1,18 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class DestroyRequest < BaseRequest
- required :handle, :string, 1
-
- def self.description
- "Shutdown a container."
- end
- end
-
- class DestroyResponse < BaseResponse
- end
- end
-end
View
19 warden-protocol/lib/warden/protocol/echo.rb
@@ -1,19 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class EchoRequest < BaseRequest
- required :message, :string, 1
-
- def self.description
- "Echo a message."
- end
- end
-
- class EchoResponse < BaseResponse
- required :message, :string, 1
- end
- end
-end
View
13 warden-protocol/lib/warden/protocol/error.rb
@@ -1,13 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class ErrorResponse < BaseResponse
- optional :message, :string, 2
- optional :data, :string, 4
- repeated :backtrace, :string, 3
- end
- end
-end
View
81 warden-protocol/lib/warden/protocol/info.rb
@@ -1,81 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class InfoRequest < BaseRequest
- required :handle, :string, 1
-
- def self.description
- "Show metadata for a container."
- end
- end
-
- class InfoResponse < BaseResponse
- class MemoryStat < BaseMessage
- optional :cache, :uint64, 1
- optional :rss, :uint64, 2
- optional :mapped_file, :uint64, 3
- optional :pgpgin, :uint64, 4
- optional :pgpgout, :uint64, 5
- optional :swap, :uint64, 6
- optional :pgfault, :uint64, 7
- optional :pgmajfault, :uint64, 8
- optional :inactive_anon, :uint64, 9
- optional :active_anon, :uint64, 10
- optional :inactive_file, :uint64, 11
- optional :active_file, :uint64, 12
- optional :unevictable, :uint64, 13
- optional :hierarchical_memory_limit, :uint64, 14
- optional :hierarchical_memsw_limit, :uint64, 15
- optional :total_cache, :uint64, 16
- optional :total_rss, :uint64, 17
- optional :total_mapped_file, :uint64, 18
- optional :total_pgpgin, :uint64, 19
- optional :total_pgpgout, :uint64, 20
- optional :total_swap, :uint64, 21
- optional :total_pgfault, :uint64, 22
- optional :total_pgmajfault, :uint64, 23
- optional :total_inactive_anon, :uint64, 24
- optional :total_active_anon, :uint64, 25
- optional :total_inactive_file, :uint64, 26
- optional :total_active_file, :uint64, 27
- optional :total_unevictable, :uint64, 28
- end
-
- class CpuStat < BaseMessage
- optional :usage, :uint64, 1 # Nanoseconds
- optional :user, :uint64, 2 # Hz (USER_HZ specifically)
- optional :system, :uint64, 3 # Hz
- end
-
- class DiskStat < BaseMessage
- optional :bytes_used, :uint64, 1
- optional :inodes_used, :uint64, 2
- end
-
- class BandwidthStat < BaseMessage
- optional :in_rate, :uint64, 1
- optional :in_burst, :uint64, 2
- optional :out_rate, :uint64, 3
- optional :out_burst, :uint64, 4
- end
-
- optional :state, :string, 10
-
- repeated :events, :string, 20
-
- optional :host_ip, :string, 30
- optional :container_ip, :string, 31
- optional :container_path, :string, 32
-
- optional :memory_stat, MemoryStat, 40
- optional :cpu_stat, CpuStat, 41
- optional :disk_stat, DiskStat, 42
- optional :bandwidth_stat, BandwidthStat, 43
-
- repeated :job_ids, :uint64, 44
- end
- end
-end
View
18 warden-protocol/lib/warden/protocol/limit_bandwidth.rb
@@ -1,18 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class LimitBandwidthRequest < BaseRequest
- required :handle, :string, 1
- optional :rate, :uint64, 2 # Bandwidth rate in byte(s)/sec
- optional :burst, :uint64, 3 # Allow burst size in byte(s)
- end
-
- class LimitBandwidthResponse < BaseResponse
- optional :rate, :uint64, 1 # Bandwidth rate in byte(s)/sec
- optional :burst, :uint64, 2 # Allow burst size in byte(s)
- end
- end
-end
View
50 warden-protocol/lib/warden/protocol/limit_disk.rb
@@ -1,50 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
-
- # The byte limits are used to compute block limits on the server side.
-
- class LimitDiskRequest < BaseRequest
- required :handle, :string, 1
-
- optional :block_limit, :uint32, 10 # Alias for `block_hard`
- optional :block, :uint64, 11 # Alias for `block_hard`
- optional :block_soft, :uint64, 12
- optional :block_hard, :uint64, 13
-
- optional :inode_limit, :uint32, 20 # Alias for `inode_hard`
- optional :inode, :uint64, 21 # Alias for `inode_hard`
- optional :inode_soft, :uint64, 22
- optional :inode_hard, :uint64, 23
-
- optional :byte_limit, :uint32, 30 # Alias for `byte_hard`
- optional :byte, :uint64, 31 # Alias for `byte_hard`
- optional :byte_soft, :uint64, 32
- optional :byte_hard, :uint64, 33
-
- def self.description
- "set or get the disk limit for the container."
- end
- end
-
- class LimitDiskResponse < BaseResponse
- optional :block_limit, :uint32, 10 # Alias for `block_hard`
- optional :block, :uint64, 11 # Alias for `block_hard`
- optional :block_soft, :uint64, 12
- optional :block_hard, :uint64, 13
-
- optional :inode_limit, :uint32, 20 # Alias for `inode_hard`
- optional :inode, :uint64, 21 # Alias for `inode_hard`
- optional :inode_soft, :uint64, 22
- optional :inode_hard, :uint64, 23
-
- optional :byte_limit, :uint32, 30 # Alias for `byte_hard`
- optional :byte, :uint64, 31 # Alias for `byte_hard`
- optional :byte_soft, :uint64, 32
- optional :byte_hard, :uint64, 33
- end
- end
-end
View
20 warden-protocol/lib/warden/protocol/limit_memory.rb
@@ -1,20 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class LimitMemoryRequest < BaseRequest
- required :handle, :string, 1
- optional :limit_in_bytes, :uint64, 2
-
- def self.description
- "Set or get the memory limit for the container."
- end
- end
-
- class LimitMemoryResponse < BaseResponse
- optional :limit_in_bytes, :uint64, 1
- end
- end
-end
View
22 warden-protocol/lib/warden/protocol/link.rb
@@ -1,22 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class LinkRequest < BaseRequest
- required :handle, :string, 1
- required :job_id, :uint32, 2
-
- def self.description
- "Do blocking read on results from a job."
- end
- end
-
- class LinkResponse < BaseResponse
- optional :exit_status, :uint32, 1
- optional :stdout, :string, 2
- optional :stderr, :string, 3
- end
- end
-end
View
17 warden-protocol/lib/warden/protocol/list.rb
@@ -1,17 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class ListRequest < BaseRequest
- def self.description
- "List containers."
- end
- end
-
- class ListResponse < BaseResponse
- repeated :handles, :string, 1
- end
- end
-end
View
50 warden-protocol/lib/warden/protocol/message.rb
@@ -0,0 +1,50 @@
+# coding: UTF-8
+
+require "warden/protocol/base"
+
+module Warden
+ module Protocol
+ class Message
+ module Type
+ def self.generate_klass_map(suffix)
+ map = Hash[self.constants.map do |name|
+ klass_name = "#{name}#{suffix}"
+ if Protocol.const_defined?(klass_name)
+ [const_get(name), Protocol.const_get(klass_name)]
+ end
+ end]
+
+ if map.respond_to?(:default_proc=)
+ map.default_proc = lambda do |h, k|
+ raise "Unknown request type: #{k}"
+ end
+ end
+
+ map
+ end
+
+ def self.to_request_klass(type)
+ @request_klass_map ||= generate_klass_map("Request")
+ @request_klass_map[type]
+ end
+
+ def self.to_response_klass(type)
+ @response_klass_map ||= generate_klass_map("Response")
+ @response_klass_map[type]
+ end
+ end
+
+ def request
+ safe do
+ Type.to_request_klass(type).decode(payload)
+ end
+ end
+
+ def response
+ safe do
+ Type.to_response_klass(type).decode(payload)
+ end
+ end
+ end
+ end
+end
View
22 warden-protocol/lib/warden/protocol/net_in.rb
@@ -1,22 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class NetInRequest < BaseRequest
- required :handle, :string, 1
- optional :container_port, :uint32, 2
- optional :host_port, :uint32, 3
-
- def self.description
- "Forward port on external interface to container."
- end
- end
-
- class NetInResponse < BaseResponse
- required :host_port, :uint32, 1
- required :container_port, :uint32, 2
- end
- end
-end
View
20 warden-protocol/lib/warden/protocol/net_out.rb
@@ -1,20 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class NetOutRequest < BaseRequest
- required :handle, :string, 1
- optional :network, :string, 2
- optional :port, :uint32, 3
-
- def self.description
- "Allow traffic from the container to address."
- end
- end
-
- class NetOutResponse < BaseResponse
- end
- end
-end
View
494 warden-protocol/lib/warden/protocol/pb.rb
@@ -0,0 +1,494 @@
+## Generated from bundle for protocol
+require "beefcake"
+
+module Warden
+ module Protocol
+
+ class CopyInRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ required :src_path, :string, 2
+ required :dst_path, :string, 3
+
+ end
+
+ class CopyInResponse
+ include Warden::Protocol::BaseMessage
+
+
+
+ end
+
+ class CopyOutRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ required :src_path, :string, 2
+ required :dst_path, :string, 3
+ optional :owner, :string, 4
+
+ end
+
+ class CopyOutResponse
+ include Warden::Protocol::BaseMessage
+
+
+
+ end
+
+ class CreateRequest
+ include Warden::Protocol::BaseMessage
+
+
+ class BindMount
+ include Warden::Protocol::BaseMessage
+
+ module Mode
+ RO = 0
+ RW = 1
+ end
+
+ required :src_path, :string, 1
+ required :dst_path, :string, 2
+ required :mode, CreateRequest::BindMount::Mode, 3
+
+ end
+
+ repeated :bind_mounts, CreateRequest::BindMount, 1
+ optional :grace_time, :uint32, 2
+ optional :handle, :string, 3
+ optional :network, :string, 4
+ optional :rootfs, :string, 5
+
+ end
+
+ class CreateResponse
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+
+ end
+
+ class DestroyRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+
+ end
+
+ class DestroyResponse
+ include Warden::Protocol::BaseMessage
+
+
+
+ end
+
+ class EchoRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :message, :string, 1
+
+ end
+
+ class EchoResponse
+ include Warden::Protocol::BaseMessage
+
+
+ required :message, :string, 1
+
+ end
+
+ class ErrorResponse
+ include Warden::Protocol::BaseMessage
+
+
+ optional :message, :string, 2
+ optional :data, :string, 4
+ repeated :backtrace, :string, 3
+
+ end
+
+ class InfoRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+
+ end
+
+ class InfoResponse
+ include Warden::Protocol::BaseMessage
+
+
+ class MemoryStat
+ include Warden::Protocol::BaseMessage
+
+
+ optional :cache, :uint64, 1
+ optional :rss, :uint64, 2
+ optional :mapped_file, :uint64, 3
+ optional :pgpgin, :uint64, 4
+ optional :pgpgout, :uint64, 5
+ optional :swap, :uint64, 6
+ optional :pgfault, :uint64, 7
+ optional :pgmajfault, :uint64, 8
+ optional :inactive_anon, :uint64, 9
+ optional :active_anon, :uint64, 10
+ optional :inactive_file, :uint64, 11
+ optional :active_file, :uint64, 12
+ optional :unevictable, :uint64, 13
+ optional :hierarchical_memory_limit, :uint64, 14
+ optional :hierarchical_memsw_limit, :uint64, 15
+ optional :total_cache, :uint64, 16
+ optional :total_rss, :uint64, 17
+ optional :total_mapped_file, :uint64, 18
+ optional :total_pgpgin, :uint64, 19
+ optional :total_pgpgout, :uint64, 20
+ optional :total_swap, :uint64, 21
+ optional :total_pgfault, :uint64, 22
+ optional :total_pgmajfault, :uint64, 23
+ optional :total_inactive_anon, :uint64, 24
+ optional :total_active_anon, :uint64, 25
+ optional :total_inactive_file, :uint64, 26
+ optional :total_active_file, :uint64, 27
+ optional :total_unevictable, :uint64, 28
+
+ end
+
+ class CpuStat
+ include Warden::Protocol::BaseMessage
+
+
+ optional :usage, :uint64, 1
+ optional :user, :uint64, 2
+ optional :system, :uint64, 3
+
+ end
+
+ class DiskStat
+ include Warden::Protocol::BaseMessage
+
+
+ optional :bytes_used, :uint64, 1
+ optional :inodes_used, :uint64, 2
+
+ end
+
+ class BandwidthStat
+ include Warden::Protocol::BaseMessage
+
+
+ optional :in_rate, :uint64, 1
+ optional :in_burst, :uint64, 2
+ optional :out_rate, :uint64, 3
+ optional :out_burst, :uint64, 4
+
+ end
+
+ optional :state, :string, 10
+ repeated :events, :string, 20
+ optional :host_ip, :string, 30
+ optional :container_ip, :string, 31
+ optional :container_path, :string, 32
+ optional :memory_stat, InfoResponse::MemoryStat, 40
+ optional :cpu_stat, InfoResponse::CpuStat, 41
+ optional :disk_stat, InfoResponse::DiskStat, 42
+ optional :bandwidth_stat, InfoResponse::BandwidthStat, 43
+ repeated :job_ids, :uint64, 44
+
+ end
+
+ class LimitBandwidthRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ optional :rate, :uint64, 2
+ optional :burst, :uint64, 3
+
+ end
+
+ class LimitBandwidthResponse
+ include Warden::Protocol::BaseMessage
+
+
+ optional :rate, :uint64, 1
+ optional :burst, :uint64, 2
+
+ end
+
+ class LimitDiskRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ optional :block_limit, :uint32, 10
+ optional :block, :uint64, 11
+ optional :block_soft, :uint64, 12
+ optional :block_hard, :uint64, 13
+ optional :inode_limit, :uint32, 20
+ optional :inode, :uint64, 21
+ optional :inode_soft, :uint64, 22
+ optional :inode_hard, :uint64, 23
+ optional :byte_limit, :uint32, 30
+ optional :byte, :uint64, 31
+ optional :byte_soft, :uint64, 32
+ optional :byte_hard, :uint64, 33
+
+ end
+
+ class LimitDiskResponse
+ include Warden::Protocol::BaseMessage
+
+
+ optional :block_limit, :uint32, 10
+ optional :block, :uint64, 11
+ optional :block_soft, :uint64, 12
+ optional :block_hard, :uint64, 13
+ optional :inode_limit, :uint32, 20
+ optional :inode, :uint64, 21
+ optional :inode_soft, :uint64, 22
+ optional :inode_hard, :uint64, 23
+ optional :byte_limit, :uint32, 30
+ optional :byte, :uint64, 31
+ optional :byte_soft, :uint64, 32
+ optional :byte_hard, :uint64, 33
+
+ end
+
+ class LimitMemoryRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ optional :limit_in_bytes, :uint64, 2
+
+ end
+
+ class LimitMemoryResponse
+ include Warden::Protocol::BaseMessage
+
+
+ optional :limit_in_bytes, :uint64, 1
+
+ end
+
+ class LinkRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ required :job_id, :uint32, 2
+
+ end
+
+ class LinkResponse
+ include Warden::Protocol::BaseMessage
+
+
+ optional :exit_status, :uint32, 1
+ optional :stdout, :string, 2
+ optional :stderr, :string, 3
+
+ end
+
+ class ListRequest
+ include Warden::Protocol::BaseMessage
+
+
+
+ end
+
+ class ListResponse
+ include Warden::Protocol::BaseMessage
+
+
+ repeated :handles, :string, 1
+
+ end
+
+ class Message
+ include Warden::Protocol::BaseMessage
+
+ module Type
+ Error = 1
+ Create = 11
+ Stop = 12
+ Destroy = 13
+ Info = 14
+ Spawn = 21
+ Link = 22
+ Run = 23
+ Stream = 24
+ NetIn = 31
+ NetOut = 32
+ CopyIn = 41
+ CopyOut = 42
+ LimitMemory = 51
+ LimitDisk = 52
+ LimitBandwidth = 53
+ Ping = 91
+ List = 92
+ Echo = 93
+ end
+
+ required :type, Message::Type, 1
+ required :payload, :bytes, 2
+
+ end
+
+ class NetInRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ optional :host_port, :uint32, 3
+ optional :container_port, :uint32, 2
+
+ end
+
+ class NetInResponse
+ include Warden::Protocol::BaseMessage
+
+
+ required :host_port, :uint32, 1
+ required :container_port, :uint32, 2
+
+ end
+
+ class NetOutRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ optional :network, :string, 2
+ optional :port, :uint32, 3
+
+ end
+
+ class NetOutResponse
+ include Warden::Protocol::BaseMessage
+
+
+
+ end
+
+ class PingRequest
+ include Warden::Protocol::BaseMessage
+
+
+
+ end
+
+ class PingResponse
+ include Warden::Protocol::BaseMessage
+
+
+
+ end
+
+ class ResourceLimits
+ include Warden::Protocol::BaseMessage
+
+
+ optional :as, :uint64, 1
+ optional :core, :uint64, 2
+ optional :cpu, :uint64, 3
+ optional :data, :uint64, 4
+ optional :fsize, :uint64, 5
+ optional :locks, :uint64, 6
+ optional :memlock, :uint64, 7
+ optional :msgqueue, :uint64, 8
+ optional :nice, :uint64, 9
+ optional :nofile, :uint64, 10
+ optional :nproc, :uint64, 11
+ optional :rss, :uint64, 12
+ optional :rtprio, :uint64, 13
+ optional :sigpending, :uint64, 14
+ optional :stack, :uint64, 15
+
+ end
+
+ class RunRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ required :script, :string, 2
+ optional :privileged, :bool, 3, :default => false
+ optional :rlimits, ResourceLimits, 4
+
+ end
+
+ class RunResponse
+ include Warden::Protocol::BaseMessage
+
+
+ optional :exit_status, :uint32, 1
+ optional :stdout, :string, 2
+ optional :stderr, :string, 3
+
+ end
+
+ class SpawnRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ required :script, :string, 2
+ optional :privileged, :bool, 3, :default => false
+ optional :rlimits, ResourceLimits, 4
+
+ end
+
+ class SpawnResponse
+ include Warden::Protocol::BaseMessage
+
+
+ required :job_id, :uint32, 1
+
+ end
+
+ class StopRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ optional :background, :bool, 10, :default => false
+ optional :kill, :bool, 20, :default => false
+
+ end
+
+ class StopResponse
+ include Warden::Protocol::BaseMessage
+
+
+
+ end
+
+ class StreamRequest
+ include Warden::Protocol::BaseMessage
+
+
+ required :handle, :string, 1
+ required :job_id, :uint32, 2
+
+ end
+
+ class StreamResponse
+ include Warden::Protocol::BaseMessage
+
+
+ optional :name, :string, 1
+ optional :data, :string, 2
+ optional :exit_status, :uint32, 3
+
+ end
+ end
+end
View
10 warden-protocol/lib/warden/protocol/pb/copy_in.proto
@@ -0,0 +1,10 @@
+package warden;
+
+message CopyInRequest {
+ required string handle = 1;
+ required string src_path = 2;
+ required string dst_path = 3;
+}
+
+message CopyInResponse {
+}
View
11 warden-protocol/lib/warden/protocol/pb/copy_out.proto
@@ -0,0 +1,11 @@
+package warden;
+
+message CopyOutRequest {
+ required string handle = 1;
+ required string src_path = 2;
+ required string dst_path = 3;
+ optional string owner = 4;
+}
+
+message CopyOutResponse {
+}
View
28 warden-protocol/lib/warden/protocol/pb/create.proto
@@ -0,0 +1,28 @@
+package warden;
+
+message CreateRequest {
+ message BindMount {
+ enum Mode {
+ RO = 0;
+ RW = 1;
+ }
+
+ required string src_path = 1;
+ required string dst_path = 2;
+ required Mode mode = 3;
+ }
+
+ repeated BindMount bind_mounts = 1;
+
+ optional uint32 grace_time = 2;
+
+ optional string handle = 3;
+
+ optional string network = 4;
+
+ optional string rootfs = 5;
+}
+
+message CreateResponse {
+ required string handle = 1;
+}
View
8 warden-protocol/lib/warden/protocol/pb/destroy.proto
@@ -0,0 +1,8 @@
+package warden;
+
+message DestroyRequest {
+ required string handle = 1;
+}
+
+message DestroyResponse {
+}
View
9 warden-protocol/lib/warden/protocol/pb/echo.proto
@@ -0,0 +1,9 @@
+package warden;
+
+message EchoRequest {
+ required string message = 1;
+}
+
+message EchoResponse {
+ required string message = 1;
+}
View
7 warden-protocol/lib/warden/protocol/pb/error.proto
@@ -0,0 +1,7 @@
+package warden;
+
+message ErrorResponse {
+ optional string message = 2;
+ optional string data = 4;
+ repeated string backtrace = 3;
+}
View
71 warden-protocol/lib/warden/protocol/pb/info.proto
@@ -0,0 +1,71 @@
+package warden;
+
+message InfoRequest {
+ required string handle = 1;
+}
+
+message InfoResponse {
+ message MemoryStat {
+ optional uint64 cache = 1;
+ optional uint64 rss = 2;
+ optional uint64 mapped_file = 3;
+ optional uint64 pgpgin = 4;
+ optional uint64 pgpgout = 5;
+ optional uint64 swap = 6;
+ optional uint64 pgfault = 7;
+ optional uint64 pgmajfault = 8;
+ optional uint64 inactive_anon = 9;
+ optional uint64 active_anon = 10;
+ optional uint64 inactive_file = 11;
+ optional uint64 active_file = 12;
+ optional uint64 unevictable = 13;
+ optional uint64 hierarchical_memory_limit = 14;
+ optional uint64 hierarchical_memsw_limit = 15;
+ optional uint64 total_cache = 16;
+ optional uint64 total_rss = 17;
+ optional uint64 total_mapped_file = 18;
+ optional uint64 total_pgpgin = 19;
+ optional uint64 total_pgpgout = 20;
+ optional uint64 total_swap = 21;
+ optional uint64 total_pgfault = 22;
+ optional uint64 total_pgmajfault = 23;
+ optional uint64 total_inactive_anon = 24;
+ optional uint64 total_active_anon = 25;
+ optional uint64 total_inactive_file = 26;
+ optional uint64 total_active_file = 27;
+ optional uint64 total_unevictable = 28;
+ }
+
+ message CpuStat {
+ optional uint64 usage = 1; // Nanoseconds
+ optional uint64 user = 2; // Hz (USER_HZ specifically)
+ optional uint64 system = 3; // Hz
+ }
+
+ message DiskStat {
+ optional uint64 bytes_used = 1;
+ optional uint64 inodes_used = 2;
+ }
+
+ message BandwidthStat {
+ optional uint64 in_rate = 1;
+ optional uint64 in_burst = 2;
+ optional uint64 out_rate = 3;
+ optional uint64 out_burst = 4;
+ }
+
+ optional string state = 10;
+
+ repeated string events = 20;
+
+ optional string host_ip = 30;
+ optional string container_ip = 31;
+ optional string container_path = 32;
+
+ optional MemoryStat memory_stat = 40;
+ optional CpuStat cpu_stat = 41;
+ optional DiskStat disk_stat = 42;
+ optional BandwidthStat bandwidth_stat = 43;
+
+ repeated uint64 job_ids = 44;
+}
View
13 warden-protocol/lib/warden/protocol/pb/limit_bandwidth.proto
@@ -0,0 +1,13 @@
+package warden;
+
+message LimitBandwidthRequest {
+ required string handle = 1;
+
+ optional uint64 rate = 2; // Bandwidth rate in byte(s)/sec
+ optional uint64 burst = 3; // Allow burst size in byte(s)
+}
+
+message LimitBandwidthResponse {
+ optional uint64 rate = 1; // Bandwidth rate in byte(s)/sec
+ optional uint64 burst = 2; // Allow burst size in byte(s)
+}
View
39 warden-protocol/lib/warden/protocol/pb/limit_disk.proto
@@ -0,0 +1,39 @@
+package warden;
+
+// The byte limits are used to compute block limits on the server side.
+
+message LimitDiskRequest {
+ required string handle = 1;
+
+ optional uint32 block_limit = 10; // Alias for `block_hard`
+ optional uint64 block = 11; // Alias for `block_hard`
+ optional uint64 block_soft = 12;
+ optional uint64 block_hard = 13;
+
+ optional uint32 inode_limit = 20; // Alias for `inode_hard`
+ optional uint64 inode = 21; // Alias for `inode_hard`
+ optional uint64 inode_soft = 22;
+ optional uint64 inode_hard = 23;
+
+ optional uint32 byte_limit = 30; // Alias for `byte_hard`
+ optional uint64 byte = 31; // Alias for `byte_hard`
+ optional uint64 byte_soft = 32;
+ optional uint64 byte_hard = 33;
+}
+
+message LimitDiskResponse {
+ optional uint32 block_limit = 10; // Alias for `block_hard`
+ optional uint64 block = 11; // Alias for `block_hard`
+ optional uint64 block_soft = 12;
+ optional uint64 block_hard = 13;
+
+ optional uint32 inode_limit = 20; // Alias for `inode_hard`
+ optional uint64 inode = 21; // Alias for `inode_hard`
+ optional uint64 inode_soft = 22;
+ optional uint64 inode_hard = 23;
+
+ optional uint32 byte_limit = 30; // Alias for `byte_hard`
+ optional uint64 byte = 31; // Alias for `byte_hard`
+ optional uint64 byte_soft = 32;
+ optional uint64 byte_hard = 33;
+}
View
11 warden-protocol/lib/warden/protocol/pb/limit_memory.proto
@@ -0,0 +1,11 @@
+package warden;
+
+message LimitMemoryRequest {
+ required string handle = 1;
+
+ optional uint64 limit_in_bytes = 2;
+}
+
+message LimitMemoryResponse {
+ optional uint64 limit_in_bytes = 1;
+}
View
13 warden-protocol/lib/warden/protocol/pb/link.proto
@@ -0,0 +1,13 @@
+package warden;
+
+message LinkRequest {
+ required string handle = 1;
+
+ required uint32 job_id = 2;
+}
+
+message LinkResponse {
+ optional uint32 exit_status = 1;
+ optional string stdout = 2;
+ optional string stderr = 3;
+}
View
8 warden-protocol/lib/warden/protocol/pb/list.proto
@@ -0,0 +1,8 @@
+package warden;
+
+message ListRequest {
+}
+
+message ListResponse {
+ repeated string handles = 1;
+}
View
34 warden-protocol/lib/warden/protocol/pb/message.proto
@@ -0,0 +1,34 @@
+package warden;
+
+message Message {
+ enum Type {
+ Error = 1;
+
+ Create = 11;
+ Stop = 12;
+ Destroy = 13;
+ Info = 14;
+
+ Spawn = 21;
+ Link = 22;
+ Run = 23;
+ Stream = 24;
+
+ NetIn = 31;
+ NetOut = 32;
+
+ CopyIn = 41;
+ CopyOut = 42;
+
+ LimitMemory = 51;
+ LimitDisk = 52;
+ LimitBandwidth = 53;
+
+ Ping = 91;
+ List = 92;
+ Echo = 93;
+ }
+
+ required Type type = 1;
+ required bytes payload = 2;
+}
View
13 warden-protocol/lib/warden/protocol/pb/net_in.proto
@@ -0,0 +1,13 @@
+package warden;
+
+message NetInRequest {
+ required string handle = 1;
+
+ optional uint32 host_port = 3;
+ optional uint32 container_port = 2;
+}
+
+message NetInResponse {
+ required uint32 host_port = 1;
+ required uint32 container_port = 2;
+}
View
11 warden-protocol/lib/warden/protocol/pb/net_out.proto
@@ -0,0 +1,11 @@
+package warden;
+
+message NetOutRequest {
+ required string handle = 1;
+
+ optional string network = 2;
+ optional uint32 port = 3;
+}
+
+message NetOutResponse {
+}
View
7 warden-protocol/lib/warden/protocol/pb/ping.proto
@@ -0,0 +1,7 @@
+package warden;
+
+message PingRequest {
+}
+
+message PingResponse {
+}
View
19 warden-protocol/lib/warden/protocol/pb/resource_limits.proto
@@ -0,0 +1,19 @@
+package warden;
+
+message ResourceLimits {
+ optional uint64 as = 1;
+ optional uint64 core = 2;
+ optional uint64 cpu = 3;
+ optional uint64 data = 4;
+ optional uint64 fsize = 5;
+ optional uint64 locks = 6;
+ optional uint64 memlock = 7;
+ optional uint64 msgqueue = 8;
+ optional uint64 nice = 9;
+ optional uint64 nofile = 10;
+ optional uint64 nproc = 11;
+ optional uint64 rss = 12;
+ optional uint64 rtprio = 13;
+ optional uint64 sigpending = 14;
+ optional uint64 stack = 15;
+}
View
15 warden-protocol/lib/warden/protocol/pb/run.proto
@@ -0,0 +1,15 @@
+package warden;
+
+message RunRequest {
+ required string handle = 1;
+
+ required string script = 2;
+ optional bool privileged = 3 [default = false];
+ optional ResourceLimits rlimits = 4;
+}
+
+message RunResponse {
+ optional uint32 exit_status = 1;
+ optional string stdout = 2;
+ optional string stderr = 3;
+}
View
13 warden-protocol/lib/warden/protocol/pb/spawn.proto
@@ -0,0 +1,13 @@
+package warden;
+
+message SpawnRequest {
+ required string handle = 1;
+
+ required string script = 2;
+ optional bool privileged = 3 [default = false];
+ optional ResourceLimits rlimits = 4;
+}
+
+message SpawnResponse {
+ required uint32 job_id = 1;
+}
View
11 warden-protocol/lib/warden/protocol/pb/stop.proto
@@ -0,0 +1,11 @@
+package warden;
+
+message StopRequest {
+ required string handle = 1;
+
+ optional bool background = 10 [default = false];
+ optional bool kill = 20 [default = false];
+}
+
+message StopResponse {
+}
View
13 warden-protocol/lib/warden/protocol/pb/stream.proto
@@ -0,0 +1,13 @@
+package warden;
+
+message StreamRequest {
+ required string handle = 1;
+
+ required uint32 job_id = 2;
+}
+
+message StreamResponse {
+ optional string name = 1;
+ optional string data = 2;
+ optional uint32 exit_status = 3;
+}
View
16 warden-protocol/lib/warden/protocol/ping.rb
@@ -1,16 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class PingRequest < BaseRequest
- def self.description
- "Ping warden."
- end
- end
-
- class PingResponse < BaseResponse
- end
- end
-end
View
25 warden-protocol/lib/warden/protocol/resource_limits.rb
@@ -1,25 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class ResourceLimits < BaseMessage
- optional :as, :uint64, 1
- optional :core, :uint64, 2
- optional :cpu, :uint64, 3
- optional :data, :uint64, 4
- optional :fsize, :uint64, 5
- optional :locks, :uint64, 6
- optional :memlock, :uint64, 7
- optional :msgqueue, :uint64, 8
- optional :nice, :uint64, 9
- optional :nofile, :uint64, 10
- optional :nproc, :uint64, 11
- optional :rss, :uint64, 12
- optional :rtprio, :uint64, 13
- optional :sigpending, :uint64, 14
- optional :stack, :uint64, 15
- end
- end
-end
View
25 warden-protocol/lib/warden/protocol/run.rb
@@ -1,25 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-require "warden/protocol/resource_limits"
-
-module Warden
- module Protocol
- class RunRequest < BaseRequest
- required :handle, :string, 1
- required :script, :string, 2
- optional :privileged, :bool, 3, :default => false
- optional :rlimits, ResourceLimits, 4
-
- def self.description
- "Short hand for spawn(link(cmd)) i.e. spawns a command, links to the result."
- end
- end
-
- class RunResponse < BaseResponse
- optional :exit_status, :uint32, 1
- optional :stdout, :string, 2
- optional :stderr, :string, 3
- end
- end
-end
View
23 warden-protocol/lib/warden/protocol/spawn.rb
@@ -1,23 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-require "warden/protocol/resource_limits"
-
-module Warden
- module Protocol
- class SpawnRequest < BaseRequest
- required :handle, :string, 1
- required :script, :string, 2
- optional :privileged, :bool, 3, :default => false
- optional :rlimits, ResourceLimits, 4
-
- def self.description
- "Spawns a command inside a container and returns the job id."
- end
- end
-
- class SpawnResponse < BaseResponse
- required :job_id, :uint32, 1
- end
- end
-end
View
20 warden-protocol/lib/warden/protocol/stop.rb
@@ -1,20 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class StopRequest < BaseRequest
- required :handle, :string, 1
- optional :background, :bool, 10
- optional :kill, :bool, 20
-
- def self.description
- "Stop all processes inside a container."
- end
- end
-
- class StopResponse < BaseResponse
- end
- end
-end
View
22 warden-protocol/lib/warden/protocol/stream.rb
@@ -1,22 +0,0 @@
-# coding: UTF-8
-
-require "warden/protocol/base"
-
-module Warden
- module Protocol
- class StreamRequest < BaseRequest
- required :handle, :string, 1
- required :job_id, :uint32, 2
-
- def self.description
- "Do blocking stream on results from a job."
- end
- end
-
- class StreamResponse < BaseResponse
- optional :name, :string, 1
- optional :data, :string, 2
- optional :exit_status, :uint32, 3
- end
- end
-end
View
2 warden-protocol/lib/warden/protocol/version.rb
@@ -2,6 +2,6 @@
module Warden
module Protocol
- VERSION = "0.0.12"
+ VERSION = "0.1.1"
end
end
View
24 warden-protocol/spec/base_spec.rb
@@ -8,7 +8,7 @@
request = Warden::Protocol::SpawnRequest.new(:handle => "blah",
:script => "script")
wrapped = request.wrap
- wrapped.should be_an_instance_of(Warden::Protocol::WrappedRequest)
+ wrapped.should be_an_instance_of(Warden::Protocol::Message)
wrapped.type.should == Warden::Protocol::SpawnRequest.type
decoded = Warden::Protocol::SpawnRequest.decode(wrapped.payload)
decoded.handle.should == request.handle
@@ -28,7 +28,7 @@
it "should respond to #wrap" do
response = Warden::Protocol::SpawnResponse.new(:job_id => 1)
wrapped = response.wrap
- wrapped.should be_an_instance_of(Warden::Protocol::WrappedResponse)
+ wrapped.should be_an_instance_of(Warden::Protocol::Message)
wrapped.type.should == Warden::Protocol::SpawnResponse.type
decoded = Warden::Protocol::SpawnResponse.decode(wrapped.payload)
decoded.job_id.should == response.job_id
@@ -43,10 +43,10 @@
end
end
-describe Warden::Protocol::WrappedRequest do
+describe "wrapped request" do
it "should respond to #request" do
- w = Warden::Protocol::WrappedRequest.new
- w.type = Warden::Protocol::Type::Spawn
+ w = Warden::Protocol::Message.new
+ w.type = Warden::Protocol::Message::Type::Spawn
w.payload = Warden::Protocol::SpawnRequest.new(:handle => "blah",
:script => "script").encode
w.should be_valid
@@ -55,19 +55,19 @@
end
it "should wrap beefcake errors" do
- w = Warden::Protocol::WrappedRequest.new
- w.type = Warden::Protocol::Type::Spawn
+ w = Warden::Protocol::Message.new
+ w.type = Warden::Protocol::Message::Type::Spawn
w.payload = "bad payload"
w.should be_valid
expect { w.request }.to raise_error(Warden::Protocol::ProtocolError)
end
end
-describe Warden::Protocol::WrappedResponse do
+describe "wrapped response" do
it "should respond to #response" do
- w = Warden::Protocol::WrappedResponse.new
- w.type = Warden::Protocol::Type::Spawn
+ w = Warden::Protocol::Message.new
+ w.type = Warden::Protocol::Message::Type::Spawn
w.payload = Warden::Protocol::SpawnResponse.new(:handle => "blah",
:job_id => 2).encode
w.should be_valid
@@ -76,8 +76,8 @@
end
it "should wrap beefcake errors" do
- w = Warden::Protocol::WrappedResponse.new
- w.type = Warden::Protocol::Type::Spawn
+ w = Warden::Protocol::Message.new
+ w.type = Warden::Protocol::Message::Type::Spawn
w.payload = "bad payload"
w.should be_valid
View
1 warden-protocol/spec/buffer_spec.rb
@@ -2,7 +2,6 @@
require "spec_helper"
require "warden/protocol/buffer"
-require "warden/protocol/echo"
describe Warden::Protocol::Buffer do
let(:request) { Warden::Protocol::EchoRequest.new(:message => "request") }
View
3 warden-protocol/spec/copy_in_spec.rb
@@ -1,7 +1,6 @@
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/copy_in"
describe Warden::Protocol::CopyInRequest do
subject(:request) do
@@ -35,8 +34,6 @@
it "should respond to #create_response" do
request.create_response.should be_a(Warden::Protocol::CopyInResponse)
end
-
- it_should_behave_like "documented request"
end
describe Warden::Protocol::CopyInResponse do
View
3 warden-protocol/spec/copy_out_spec.rb
@@ -1,7 +1,6 @@
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/copy_out"
describe Warden::Protocol::CopyOutRequest do
subject(:request) do
@@ -40,8 +39,6 @@
it "should respond to #create_response" do
request.create_response.should be_a(Warden::Protocol::CopyOutResponse)
end
-
- it_should_behave_like "documented request"
end
describe Warden::Protocol::CopyOutResponse do
View
3 warden-protocol/spec/create_spec.rb
@@ -1,7 +1,6 @@
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/create"
describe Warden::Protocol::CreateRequest do
subject(:request) do
@@ -50,8 +49,6 @@
it "should respond to #create_response" do
request.create_response.should be_a(Warden::Protocol::CreateResponse)
end
-
- it_should_behave_like "documented request"
end
describe Warden::Protocol::CreateResponse do
View
3 warden-protocol/spec/destroy_spec.rb
@@ -1,7 +1,6 @@
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/destroy"
describe Warden::Protocol::DestroyRequest do
subject(:request) do
@@ -20,8 +19,6 @@
it "should respond to #create_response" do
request.create_response.should be_a(Warden::Protocol::DestroyResponse)
end
-
- it_should_behave_like "documented request"
end
describe Warden::Protocol::DestroyResponse do
View
4 warden-protocol/spec/echo_spec.rb
@@ -1,8 +1,6 @@
-# -*- coding: utf-8 -*-
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/echo"
describe Warden::Protocol::EchoRequest do
subject(:request) do
@@ -22,8 +20,6 @@
it "should respond to #create_response" do
request.create_response.should be_a(Warden::Protocol::EchoResponse)
end
-
- it_should_behave_like "documented request"
end
describe Warden::Protocol::EchoResponse do
View
1 warden-protocol/spec/error_spec.rb
@@ -1,7 +1,6 @@
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/error"
describe Warden::Protocol::ErrorResponse do
subject(:response) do
View
3 warden-protocol/spec/info_spec.rb
@@ -1,7 +1,6 @@
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/info"
describe Warden::Protocol::InfoRequest do
subject(:request) do
@@ -21,8 +20,6 @@
it "should respond to #create_response" do
request.create_response.should be_a(Warden::Protocol::InfoResponse)
end
-
- it_should_behave_like "documented request"
end
describe Warden::Protocol::InfoResponse::CpuStat do
View
3 warden-protocol/spec/limit_bandwidth_spec.rb
@@ -1,7 +1,6 @@
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/limit_bandwidth"
describe Warden::Protocol::LimitBandwidthRequest do
subject(:request) do
@@ -31,8 +30,6 @@
it "should respond to #create_response" do
request.create_response.should be_a(Warden::Protocol::LimitBandwidthResponse)
end
-
- it_should_behave_like "documented request"
end
describe Warden::Protocol::LimitBandwidthResponse do
View
3 warden-protocol/spec/limit_disk_spec.rb
@@ -1,7 +1,6 @@
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/limit_disk"
shared_examples "disk limiting" do
field :block_limit do
@@ -85,8 +84,6 @@
it "should respond to #create_response" do
request.create_response.should be_a(Warden::Protocol::LimitDiskResponse)
end
-
- it_should_behave_like "documented request"
end
describe Warden::Protocol::LimitDiskResponse do
View
3 warden-protocol/spec/limit_memory_spec.rb
@@ -1,7 +1,6 @@
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/limit_memory"
describe Warden::Protocol::LimitMemoryRequest do
subject(:request) do
@@ -26,8 +25,6 @@
it "should respond to #create_response" do
request.create_response.should be_a(Warden::Protocol::LimitMemoryResponse)
end
-
- it_should_behave_like "documented request"
end
describe Warden::Protocol::LimitMemoryResponse do
View
3 warden-protocol/spec/link_spec.rb
@@ -1,7 +1,6 @@
# coding: UTF-8
require "spec_helper"
-require "warden/protocol/link"
describe Warden::Protocol::LinkRequest do
subject(:request) do
@@ -26,8 +25,6 @@