vmfloaty 0.4.0 → 0.5.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: e04a3143e6097ed642f76e19742196609e21a292
4
- data.tar.gz: 8413045d1ed7a831b82c62ca524dd8b446081ddd
3
+ metadata.gz: 635cb7b974854695815a6287203b5db7842ccfdd
4
+ data.tar.gz: 8bf5c5be05395beb8154243aa212d08d94559869
5
5
  SHA512:
6
- metadata.gz: ead2883c0135e76d9e590b953f25362238e2eb5f876b5b556d81a3c7d49178b641e0aa8294f2899cdb6135a99cfa040f8c2d87c28c85f44a5d321342e2553a42
7
- data.tar.gz: 918ad38d4e785ec8467a2db3ce50ff30fc819bf08a6ef9c291d11d1e624f0c256731da9d2aa2f55d6a23e175431c18d29a79775300827283ff383422d615637a
6
+ metadata.gz: 7fe3df32eca62872bcf93fca60ddbb312ee89e24fae6952f5f7d3fcad5f20b5bb22e418c4e0dc9a741721d37375039378083303dea0d54df7e212409613de8f1
7
+ data.tar.gz: 0063aba22c8ef7a481b13792fe90ccc15d3b117bd439436279ec5f2709cc5b2f91da84b55e59844ae0d68b20c28dc7fef1a2e9f6d584614f67e4b9ccd0ebaf68
data/lib/vmfloaty.rb CHANGED
@@ -212,7 +212,14 @@ class Vmfloaty
212
212
 
213
213
  if ans
214
214
  # delete vms
215
- Pooler.delete(verbose, url, running_vms, token)
215
+ puts "Scheduling all vms for for deletion"
216
+ response = Pooler.delete(verbose, url, running_vms, token)
217
+ response.each do |host,vals|
218
+ if vals['ok'] == false
219
+ STDERR.puts "There was a problem with your request for vm #{host}."
220
+ STDERR.puts vals
221
+ end
222
+ end
216
223
  end
217
224
  end
218
225
 
@@ -85,17 +85,15 @@ class Pooler
85
85
  conn.headers['X-AUTH-TOKEN'] = token
86
86
  end
87
87
 
88
+ response_body = {}
89
+
88
90
  hosts.each do |host|
89
- puts "Scheduling host #{host} for deletion"
90
91
  response = conn.delete "vm/#{host}"
91
92
  res_body = JSON.parse(response.body)
92
- if res_body['ok']
93
- puts "Deletion for vm #{host} successfully scheduled"
94
- else
95
- STDERR.puts "There was a problem with your request for vm #{host}."
96
- STDERR.puts res_body
97
- end
93
+ response_body[host] = res_body
98
94
  end
95
+
96
+ response_body
99
97
  end
100
98
 
101
99
  def self.status(verbose, url)
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Version
3
- @version = '0.4.0'
3
+ @version = '0.5.0'
4
4
 
5
5
  def self.get
6
6
  @version
@@ -14,7 +14,7 @@ describe Pooler do
14
14
 
15
15
  it "returns a token from vmpooler" do
16
16
  stub_request(:post, "https://first.last:password@vmpooler.example.com/token").
17
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.1'}).
17
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2'}).
18
18
  to_return(:status => 200, :body => @get_token_response, :headers => {})
19
19
 
20
20
  token = Auth.get_token(false, @vmpooler_url, "first.last", "password")
@@ -30,7 +30,7 @@ describe Pooler do
30
30
 
31
31
  it "deletes the specified token" do
32
32
  stub_request(:delete, "https://first.last:password@vmpooler.example.com/token/utpg2i2xswor6h8ttjhu3d47z53yy47y").
33
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
33
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.2'}).
34
34
  to_return(:status => 200, :body => @delete_token_response, :headers => {})
35
35
 
36
36
  expect(Auth.delete_token(false, @vmpooler_url, "first.last", "password", @token)).to eq JSON.parse(@delete_token_response)
@@ -45,7 +45,7 @@ describe Pooler do
45
45
 
46
46
  it "checks the status of a token" do
47
47
  stub_request(:get, "#{@vmpooler_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y").
48
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
48
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.2'}).
49
49
  to_return(:status => 200, :body => @token_status_response, :headers => {})
50
50
 
51
51
  expect(Auth.token_status(false, @vmpooler_url, @token)).to eq JSON.parse(@token_status_response)
@@ -46,7 +46,7 @@ describe Pooler do
46
46
 
47
47
  it "retrieves a single vm with a token" do
48
48
  stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386").
49
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.1', 'X-Auth-Token'=>'mytokenfile'}).
49
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
50
50
  to_return(:status => 200, :body => @retrieve_response_body_single, :headers => {})
51
51
 
52
52
  vm_hash = {}
@@ -59,7 +59,7 @@ describe Pooler do
59
59
 
60
60
  it "retrieves a multiple vms with a token" do
61
61
  stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386+debian-7-i386+centos-7-x86_64").
62
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.1', 'X-Auth-Token'=>'mytokenfile'}).
62
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
63
63
  to_return(:status => 200, :body => @retrieve_response_body_double, :headers => {})
64
64
 
65
65
  vm_hash = {}
@@ -83,7 +83,7 @@ describe Pooler do
83
83
  it "modifies the TTL of a vm" do
84
84
  stub_request(:put, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6").
85
85
  with(:body => {"{\"lifetime\":12}"=>true},
86
- :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.1', 'X-Auth-Token'=>'mytokenfile'}).
86
+ :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
87
87
  to_return(:status => 200, :body => @modify_response_body_success, :headers => {})
88
88
 
89
89
  modify_req = Pooler.modify(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', 12, nil)
@@ -94,14 +94,15 @@ describe Pooler do
94
94
  describe "#delete" do
95
95
  before :each do
96
96
  @delete_response_body_success = "{\"ok\":true}"
97
+ @delete_response = {"fq6qlpjlsskycq6"=>{"ok"=>true}}
97
98
  end
98
99
 
99
100
  it "deletes a specified vm" do
100
101
  stub_request(:delete, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6").
101
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1', 'X-Auth-Token'=>'mytokenfile'}).
102
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
102
103
  to_return(:status => 200, :body => @delete_response_body_success, :headers => {})
103
104
 
104
- #expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile')).to output(/Scheduling host fq6qlpjlsskycq6 for deletion/).to_stdout
105
+ expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile')).to eq @delete_response
105
106
  end
106
107
  end
107
108
 
@@ -113,7 +114,7 @@ describe Pooler do
113
114
 
114
115
  it "prints the status" do
115
116
  stub_request(:get, "#{@vmpooler_url}/status").
116
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
117
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.2'}).
117
118
  to_return(:status => 200, :body => @status_response_body, :headers => {})
118
119
 
119
120
  status = Pooler.status(false, @vmpooler_url)
@@ -137,7 +138,7 @@ describe Pooler do
137
138
 
138
139
  it "makes a query about a vm" do
139
140
  stub_request(:get, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6").
140
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
141
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.2'}).
141
142
  to_return(:status => 200, :body => @query_response_body, :headers => {})
142
143
 
143
144
  query_req = Pooler.query(false, @vmpooler_url, 'fq6qlpjlsskycq6')
@@ -152,7 +153,7 @@ describe Pooler do
152
153
 
153
154
  it "makes a snapshot for a single vm" do
154
155
  stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/snapshot").
155
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.1', 'X-Auth-Token'=>'mytokenfile'}).
156
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
156
157
  to_return(:status => 200, :body => @snapshot_response_body, :headers => {})
157
158
 
158
159
  snapshot_req = Pooler.snapshot(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile')
@@ -167,7 +168,7 @@ describe Pooler do
167
168
 
168
169
  it "makes a request to revert a vm from a snapshot" do
169
170
  stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/snapshot/dAfewKNfaweLKNve").
170
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.1', 'X-Auth-Token'=>'mytokenfile'}).
171
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'0', 'User-Agent'=>'Faraday v0.9.2', 'X-Auth-Token'=>'mytokenfile'}).
171
172
  to_return(:status => 200, :body => @revert_response_body, :headers => {})
172
173
 
173
174
  revert_req = Pooler.revert(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', 'dAfewKNfaweLKNve')
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmfloaty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-02 00:00:00.000000000 Z
11
+ date: 2016-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.9'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.9'
41
41
  description: A helper tool for vmpooler to help you stay afloat
@@ -70,17 +70,17 @@ require_paths:
70
70
  - lib
71
71
  required_ruby_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - '>='
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.4.8
83
+ rubygems_version: 2.2.2
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: CLI application to interface with vmpooler