nettica 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/History.txt +4 -0
  2. data/bin/nettica +38 -26
  3. data/lib/nettica.rb +1 -1
  4. metadata +2 -2
@@ -1,3 +1,7 @@
1
+ == 0.3.0 / 2008-01-29
2
+
3
+ * Fixed update_record in command line script
4
+
1
5
  == 0.2.0 / 2008-01-28
2
6
 
3
7
  * Expanded api in command line script
@@ -7,12 +7,20 @@ require 'rubygems'
7
7
  require 'nettica/client'
8
8
 
9
9
  options = OpenStruct.new
10
- options.ttl = 0
11
- options.priority = 0
10
+ options.ttl = [0]
11
+ options.priority = [0]
12
12
 
13
13
  opts = OptionParser.new do |opts|
14
- opts.banner = "Usage: nettica -u username -p password -c command"
15
- opts.separator "Runs the given nettica service command"
14
+ opts.banner = "Usage: nettica -u username -p password -c command [options]"
15
+ opts.separator "Runs the given nettica service command, for example:"
16
+ opts.separator ""
17
+ opts.separator " nettica -u my_user -p my_pass -c list_domain -d foo.com"
18
+ opts.separator " nettica -u my_user -p my_pass -c add_record -h bar -d foo.com -r A -t 300"
19
+ opts.separator " -a 192.168.1.1"
20
+ opts.separator " nettica -u my_user -p my_pass -c update_record -h bar -d foo.com"
21
+ opts.separator " -a 192.168.1.1,10.0.0.1"
22
+ opts.separator " nettica -u my_user -p my_pass -c update_record -h bar -d foo.com -a 10.0.0.1"
23
+ opts.separator " -t 60,300"
16
24
  opts.separator ""
17
25
  opts.separator "Options:"
18
26
 
@@ -22,23 +30,23 @@ opts = OptionParser.new do |opts|
22
30
  opts.on("-p", "--password PASSWORD", "Nettica password to use for authentication") do |val|
23
31
  options.password = val
24
32
  end
25
- opts.on("-d", "--domain DOMAIN_NAME", "Domain name to apply command to") do |val|
33
+ opts.on("-d", "--domain DOMAIN_NAME", Array, "Domain name to apply command to") do |val|
26
34
  options.domain = val
27
35
  end
28
- opts.on("-h", "--host HOST_NAME", "Hostname to act upon") do |val|
36
+ opts.on("-h", "--host HOST_NAME", Array, "Hostname to act upon") do |val|
29
37
  options.host = val
30
38
  end
31
39
  opts.on("-i", "--ip IP", "IP address") do |val|
32
40
  options.ip = val
33
41
  end
34
- opts.on("-r", "--recordtype RECORD_TYPE", "Domain record type (A, CNAME, MX, F, TXT,", "SRV)") do |val|
42
+ opts.on("-r", "--recordtype RECORD_TYPE", Array, "Domain record type (A, CNAME, MX, F, TXT,", "SRV)") do |val|
35
43
  options.recordtype = val
36
44
  end
37
- opts.on("-t", "--ttl TIME_TO_LIVE", "TTL for domain entries", Integer) do |val|
38
- options.ttl = val
45
+ opts.on("-t", "--ttl TIME_TO_LIVE", Array, "TTL for domain entries") do |val|
46
+ options.ttl = val.collect {|each| each.to_i}
39
47
  end
40
- opts.on("-o", "--priority PRIORITY", "Priority for MX/F records", Integer) do |val|
41
- options.priority = val
48
+ opts.on("-o", "--priority PRIORITY", Array, "Priority for MX/F records") do |val|
49
+ options.priority = val.collect {|each| each.to_i}
42
50
  end
43
51
  opts.on("-g", "--group GROUP", "Domain group") do |val|
44
52
  options.group = val
@@ -46,7 +54,7 @@ opts = OptionParser.new do |opts|
46
54
  opts.on("-m", "--master MASTER", "Master domain") do |val|
47
55
  options.master = val
48
56
  end
49
- opts.on("-a", "--data DATA", "IP when creating/deleting records") do |val|
57
+ opts.on("-a", "--data DATA", Array, "IP when creating/deleting records") do |val|
50
58
  options.data = val
51
59
  end
52
60
 
@@ -69,9 +77,7 @@ end
69
77
 
70
78
  begin
71
79
  args = opts.parse!(ARGV)
72
- p options
73
80
  raise "Missing required flag" if ! options.username || ! options.password || ! options.command
74
-
75
81
  rescue Exception => e
76
82
  puts e, "", opts
77
83
  exit
@@ -85,26 +91,32 @@ case options.command
85
91
  when :get_service_info
86
92
  result = client.get_service_info()
87
93
  when :list_domain
88
- result = client.list_domain(options.domain)
94
+ result = client.list_domain(options.domain.first)
89
95
  when :update_record
90
- dr = client.create_domain_record(options.domain, options.host, options.recordtype,
91
- options.data, options.ttl, options.priority)
92
- # result = client.update_record(dr, ?)
96
+ drold = client.create_domain_record(options.domain.first, options.host.first, options.recordtype.first,
97
+ options.data.first, options.ttl.first, options.priority.first)
98
+ drnew = client.create_domain_record(options.domain[1] || options.domain.first,
99
+ options.host[1] || options.host.first,
100
+ options.recordtype[1] || options.recordtype.first,
101
+ options.data[1] || options.data.first,
102
+ options.ttl[1] || options.ttl.first,
103
+ options.priority[1] || options.priority.first)
104
+ result = client.update_record(drold, drnew)
93
105
  when :delete_record
94
- dr = client.create_domain_record(options.domain, options.host, options.recordtype,
95
- options.data, options.ttl, options.priority)
106
+ dr = client.create_domain_record(options.domain.first, options.host.first, options.recordtype.first,
107
+ options.data.first, options.ttl.first, options.priority.first)
96
108
  result = client.delete_record(dr)
97
109
  when :apply_template
98
- result = client.apply_template(options.domain, options.group)
110
+ result = client.apply_template(options.domain.first, options.group)
99
111
  when :create_secondary_zone
100
- result = client.create_secondary_zone(options.domain, options.master, options.ip)
112
+ result = client.create_secondary_zone(options.domain.first, options.master, options.ip)
101
113
  when :delete_zone
102
- result = client.delete_zone(options.domain)
114
+ result = client.delete_zone(options.domain.first)
103
115
  when :create_zone
104
- result = client.create_zone(options.domain)
116
+ result = client.create_zone(options.domain.first)
105
117
  when :add_record
106
- dr = client.create_domain_record(options.domain, options.host, options.recordtype,
107
- options.data, options.ttl, options.priority)
118
+ dr = client.create_domain_record(options.domain.first, options.host.first, options.recordtype.first,
119
+ options.data.first, options.ttl.first, options.priority.first)
108
120
  result = client.add_record(dr)
109
121
  end
110
122
 
@@ -1,3 +1,3 @@
1
1
  class Nettica
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nettica
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-28 00:00:00 -05:00
12
+ date: 2008-01-29 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency