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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9c927414534a3054860a68db73d51a49d1bd5c1
4
- data.tar.gz: 4d0fad222ff7e1c33f1df050b8dae59100aa46b7
3
+ metadata.gz: 9a16c71e8eb82bf60dc70d432fd07e0cedfb3ab4
4
+ data.tar.gz: e4a445b4b3590395a4f569ce8e060a4f3a566448
5
5
  SHA512:
6
- metadata.gz: bd4c386193f64bc74f686902acd1e13a772d2ceffedb94773dc910cbc1d7bac7c17bd5e07599f4b408016aada6c750ff194dd6171f03eeec95bc50db9530382c
7
- data.tar.gz: ad6dea3f00c6066606d3da6ad8f335abaca89ce733f4eb84087314d1cafd5714d3af91100e08669501ebaeb3932408f3cc69a872153533c54bbc2ddc24c5a410
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.1)
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.4.3)
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)
@@ -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, @user)
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, @user)
59
+ task = Task.create(@client, @image, @sshCmd)
56
60
  run = true
57
61
  while(run) do
58
62
  sleep(2)
@@ -28,12 +28,16 @@ module MescalCli
28
28
  @base_url = base_url + "tasks"
29
29
  end
30
30
 
31
- def create(image, cmd, user)
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
@@ -1,15 +1,26 @@
1
1
  module MescalCli
2
2
  class Task
3
- attr_reader :id, :state, :slave_id
3
+ attr_reader :id, :image, :cmd, :slave_id
4
+ attr_accessor :state
4
5
 
5
- def self.create(client, image, cmd, user)
6
- resp = client.task.create(image, cmd, user)
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, user)
9
+ Task.new(client, obj['id'], image, cmd)
9
10
  end
10
11
 
11
- def initialize(client, id, image, cmd, user)
12
- @client, @id, @image, @cmd, @user = client, id, image, cmd, user
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
@@ -1,3 +1,3 @@
1
1
  module MescalCli
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/mescal-cli.rb CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'rest-client'
3
3
  require 'yajl'
4
4
  require 'multi_json'
5
+ require 'table_print'
5
6
  require 'mescal-cli/config'
6
7
  require 'mescal-cli/task'
7
8
  require 'mescal-cli/pailer'
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.2
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-08 00:00:00.000000000 Z
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