From a85509f5e288c9ccc70400f2ce93842e57a1af23 Mon Sep 17 00:00:00 2001 From: nopedial Date: Sat, 26 Oct 2013 00:16:19 +0200 Subject: add fetch API to git output --- lib/oxidized.rb | 1 + lib/oxidized/model/ironware.rb | 1 + lib/oxidized/output/git.rb | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/lib/oxidized.rb b/lib/oxidized.rb index ec1a901..99b1ea6 100644 --- a/lib/oxidized.rb +++ b/lib/oxidized.rb @@ -1,4 +1,5 @@ module Oxidized + Encoding.default_external = 'UTF-8' Directory = File.expand_path File.join File.dirname(__FILE__), '../' require 'oxidized/core' end diff --git a/lib/oxidized/model/ironware.rb b/lib/oxidized/model/ironware.rb index 3dd9ef2..e501f76 100644 --- a/lib/oxidized/model/ironware.rb +++ b/lib/oxidized/model/ironware.rb @@ -16,6 +16,7 @@ class IronWare < Oxidized::Model end cmd 'show chassis' do |cfg| + cfg.gsub! "\xFF", '' # ugly hack - avoids JSON.dump utf-8 breakage on 1.9.. comment cfg end diff --git a/lib/oxidized/output/git.rb b/lib/oxidized/output/git.rb index 202893c..f23b35a 100644 --- a/lib/oxidized/output/git.rb +++ b/lib/oxidized/output/git.rb @@ -37,6 +37,15 @@ class Git < Output end end + def fetch node, group + begin + repo = Repo.new(@cfg[:repo]) + (repo.tree / node).data + rescue + 'node not found' + end + end + private def update_repo repo, file, data, msg, actor -- cgit v1.2.1