splicer-rackspace 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/splicer/rackspace.rb +12 -0
- data/lib/splicer/rackspace/config.rb +19 -0
- data/lib/splicer/rackspace/provider.rb +102 -0
- data/lib/splicer/rackspace/version.rb +5 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/splicer/rackspace/config_spec.rb +26 -0
- data/spec/splicer/rackspace/provider_spec.rb +8 -0
- data/splicer-rackspace.gemspec +27 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9325ef5229cb9e11dd797df6016985219d8d3bb8
|
4
|
+
data.tar.gz: a48cba9df16494208d1a6f7cd295e59310757899
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0764521d534c8b2aab6d8f3b35ffc1fce48038660bfdc7de870925757158cfcf218b3a4c2ff83a6dc9c0c782a764ae6691af55d16bb8b5713758cd56ae164784
|
7
|
+
data.tar.gz: fc2b518b362b9002dbb191f8de64ef93b02895b7bd5eaae7680db75092eaac830f2633195f687a12280bb6838b69da60185fb755d700e1cbc55dc0e6d5fb3f1b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.6
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Oliver Garcia
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Splicer::Rackspace
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'splicer-rackspace'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install splicer-rackspace
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Splicer
|
2
|
+
module Rackspace
|
3
|
+
|
4
|
+
class Config
|
5
|
+
attr_reader :api_key, :username, :email
|
6
|
+
|
7
|
+
def initialize(api_key:, username:, email:)
|
8
|
+
@api_key = api_key
|
9
|
+
@username = username
|
10
|
+
@email = email
|
11
|
+
end
|
12
|
+
|
13
|
+
def provider
|
14
|
+
Provider.new(self)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Splicer
|
2
|
+
module Rackspace
|
3
|
+
|
4
|
+
class Provider < Splicer::Provider
|
5
|
+
attr_reader :client, :records, :config
|
6
|
+
|
7
|
+
def initialize(config)
|
8
|
+
@config = config
|
9
|
+
@client = Fog::DNS.new(provider: 'Rackspace', rackspace_api_key: config.api_key, rackspace_username: config.username)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_zone(zone)
|
13
|
+
Splicer.logger.debug "[SPLICER][RACKSPACE] #create_zone zone=#{zone.inspect}"
|
14
|
+
domain = client.zones.get(zone.name)
|
15
|
+
|
16
|
+
if domain
|
17
|
+
client.zones.create(domain: zone.name, email: config.email)
|
18
|
+
else
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete_zone(zone)
|
24
|
+
Splicer.logger.debug "[SPLICER][RACKSPACE] #delete_zone zone=#{zone.inspect}"
|
25
|
+
domain = client.zones.get(zone.name)
|
26
|
+
domain ? domain.destroy : false
|
27
|
+
end
|
28
|
+
|
29
|
+
def delete_record_in_zone(record, zone)
|
30
|
+
Splicer.logger.debug "[SPLICER][RACKSPACE] #delete_record_in_zone record=#{record.inspect} zone=#{zone.inspect}"
|
31
|
+
domain = client.zones.get(zone.name)
|
32
|
+
return false unless domain
|
33
|
+
|
34
|
+
rax_record = domain.records.detect { |r| r.name == record.name && r.type == record.type }
|
35
|
+
rax_record ? rax_record.destroy : false
|
36
|
+
end
|
37
|
+
|
38
|
+
def update_record_in_zone(record, zone)
|
39
|
+
Splicer.logger.debug "[SPLICER][RACKSPACE] #update_record_in_zone record=#{record.inspect} zone=#{zone.inspect}"
|
40
|
+
domain = client.zones.get(zone.name)
|
41
|
+
return false unless domain
|
42
|
+
|
43
|
+
rax_record = domain.records.detect { |r| r.name == record.name && r.type == record.type }
|
44
|
+
rax_record ? rax_record.update(record_payload(record)) : false
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_record_in_zone(record, zone)
|
48
|
+
Splicer.logger.debug "[SPLICER][RACKSPACE] #create_record_in_zone record=#{record.inspect} zone=#{zone.inspect}"
|
49
|
+
domain = client.zones.get(zone.name) || client.zones.create(domain: zone.name, email: config.email)
|
50
|
+
|
51
|
+
rax_record = domain.records.detect { |r| r.name == record.name && r.type == record.type }
|
52
|
+
rax_record ? false : domain.records.create(record_payload(record))
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_records_for(zone)
|
56
|
+
Splicer.logger.debug "[SPLICER][RACKSPACE] #get_records_for zone=#{zone.inspect}"
|
57
|
+
domain = client.zones.get(zone.name)
|
58
|
+
return [] unless domain
|
59
|
+
domains.records
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def record_payload(record)
|
65
|
+
payload = {
|
66
|
+
type: record.type,
|
67
|
+
name: record.name ? record.name : '',
|
68
|
+
ttl: record.ttl
|
69
|
+
}
|
70
|
+
case record
|
71
|
+
when Splicer::Records::ARecord
|
72
|
+
payload.merge!({ value: record.ip })
|
73
|
+
when Splicer::Records::AAAARecord
|
74
|
+
payload.merge!({ value: record.ip })
|
75
|
+
when Splicer::Records::CNAMERecord
|
76
|
+
payload.merge!({ value: record.cname })
|
77
|
+
when Splicer::Records::MXRecord
|
78
|
+
payload.merge!({ value: record.exchanger, mxLevel: record.priority })
|
79
|
+
when Splicer::Records::NSRecord
|
80
|
+
payload.merge!({ value: record.server })
|
81
|
+
when Splicer::Records::PTRRecord
|
82
|
+
payload.merge!({ value: record.host })
|
83
|
+
when Splicer::Records::SRVRecord
|
84
|
+
payload.merge!({
|
85
|
+
value: record.target,
|
86
|
+
weight: record.weight,
|
87
|
+
priority: record.priority,
|
88
|
+
port: record.port
|
89
|
+
})
|
90
|
+
when Splicer::Records::TXTRecord
|
91
|
+
payload.merge!({
|
92
|
+
value: record.text
|
93
|
+
})
|
94
|
+
else
|
95
|
+
payload = {}
|
96
|
+
end
|
97
|
+
payload
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Splicer::Rackspace::Config do
|
4
|
+
let(:config) { Splicer::Rackspace::Config.new(api_key: 'api_key', username: 'username', email: 'email@example.com') }
|
5
|
+
|
6
|
+
describe '#initialize' do
|
7
|
+
subject { config }
|
8
|
+
|
9
|
+
it "should find :api_key to be equal to 'api_key'" do
|
10
|
+
expect(config.api_key).to eq('api_key')
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should find :username to be equal to 'username'" do
|
14
|
+
expect(config.username).to eq('username')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should find :email to be equal to 'email@example.com'" do
|
18
|
+
expect(config.email).to eq('email@example.com')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#provider' do
|
23
|
+
subject { config.provider }
|
24
|
+
it { should be_a(Splicer::Rackspace::Provider) }
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Splicer::Rackspace::Provider do
|
4
|
+
let(:config) { Splicer::Rackspace::Config.new(api_key: 'api_key', username: 'username', email: 'email@example.com') }
|
5
|
+
let(:provider) { Splicer::Rackspace::Provider.new(config) }
|
6
|
+
|
7
|
+
# TODO Write tests
|
8
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'splicer/rackspace/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'splicer-rackspace'
|
8
|
+
spec.version = Splicer::Rackspace::VERSION
|
9
|
+
spec.authors = ['Oliver Garcia']
|
10
|
+
spec.email = ['oliver@pressable.com']
|
11
|
+
spec.description = 'The Splicer adapter for interacting Rackspace Cloud DNS'
|
12
|
+
spec.summary = 'Use this gem together with Splicer if you are using multiple DNS providers, and want a unified interface to manage each of them simultaneously'
|
13
|
+
spec.homepage = 'https://github.com/pressable/splicer-rackspace'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'splicer', '~> 2.2', '>= 2.2.0'
|
22
|
+
spec.add_dependency 'fog', '~> 1.29'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3', '>= 1.3.0'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.4', '>= 10.4.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.4.0', '>= 3.4.0'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: splicer-rackspace
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oliver Garcia
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: splicer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.2.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.2'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.2.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: fog
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.29'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.29'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.3'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.3.0
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1.3'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.3.0
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '10.4'
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 10.4.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '10.4'
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 10.4.0
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: rspec
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 3.4.0
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.4.0
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.4.0
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 3.4.0
|
107
|
+
description: The Splicer adapter for interacting Rackspace Cloud DNS
|
108
|
+
email:
|
109
|
+
- oliver@pressable.com
|
110
|
+
executables: []
|
111
|
+
extensions: []
|
112
|
+
extra_rdoc_files: []
|
113
|
+
files:
|
114
|
+
- ".gitignore"
|
115
|
+
- ".rspec"
|
116
|
+
- ".ruby-version"
|
117
|
+
- Gemfile
|
118
|
+
- LICENSE.txt
|
119
|
+
- README.md
|
120
|
+
- Rakefile
|
121
|
+
- lib/splicer/rackspace.rb
|
122
|
+
- lib/splicer/rackspace/config.rb
|
123
|
+
- lib/splicer/rackspace/provider.rb
|
124
|
+
- lib/splicer/rackspace/version.rb
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
- spec/splicer/rackspace/config_spec.rb
|
127
|
+
- spec/splicer/rackspace/provider_spec.rb
|
128
|
+
- splicer-rackspace.gemspec
|
129
|
+
homepage: https://github.com/pressable/splicer-rackspace
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.4.8
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Use this gem together with Splicer if you are using multiple DNS providers,
|
153
|
+
and want a unified interface to manage each of them simultaneously
|
154
|
+
test_files:
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
- spec/splicer/rackspace/config_spec.rb
|
157
|
+
- spec/splicer/rackspace/provider_spec.rb
|