vmfloaty 0.2.19 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/vmfloaty.rb +24 -7
- data/lib/vmfloaty/auth.rb +3 -3
- data/lib/vmfloaty/pooler.rb +17 -7
- data/lib/vmfloaty/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e22ca01b2db81f1c9fcc0332a6ad701eddb36566
|
4
|
+
data.tar.gz: 7656dd21e3e635bfbb80c88e251629fb6b3938fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 771a0f09058b031084f92ed1b12ab0d6836cfec45900bf131e6cfb4046553d9ae437b31bcd2d7e8e1acf7254a417cce7b4dcaecb113fd7a961c06b1eb6e2f2ac
|
7
|
+
data.tar.gz: 78eb6e29cc49eadd4a505e4c90423926698058fc825b1a961246519c8f16772953826a8bb99fa64eb6285595e8f4e767eec11ee004795f6f985ed3b17376b593
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ gem install vmfloaty
|
|
47
47
|
Grabbing a token for authenticated pooler requests:
|
48
48
|
|
49
49
|
```
|
50
|
-
floaty token get --user me --url https://vmpooler.mycompany.net
|
50
|
+
floaty token get --user me --url https://vmpooler.mycompany.net/api/v1
|
51
51
|
```
|
52
52
|
|
53
53
|
This command will then ask you to log in. If successful, it will return a token that you can save either in a dotfile or use with other cli commands.
|
@@ -55,7 +55,7 @@ This command will then ask you to log in. If successful, it will return a token
|
|
55
55
|
Grabbing vms:
|
56
56
|
|
57
57
|
```
|
58
|
-
floaty get centos-7-x86_64=2 debian-7-x86_64=1 windows-10=3 --token mytokenstring --url https://vmpooler.mycompany.net
|
58
|
+
floaty get centos-7-x86_64=2 debian-7-x86_64=1 windows-10=3 --token mytokenstring --url https://vmpooler.mycompany.net/api/v1
|
59
59
|
```
|
60
60
|
|
61
61
|
### vmfloaty dotfile
|
@@ -64,7 +64,7 @@ If you do not wish to continuely specify various config options with the cli, yo
|
|
64
64
|
|
65
65
|
```yaml
|
66
66
|
#file at /Users/me/.vmfloaty.yml
|
67
|
-
url: 'http://vmpooler.mycompany.net'
|
67
|
+
url: 'http://vmpooler.mycompany.net/api/v1'
|
68
68
|
user: 'brian'
|
69
69
|
token: 'tokenstring'
|
70
70
|
```
|
@@ -143,7 +143,7 @@ end
|
|
143
143
|
|
144
144
|
if __FILE__ == $0
|
145
145
|
verbose = true
|
146
|
-
url = 'https://vmpooler.mycompany.net'
|
146
|
+
url = 'https://vmpooler.mycompany.net/api/v1'
|
147
147
|
token = aquire_token(verbose, url)
|
148
148
|
os = ARGV[0]
|
149
149
|
|
data/lib/vmfloaty.rb
CHANGED
@@ -125,29 +125,46 @@ class Vmfloaty
|
|
125
125
|
|
126
126
|
command :modify do |c|
|
127
127
|
c.syntax = 'floaty modify [hostname]'
|
128
|
-
c.summary = 'Modify a vms tags and
|
128
|
+
c.summary = 'Modify a vms tags, TTL, and disk space'
|
129
129
|
c.description = ''
|
130
130
|
c.example 'Modifies myhost1 to have a TTL of 12 hours and adds a custom tag', 'floaty modify myhost1 --lifetime 12 --url https://myurl --token mytokenstring --tags \'{"tag":"myvalue"}\''
|
131
131
|
c.option '--verbose', 'Enables verbose output'
|
132
132
|
c.option '--url STRING', String, 'URL of vmpooler'
|
133
133
|
c.option '--token STRING', String, 'Token for vmpooler'
|
134
134
|
c.option '--lifetime INT', Integer, 'VM TTL (Integer, in hours)'
|
135
|
+
c.option '--disk INT', Integer, 'Increases VM disk space (Integer, in gb)'
|
135
136
|
c.option '--tags STRING', String, 'free-form VM tagging (json)'
|
136
137
|
c.action do |args, options|
|
137
138
|
verbose = options.verbose || config['verbose']
|
138
139
|
url = options.url ||= config['url']
|
139
140
|
hostname = args[0]
|
140
141
|
lifetime = options.lifetime
|
142
|
+
disk = options.disk
|
141
143
|
tags = JSON.parse(options.tags) if options.tags
|
142
144
|
token = options.token || config['token']
|
143
145
|
|
144
|
-
|
145
|
-
|
146
|
-
|
146
|
+
if lifetime || tags
|
147
|
+
modify_req = Pooler.modify(verbose, url, hostname, token, lifetime, tags)
|
148
|
+
|
149
|
+
if modify_req["ok"]
|
150
|
+
puts "Successfully modified vm #{hostname}."
|
151
|
+
else
|
152
|
+
STDERR.puts "Could not modify given host #{hostname} at #{url}."
|
153
|
+
puts modify_req
|
154
|
+
exit 1
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
if disk
|
159
|
+
disk_req = Pooler.disk(verbose, url, hostname, token, disk)
|
160
|
+
if disk_req["ok"]
|
161
|
+
puts "Successfully updated disk space of vm #{hostname}."
|
162
|
+
else
|
163
|
+
STDERR.puts "Could not modify given host #{hostname} at #{url}."
|
164
|
+
puts disk_req
|
165
|
+
exit 1
|
166
|
+
end
|
147
167
|
else
|
148
|
-
STDERR.puts "Could not modify given host #{hostname} at #{url}."
|
149
|
-
puts modify_req
|
150
|
-
exit 1
|
151
168
|
end
|
152
169
|
end
|
153
170
|
end
|
data/lib/vmfloaty/auth.rb
CHANGED
@@ -6,7 +6,7 @@ class Auth
|
|
6
6
|
def self.get_token(verbose, url, user, password)
|
7
7
|
conn = Http.get_conn_with_auth(verbose, url, user, password)
|
8
8
|
|
9
|
-
resp = conn.post "
|
9
|
+
resp = conn.post "token"
|
10
10
|
|
11
11
|
res_body = JSON.parse(resp.body)
|
12
12
|
if res_body["ok"]
|
@@ -26,7 +26,7 @@ class Auth
|
|
26
26
|
|
27
27
|
conn = Http.get_conn_with_auth(verbose, url, user, password)
|
28
28
|
|
29
|
-
response = conn.delete "
|
29
|
+
response = conn.delete "token/#{token}"
|
30
30
|
res_body = JSON.parse(response.body)
|
31
31
|
if res_body["ok"]
|
32
32
|
return res_body
|
@@ -45,7 +45,7 @@ class Auth
|
|
45
45
|
|
46
46
|
conn = Http.get_conn(verbose, url)
|
47
47
|
|
48
|
-
response = conn.get "
|
48
|
+
response = conn.get "token/#{token}"
|
49
49
|
res_body = JSON.parse(response.body)
|
50
50
|
|
51
51
|
if res_body["ok"]
|
data/lib/vmfloaty/pooler.rb
CHANGED
@@ -6,7 +6,7 @@ class Pooler
|
|
6
6
|
def self.list(verbose, url, os_filter=nil)
|
7
7
|
conn = Http.get_conn(verbose, url)
|
8
8
|
|
9
|
-
response = conn.get '
|
9
|
+
response = conn.get 'vm'
|
10
10
|
response_body = JSON.parse(response.body)
|
11
11
|
|
12
12
|
if os_filter
|
@@ -37,7 +37,7 @@ class Pooler
|
|
37
37
|
raise "No operating systems provided to obtain. See `floaty get --help` for more information on how to get VMs."
|
38
38
|
end
|
39
39
|
|
40
|
-
response = conn.post "
|
40
|
+
response = conn.post "vm/#{os_string}"
|
41
41
|
|
42
42
|
res_body = JSON.parse(response.body)
|
43
43
|
if res_body["ok"]
|
@@ -60,7 +60,7 @@ class Pooler
|
|
60
60
|
conn.headers['X-AUTH-TOKEN'] = token
|
61
61
|
|
62
62
|
response = conn.put do |req|
|
63
|
-
req.url "
|
63
|
+
req.url "vm/#{hostname}"
|
64
64
|
req.body = modify_body.to_json
|
65
65
|
end
|
66
66
|
|
@@ -68,6 +68,16 @@ class Pooler
|
|
68
68
|
res_body
|
69
69
|
end
|
70
70
|
|
71
|
+
def self.disk(verbose, url, hostname, token, disk)
|
72
|
+
conn = Http.get_conn(verbose, url)
|
73
|
+
conn.headers['X-AUTH-TOKEN'] = token
|
74
|
+
|
75
|
+
response = conn.post "vm/#{hostname}/disk/#{disk}"
|
76
|
+
|
77
|
+
res_body = JSON.parse(response.body)
|
78
|
+
res_body
|
79
|
+
end
|
80
|
+
|
71
81
|
def self.delete(verbose, url, hosts, token)
|
72
82
|
conn = Http.get_conn(verbose, url)
|
73
83
|
|
@@ -77,7 +87,7 @@ class Pooler
|
|
77
87
|
|
78
88
|
hosts.each do |host|
|
79
89
|
puts "Scheduling host #{host} for deletion"
|
80
|
-
response = conn.delete "
|
90
|
+
response = conn.delete "vm/#{host}"
|
81
91
|
res_body = JSON.parse(response.body)
|
82
92
|
if res_body['ok']
|
83
93
|
puts "Deletion for vm #{host} successfully scheduled"
|
@@ -107,7 +117,7 @@ class Pooler
|
|
107
117
|
def self.query(verbose, url, hostname)
|
108
118
|
conn = Http.get_conn(verbose, url)
|
109
119
|
|
110
|
-
response = conn.get "
|
120
|
+
response = conn.get "vm/#{hostname}"
|
111
121
|
res_body = JSON.parse(response.body)
|
112
122
|
|
113
123
|
res_body
|
@@ -117,7 +127,7 @@ class Pooler
|
|
117
127
|
conn = Http.get_conn(verbose, url)
|
118
128
|
conn.headers['X-AUTH-TOKEN'] = token
|
119
129
|
|
120
|
-
response = conn.post "
|
130
|
+
response = conn.post "vm/#{hostname}/snapshot"
|
121
131
|
res_body = JSON.parse(response.body)
|
122
132
|
res_body
|
123
133
|
end
|
@@ -126,7 +136,7 @@ class Pooler
|
|
126
136
|
conn = Http.get_conn(verbose, url)
|
127
137
|
conn.headers['X-AUTH-TOKEN'] = token
|
128
138
|
|
129
|
-
response = conn.post "
|
139
|
+
response = conn.post "vm/#{hostname}/snapshot/#{snapshot_sha}"
|
130
140
|
res_body = JSON.parse(response.body)
|
131
141
|
res_body
|
132
142
|
end
|
data/lib/vmfloaty/version.rb
CHANGED
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
|
+
version: 0.3.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:
|
11
|
+
date: 2016-05-03 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.
|
83
|
+
rubygems_version: 2.2.2
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: CLI application to interface with vmpooler
|