hetzner-api 1.0.0.beta.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -1
- data/LICENSE +23 -0
- data/features/hetzner.feature +6 -2
- data/hetzner-api.gemspec +2 -0
- data/lib/hetzner/api/cli.rb +32 -17
- data/lib/hetzner/api/version.rb +1 -1
- metadata +49 -22
data/Gemfile.lock
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hetzner-api (1.0.0.beta.
|
4
|
+
hetzner-api (1.0.0.beta.2)
|
5
5
|
httparty
|
6
|
+
json
|
6
7
|
thor
|
8
|
+
xml-simple
|
7
9
|
|
8
10
|
GEM
|
9
11
|
remote: http://rubygems.org/
|
@@ -46,6 +48,7 @@ GEM
|
|
46
48
|
sys-uname (0.8.4)
|
47
49
|
term-ansicolor (1.0.5)
|
48
50
|
thor (0.14.3)
|
51
|
+
xml-simple (1.0.12)
|
49
52
|
|
50
53
|
PLATFORMS
|
51
54
|
ruby
|
@@ -60,5 +63,7 @@ DEPENDENCIES
|
|
60
63
|
fakeweb
|
61
64
|
hetzner-api!
|
62
65
|
httparty
|
66
|
+
json
|
63
67
|
rspec (>= 2.0.0)
|
64
68
|
thor
|
69
|
+
xml-simple
|
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2010 Roland Moriz, http://moriz.de
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
--
|
23
|
+
<a href="http://moriz.de/opensource">a Moriz GmbH OpenSource project.</a>
|
data/features/hetzner.feature
CHANGED
@@ -8,11 +8,15 @@ Feature: Hetzner
|
|
8
8
|
When I run "hetzner boot 11.11.11.111 --username='myusername' --password='mycoolpassword'"
|
9
9
|
Then the output should contain "11.11.11.111"
|
10
10
|
|
11
|
+
Scenario: Display the status of all failover IPs
|
12
|
+
When I run "hetzner failover --username='myusername' --password='mycoolpassword'"
|
13
|
+
Then the output should contain "active_server_ip"
|
14
|
+
|
11
15
|
Scenario: Display the status of a failover IP
|
12
16
|
When I run "hetzner failover 11.11.11.111 --username='myusername' --password='mycoolpassword'"
|
13
17
|
Then the output should contain "11.11.11.111"
|
14
18
|
|
15
19
|
Scenario: Update the failover delegation of an ip
|
16
|
-
When I run "hetzner failover 11.11.11.
|
17
|
-
Then the output should contain "
|
20
|
+
When I run "hetzner failover 22.22.22.222 --to 11.11.11.112 --username='myusername' --password='mycoolpassword'"
|
21
|
+
Then the output should contain "active_server_ip"
|
18
22
|
|
data/hetzner-api.gemspec
CHANGED
data/lib/hetzner/api/cli.rb
CHANGED
@@ -2,13 +2,14 @@ require 'thor'
|
|
2
2
|
require 'ipaddr'
|
3
3
|
require 'pp'
|
4
4
|
require 'json'
|
5
|
+
require 'xmlsimple'
|
5
6
|
|
6
7
|
module Hetzner
|
7
8
|
class API
|
8
9
|
class CLI < Thor
|
9
10
|
attr_accessor :api
|
10
11
|
|
11
|
-
desc "boot ACTION [SERVER_IP]", "
|
12
|
+
desc "boot ACTION [SERVER_IP]", "get available boot options"
|
12
13
|
method_options :username => :string
|
13
14
|
method_options :password => :string
|
14
15
|
method_options :set => 'get'
|
@@ -21,33 +22,47 @@ module Hetzner
|
|
21
22
|
when 'get'
|
22
23
|
require_ip ip
|
23
24
|
result = @api.boot? ip
|
24
|
-
pp result.parsed_response
|
25
25
|
end
|
26
|
+
|
27
|
+
output(result)
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
desc "failover [SERVER_IP]", "get available boot options"
|
30
|
+
desc "failover [SERVER_IP] (--to [FAILOVER_IP])", "get/set failover of SERVER_IP (to FAILOVER_IP)"
|
30
31
|
method_options :username => :string
|
31
32
|
method_options :password => :string
|
32
|
-
method_options :
|
33
|
-
|
34
|
-
def failover(ip)
|
35
|
-
require_ip ip
|
33
|
+
method_options :to => :string
|
34
|
+
|
35
|
+
def failover(ip = nil)
|
36
36
|
generate_api_instance
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
result = @api.failover? ip
|
45
|
-
pp result.parsed_response
|
37
|
+
|
38
|
+
if options.to
|
39
|
+
require_ip ip
|
40
|
+
require_ip options.to
|
41
|
+
result = @api.failover! ip, options.to
|
42
|
+
else
|
43
|
+
result = @api.failover? ip
|
46
44
|
end
|
45
|
+
|
46
|
+
output(result)
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
|
+
def output(result)
|
52
|
+
@render = 'xml'
|
53
|
+
case @render
|
54
|
+
when 'pp'
|
55
|
+
pp result.parsed_response
|
56
|
+
when 'yaml'
|
57
|
+
puts result.parsed_response.to_yaml
|
58
|
+
when 'xml'
|
59
|
+
puts XmlSimple.xml_out result.parsed_response, 'RootName' => 'result', 'AnonymousTag' => '' # dirty
|
60
|
+
when 'json'
|
61
|
+
else
|
62
|
+
jj JSON.parse result.response.body
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
51
66
|
def require_ip(ip)
|
52
67
|
ip = IPAddr.new ip
|
53
68
|
rescue ArgumentError
|
data/lib/hetzner/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hetzner-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
|
11
|
-
- 2
|
12
|
-
version: 1.0.0.beta.2
|
10
|
+
version: 1.0.0
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Roland Moriz
|
@@ -17,7 +15,7 @@ autorequire:
|
|
17
15
|
bindir: bin
|
18
16
|
cert_chain: []
|
19
17
|
|
20
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-15 00:00:00 +02:00
|
21
19
|
default_executable:
|
22
20
|
dependencies:
|
23
21
|
- !ruby/object:Gem::Dependency
|
@@ -49,9 +47,37 @@ dependencies:
|
|
49
47
|
type: :runtime
|
50
48
|
version_requirements: *id002
|
51
49
|
- !ruby/object:Gem::Dependency
|
52
|
-
name:
|
50
|
+
name: json
|
53
51
|
prerelease: false
|
54
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: xml-simple
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :runtime
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: bundler
|
79
|
+
prerelease: false
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
55
81
|
none: false
|
56
82
|
requirements:
|
57
83
|
- - ">="
|
@@ -63,11 +89,11 @@ dependencies:
|
|
63
89
|
- 2
|
64
90
|
version: 1.0.2
|
65
91
|
type: :development
|
66
|
-
version_requirements: *
|
92
|
+
version_requirements: *id005
|
67
93
|
- !ruby/object:Gem::Dependency
|
68
94
|
name: autotest
|
69
95
|
prerelease: false
|
70
|
-
requirement: &
|
96
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
71
97
|
none: false
|
72
98
|
requirements:
|
73
99
|
- - ">="
|
@@ -77,11 +103,11 @@ dependencies:
|
|
77
103
|
- 0
|
78
104
|
version: "0"
|
79
105
|
type: :development
|
80
|
-
version_requirements: *
|
106
|
+
version_requirements: *id006
|
81
107
|
- !ruby/object:Gem::Dependency
|
82
108
|
name: autotest-fsevent
|
83
109
|
prerelease: false
|
84
|
-
requirement: &
|
110
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
85
111
|
none: false
|
86
112
|
requirements:
|
87
113
|
- - ">="
|
@@ -91,11 +117,11 @@ dependencies:
|
|
91
117
|
- 0
|
92
118
|
version: "0"
|
93
119
|
type: :development
|
94
|
-
version_requirements: *
|
120
|
+
version_requirements: *id007
|
95
121
|
- !ruby/object:Gem::Dependency
|
96
122
|
name: autotest-growl
|
97
123
|
prerelease: false
|
98
|
-
requirement: &
|
124
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
99
125
|
none: false
|
100
126
|
requirements:
|
101
127
|
- - ">="
|
@@ -105,11 +131,11 @@ dependencies:
|
|
105
131
|
- 0
|
106
132
|
version: "0"
|
107
133
|
type: :development
|
108
|
-
version_requirements: *
|
134
|
+
version_requirements: *id008
|
109
135
|
- !ruby/object:Gem::Dependency
|
110
136
|
name: rspec
|
111
137
|
prerelease: false
|
112
|
-
requirement: &
|
138
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
113
139
|
none: false
|
114
140
|
requirements:
|
115
141
|
- - ">="
|
@@ -121,11 +147,11 @@ dependencies:
|
|
121
147
|
- 0
|
122
148
|
version: 2.0.0
|
123
149
|
type: :development
|
124
|
-
version_requirements: *
|
150
|
+
version_requirements: *id009
|
125
151
|
- !ruby/object:Gem::Dependency
|
126
152
|
name: fakeweb
|
127
153
|
prerelease: false
|
128
|
-
requirement: &
|
154
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
129
155
|
none: false
|
130
156
|
requirements:
|
131
157
|
- - ">="
|
@@ -135,11 +161,11 @@ dependencies:
|
|
135
161
|
- 0
|
136
162
|
version: "0"
|
137
163
|
type: :development
|
138
|
-
version_requirements: *
|
164
|
+
version_requirements: *id010
|
139
165
|
- !ruby/object:Gem::Dependency
|
140
166
|
name: cucumber
|
141
167
|
prerelease: false
|
142
|
-
requirement: &
|
168
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
143
169
|
none: false
|
144
170
|
requirements:
|
145
171
|
- - ">="
|
@@ -149,11 +175,11 @@ dependencies:
|
|
149
175
|
- 0
|
150
176
|
version: "0"
|
151
177
|
type: :development
|
152
|
-
version_requirements: *
|
178
|
+
version_requirements: *id011
|
153
179
|
- !ruby/object:Gem::Dependency
|
154
180
|
name: aruba
|
155
181
|
prerelease: false
|
156
|
-
requirement: &
|
182
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
157
183
|
none: false
|
158
184
|
requirements:
|
159
185
|
- - ">="
|
@@ -163,7 +189,7 @@ dependencies:
|
|
163
189
|
- 0
|
164
190
|
version: "0"
|
165
191
|
type: :development
|
166
|
-
version_requirements: *
|
192
|
+
version_requirements: *id012
|
167
193
|
description: A wrapper for Hetzner.de's server management API
|
168
194
|
email:
|
169
195
|
- roland@moriz.de
|
@@ -177,6 +203,7 @@ files:
|
|
177
203
|
- .gitignore
|
178
204
|
- Gemfile
|
179
205
|
- Gemfile.lock
|
206
|
+
- LICENSE
|
180
207
|
- README.rdoc
|
181
208
|
- Rakefile
|
182
209
|
- bin/hetzner
|