hyperkit 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hyperkit/client/containers.rb +31 -13
- data/lib/hyperkit/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf6274925427cf1c5670ea2af9eac26f7c959c3e
|
4
|
+
data.tar.gz: 2ba1e84fb843852eb70f07622b2a64b7407dd629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2387348bed823792209239144e5f46157aff3c470a12531956392cc1dab6c8b76badde557a36c5208eea70a8cbd695267cd753ec8a53ece6125bf7fbd0a9491
|
7
|
+
data.tar.gz: 7a82b8c65626199c48c9eff76834662d81b9822904f4f6e4f5abd60964096ec6831825797a3770df919fc3b0962144375824ccb5a2c8e6bc725ad1c664cdff1c
|
@@ -284,6 +284,9 @@ module Hyperkit
|
|
284
284
|
# @param options [Hash] Additional data to be passed
|
285
285
|
# @option options [Hash] :environment Environment variables to set prior to command execution
|
286
286
|
# @option options [Boolean] :sync If <code>false</code>, returns an asynchronous operation that must be passed to {Hyperkit::Client::Operations#wait_for_operation}. If <code>true</code>, automatically waits and returns the result of the operation. Defaults to value of {Hyperkit::Configurable#auto_sync}.
|
287
|
+
# @option options [Boolean] :wait_for_websocket If <code>true</code> block and wait for a websocket connection to start.
|
288
|
+
# @option options [Boolean] :interactive If <code>true</code>a single websocket is returned and is mapped to a pts device for stdin, stdout and stderr of the execed process. If false, three pipes will be setup, one for each of stdin, stdout and stderr.
|
289
|
+
# @option options [Boolean] :record_output If <code>true</code>, captures the output of stdout and stderr.
|
287
290
|
# @return [Sawyer::Resource] Operation or result, depending value of <code>:sync</code> parameter and/or {Hyperkit::Client::auto_sync}
|
288
291
|
#
|
289
292
|
# @example Run a command (passed as a string) in container "test-container"
|
@@ -312,8 +315,9 @@ module Hyperkit
|
|
312
315
|
response = post(File.join(container_path(container), "exec"), {
|
313
316
|
command: command,
|
314
317
|
environment: opts[:environment] || {},
|
315
|
-
"wait-for-websocket" => false,
|
316
|
-
interactive: false
|
318
|
+
"wait-for-websocket" => options[:wait_for_websocket] || false,
|
319
|
+
interactive: options[:interactive] || false,
|
320
|
+
"record-output" => options[:record_output] || false
|
317
321
|
}).metadata
|
318
322
|
|
319
323
|
handle_async(response, options[:sync])
|
@@ -832,24 +836,31 @@ module Hyperkit
|
|
832
836
|
#
|
833
837
|
# @param container [String] Container name
|
834
838
|
# @param source_file [String] Full path to a file within the container
|
835
|
-
# @param
|
839
|
+
# @param dest [String, IO] Full path of desired output file (will be created/overwritten), or an IO object to write to
|
836
840
|
# @return [String] Full path to the local output file
|
837
841
|
#
|
838
842
|
# @example Copy /etc/passwd in container "test" to the local file /tmp/passwd
|
839
843
|
# Hyperkit.pull_file("test", "/etc/passwd", "/tmp/passwd") #=> "/tmp/passwd"
|
840
|
-
|
844
|
+
#
|
845
|
+
# @example Copy /etc/passwd in container "test" to a StringIO object
|
846
|
+
# Hyperkit.pull_file("test", "/etc/passwd", StringIO.new) #=> <StringIO:0x007fd196061a70>
|
847
|
+
def pull_file(container, source_file, dest)
|
841
848
|
contents = get(file_path(container, source_file), url_encode: false)
|
842
849
|
headers = last_response.headers
|
843
850
|
|
844
|
-
|
845
|
-
|
846
|
-
|
851
|
+
if dest.respond_to? :write
|
852
|
+
dest.write(contents)
|
853
|
+
else
|
854
|
+
File.open(dest, "wb") do |f|
|
855
|
+
f.write(contents)
|
856
|
+
end
|
847
857
|
|
848
|
-
|
849
|
-
|
858
|
+
if headers["x-lxd-mode"]
|
859
|
+
File.chmod(headers["x-lxd-mode"].to_i(8), dest)
|
860
|
+
end
|
850
861
|
end
|
851
862
|
|
852
|
-
|
863
|
+
dest
|
853
864
|
|
854
865
|
end
|
855
866
|
|
@@ -909,7 +920,7 @@ module Hyperkit
|
|
909
920
|
#
|
910
921
|
# @param container [String] Container name
|
911
922
|
# @param source_file [String] Full path to a file within the container
|
912
|
-
# @param
|
923
|
+
# @param dest [String, IO] Full path of desired output file (will be created/overwritten), or an IO object to write to
|
913
924
|
# @param options [Hash] Additional data to be passed
|
914
925
|
# @option options [Fixnum] :uid Owner to assign to the file
|
915
926
|
# @option options [Fixnum] :gid Group to assign to the file
|
@@ -919,6 +930,9 @@ module Hyperkit
|
|
919
930
|
# @example Copy /tmp/test.txt from the local system to /etc/passwd in the container
|
920
931
|
# Hyperkit.push_file("/tmp/test.txt", "test-container", "/etc/passwd")
|
921
932
|
#
|
933
|
+
# @example Write the contents of a StringIO object to /etc/passwd in the container
|
934
|
+
# Hyperkit.push_file(StringIO.new("test string"), "test-container", "/etc/passwd")
|
935
|
+
#
|
922
936
|
# @example Assign uid, gid, and mode to a file:
|
923
937
|
# Hyperkit.push_file("/tmp/test.txt",
|
924
938
|
# "test-container",
|
@@ -927,10 +941,14 @@ module Hyperkit
|
|
927
941
|
# gid: 1000,
|
928
942
|
# mode: 0644
|
929
943
|
# )
|
930
|
-
def push_file(
|
944
|
+
def push_file(source, container, dest_file, options={})
|
931
945
|
|
932
946
|
write_file(container, dest_file, options) do |f|
|
933
|
-
|
947
|
+
if source.respond_to? :read
|
948
|
+
f.write source.read
|
949
|
+
else
|
950
|
+
f.write File.read(source)
|
951
|
+
end
|
934
952
|
end
|
935
953
|
|
936
954
|
end
|
data/lib/hyperkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Shantz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -109,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.5.1
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Hyperkit is a flat API wrapper for LXD, the next-generation hypervisor
|
116
116
|
test_files: []
|
117
|
-
has_rdoc:
|