forked from zstyblik/go-facter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from KittenConnect/dev
Dev
- Loading branch information
Showing
13 changed files
with
121 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
package main | ||
package base | ||
|
||
import ( | ||
_ "github.com/KittenConnect/go-facter/lib/facters/disk" | ||
_ "github.com/KittenConnect/go-facter/lib/facters/mem" | ||
_ "github.com/KittenConnect/go-facter/lib/facters/net" | ||
|
||
_ "github.com/KittenConnect/go-facter/lib/facters/routehOS" | ||
) |
2 changes: 1 addition & 1 deletion
2
cmd/facter/imports_darwin.go → lib/facters/routehOS/base/imports_darwin.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package main | ||
package base | ||
|
||
// import () |
2 changes: 1 addition & 1 deletion
2
cmd/facter/imports_linux.go → lib/facters/routehOS/base/imports_linux.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package base | ||
|
||
import ( | ||
_ "github.com/KittenConnect/go-facter/lib/facters/cpu" | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package extended | ||
|
||
import ( | ||
_ "github.com/KittenConnect/go-facter/lib/facters/routehOS/extended/networking" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package routehOS | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"regexp" | ||
|
||
"github.com/KittenConnect/go-facter/lib/facter" | ||
) | ||
|
||
var ( | ||
PluginName = "bird" | ||
|
||
reBirdVersion = regexp.MustCompile(`BIRD version ([\d\.]+)`) | ||
reBirdConfig = regexp.MustCompile(`[\s]+-c[\s]+<config-file>[\w\s]+instead[\w\s]+\n[\s]+([\/-_.\w]+)`) | ||
) | ||
|
||
func init() { | ||
facter.RegisterSafe(PluginName, []string{"bird."}, GetBirdFacts) | ||
} | ||
|
||
func GetBirdFacts(f facter.IFacter) error { | ||
cmd := exec.Command("bird", "--version") | ||
|
||
// Run the command and retrieve the output | ||
output, err := cmd.CombinedOutput() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
versionOut := string(output) | ||
|
||
result := reBirdVersion.FindStringSubmatch(versionOut) | ||
|
||
if len(result) < 1 { | ||
return fmt.Errorf("cannot find [ %s ] in BIRD version output", reBirdVersion.String()) | ||
} | ||
|
||
cmd = exec.Command("bird", "--help") | ||
|
||
// Run the command and retrieve the output | ||
output, err = cmd.CombinedOutput() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
helpOut := string(output) | ||
|
||
f.Add("bird", map[string]interface{}{ | ||
"version": result[1], | ||
"conf_file": reBirdConfig.FindStringSubmatch(helpOut)[1], | ||
|
||
// "pid_file": reRADVDPidFile.FindStringSubmatch(out)[1], | ||
// "log_file": reRADVDLogFile.FindStringSubmatch(out)[1], | ||
// "log_facility": reRADVDSyslogFc.FindStringSubmatch(out)[1], | ||
}) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package networking | ||
|
||
import ( | ||
_ "github.com/KittenConnect/go-facter/lib/facters/routehOS/extended/networking/bird" | ||
_ "github.com/KittenConnect/go-facter/lib/facters/routehOS/extended/networking/radvd" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package routehOS | ||
|
||
import ( | ||
_ "github.com/KittenConnect/go-facter/lib/facters/routehOS/base" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//go:build facter_extended | ||
// +build facter_extended | ||
|
||
package routehOS | ||
|
||
import ( | ||
_ "github.com/KittenConnect/go-facter/lib/facters/routehOS/extended" | ||
) |