miasma-lxd 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 768837675895e46e18d2454a8755dabf7a643689
4
- data.tar.gz: 3696866fc4fae82a6c807826927acb6bd727dac2
3
+ metadata.gz: ba646017086951faed7f23359b872ae84c1f8baf
4
+ data.tar.gz: 6ab50e243b95ca6f3ac766175ca239554a57b7c7
5
5
  SHA512:
6
- metadata.gz: 9b76ccc003a7a69d5a83f1d4d0fc683ae344a7e4b9c80e121d81f05271306a7a62c89287a0dfa1cc3739380edcae548c627999a776fb9354d65799ff0cd7248e
7
- data.tar.gz: 3c7c6f533d4c53855a5106118745356a9e77dfc060af697b18d1907d051b4fe83515b707622d9867d7753c2c6c61ca5dd9af5b4ca3a85f692ac3ffa9cd60d94f
6
+ metadata.gz: 39daf7fd1c6bd5e1d6f334de2aa4cc40595431ea25a53d46758bfd1972ce7530a18913c8a1b07dffd3214ca61b71b154a07ebe46bd48f268cfe7f9e4cedc24fd
7
+ data.tar.gz: c1607129c66022cbad4960c779b994a31d7210fc3295eb24bea8c49e8cc97caf558e31d7cec7d0a23948babc669919fbe9808f8b3f53ab85d816369678f4b728
data/CHANGELOG.md CHANGED
@@ -1,2 +1,9 @@
1
+ # v0.1.2
2
+ * Allow timeout configuration on exec waiter
3
+ * Do not automatically close connection on EOF
4
+ * Stream uploads instead of full read then write
5
+ * Allow return of status code
6
+ * Support sending custom environment variables
7
+
1
8
  # v0.1.0
2
9
  * Initial release
@@ -16,6 +16,9 @@ module Miasma
16
16
  'stopped' => :stopped
17
17
  )
18
18
 
19
+ # @return [Integer]
20
+ DEFAULT_EXEC_TIMEOUT = 20
21
+
19
22
  # Reload a server model's data
20
23
  #
21
24
  # @param server [Miasma::Models::Compute::Server]
@@ -161,7 +164,6 @@ module Miasma
161
164
  # @param io [IO-ish]
162
165
  # @param remote_path [String]
163
166
  # @return [TrueClass]
164
- # @todo update to write in chunks when over `n` size
165
167
  def server_put_file(server, io, remote_path, options={})
166
168
  request(
167
169
  :method => :post,
@@ -169,8 +171,9 @@ module Miasma
169
171
  :params => {
170
172
  :path => remote_path
171
173
  },
172
- :body => io.read,
174
+ :body => io,
173
175
  :headers => {
176
+ 'Transfer-Encoding' => 'chunked',
174
177
  'X-LXD-uid' => options.fetch(:uid, 0),
175
178
  'X-LXD-gid' => options.fetch(:gid, 0),
176
179
  'X-LXD-mode' => options.fetch(:mode, 0700)
@@ -185,7 +188,9 @@ module Miasma
185
188
  # @param command [String]
186
189
  # @param options [Hash]
187
190
  # @option options [IO] :stream write command output
188
- # @return [TrueClass, FalseClass] command was successful
191
+ # @option options [Integer] :return_exit_code
192
+ # @option options [Integer] :timeout
193
+ # @return [TrueClass, FalseClass, Integer] command was successful
189
194
  def server_execute(server, command, options={})
190
195
  result = request(
191
196
  :method => :post,
@@ -194,7 +199,8 @@ module Miasma
194
199
  :json => Smash.new(
195
200
  :command => Shellwords.shellwords(command),
196
201
  :interactive => true,
197
- 'wait-for-websocket' => true
202
+ 'wait-for-websocket' => true,
203
+ :environment => options.fetch(:environment, {})
198
204
  )
199
205
  )
200
206
  dest = URI.parse(api_endpoint)
@@ -225,12 +231,16 @@ module Miasma
225
231
  ]
226
232
  end
227
233
  ]
228
- wait_for_operation(operation, options.fetch(:timeout, 20))
234
+ wait_for_operation(operation, options.fetch(:timeout, DEFAULT_EXEC_TIMEOUT))
229
235
  websockets.map(&:last).map(&:close)
230
236
  result = request(
231
237
  :path => "operations/#{operation}"
232
238
  )
233
- result.get(:body, :metadata, :metadata, :return) == 0
239
+ if(options[:return_exit_code])
240
+ result.get(:body, :metadata, :metadata, :return)
241
+ else
242
+ result.get(:body, :metadata, :metadata, :return) == 0
243
+ end
234
244
  end
235
245
 
236
246
  protected
@@ -240,13 +250,13 @@ module Miasma
240
250
  # @param op_uuid [String]
241
251
  # @param timeout [Integer]
242
252
  # @return [TrueClass]
243
- def wait_for_operation(op_uuid, timeout=20)
253
+ def wait_for_operation(op_uuid, timeout=DEFAULT_EXEC_TIMEOUT)
244
254
  op_uuid = op_uuid.sub("/#{version}/operations/", '')
245
255
  request(
246
256
  :path => "operations/#{op_uuid}/wait",
247
257
  :params => {
248
258
  :status_code => 200,
249
- :timeout => 20
259
+ :timeout => timeout
250
260
  }
251
261
  )
252
262
  true
@@ -1,4 +1,4 @@
1
1
  module MiasmaLxd
2
2
  # Current library version
3
- VERSION = Gem::Version.new('0.1.0')
3
+ VERSION = Gem::Version.new('0.1.2')
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miasma-lxd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-05 00:00:00.000000000 Z
11
+ date: 2015-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bogo-websocket