corona 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05542efc8878a1c42874c4a0fb32badca922a9b5
4
- data.tar.gz: 0758f35f168258f9c9db2f98eb5855517fbfbbbc
3
+ metadata.gz: 05d90e5d39580853fa3d8de2d8bb23ab5e71c059
4
+ data.tar.gz: af308eb023c66b5c1c7148ccc2fdd3168de87f87
5
5
  SHA512:
6
- metadata.gz: f47ae73a9939219ea5cb37314d64b5a9c826d6822eef1246f9061a0e97150c8f2ed266aeb2981b87991b30972fcfd1b9241412f2755e78794f4f29900bdfec8c
7
- data.tar.gz: 37e81fa4f1bf58cb8867945409b13f498540169a5899a96c94d59af26e3e77143ed9b58dd314bab8d21442bd258993f403804ab9771cc6b27f3e49cbeb4e9bd3
6
+ metadata.gz: 953a40c47c411c1666a4f0731b6f865dd6db15e44fd01cf2c65c9534120d0f04c5716df983831b6be116aeee73f53d426d5b95a5f9d5e3e64e60541aeae038bb
7
+ data.tar.gz: d76d38b3c9af8a87606645e60c09fbefba2da67ee5c56ac2e9731a52186aff3f28ea06be8f5803e4855d315641f9409c1367062883b7f4de7ed93a5bcb764736
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- corona (0.0.10)
4
+ corona (0.0.11)
5
+ asetus
5
6
  sequel
6
7
  slop
7
8
  snmp
@@ -10,6 +11,8 @@ PATH
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
14
+ asetus (0.0.6)
15
+ slop
13
16
  sequel (4.7.0)
14
17
  slop (3.4.7)
15
18
  snmp (1.1.1)
data/README.md CHANGED
@@ -15,3 +15,20 @@
15
15
  * You need to configure SNMP community
16
16
  * You need to define CIDR to poll and CIDRs to ignore (subset of those you poll)
17
17
  * CIDR in example config is list, but can be replaced with 'string' which points to file, where CIDRs are listed
18
+
19
+ # Use
20
+ ```
21
+ [fisakytt@lan-login1 ~/projects/corona]% corona --help
22
+ Usage: corona [options] [argument]
23
+ -d, --debug Debugging on
24
+ -p, --poll Poll CIDR [argument]
25
+ -r, --remove Remove [argument] from DB
26
+ -m, --max-delete Maximum number to delete, default 1
27
+ -o, --purge-old Remove records order than [argument] days
28
+ -s, --simulate Simulate, do not change DB
29
+ -h, --help Display this help message.
30
+
31
+ % corona -p 192.0.2.0/28 # poll specific CIDR
32
+ % corona -r core-sw1 # remove specific record
33
+ % corona -o 7 # remore records older than 7 days
34
+ ```
data/corona.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'corona'
3
- s.version = '0.0.10'
3
+ s.version = '0.0.11'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = [ 'Saku Ytti' ]
6
6
  s.email = %w( saku@ytti.fi )
@@ -16,4 +16,5 @@ Gem::Specification.new do |s|
16
16
  s.add_dependency 'sqlite3'
17
17
  s.add_dependency 'snmp'
18
18
  s.add_dependency 'slop'
19
+ s.add_dependency 'asetus'
19
20
  end
data/lib/corona/cli.rb CHANGED
@@ -3,6 +3,7 @@ module Corona
3
3
  MAX_DELETE = 1
4
4
  require 'corona'
5
5
  require 'slop'
6
+ class NoConfig < CoronaError; end
6
7
 
7
8
  def run
8
9
  if @opts[:poll]
@@ -22,6 +23,11 @@ module Corona
22
23
  args, @opts = opts_parse
23
24
  @arg = args.shift
24
25
  CFG.debug = true if @opts[:debug]
26
+ if CFGS.system.empty? and CFGS.user.empty?
27
+ CFGS.user = CFGS.default
28
+ CFGS.save :user
29
+ raise NoConfig, 'edit ~/.config/corona/config'
30
+ end
25
31
  end
26
32
 
27
33
  def opts_parse
@@ -0,0 +1,29 @@
1
+ module Corona
2
+ require 'asetus'
3
+ require 'fileutils'
4
+
5
+ class Config
6
+ Root = File.join ENV['HOME'], '.config', 'corona'
7
+ Crash = File.join Root, 'crash'
8
+ end
9
+
10
+ FileUtils.mkdir_p Config::Root
11
+ CFGS = Asetus.new :name=>'corona', :load=>'false', :key_to_s=>true
12
+
13
+ CFGS.default.community = 'public'
14
+ CFGS.default.db = File.join Config::Root, 'corona.db'
15
+ CFGS.default.poll = %w( 10.10.10.0/24 10.10.20.0/24 )
16
+ CFGS.default.ignore = %w( 10.10.10.42/32 10.10.20.42/32 )
17
+ CFGS.default.mgmt = %w( lo0.0 loopback0 vlan2 )
18
+ CFGS.default.threads = 50
19
+ CFGS.default.timeout = 0.25
20
+ CFGS.default.retries = 2
21
+ CFGS.default.log = File.join Config::Root, 'log'
22
+ CFGS.default.debug = false
23
+
24
+ CFGS.load
25
+ CFG = CFGS.cfg
26
+
27
+ Log.file = CFG.log if CFG.log
28
+ Log.level = Logger::INFO unless CFG.debug
29
+ end
data/lib/corona/core.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'corona/log'
2
- require 'corona/config/core'
2
+ require 'corona/config'
3
3
  require 'corona/snmp'
4
4
  require 'corona/db/db'
5
5
  require 'corona/model'
data/lib/corona/model.rb CHANGED
@@ -39,7 +39,9 @@ module Corona
39
39
  else
40
40
  case sysObjectID
41
41
  when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.12356.'))
42
- 'fortios' # 1.3.6.1.4.1.12356.101.1.10004
42
+ 'fortios' # 1.3.6.1.4.1.12356.101.1.10004
43
+ when Regexp.new('^' + Regexp.quote('1.3.6.1.4.1.6486.'))
44
+ 'aos' # 1.3.6.1.4.1.6486.800.1.1.2.1.11.2.2
43
45
  else
44
46
  'unsupported'
45
47
  end
data/lib/corona.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module Corona
2
+ class CoronaError < StandardError; end
2
3
  require 'corona/core'
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corona
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saku Ytti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-13 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: asetus
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Threaded SNMP poll based network discovery. Devices are stored in SQL
70
84
  email:
71
85
  - saku@ytti.fi
@@ -84,8 +98,7 @@ files:
84
98
  - corona.gemspec
85
99
  - lib/corona.rb
86
100
  - lib/corona/cli.rb
87
- - lib/corona/config/bootstrap.rb
88
- - lib/corona/config/core.rb
101
+ - lib/corona/config.rb
89
102
  - lib/corona/core.rb
90
103
  - lib/corona/db/db.rb
91
104
  - lib/corona/db/model.rb
@@ -1,15 +0,0 @@
1
- module Corona
2
- require 'fileutils'
3
- FileUtils.mkdir_p Config::Root
4
- CFG.community = 'public'
5
- CFG.db = File.join Config::Root, 'corona.db'
6
- CFG.poll = %w( 10.10.10.0/24 10.10.20.0/24 )
7
- CFG.ignore = %w( 10.10.10.42/32 10.10.20.42/32 )
8
- CFG.mgmt = %w( lo0.0 loopback0 vlan2 )
9
- CFG.threads = 50
10
- CFG.timeout = 0.25
11
- CFG.retries = 2
12
- CFG.log = File.join Config::Root, 'log'
13
- CFG.debug = false
14
- CFG.save
15
- end
@@ -1,26 +0,0 @@
1
- module Corona
2
- require 'ostruct'
3
- require 'yaml'
4
- class Config < OpenStruct
5
- Root = File.join ENV['HOME'], '.config', 'corona'
6
- Crash = File.join Root, 'crash'
7
- def initialize file=File.join(Config::Root, 'config')
8
- super()
9
- @file = file.to_s
10
- end
11
- def load
12
- if File.exists? @file
13
- marshal_load YAML.load_file @file
14
- else
15
- require 'corona/config/bootstrap'
16
- end
17
- end
18
- def save
19
- File.write @file, YAML.dump(marshal_dump)
20
- end
21
- end
22
- CFG = Config.new
23
- CFG.load
24
- Log.file = CFG.log if CFG.log
25
- Log.level = Logger::INFO unless CFG.debug
26
- end