piglop-ovh-rb 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,19 @@
1
+ module OvhRb
2
+ class OvhObject
3
+ include Converter
4
+
5
+ def initialize(object)
6
+ object.__xmlele.each do |attr, value|
7
+ value = convert_to_ovh_object(value)
8
+
9
+ attr_name = attr.name.underscore
10
+ instance_variable_set("@#{attr_name}", value)
11
+ unless self.class.method_defined?(attr_name)
12
+ self.class.class_eval do
13
+ define_method(attr_name) { instance_variable_get("@#{attr_name}") }
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ module OvhRb
2
+ class Session
3
+ include SoapRequestHandler
4
+
5
+ def initialize(nic, password, language = 'en', mulisession = true)
6
+ @nic = nic
7
+ @password = password
8
+ @language = language
9
+ @multisession = mulisession
10
+
11
+ self.soap_object = ManagerPortType.new
12
+ @session_id = login(@nic, @password, @language, @multisession)
13
+
14
+ if block_given?
15
+ begin
16
+ yield self
17
+ # ensure
18
+ # logout
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,50 @@
1
+ module OvhRb
2
+ module SoapRequestHandler
3
+ include Converter
4
+
5
+ attr_accessor :soap_object, :session_id
6
+
7
+ def method_missing(name, *args)
8
+ soap_method_name = name.to_s.camelize(:lower)
9
+
10
+ if soap_object.respond_to? soap_method_name
11
+ self.class.class_eval do
12
+ define_method_used = "define_#{(soap_method_name=="login"? "login" : "soapi")}_method"
13
+ send(define_method_used, name, soap_method_name)
14
+ end
15
+ send(name, *args)
16
+ else
17
+ super
18
+ end
19
+ end
20
+
21
+ def self.included(base)
22
+ base.extend(ClassMethods)
23
+ end
24
+
25
+ module ClassMethods
26
+ protected
27
+ def define_login_method(name, soap_method_name)
28
+ define_method(name) do |*method_args|
29
+ soap_object.send(soap_method_name, *method_args)
30
+ end
31
+ end
32
+
33
+ def define_soapi_method(name, soap_method_name)
34
+ define_method(name) do |*method_args|
35
+ soap_response = nil
36
+ soap_response = begin
37
+ soap_object.send(soap_method_name, *method_args.insert(0, session_id))
38
+ rescue ArgumentError => e
39
+ if e.to_s =~ /for 0/
40
+ soap_object.send(soap_method_name)
41
+ else
42
+ raise e
43
+ end
44
+ end
45
+ convert_to_ovh_object(soap_response) if soap_response
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,7 @@
1
+ ---
2
+ nic: XXX-ovh
3
+ password: XXX
4
+ aliases:
5
+ kim1: ksXXX.kimsufi.com
6
+ kim1_ip: X.X.X.X
7
+ failover1: X.X.X.X
@@ -0,0 +1,56 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{piglop-ovh-rb}
8
+ s.version = "0.1.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Michael Witrant", "Aur\303\251lien AMILIN"]
12
+ s.date = %q{2010-10-10}
13
+ s.email = %q{mike@lepton.fr}
14
+ s.executables = ["ovhrb", "failover_check"]
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "bin/failover_check",
26
+ "bin/ovhrb",
27
+ "lib/ovh-rb.rb",
28
+ "lib/ovhrb/config.rb",
29
+ "lib/ovhrb/converter.rb",
30
+ "lib/ovhrb/core_additions.rb",
31
+ "lib/ovhrb/manager/manager.rb",
32
+ "lib/ovhrb/manager/managerDriver.rb",
33
+ "lib/ovhrb/manager/managerServiceClient.rb",
34
+ "lib/ovhrb/ovh_object.rb",
35
+ "lib/ovhrb/session.rb",
36
+ "lib/ovhrb/soap_request_handler.rb",
37
+ "ovhrb.yml.sample",
38
+ "piglop-ovh-rb.gemspec"
39
+ ]
40
+ s.homepage = %q{http://github.com/piglop/ovh-rb}
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.3.7}
44
+ s.summary = %q{ovh-rb helps you to use the OVH SOAPI in a ruby way}
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ else
52
+ end
53
+ else
54
+ end
55
+ end
56
+
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: piglop-ovh-rb
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 3
10
+ version: 0.1.3
11
+ platform: ruby
12
+ authors:
13
+ - Michael Witrant
14
+ - "Aur\xC3\xA9lien AMILIN"
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-10-10 00:00:00 +02:00
20
+ default_executable:
21
+ dependencies: []
22
+
23
+ description:
24
+ email: mike@lepton.fr
25
+ executables:
26
+ - ovhrb
27
+ - failover_check
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - LICENSE
32
+ - README.rdoc
33
+ files:
34
+ - .gitignore
35
+ - LICENSE
36
+ - README.rdoc
37
+ - Rakefile
38
+ - VERSION
39
+ - bin/failover_check
40
+ - bin/ovhrb
41
+ - lib/ovh-rb.rb
42
+ - lib/ovhrb/config.rb
43
+ - lib/ovhrb/converter.rb
44
+ - lib/ovhrb/core_additions.rb
45
+ - lib/ovhrb/manager/manager.rb
46
+ - lib/ovhrb/manager/managerDriver.rb
47
+ - lib/ovhrb/manager/managerServiceClient.rb
48
+ - lib/ovhrb/ovh_object.rb
49
+ - lib/ovhrb/session.rb
50
+ - lib/ovhrb/soap_request_handler.rb
51
+ - ovhrb.yml.sample
52
+ - piglop-ovh-rb.gemspec
53
+ has_rdoc: true
54
+ homepage: http://github.com/piglop/ovh-rb
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options:
59
+ - --charset=UTF-8
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.3.7
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: ovh-rb helps you to use the OVH SOAPI in a ruby way
87
+ test_files: []
88
+