mescal-cli 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -2
- data/lib/mescal-cli/cli.rb +7 -3
- data/lib/mescal-cli/client.rb +5 -1
- data/lib/mescal-cli/task.rb +21 -6
- data/lib/mescal-cli/version.rb +1 -1
- data/lib/mescal-cli.rb +1 -0
- data/mescal-cli.gemspec +1 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a16c71e8eb82bf60dc70d432fd07e0cedfb3ab4
|
4
|
+
data.tar.gz: e4a445b4b3590395a4f569ce8e060a4f3a566448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5d369481d3440d4b1578c2b4d9e77ae22cd435c3e686677b13d2a874225371efca55eb41fa7b96bf8935630497ced402587ee54ced6cbe20446fbdd5684b26f
|
7
|
+
data.tar.gz: 8f4f64231d9a43868b834ea20ca66cf2f2aec9955892489e50064d0031f690740f0a4cc8bb5a1e9c56ce924fb1d2f0e6e7d43dd61ff91c6b2673af2896a694a5
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mescal-cli (0.0.
|
4
|
+
mescal-cli (0.0.2)
|
5
5
|
multi_json (~> 1.11, >= 1.11.0)
|
6
6
|
rest-client (~> 1.8, >= 1.8.0)
|
7
|
+
table_print (~> 1.5.3, >= 1.5.3)
|
7
8
|
yajl-ruby (~> 1.2, >= 1.2.1)
|
8
9
|
|
9
10
|
GEM
|
@@ -13,7 +14,7 @@ GEM
|
|
13
14
|
unf (>= 0.0.5, < 1.0.0)
|
14
15
|
http-cookie (1.0.2)
|
15
16
|
domain_name (~> 0.5)
|
16
|
-
mime-types (2.
|
17
|
+
mime-types (2.5)
|
17
18
|
multi_json (1.11.0)
|
18
19
|
netrc (0.10.3)
|
19
20
|
rake (10.4.2)
|
@@ -21,6 +22,7 @@ GEM
|
|
21
22
|
http-cookie (>= 1.0.2, < 2.0)
|
22
23
|
mime-types (>= 1.16, < 3.0)
|
23
24
|
netrc (~> 0.7)
|
25
|
+
table_print (1.5.3)
|
24
26
|
unf (0.1.4)
|
25
27
|
unf_ext
|
26
28
|
unf_ext (0.0.7.1)
|
data/lib/mescal-cli/cli.rb
CHANGED
@@ -10,7 +10,6 @@ module MescalCli
|
|
10
10
|
@client = Client.new(config['mescal'])
|
11
11
|
@image = config['image']
|
12
12
|
@cmd = ARGV[1] || config['cmd']
|
13
|
-
@user = Etc.getlogin
|
14
13
|
@sshCmd = config['sshCmd']
|
15
14
|
end
|
16
15
|
|
@@ -22,12 +21,17 @@ module MescalCli
|
|
22
21
|
case @mode
|
23
22
|
when "run" then run
|
24
23
|
when "ssh" then ssh
|
24
|
+
when "list" then list
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def list
|
29
|
+
tp Task.list(@client), {id: {width: 48}}, :image, :cmd, :state
|
30
|
+
end
|
31
|
+
|
28
32
|
def run
|
29
33
|
puts "Sending task to Mescal..."
|
30
|
-
task = Task.create(@client, @image, @cmd
|
34
|
+
task = Task.create(@client, @image, @cmd)
|
31
35
|
run = true
|
32
36
|
threads = []
|
33
37
|
pailer_started = false
|
@@ -52,7 +56,7 @@ module MescalCli
|
|
52
56
|
end
|
53
57
|
|
54
58
|
def ssh
|
55
|
-
task = Task.create(@client, @image, @sshCmd
|
59
|
+
task = Task.create(@client, @image, @sshCmd)
|
56
60
|
run = true
|
57
61
|
while(run) do
|
58
62
|
sleep(2)
|
data/lib/mescal-cli/client.rb
CHANGED
@@ -28,12 +28,16 @@ module MescalCli
|
|
28
28
|
@base_url = base_url + "tasks"
|
29
29
|
end
|
30
30
|
|
31
|
-
def create(image, cmd
|
31
|
+
def create(image, cmd)
|
32
32
|
RestClient.post @base_url, image: image, cmd: cmd, port: 22
|
33
33
|
end
|
34
34
|
|
35
35
|
def get(id)
|
36
36
|
RestClient.get "#{@base_url}/#{id}"
|
37
37
|
end
|
38
|
+
|
39
|
+
def list
|
40
|
+
RestClient.get "#{@base_url}"
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
data/lib/mescal-cli/task.rb
CHANGED
@@ -1,15 +1,26 @@
|
|
1
1
|
module MescalCli
|
2
2
|
class Task
|
3
|
-
attr_reader :id, :
|
3
|
+
attr_reader :id, :image, :cmd, :slave_id
|
4
|
+
attr_accessor :state
|
4
5
|
|
5
|
-
def self.create(client, image, cmd
|
6
|
-
resp = client.task.create(image, cmd
|
6
|
+
def self.create(client, image, cmd)
|
7
|
+
resp = client.task.create(image, cmd)
|
7
8
|
obj = MultiJson.load(resp)
|
8
|
-
Task.new(client, obj['id'], image, cmd
|
9
|
+
Task.new(client, obj['id'], image, cmd)
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
-
|
12
|
+
def self.list(client)
|
13
|
+
resp = client.task.list
|
14
|
+
obj = MultiJson.load(resp)
|
15
|
+
obj.map do |jsTask|
|
16
|
+
t = Task.new(nil, jsTask['id'], jsTask['image'], jsTask['cmd'])
|
17
|
+
t.state = jsTask['state']
|
18
|
+
t
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(client, id, image, cmd)
|
23
|
+
@client, @id, @image, @cmd = client, id, image, cmd
|
13
24
|
end
|
14
25
|
|
15
26
|
def update!
|
@@ -33,5 +44,9 @@ module MescalCli
|
|
33
44
|
def ssh_port
|
34
45
|
@ports.find { |p| p[0] == 22 }[1]
|
35
46
|
end
|
47
|
+
|
48
|
+
def to_s
|
49
|
+
"#{@id} #{@image} #{@cmd}"
|
50
|
+
end
|
36
51
|
end
|
37
52
|
end
|
data/lib/mescal-cli/version.rb
CHANGED
data/lib/mescal-cli.rb
CHANGED
data/mescal-cli.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "rake", "~> 10.0"
|
22
22
|
|
23
23
|
spec.add_runtime_dependency 'rest-client', '~> 1.8', '>= 1.8.0'
|
24
|
+
spec.add_runtime_dependency 'table_print', '~> 1.5.3', '>= 1.5.3'
|
24
25
|
spec.add_runtime_dependency 'yajl-ruby', '~> 1.2', '>= 1.2.1'
|
25
26
|
spec.add_runtime_dependency 'multi_json', '~> 1.11', '>= 1.11.0'
|
26
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mescal-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Kite
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,6 +58,26 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 1.8.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: table_print
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.5.3
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.5.3
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.5.3
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.5.3
|
61
81
|
- !ruby/object:Gem::Dependency
|
62
82
|
name: yajl-ruby
|
63
83
|
requirement: !ruby/object:Gem::Requirement
|