ssp 0.3.3 → 0.4

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.
@@ -0,0 +1,44 @@
1
+ require 'linode'
2
+ require 'ssp/config'
3
+
4
+ class OpenStruct
5
+ undef :type # fixing object.type deprecation issue
6
+ end
7
+
8
+ class SSP::App::Domain < Thor
9
+ namespace :domain
10
+
11
+ class_option :linode_token,
12
+ :desc => "Linode API Token",
13
+ :default => SSP::Config[:linode][:token]
14
+
15
+
16
+ desc "update DOMAIN IP", "Updates DNS entry for DOMAIN to IP"
17
+ method_option :ttl, :desc => "TTL for record", :default => 0
18
+ def update(domain, ip)
19
+ host, domain = domain.split(".", 2)
20
+
21
+ zone = linode.domain.list.detect do |d|
22
+ d.domain == domain
23
+ end
24
+ raise Thor::Error, "Zone not found for #{domain}" unless zone
25
+
26
+ records = linode.domain.resource.list(:domainid => zone.domainid)
27
+ if current_record = records.detect {|r| r.type == "A" && r.name == host}
28
+ record = linode.domain.resource.update :domainid => zone.domainid, :resourceid => current_record.resourceid, :target => ip, :ttl_sec => options[:ttl]
29
+ unless record.resourceid
30
+ raise Thor::Error, "Failed to update the record for #{host} in #{domain}"
31
+ end
32
+ else
33
+ record = linode.domain.resource.create :domainid => zone.domainid, :type => "A", :name => host, :target => ip, :ttl_sec => options[:ttl]
34
+ unless record.resourceid
35
+ raise Thor::Error, "Failed to create a new record for #{host} in #{domain}"
36
+ end
37
+ end
38
+ end
39
+
40
+ private
41
+ def linode
42
+ @linode ||= Linode.new(:api_key => options[:linode_token])
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module SSP
2
- VERSION = "0.3.3"
2
+ VERSION = "0.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 3
10
- version: 0.3.3
8
+ - 4
9
+ version: "0.4"
11
10
  platform: ruby
12
11
  authors:
13
12
  - !binary |
@@ -17,7 +16,7 @@ autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
18
 
20
- date: 2010-09-29 00:00:00 +02:00
19
+ date: 2010-10-03 00:00:00 +02:00
21
20
  default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
@@ -82,6 +81,22 @@ dependencies:
82
81
  version: 1.0.1
83
82
  type: :runtime
84
83
  version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ name: linode
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ~>
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ - 6
96
+ - 2
97
+ version: 0.6.2
98
+ type: :runtime
99
+ version_requirements: *id005
85
100
  description: " The SSP gem provides various command line tools that\n Secret Sauce Partners, Inc. uses internally.\n"
86
101
  email: dev@secretsaucepartners.com
87
102
  executables:
@@ -97,6 +112,7 @@ files:
97
112
  - lib/ssp/app.rb
98
113
  - lib/ssp/application/bags.rb
99
114
  - lib/ssp/application/chef.rb
115
+ - lib/ssp/application/domain.rb
100
116
  - lib/ssp/application/node.rb
101
117
  - lib/ssp/application/office_node.rb
102
118
  - lib/ssp/application/pair.rb