hetzner-api 1.0.0.beta.1 → 1.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hetzner-api (1.0.0.alpha.3)
4
+ hetzner-api (1.0.0.beta.1)
5
5
  httparty
6
6
  thor
7
7
 
@@ -12,6 +12,8 @@ GEM
12
12
  background_process
13
13
  cucumber (~> 0.9.0)
14
14
  autotest (4.2.10)
15
+ autotest-fsevent (0.2.3)
16
+ sys-uname
15
17
  autotest-growl (0.2.4)
16
18
  autotest (>= 4.2.4)
17
19
  background_process (1.2)
@@ -31,16 +33,17 @@ GEM
31
33
  httparty (0.6.1)
32
34
  crack (= 0.1.8)
33
35
  json (1.4.6)
34
- rspec (2.0.0.rc)
35
- rspec-core (= 2.0.0.rc)
36
- rspec-expectations (= 2.0.0.rc)
37
- rspec-mocks (= 2.0.0.rc)
38
- rspec-core (2.0.0.rc)
39
- rspec-expectations (2.0.0.rc)
36
+ rspec (2.0.0)
37
+ rspec-core (= 2.0.0)
38
+ rspec-expectations (= 2.0.0)
39
+ rspec-mocks (= 2.0.0)
40
+ rspec-core (2.0.0)
41
+ rspec-expectations (2.0.0)
40
42
  diff-lcs (>= 1.1.2)
41
- rspec-mocks (2.0.0.rc)
42
- rspec-core (= 2.0.0.rc)
43
- rspec-expectations (= 2.0.0.rc)
43
+ rspec-mocks (2.0.0)
44
+ rspec-core (= 2.0.0)
45
+ rspec-expectations (= 2.0.0)
46
+ sys-uname (0.8.4)
44
47
  term-ansicolor (1.0.5)
45
48
  thor (0.14.3)
46
49
 
@@ -50,11 +53,12 @@ PLATFORMS
50
53
  DEPENDENCIES
51
54
  aruba
52
55
  autotest
56
+ autotest-fsevent
53
57
  autotest-growl
54
58
  bundler (>= 1.0.2)
55
59
  cucumber
56
60
  fakeweb
57
61
  hetzner-api!
58
62
  httparty
59
- rspec (~> 2.0.0.rc)
63
+ rspec (>= 2.0.0)
60
64
  thor
data/README.rdoc CHANGED
@@ -40,28 +40,28 @@ see http://wiki.hetzner.de/index.php?title=Robot_Webservice_en for details.
40
40
  should fail for the specific IP if a manual reset is active
41
41
  should fail for the specific IP if reset is unavailable
42
42
  should fail for the specific IP if IP is unknown
43
-
43
+
44
44
  Boot
45
45
  query boot configuration
46
46
  should display the boot configuration
47
47
  the rescue system
48
48
  should be able to activate
49
49
  should be able to deactivate
50
-
50
+
51
51
  Rdns
52
52
  should query the current rdns status
53
53
  should be able to set a new ptr
54
54
  should be able to remove a new ptr
55
-
55
+
56
56
  VNC
57
57
  should be able to query vnc boot status
58
58
  should be able to set vnc boot status
59
59
  should be able to disable vnc boot status
60
-
60
+
61
61
  WOL
62
62
  should be able to query WOL status
63
63
  should be able to send a WOL notification
64
-
64
+
65
65
  IP
66
66
  information
67
67
  should be able to display all IP addresses of the customer account
@@ -70,7 +70,7 @@ see http://wiki.hetzner.de/index.php?title=Robot_Webservice_en for details.
70
70
  manage traffic warnings
71
71
  should be able to activate and set traffic warning limits on a specific IP address
72
72
  should be able to deactivate traffic warnings for a specific IP address
73
-
73
+
74
74
  Subnet
75
75
  information
76
76
  should be able to display all IP subnets of the customer account
@@ -79,22 +79,28 @@ see http://wiki.hetzner.de/index.php?title=Robot_Webservice_en for details.
79
79
  manage traffic warnings
80
80
  should be able to activate and set traffic warning limits on a specific IP address
81
81
  should be able to deactivate traffic warnings for a specific IP address
82
-
82
+
83
83
  Server
84
84
  information
85
85
  should be able to display all servers of the customer account
86
86
  should be able to display a specific server by its IP address
87
-
87
+
88
88
  Plesk
89
89
  should be able to query plesk boot option status
90
90
  should be able to activate plesk boot option
91
91
  should be able to disable plesk boot option
92
-
92
+
93
+ Failover
94
+ should be able to query the status of all failover IPs
95
+ should be able to query the status of a single failover IP
96
+ should be able to set the status of a single failover IP
97
+
93
98
  Traffic
94
99
  should display the traffic for a specific ip address and a subnet
95
100
  should display the traffic for serveral IP addresse and no subnet
96
101
  should display the traffic for subnets and no ip address
97
-
102
+
103
+
98
104
 
99
105
  == Readme (rdoc)
100
106
 
data/cucumber.yml CHANGED
@@ -1 +1,2 @@
1
- default: --format html --out report.html --format pretty
1
+ default: --format pretty
2
+ autotest: features -r features --format pretty --color
@@ -3,6 +3,16 @@ Feature: Hetzner
3
3
  As a CLI
4
4
  I want to provider a decent, objective interface
5
5
 
6
- Scenario: Display boot options for one server
7
- When I run "hetzner boot get 11.11.11.111 --username='myusername' --password='mycoolpassword'"
8
- Then the output should contain "11.11.11.111"
6
+
7
+ Scenario: Display available boot options for a specific server
8
+ When I run "hetzner boot 11.11.11.111 --username='myusername' --password='mycoolpassword'"
9
+ Then the output should contain "11.11.11.111"
10
+
11
+ Scenario: Display the status of a failover IP
12
+ When I run "hetzner failover 11.11.11.111 --username='myusername' --password='mycoolpassword'"
13
+ Then the output should contain "11.11.11.111"
14
+
15
+ Scenario: Update the failover delegation of an ip
16
+ When I run "hetzner failover 11.11.11.111 --set --username='myusername' --password='mycoolpassword'"
17
+ Then the output should contain "11.11.11.111"
18
+
data/hetzner-api.gemspec CHANGED
@@ -19,8 +19,9 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_development_dependency "bundler", ">= 1.0.2"
21
21
  s.add_development_dependency "autotest"
22
+ s.add_development_dependency "autotest-fsevent"
22
23
  s.add_development_dependency "autotest-growl"
23
- s.add_development_dependency "rspec", "~> 2.0.0.rc"
24
+ s.add_development_dependency "rspec", ">= 2.0.0"
24
25
  s.add_development_dependency "fakeweb"
25
26
  s.add_development_dependency "cucumber"
26
27
  s.add_development_dependency "aruba"
@@ -11,16 +11,38 @@ module Hetzner
11
11
  desc "boot ACTION [SERVER_IP]", "'get' available boot options"
12
12
  method_options :username => :string
13
13
  method_options :password => :string
14
+ method_options :set => 'get'
14
15
 
15
- def boot(action, ip = '')
16
+ def boot(ip = "")
17
+ require_ip ip
16
18
  generate_api_instance
17
- case action
19
+
20
+ case options.set
18
21
  when 'get'
19
22
  require_ip ip
20
23
  result = @api.boot? ip
21
24
  pp result.parsed_response
22
- else
23
- raise UnknownArgumentError, "'#{action}' is not a valid action!"
25
+ end
26
+ end
27
+
28
+
29
+ desc "failover [SERVER_IP]", "get available boot options"
30
+ method_options :username => :string
31
+ method_options :password => :string
32
+ method_options :set => 'get'
33
+
34
+ def failover(ip)
35
+ require_ip ip
36
+ generate_api_instance
37
+
38
+ case options.set
39
+ when 'set'
40
+ result = @api.failover! ip
41
+ pp result.parsed_response
42
+ # raise UnknownArgumentError, "'#{action}' is not a valid action!"
43
+ when 'get'
44
+ result = @api.failover? ip
45
+ pp result.parsed_response
24
46
  end
25
47
  end
26
48
 
@@ -10,7 +10,7 @@ module Hetzner
10
10
 
11
11
  # redirects the failover_ip to another server ip
12
12
  def failover!(failover_ip, active_server_ip)
13
- path = "/rdns/#{failover_ip}"
13
+ path = "/failover/#{failover_ip}"
14
14
  perform_post path, :query => { :active_server_ip => active_server_ip }
15
15
  end
16
16
  end
@@ -1,5 +1,5 @@
1
1
  module Hetzner
2
2
  class API
3
- VERSION = "1.0.0.beta.1"
3
+ VERSION = "1.0.0.beta.2"
4
4
  end
5
5
  end
data/spec/api_stubs.rb CHANGED
@@ -154,5 +154,16 @@ FakeWeb.register_uri :post, uri(nil, "?from=2010-09-01&type=month&ip[]=#{WORKI
154
154
 
155
155
  FakeWeb.register_uri :post, uri(nil, "?from=2010-01&to=2010-10&type=year&subnet[]=#{WORKING_SUBNET_IP}&subnet[]=#{WORKING_SUBNET_IP_2}"),
156
156
  :response => fixture('post_with_two_subnets_and_no_ip_year.raw')
157
+
158
+
159
+ @resource = 'failover'
160
+
161
+ FakeWeb.register_uri :get, uri,
162
+ :response => fixture('get.raw')
157
163
 
164
+ FakeWeb.register_uri :get, uri("#{FAILOVER_IP}"),
165
+ :response => fixture('get_with_failover_ip.raw')
166
+
167
+ FakeWeb.register_uri :post, uri("#{FAILOVER_IP}?active_server_ip=#{WORKING_IP_2}"),
168
+ :response => fixture('post_with_active_server_ip.raw')
158
169
  #pp FakeWeb::Registry.instance.uri_map
@@ -0,0 +1,23 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: application/json
3
+
4
+ [
5
+ {
6
+ "failover":
7
+ {
8
+ "ip":"22.22.22.222",
9
+ "netmask":"255.255.255.255",
10
+ "server_ip": "22.22.22.222",
11
+ "active_server_ip": "22.22.22.222"
12
+ }
13
+ },
14
+ {
15
+ "failover":
16
+ {
17
+ "ip":"22.22.22.223",
18
+ "netmask":"255.255.255.255",
19
+ "server_ip": "22.22.22.223",
20
+ "active_server_ip": "22.22.22.222"
21
+ }
22
+ }
23
+ ]
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: application/json
3
+
4
+ {
5
+ "failover":
6
+ {
7
+ "ip":"22.22.22.222",
8
+ "netmask":"255.255.255.255",
9
+ "server_ip": "22.22.22.222",
10
+ "active_server_ip": "11.11.11.111"
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: application/json
3
+
4
+ {
5
+ "failover":
6
+ {
7
+ "ip":"22.22.22.222",
8
+ "netmask":"255.255.255.255",
9
+ "server_ip": "22.22.22.222",
10
+ "active_server_ip": "11.11.11.112"
11
+ }
12
+ }
@@ -313,6 +313,45 @@ describe "Plesk" do
313
313
  end
314
314
  end
315
315
 
316
+ describe "Failover" do
317
+ before(:all) do
318
+ @h = Hetzner::API.new API_USERNAME, API_PASSWORD
319
+ end
320
+
321
+ it "should be able to query the status of all failover IPs" do
322
+ result = @h.failover?
323
+ result.response.should be_an_instance_of Net::HTTPOK
324
+ result.parsed_response.should have(2).entries
325
+
326
+ # default in mode
327
+ result[0]['failover']['ip'].should == FAILOVER_IP
328
+ result[0]['failover']['active_server_ip'].should == FAILOVER_IP
329
+
330
+ # currently re-routed
331
+ result[1]['failover']['ip'].should == FAILOVER_IP_2
332
+ result[1]['failover']['active_server_ip'].should == FAILOVER_IP
333
+ end
334
+
335
+ it "should be able to query the status of a single failover IP" do
336
+ result = @h.failover? FAILOVER_IP
337
+ result.response.should be_an_instance_of Net::HTTPOK
338
+ result['failover']['ip'].should == FAILOVER_IP
339
+ result['failover']['netmask'].should == '255.255.255.255'
340
+ result['failover']['server_ip'].should == FAILOVER_IP
341
+ result['failover']['active_server_ip'].should == WORKING_IP
342
+ end
343
+
344
+ it "should be able to set the status of a single failover IP" do
345
+ result = @h.failover! FAILOVER_IP, WORKING_IP_2
346
+ result.response.should be_an_instance_of Net::HTTPOK
347
+ result['failover']['ip'].should == FAILOVER_IP
348
+ result['failover']['netmask'].should == '255.255.255.255'
349
+ result['failover']['server_ip'].should == FAILOVER_IP
350
+ result['failover']['active_server_ip'].should == WORKING_IP_2
351
+ end
352
+ end
353
+
354
+
316
355
  describe "Traffic" do
317
356
  before(:all) do
318
357
  @h = Hetzner::API.new API_USERNAME, API_PASSWORD
@@ -8,6 +8,9 @@ RESET_IP_NOT_AVAILABLE = '11.11.11.223'
8
8
  RESET_IP_MANUAL_ACTIVE = '11.11.11.224'
9
9
  RESET_IP_FAILED = '11.11.11.225'
10
10
 
11
+ FAILOVER_IP = '22.22.22.222'
12
+ FAILOVER_IP_2 = '22.22.22.223'
13
+
11
14
  TEST_PTR = 'testen.de'
12
15
  RDNS_TEST_IP = ''
13
16
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hetzner-api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196353
4
+ hash: 62196359
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
10
  - beta
11
- - 1
12
- version: 1.0.0.beta.1
11
+ - 2
12
+ version: 1.0.0.beta.2
13
13
  platform: ruby
14
14
  authors:
15
15
  - Roland Moriz
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-10-11 00:00:00 +02:00
20
+ date: 2010-10-12 00:00:00 +02:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -79,7 +79,7 @@ dependencies:
79
79
  type: :development
80
80
  version_requirements: *id004
81
81
  - !ruby/object:Gem::Dependency
82
- name: autotest-growl
82
+ name: autotest-fsevent
83
83
  prerelease: false
84
84
  requirement: &id005 !ruby/object:Gem::Requirement
85
85
  none: false
@@ -93,38 +93,37 @@ dependencies:
93
93
  type: :development
94
94
  version_requirements: *id005
95
95
  - !ruby/object:Gem::Dependency
96
- name: rspec
96
+ name: autotest-growl
97
97
  prerelease: false
98
98
  requirement: &id006 !ruby/object:Gem::Requirement
99
99
  none: false
100
100
  requirements:
101
- - - ~>
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- hash: 7712058
103
+ hash: 3
104
104
  segments:
105
- - 2
106
- - 0
107
105
  - 0
108
- - rc
109
- version: 2.0.0.rc
106
+ version: "0"
110
107
  type: :development
111
108
  version_requirements: *id006
112
109
  - !ruby/object:Gem::Dependency
113
- name: fakeweb
110
+ name: rspec
114
111
  prerelease: false
115
112
  requirement: &id007 !ruby/object:Gem::Requirement
116
113
  none: false
117
114
  requirements:
118
115
  - - ">="
119
116
  - !ruby/object:Gem::Version
120
- hash: 3
117
+ hash: 15
121
118
  segments:
119
+ - 2
122
120
  - 0
123
- version: "0"
121
+ - 0
122
+ version: 2.0.0
124
123
  type: :development
125
124
  version_requirements: *id007
126
125
  - !ruby/object:Gem::Dependency
127
- name: cucumber
126
+ name: fakeweb
128
127
  prerelease: false
129
128
  requirement: &id008 !ruby/object:Gem::Requirement
130
129
  none: false
@@ -138,7 +137,7 @@ dependencies:
138
137
  type: :development
139
138
  version_requirements: *id008
140
139
  - !ruby/object:Gem::Dependency
141
- name: aruba
140
+ name: cucumber
142
141
  prerelease: false
143
142
  requirement: &id009 !ruby/object:Gem::Requirement
144
143
  none: false
@@ -151,6 +150,20 @@ dependencies:
151
150
  version: "0"
152
151
  type: :development
153
152
  version_requirements: *id009
153
+ - !ruby/object:Gem::Dependency
154
+ name: aruba
155
+ prerelease: false
156
+ requirement: &id010 !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ hash: 3
162
+ segments:
163
+ - 0
164
+ version: "0"
165
+ type: :development
166
+ version_requirements: *id010
154
167
  description: A wrapper for Hetzner.de's server management API
155
168
  email:
156
169
  - roland@moriz.de
@@ -198,6 +211,9 @@ files:
198
211
  - spec/fixtures/boot/vnc/delete.raw
199
212
  - spec/fixtures/boot/vnc/get.raw
200
213
  - spec/fixtures/boot/vnc/post.raw
214
+ - spec/fixtures/failover/get.raw
215
+ - spec/fixtures/failover/get_with_failover_ip.raw
216
+ - spec/fixtures/failover/post_with_active_server_ip.raw
201
217
  - spec/fixtures/ip/get.raw
202
218
  - spec/fixtures/ip/get_with_ip.raw
203
219
  - spec/fixtures/ip/get_with_server_ip.raw