hetzner-api 0.0.2 → 1.0.0.alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +60 -0
  4. data/README.rdoc +1 -1
  5. data/Rakefile +2 -45
  6. data/bin/hetzner +3 -0
  7. data/cucumber.yml +1 -0
  8. data/features/hetzner.feature +8 -0
  9. data/features/support/setup.rb +1 -0
  10. data/hetzner-api.gemspec +25 -60
  11. data/lib/hetzner-api.rb +9 -8
  12. data/lib/{api → hetzner-api/api}/boot.rb +0 -0
  13. data/lib/hetzner-api/api/cli.rb +46 -0
  14. data/lib/{api → hetzner-api/api}/failover.rb +0 -0
  15. data/lib/{api → hetzner-api/api}/rdns.rb +0 -0
  16. data/lib/{api → hetzner-api/api}/rescue.rb +0 -0
  17. data/lib/{api → hetzner-api/api}/reset.rb +0 -0
  18. data/lib/{api → hetzner-api/api}/vnc.rb +0 -0
  19. data/lib/{api → hetzner-api/api}/windows.rb +0 -0
  20. data/lib/{api → hetzner-api/api}/wol.rb +0 -0
  21. data/lib/hetzner-api/version.rb +5 -0
  22. data/spec/api_stubs.rb +49 -0
  23. data/spec/fixtures/reset/get.raw +4 -0
  24. data/spec/fixtures/reset/get_with_ip.raw +4 -0
  25. data/spec/fixtures/reset/get_with_ip_unavailable.raw +8 -0
  26. data/spec/fixtures/reset/get_with_ip_unknown.raw +4 -0
  27. data/spec/fixtures/reset/post_with_ip.raw +10 -0
  28. data/spec/fixtures/reset/post_with_ip_invalid_input.raw +4 -0
  29. data/spec/fixtures/reset/post_with_ip_manual_active.raw +4 -0
  30. data/spec/fixtures/reset/post_with_ip_unavailable.raw +4 -0
  31. data/spec/fixtures/reset/post_with_ip_unknown.raw +4 -0
  32. data/spec/hetzner_spec.rb +71 -43
  33. data/spec/spec_constants.rb +13 -0
  34. data/spec/spec_helper.rb +7 -10
  35. metadata +170 -44
  36. data/.document +0 -5
  37. data/LICENSE +0 -20
  38. data/VERSION +0 -1
  39. data/spec/spec.opts +0 -1
data/.gitignore CHANGED
@@ -17,5 +17,8 @@ tmtags
17
17
  coverage
18
18
  rdoc
19
19
  pkg
20
+ *.gem
21
+ .bundle
20
22
 
21
23
  ## PROJECT::SPECIFIC
24
+ report.html
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in hetzner-api.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hetzner-api (1.0.0)
5
+ httparty
6
+ thor
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ aruba (0.2.3)
12
+ background_process
13
+ cucumber (~> 0.9.0)
14
+ autotest (4.2.10)
15
+ autotest-growl (0.2.4)
16
+ autotest (>= 4.2.4)
17
+ background_process (1.2)
18
+ builder (2.1.2)
19
+ crack (0.1.8)
20
+ cucumber (0.9.2)
21
+ builder (~> 2.1.2)
22
+ diff-lcs (~> 1.1.2)
23
+ gherkin (~> 2.2.5)
24
+ json (~> 1.4.6)
25
+ term-ansicolor (~> 1.0.5)
26
+ diff-lcs (1.1.2)
27
+ fakeweb (1.3.0)
28
+ gherkin (2.2.8)
29
+ json (~> 1.4.6)
30
+ term-ansicolor (~> 1.0.5)
31
+ httparty (0.6.1)
32
+ crack (= 0.1.8)
33
+ 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)
40
+ 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)
44
+ term-ansicolor (1.0.5)
45
+ thor (0.14.3)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ aruba
52
+ autotest
53
+ autotest-growl
54
+ bundler (>= 1.0.2)
55
+ cucumber
56
+ fakeweb
57
+ hetzner-api!
58
+ httparty
59
+ rspec (~> 2.0.0.rc)
60
+ thor
data/README.rdoc CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A HTTParty[http://httparty.rubyforge.org/] based wrapper for Hetzner.de's server management API.
4
4
 
5
- see http://wiki.hetzner.de/index.php/Robot_Webservice_en for details.
5
+ see http://wiki.hetzner.de/index.php?title=Robot_Webservice_en for details.
6
6
 
7
7
  == Installation
8
8
 
data/Rakefile CHANGED
@@ -1,45 +1,2 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "hetzner-api"
8
- gem.summary = %Q{A small, unofficial wrapper for Hetzner.de's API (server management)}
9
- gem.description = %Q{A small, unofficial wrapper for Hetzner.de's API (server management)}
10
- gem.email = "roland@rails.io"
11
- gem.homepage = "http://github.com/rmoriz/hetzner-api"
12
- gem.authors = ["Roland Moriz"]
13
- gem.add_development_dependency "rspec", ">= 1.2.9"
14
- gem.add_dependency "httparty", ">= 0.6.1"
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
20
-
21
- require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
25
- end
26
-
27
- Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.pattern = 'spec/**/*_spec.rb'
30
- spec.rcov = true
31
- end
32
-
33
- task :spec => :check_dependencies
34
-
35
- task :default => :spec
36
-
37
- require 'rake/rdoctask'
38
- Rake::RDocTask.new do |rdoc|
39
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
-
41
- rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "hetzner-api #{version}"
43
- rdoc.rdoc_files.include('README*')
44
- rdoc.rdoc_files.include('lib/**/*.rb')
45
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/hetzner ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'hetzner-api'
3
+ Hetzner::API::CLI.start
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --format html --out report.html --format pretty
@@ -0,0 +1,8 @@
1
+ Feature: Hetzner
2
+ In order to manage one or many dedicated servers at hetzner
3
+ As a CLI
4
+ I want to provider a decent, objective interface
5
+
6
+ Scenario: Display boot options for one server
7
+ When I run "hetzner boot show 78.46.50.215 --username --password "
8
+ Then the output should contain "178.46.50.215"
@@ -0,0 +1 @@
1
+ require 'aruba'
data/hetzner-api.gemspec CHANGED
@@ -1,66 +1,31 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/hetzner-api/version", __FILE__)
5
3
 
6
4
  Gem::Specification.new do |s|
7
- s.name = %q{hetzner-api}
8
- s.version = "0.0.2"
5
+ s.name = "hetzner-api"
6
+ s.version = Hetzner::Api::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ['Roland Moriz']
9
+ s.email = ['roland@moriz.de']
10
+ s.homepage = "http://moriz.de/opensource/hetzner-api"
11
+ s.summary = "A wrapper for Hetzner.de's server management API"
12
+ s.description = "A wrapper for Hetzner.de's server management API"
9
13
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Roland Moriz"]
12
- s.date = %q{2010-09-03}
13
- s.description = %q{A small, unofficial wrapper for Hetzner.de's API (server management)}
14
- s.email = %q{roland@rails.io}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "hetzner-api.gemspec",
27
- "lib/api/boot.rb",
28
- "lib/api/failover.rb",
29
- "lib/api/rdns.rb",
30
- "lib/api/rescue.rb",
31
- "lib/api/reset.rb",
32
- "lib/api/vnc.rb",
33
- "lib/api/windows.rb",
34
- "lib/api/wol.rb",
35
- "lib/hetzner-api.rb",
36
- "spec/hetzner_spec.rb",
37
- "spec/spec.opts",
38
- "spec/spec_helper.rb"
39
- ]
40
- s.homepage = %q{http://github.com/rmoriz/hetzner-api}
41
- s.rdoc_options = ["--charset=UTF-8"]
42
- s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.3.6}
44
- s.summary = %q{A small, unofficial wrapper for Hetzner.de's API (server management)}
45
- s.test_files = [
46
- "spec/hetzner_spec.rb",
47
- "spec/spec_helper.rb"
48
- ]
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "hetzner-api"
49
16
 
50
- if s.respond_to? :specification_version then
51
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
- s.specification_version = 3
53
-
54
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
56
- s.add_runtime_dependency(%q<httparty>, [">= 0.6.1"])
57
- else
58
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
59
- s.add_dependency(%q<httparty>, [">= 0.6.1"])
60
- end
61
- else
62
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
63
- s.add_dependency(%q<httparty>, [">= 0.6.1"])
64
- end
17
+ s.add_dependency 'httparty'
18
+ s.add_dependency 'thor'
19
+
20
+ s.add_development_dependency "bundler", ">= 1.0.2"
21
+ s.add_development_dependency "autotest"
22
+ s.add_development_dependency "autotest-growl"
23
+ s.add_development_dependency "rspec", "~> 2.0.0.rc"
24
+ s.add_development_dependency "fakeweb"
25
+ s.add_development_dependency "cucumber"
26
+ s.add_development_dependency "aruba"
27
+
28
+ s.files = `git ls-files`.split("\n")
29
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
30
+ s.require_path = 'lib'
65
31
  end
66
-
data/lib/hetzner-api.rb CHANGED
@@ -1,14 +1,15 @@
1
1
  require 'httparty'
2
2
  require 'forwardable'
3
3
 
4
- require 'api/boot'
5
- require 'api/failover'
6
- require 'api/rdns'
7
- require 'api/rescue'
8
- require 'api/reset'
9
- require 'api/vnc'
10
- require 'api/windows'
11
- require 'api/wol'
4
+ require 'hetzner-api/api/cli'
5
+ require 'hetzner-api/api/boot'
6
+ require 'hetzner-api/api/failover'
7
+ require 'hetzner-api/api/rdns'
8
+ require 'hetzner-api/api/rescue'
9
+ require 'hetzner-api/api/reset'
10
+ require 'hetzner-api/api/vnc'
11
+ require 'hetzner-api/api/windows'
12
+ require 'hetzner-api/api/wol'
12
13
 
13
14
  module Hetzner
14
15
  class API
File without changes
@@ -0,0 +1,46 @@
1
+ require 'thor'
2
+ require 'ipaddr'
3
+ require 'pp'
4
+ require 'json'
5
+
6
+ module Hetzner
7
+ class API
8
+ class CLI < Thor
9
+ attr_accessor :api
10
+
11
+ desc "boot ACTION [SERVER_IP]", "'get' available boot options"
12
+ method_options :username => :string
13
+ method_options :password => :string
14
+
15
+ def boot(action, ip = '')
16
+ generate_api_instance
17
+ case action
18
+ when 'get'
19
+ require_ip ip
20
+ result = @api.boot?(ip)
21
+ pp result.parsed_response
22
+ #result.body.to_yaml
23
+ else
24
+ raise UnknownArgumentError, "'#{action}' is not a valid action!"
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def require_ip(ip)
31
+ ip = IPAddr.new ip
32
+ rescue ArgumentError
33
+ raise RequiredArgumentMissingError, "server IP missing!"
34
+ end
35
+
36
+ def generate_api_instance
37
+ if options.username && options.password
38
+ @api = Hetzner::API.new options.username, options.password
39
+ else
40
+ # TODO: load from .hetzner
41
+ raise RequiredArgumentMissingError, "missing credentials!"
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ module Hetzner
2
+ class Api
3
+ VERSION = "1.0.0.alpha.1"
4
+ end
5
+ end
data/spec/api_stubs.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'fakeweb'
2
+
3
+ @base_dir = File.dirname(__FILE__)
4
+
5
+ def fixture(path)
6
+ File.expand_path(@base_dir + '/fixtures/' + @resource + '/' + path)
7
+ end
8
+
9
+ def uri(path = nil)
10
+ url = "https://#{API_USERNAME}:#{API_PASSWORD}@#{API_SERVER}/#{@resource}"
11
+ url << "/#{path}" if path
12
+ url
13
+ end
14
+
15
+ FakeWeb.allow_net_connect = false
16
+
17
+
18
+ @resource = 'reset'
19
+
20
+ FakeWeb.register_uri :get, uri,
21
+ :response => fixture('get.raw')
22
+
23
+ FakeWeb.register_uri :get, uri("#{WORKING_IP}"),
24
+ :response => fixture('get_with_ip.raw')
25
+
26
+ FakeWeb.register_uri :get, uri("#{UNKOWN_IP}"),
27
+ :response => fixture('get_with_ip_unknown.raw')
28
+
29
+ FakeWeb.register_uri :get, uri("#{RESET_IP_NOT_AVAILABLE}"),
30
+ :response => fixture('get_with_ip_unavailable.raw')
31
+
32
+
33
+ FakeWeb.register_uri :post, uri("#{WORKING_IP}?type=sw"),
34
+ :response => fixture('post_with_ip.raw')
35
+
36
+ FakeWeb.register_uri :post, uri("#{WORKING_IP}?type=foo"),
37
+ :response => fixture('post_with_ip_invalid_input.raw')
38
+
39
+ FakeWeb.register_uri :post, uri("#{RESET_IP_MANUAL_ACTIVE}?type=sw"),
40
+ :response => fixture('post_with_ip_manual_active.raw')
41
+
42
+ FakeWeb.register_uri :post, uri("#{RESET_IP_NOT_AVAILABLE}?type=sw"),
43
+ :response => fixture('post_with_ip_unavailable.raw')
44
+
45
+ FakeWeb.register_uri :post, uri("#{UNKOWN_IP}?type=sw"),
46
+ :response => fixture('post_with_ip_unknown.raw')
47
+
48
+
49
+ #pp FakeWeb::Registry.instance.uri_map
@@ -0,0 +1,4 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: application/json
3
+
4
+ [{"reset":{"server_ip":"11.11.11.111","type":["man","hw","sw"]}}]
@@ -0,0 +1,4 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: application/json
3
+
4
+ {"reset":{"server_ip":"78.46.50.215","type":["man","hw","sw"]}}
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 404 Not Found
2
+ Date: Thu, 07 Oct 2010 15:11:38 GMT
3
+ Server: Apache
4
+ X-Powered-By: PHP/5.2.14
5
+ Content-Length: 79
6
+ Content-Type: application/json
7
+
8
+ {"error":{"status":404,"code":"RESET_NOT_AVAILABLE","message":""}}
@@ -0,0 +1,4 @@
1
+ HTTP/1.1 404 Not Found
2
+ Content-Type: application/json
3
+
4
+ {"error":{"status":404,"code":"SERVER_NOT_FOUND","message":"server not found"}}
@@ -0,0 +1,10 @@
1
+ HTTP/1.1 200 OK
2
+ Content-Type: application/json
3
+
4
+ {
5
+ "reset":
6
+ {
7
+ "server_ip": "11.11.11.111",
8
+ "type": "hw"
9
+ }
10
+ }
@@ -0,0 +1,4 @@
1
+ HTTP/1.1 400
2
+ Content-Type: application/json
3
+
4
+ {"error":{"status":400,"code":"INVALID_INPUT","message":""}}
@@ -0,0 +1,4 @@
1
+ HTTP/1.1 409
2
+ Content-Type: application/json
3
+
4
+ {"error":{"status":409,"code":"RESET_MANUAL_ACTIVE","message":""}}
@@ -0,0 +1,4 @@
1
+ HTTP/1.1 404 Not Found
2
+ Content-Type: application/json
3
+
4
+ {"error":{"status":404,"code":"RESET_NOT_AVAILABLE","message":""}}
@@ -0,0 +1,4 @@
1
+ HTTP/1.1 404 Not Found
2
+ Content-Type: application/json
3
+
4
+ {"error":{"status":404,"code":"SERVER_NOT_FOUND","message":""}}
data/spec/hetzner_spec.rb CHANGED
@@ -1,41 +1,69 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'hetzner-api'
2
+ require 'spec_helper'
2
3
 
3
- TEST_IP = ''
4
- TEST_PTR = ''
5
- RDNS_TEST_IP = ''
6
- USERNAME = ''
7
- PASSWORD = ''
8
-
9
4
  describe "Reset" do
10
- describe "query status" do
5
+ describe "query" do
11
6
  before(:all) do
12
- @h = Hetzner::API.new(USERNAME, PASSWORD)
7
+ @h = Hetzner::API.new(API_USERNAME, API_PASSWORD)
13
8
  end
14
9
 
15
- it "should list available reset options" do
10
+ it "should list available reset options for all servers" do
16
11
  result = @h.reset?
17
- result.should == [{"reset"=>{"server_ip"=>TEST_IP, "type"=>["man", "hw", "sw"]}}]
12
+ result.response.should be_an_instance_of Net::HTTPOK
13
+ result.parsed_response.should have_at_least(1).entry
18
14
  end
19
15
 
20
- it "should list available reset options" do
21
- result = @h.reset? TEST_IP
22
- result.should == {"reset"=>{"server_ip"=>TEST_IP, "type"=>["man", "hw", "sw"]}}
16
+ it "should list available reset options for a specific IP" do
17
+ result = @h.reset? WORKING_IP
18
+ result.response.should be_an_instance_of Net::HTTPOK
19
+ result.parsed_response.should have_key('reset')
23
20
  end
24
21
 
25
- it "should fail on a unknown ip" do
26
- result = @h.reset? "127.0.0.1"
27
- result['error']['status'].should == 404
22
+ it "should fail when IP is unknown" do
23
+ result = @h.reset? UNKOWN_IP
24
+ result.response.should be_an_instance_of Net::HTTPNotFound
25
+ result.parsed_response.should have_JSON_error_code :SERVER_NOT_FOUND
28
26
  end
27
+
28
+ it "should fail when IP has no reset option" do
29
+ result = @h.reset? RESET_IP_NOT_AVAILABLE
30
+ result.response.should be_an_instance_of Net::HTTPNotFound
31
+ result.parsed_response.should have_JSON_error_code :RESET_NOT_AVAILABLE
32
+ end
29
33
  end
30
34
 
31
- describe "do reset" do
35
+ describe "execution" do
32
36
  before(:all) do
33
- @h = Hetzner::API.new(USERNAME, PASSWORD)
37
+ @h = Hetzner::API.new(API_USERNAME, API_PASSWORD)
38
+ end
39
+
40
+ it "should reset the specific IP" do
41
+ result = @h.reset! WORKING_IP, :sw
42
+ result.response.should be_an_instance_of Net::HTTPOK
43
+ end
44
+
45
+ it "should fail for the specific IP if input is invalid" do
46
+ result = @h.reset! WORKING_IP, :foo
47
+ result.response.should be_an_instance_of Net::HTTPBadRequest
48
+ result.parsed_response.should have_JSON_error_code :INVALID_INPUT
49
+ end
50
+
51
+ it "should fail for the specific IP if a manual reset is active" do
52
+ result = @h.reset! RESET_IP_MANUAL_ACTIVE, :sw
53
+ result.response.should be_an_instance_of Net::HTTPConflict
54
+ result.parsed_response.should have_JSON_error_code :RESET_MANUAL_ACTIVE
55
+ end
56
+
57
+ it "should fail for the specific IP if reset is unavailable" do
58
+ result = @h.reset! RESET_IP_NOT_AVAILABLE, :sw
59
+ result.response.should be_an_instance_of Net::HTTPNotFound
60
+ result.parsed_response.should have_JSON_error_code :RESET_NOT_AVAILABLE
34
61
  end
35
62
 
36
- it "should reset the server" do
37
- result = @h.reset! "123.123.123.223", :sw
38
- result.should == { "reset"=> {"server_ip"=>"123.123.123.123", "type"=> "sw" } }
63
+ it "should fail for the specific IP if IP is unknown" do
64
+ result = @h.reset! UNKOWN_IP, :sw
65
+ result.response.should be_an_instance_of Net::HTTPNotFound
66
+ result.parsed_response.should have_JSON_error_code :SERVER_NOT_FOUND
39
67
  end
40
68
  end
41
69
  end
@@ -47,8 +75,8 @@ describe "Boot" do
47
75
  end
48
76
 
49
77
  it "should display the boot configuration" do
50
- result = @h.boot? TEST_IP
51
- result.should == {"boot"=>{"vnc"=>{"arch"=>[64, 32], "server_ip"=>TEST_IP, "lang"=>["de_DE", "en_US", "fr_FR"], "dist"=>["centOS-5.3", "centOS-5.4", "centOS-5.5", "Fedora-11", "Fedora-12", "Fedora-13", "Fedora-9", "openSUSE-11.0", "openSUSE-11.1", "openSUSE-11.3"], "password"=>nil, "active"=>false}, "rescue"=>{"arch"=>[64, 32], "os"=>["linux", "freebsd", "opensolaris", "vkvm"], "server_ip"=>TEST_IP, "password"=>nil, "active"=>false}, "windows"=>{"server_ip"=>TEST_IP, "lang"=>nil, "dist"=>nil, "password"=>nil, "active"=>false}}}
78
+ result = @h.boot? WORKING_IP
79
+ result.should == {"boot"=>{"vnc"=>{"arch"=>[64, 32], "server_ip"=>WORKING_IP, "lang"=>["de_DE", "en_US", "fr_FR"], "dist"=>["centOS-5.3", "centOS-5.4", "centOS-5.5", "Fedora-11", "Fedora-12", "Fedora-13", "Fedora-9", "openSUSE-11.0", "openSUSE-11.1", "openSUSE-11.3"], "password"=>nil, "active"=>false}, "rescue"=>{"arch"=>[64, 32], "os"=>["linux", "freebsd", "opensolaris", "vkvm"], "server_ip"=>WORKING_IP, "password"=>nil, "active"=>false}, "windows"=>{"server_ip"=>WORKING_IP, "lang"=>nil, "dist"=>nil, "password"=>nil, "active"=>false}}}
52
80
  end
53
81
  end
54
82
 
@@ -57,17 +85,17 @@ describe "Boot" do
57
85
  @h = Hetzner::API.new(USERNAME, PASSWORD)
58
86
  end
59
87
  it "should be able to activate" do
60
- result = @h.enable_rescue! TEST_IP
88
+ result = @h.enable_rescue! WORKING_IP
61
89
 
62
- # {"rescue"=>{"arch"=>64, "os"=>"linux", "server_ip"=>TEST_IP, "password"=>"h9JbXPz8", "active"=>true}}
90
+ # {"rescue"=>{"arch"=>64, "os"=>"linux", "server_ip"=>WORKING_IP, "password"=>"h9JbXPz8", "active"=>true}}
63
91
  result['rescue']['arch'].should == 64
64
92
  result['rescue']['os'].should == 'linux'
65
93
  result['rescue']['active'].should be_true
66
94
  end
67
95
 
68
96
  it "should be able to deactivate" do
69
- result = @h.disable_rescue! TEST_IP
70
- result.should == {"rescue"=>{"arch"=>[64, 32], "os"=>["linux", "freebsd", "opensolaris", "vkvm"], "server_ip"=>TEST_IP, "password"=>nil, "active"=>false}}
97
+ result = @h.disable_rescue! WORKING_IP
98
+ result.should == {"rescue"=>{"arch"=>[64, 32], "os"=>["linux", "freebsd", "opensolaris", "vkvm"], "server_ip"=>WORKING_IP, "password"=>nil, "active"=>false}}
71
99
  end
72
100
  end
73
101
  end
@@ -78,19 +106,19 @@ describe "Rdns" do
78
106
  end
79
107
 
80
108
  it "should query the current rdns status" do
81
- result = @h.rdns? TEST_IP
82
- result['rdns']['ip'].should == TEST_IP
109
+ result = @h.rdns? WORKING_IP
110
+ result['rdns']['ip'].should == WORKING_IP
83
111
  result['rdns']['ptr'].should == TEST_PTR
84
112
  end
85
113
 
86
114
  it "should be able to set a new ptr" do
87
- result = @h.rdns! RDNS_TEST_IP, 'testen.de'
88
- result['rdns']['ip'].should == RDNS_TEST_IP
115
+ result = @h.rdns! RDNS_WORKING_IP, 'testen.de'
116
+ result['rdns']['ip'].should == RDNS_WORKING_IP
89
117
  result['rdns']['ptr'].should == 'testen.de'
90
118
  end
91
119
 
92
120
  it "should be able to remove a new ptr" do
93
- result = @h.delete_rdns! RDNS_TEST_IP
121
+ result = @h.delete_rdns! RDNS_WORKING_IP
94
122
  puts result
95
123
  end
96
124
  end
@@ -101,22 +129,22 @@ describe "VNC" do
101
129
  end
102
130
 
103
131
  it "should be able to query vnc boot status" do
104
- result = @h.boot_vnc? TEST_IP
105
- result['vnc']['server_ip'].should == TEST_IP
132
+ result = @h.boot_vnc? WORKING_IP
133
+ result['vnc']['server_ip'].should == WORKING_IP
106
134
  result['vnc']['active'].should be_false
107
135
  result['vnc']['password'].should be_nil
108
136
  end
109
137
 
110
138
  it "should be able to set vnc boot status" do
111
- result = @h.boot_vnc! TEST_IP, 'Fedora-13', '32', 'en_US'
112
- result['vnc']['server_ip'].should == TEST_IP
139
+ result = @h.boot_vnc! WORKING_IP, 'Fedora-13', '32', 'en_US'
140
+ result['vnc']['server_ip'].should == WORKING_IP
113
141
  result['vnc']['active'].should be_true
114
142
  result['vnc']['password'].should_not be_nil
115
143
  end
116
144
 
117
145
  it "should be able to disable vnc boot status" do
118
- result = @h.disable_boot_vnc! TEST_IP
119
- result['vnc']['server_ip'].should == TEST_IP
146
+ result = @h.disable_boot_vnc! WORKING_IP
147
+ result['vnc']['server_ip'].should == WORKING_IP
120
148
  result['vnc']['active'].should be_false
121
149
  result['vnc']['password'].should be_nil
122
150
  end
@@ -128,12 +156,12 @@ describe "WOL" do
128
156
  end
129
157
 
130
158
  it "should be able to query WOL status" do
131
- result = @h.wol? TEST_IP
132
- result['wol']['server_ip'].should == TEST_IP
159
+ result = @h.wol? WORKING_IP
160
+ result['wol']['server_ip'].should == WORKING_IP
133
161
  end
134
162
 
135
163
  it "should be able to send a WOL notification" do
136
- result = @h.wol! TEST_IP
137
- result['wol']['server_ip'].should == TEST_IP
164
+ result = @h.wol! WORKING_IP
165
+ result['wol']['server_ip'].should == WORKING_IP
138
166
  end
139
167
  end
@@ -0,0 +1,13 @@
1
+ WORKING_IP = '11.11.11.111'
2
+ UNKOWN_IP = '11.11.11.222'
3
+
4
+ RESET_IP_NOT_AVAILABLE = '11.11.11.223'
5
+ RESET_IP_MANUAL_ACTIVE = '11.11.11.224'
6
+ RESET_IP_FAILED = '11.11.11.225'
7
+
8
+ TEST_PTR = ''
9
+ RDNS_TEST_IP = ''
10
+
11
+ API_SERVER = 'robot-ws.your-server.de'
12
+ API_USERNAME = 'myusername'
13
+ API_PASSWORD = 'mycoolpassword'
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,8 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ require "spec_constants"
2
+ require "api_stubs"
3
3
 
4
- require 'rubygems'
5
- require 'hetzner-api'
6
- require 'spec'
7
- require 'spec/autorun'
8
-
9
- Spec::Runner.configure do |config|
10
-
11
- end
4
+ RSpec::Matchers.define :have_JSON_error_code do |expected|
5
+ match do |actual|
6
+ actual['error']['code'] == expected.to_s
7
+ end
8
+ end
metadata CHANGED
@@ -1,12 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hetzner-api
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: -3702664322
5
+ prerelease: true
5
6
  segments:
7
+ - 1
6
8
  - 0
7
9
  - 0
8
- - 2
9
- version: 0.0.2
10
+ - alpha
11
+ - 1
12
+ version: 1.0.0.alpha.1
10
13
  platform: ruby
11
14
  authors:
12
15
  - Roland Moriz
@@ -14,96 +17,219 @@ autorequire:
14
17
  bindir: bin
15
18
  cert_chain: []
16
19
 
17
- date: 2010-09-03 00:00:00 +02:00
20
+ date: 2010-10-07 00:00:00 +02:00
18
21
  default_executable:
19
22
  dependencies:
20
23
  - !ruby/object:Gem::Dependency
21
- name: rspec
24
+ name: httparty
22
25
  prerelease: false
23
26
  requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
24
28
  requirements:
25
29
  - - ">="
26
30
  - !ruby/object:Gem::Version
31
+ hash: 3
27
32
  segments:
28
- - 1
29
- - 2
30
- - 9
31
- version: 1.2.9
32
- type: :development
33
+ - 0
34
+ version: "0"
35
+ type: :runtime
33
36
  version_requirements: *id001
34
37
  - !ruby/object:Gem::Dependency
35
- name: httparty
38
+ name: thor
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 3
41
46
  segments:
42
47
  - 0
43
- - 6
44
- - 1
45
- version: 0.6.1
48
+ version: "0"
46
49
  type: :runtime
47
50
  version_requirements: *id002
48
- description: A small, unofficial wrapper for Hetzner.de's API (server management)
49
- email: roland@rails.io
50
- executables: []
51
-
51
+ - !ruby/object:Gem::Dependency
52
+ name: bundler
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 19
60
+ segments:
61
+ - 1
62
+ - 0
63
+ - 2
64
+ version: 1.0.2
65
+ type: :development
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: autotest
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ type: :development
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: autotest-growl
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ type: :development
94
+ version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ hash: 7712058
104
+ segments:
105
+ - 2
106
+ - 0
107
+ - 0
108
+ - rc
109
+ version: 2.0.0.rc
110
+ type: :development
111
+ version_requirements: *id006
112
+ - !ruby/object:Gem::Dependency
113
+ name: fakeweb
114
+ prerelease: false
115
+ requirement: &id007 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ type: :development
125
+ version_requirements: *id007
126
+ - !ruby/object:Gem::Dependency
127
+ name: cucumber
128
+ prerelease: false
129
+ requirement: &id008 !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ type: :development
139
+ version_requirements: *id008
140
+ - !ruby/object:Gem::Dependency
141
+ name: aruba
142
+ prerelease: false
143
+ requirement: &id009 !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ hash: 3
149
+ segments:
150
+ - 0
151
+ version: "0"
152
+ type: :development
153
+ version_requirements: *id009
154
+ description: A wrapper for Hetzner.de's server management API
155
+ email:
156
+ - roland@moriz.de
157
+ executables:
158
+ - hetzner
52
159
  extensions: []
53
160
 
54
- extra_rdoc_files:
55
- - LICENSE
56
- - README.rdoc
161
+ extra_rdoc_files: []
162
+
57
163
  files:
58
- - .document
59
164
  - .gitignore
60
- - LICENSE
165
+ - Gemfile
166
+ - Gemfile.lock
61
167
  - README.rdoc
62
168
  - Rakefile
63
- - VERSION
169
+ - bin/hetzner
170
+ - cucumber.yml
171
+ - features/hetzner.feature
172
+ - features/support/setup.rb
64
173
  - hetzner-api.gemspec
65
- - lib/api/boot.rb
66
- - lib/api/failover.rb
67
- - lib/api/rdns.rb
68
- - lib/api/rescue.rb
69
- - lib/api/reset.rb
70
- - lib/api/vnc.rb
71
- - lib/api/windows.rb
72
- - lib/api/wol.rb
73
174
  - lib/hetzner-api.rb
175
+ - lib/hetzner-api/api/boot.rb
176
+ - lib/hetzner-api/api/cli.rb
177
+ - lib/hetzner-api/api/failover.rb
178
+ - lib/hetzner-api/api/rdns.rb
179
+ - lib/hetzner-api/api/rescue.rb
180
+ - lib/hetzner-api/api/reset.rb
181
+ - lib/hetzner-api/api/vnc.rb
182
+ - lib/hetzner-api/api/windows.rb
183
+ - lib/hetzner-api/api/wol.rb
184
+ - lib/hetzner-api/version.rb
185
+ - spec/api_stubs.rb
186
+ - spec/fixtures/reset/get.raw
187
+ - spec/fixtures/reset/get_with_ip.raw
188
+ - spec/fixtures/reset/get_with_ip_unavailable.raw
189
+ - spec/fixtures/reset/get_with_ip_unknown.raw
190
+ - spec/fixtures/reset/post_with_ip.raw
191
+ - spec/fixtures/reset/post_with_ip_invalid_input.raw
192
+ - spec/fixtures/reset/post_with_ip_manual_active.raw
193
+ - spec/fixtures/reset/post_with_ip_unavailable.raw
194
+ - spec/fixtures/reset/post_with_ip_unknown.raw
74
195
  - spec/hetzner_spec.rb
75
- - spec/spec.opts
196
+ - spec/spec_constants.rb
76
197
  - spec/spec_helper.rb
77
198
  has_rdoc: true
78
- homepage: http://github.com/rmoriz/hetzner-api
199
+ homepage: http://moriz.de/opensource/hetzner-api
79
200
  licenses: []
80
201
 
81
202
  post_install_message:
82
- rdoc_options:
83
- - --charset=UTF-8
203
+ rdoc_options: []
204
+
84
205
  require_paths:
85
206
  - lib
86
207
  required_ruby_version: !ruby/object:Gem::Requirement
208
+ none: false
87
209
  requirements:
88
210
  - - ">="
89
211
  - !ruby/object:Gem::Version
212
+ hash: 3
90
213
  segments:
91
214
  - 0
92
215
  version: "0"
93
216
  required_rubygems_version: !ruby/object:Gem::Requirement
217
+ none: false
94
218
  requirements:
95
219
  - - ">="
96
220
  - !ruby/object:Gem::Version
221
+ hash: 23
97
222
  segments:
98
- - 0
99
- version: "0"
223
+ - 1
224
+ - 3
225
+ - 6
226
+ version: 1.3.6
100
227
  requirements: []
101
228
 
102
- rubyforge_project:
103
- rubygems_version: 1.3.6
229
+ rubyforge_project: hetzner-api
230
+ rubygems_version: 1.3.7
104
231
  signing_key:
105
232
  specification_version: 3
106
- summary: A small, unofficial wrapper for Hetzner.de's API (server management)
107
- test_files:
108
- - spec/hetzner_spec.rb
109
- - spec/spec_helper.rb
233
+ summary: A wrapper for Hetzner.de's server management API
234
+ test_files: []
235
+
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010 Roland Moriz
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.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.2
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color