summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile2
-rw-r--r--README.md2
-rw-r--r--lib/oxidized/manager.rb1
-rw-r--r--lib/oxidized/source/csv.rb4
4 files changed, 7 insertions, 2 deletions
diff --git a/Gemfile b/Gemfile
index fa75df1..23758ed 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,3 +1,3 @@
source 'https://rubygems.org'
-
+gem 'gpgme'
gemspec
diff --git a/README.md b/README.md
index fe58322..61e8b8a 100644
--- a/README.md
+++ b/README.md
@@ -235,12 +235,14 @@ oxidized
Now tell Oxidized where it finds a list of network devices to backup configuration from. You can either use CSV or SQLite as source. To create a CSV source add the following snippet:
+Note: If gpg is set to anything other than false it will attempt to decrypt the file contents
```
source:
default: csv
csv:
file: ~/.config/oxidized/router.db
delimiter: !ruby/regexp /:/
+ gpg: 'false'
map:
name: 0
model: 1
diff --git a/lib/oxidized/manager.rb b/lib/oxidized/manager.rb
index bf28ae7..60394fd 100644
--- a/lib/oxidized/manager.rb
+++ b/lib/oxidized/manager.rb
@@ -3,6 +3,7 @@ module Oxidized
require 'oxidized/input/input'
require 'oxidized/output/output'
require 'oxidized/source/source'
+ require 'gpgme'
class Manager
class << self
def load dir, file
diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb
index d498e0b..c41162d 100644
--- a/lib/oxidized/source/csv.rb
+++ b/lib/oxidized/source/csv.rb
@@ -11,6 +11,7 @@ class CSV < Source
Oxidized.asetus.user.source.csv.delimiter = /:/
Oxidized.asetus.user.source.csv.map.name = 0
Oxidized.asetus.user.source.csv.map.model = 1
+ Oxidized.asetus.user.source.csv.gpg = false
Oxidized.asetus.save :user
raise NoConfig, 'no source csv config, edit ~/.config/oxidized/config'
end
@@ -18,7 +19,8 @@ class CSV < Source
def load
nodes = []
- open(File.expand_path @cfg.file).each_line do |line|
+ file = @cfg.gpg == 'false' ? open(File.expand_path @cfg.file) : crypto.decrypt File.open(@cfg.file)
+ open(file).each_line do |line|
next if line.match(/^\s*#/)
data = line.chomp.split(@cfg.delimiter, -1)
next if data.empty?