mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
renamed message fileextension to message filename
This commit is contained in:
parent
5b065faa3d
commit
bf75a44fbf
19 changed files with 84 additions and 79 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -11,4 +11,5 @@ changes.md
|
|||
steward.sock
|
||||
ships/
|
||||
.gitignore
|
||||
testing_messages/
|
||||
testing_messages/
|
||||
test.file
|
||||
|
|
20
README.md
20
README.md
|
@ -12,7 +12,7 @@ Command And Control anything like Servers, Containers, VM's or others by creatin
|
|||
[
|
||||
{
|
||||
"directory":"cli_command__result",
|
||||
"fileExtension": ".result",
|
||||
"fileName": "some-file-name.result",
|
||||
"toNode": "ship1",
|
||||
"data": ["bash","-c","sleep 5 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
|
@ -191,11 +191,11 @@ Print the output of the reply message to the console.
|
|||
|
||||
#### REQToFileAppend
|
||||
|
||||
Append the output of the reply message to a log file specified with the `directory` and `fileExtension` fields.
|
||||
Append the output of the reply message to a log file specified with the `directory` and `fileName` fields.
|
||||
|
||||
#### REQToFile
|
||||
|
||||
Write the output of the reply message to a log file specified with the `directory` and `fileExtension` fields.
|
||||
Write the output of the reply message to a log file specified with the `directory` and `fileName` fields.
|
||||
|
||||
### Errors reporting
|
||||
|
||||
|
@ -394,10 +394,10 @@ methodTimeout
|
|||
// For example "syslog","metrics", or "metrics/mysensor"
|
||||
// The type is typically used in the handler of a method.
|
||||
directory
|
||||
// FileExtension is used to be able to set a wanted extension
|
||||
// FileName is used to be able to set a wanted name
|
||||
// on a file being saved as the result of data being handled
|
||||
// by a method handler.
|
||||
fileExtension
|
||||
fileName
|
||||
// operation are used to give an opCmd and opArg's.
|
||||
operation
|
||||
```
|
||||
|
@ -459,7 +459,7 @@ and another example
|
|||
[
|
||||
{
|
||||
"directory":"opcommand_logs",
|
||||
"fileExtension": ".log",
|
||||
"fileName": "some.log",
|
||||
"toNode": "ship2",
|
||||
"data": [],
|
||||
"method":"REQOpCommand",
|
||||
|
@ -531,7 +531,7 @@ To send a Op Command message for process listing with custom timeout and amount
|
|||
[
|
||||
{
|
||||
"directory":"opcommand_logs",
|
||||
"fileExtension": ".log",
|
||||
"fileName": "some.log",
|
||||
"toNode": "ship2",
|
||||
"data": [],
|
||||
"method":"REQOpCommand",
|
||||
|
@ -553,7 +553,7 @@ To send and Op Command to stop a subscriber on a node
|
|||
[
|
||||
{
|
||||
"directory":"opcommand_logs",
|
||||
"fileExtension": ".log",
|
||||
"fileName": "some.log",
|
||||
"toNode": "ship2",
|
||||
"data": [],
|
||||
"method":"REQOpCommand",
|
||||
|
@ -580,7 +580,7 @@ To send and Op Command to start a subscriber on a node
|
|||
[
|
||||
{
|
||||
"directory":"opcommand_logs",
|
||||
"fileExtension": ".log",
|
||||
"fileName": "some.log",
|
||||
"toNode": "ship2",
|
||||
"data": [],
|
||||
"method":"REQOpCommand",
|
||||
|
@ -606,7 +606,7 @@ Tail a log file on a node, and save the result of the tail centrally at the dire
|
|||
[
|
||||
{
|
||||
"directory": "./my/log/files/",
|
||||
"fileExtension": ".log",
|
||||
"fileName": "some.log",
|
||||
"toNode": "ship2",
|
||||
"data": ["./test.log"],
|
||||
"method":"REQTailFile",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"directory": "random_text_log",
|
||||
"fileExtension": ".log",
|
||||
"fileName": "somefile.log",
|
||||
"toNode": "central",
|
||||
"data": ["some message sent from a ship for testing\n"],
|
||||
"commandOrEvent":"EventACK",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"directory":"cli/command/result",
|
||||
"fileExtension": ".result",
|
||||
"fileName": "somefile.result",
|
||||
"toNode": "ship1",
|
||||
"data": ["bash","-c","sleep 3 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"directory": "vg-sin-hjemmeside",
|
||||
"fileExtension": ".html",
|
||||
"fileName": "somefile.html",
|
||||
"toNode": "ship1",
|
||||
"data": ["http://vg.no"],
|
||||
"method":"REQHttpGet",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"directory": "ping",
|
||||
"fileExtension":".ping.log",
|
||||
"fileName":"somefile.ping.log",
|
||||
"toNode": "ship1",
|
||||
"data": [""],
|
||||
"method":"REQPing",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"directory":"some-directory",
|
||||
"fileExtension":".result",
|
||||
"fileName":"somefile.result",
|
||||
"toNode": "ship1",
|
||||
"data": ["bash","-c","tree ../"],
|
||||
"replyMethod":"REQToFileAppend",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"directory": "metrics/network/sniffer",
|
||||
"fileExtension": ".html",
|
||||
"fileName": "somefile.html",
|
||||
"toNode": "ship2",
|
||||
"data": ["http://erter.org"],
|
||||
"method":"REQHttpGet",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"directory":"opcommand_logs",
|
||||
"fileExtension": ".log",
|
||||
"fileName": "somefile.log",
|
||||
"toNode": "ship2",
|
||||
"data": [],
|
||||
"method":"REQOpCommand",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"directory":"opcommand_logs",
|
||||
"fileExtension": ".log",
|
||||
"fileName": "somefile.log",
|
||||
"toNode": "ship2",
|
||||
"data": [],
|
||||
"method":"REQOpCommand",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"directory":"opcommand_logs",
|
||||
"fileExtension": ".log",
|
||||
"fileName": "somefile.log",
|
||||
"toNode": "ship2",
|
||||
"data": [],
|
||||
"method":"REQOpCommand",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"directory": "./mine-tail-filer/",
|
||||
"fileExtension": ".log",
|
||||
"fileName": "somefile.log",
|
||||
"toNode": "ship2",
|
||||
"data": ["/var/log/system.log"],
|
||||
"method":"REQTailFile",
|
||||
|
|
|
@ -41,10 +41,10 @@ type Message struct {
|
|||
// For example "syslog","metrics", or "metrics/mysensor"
|
||||
// The type is typically used in the handler of a method.
|
||||
Directory string `json:"directory" yaml:"directory"`
|
||||
// FileExtension is used to be able to set a wanted extension
|
||||
// FileName is used to be able to set a wanted extension
|
||||
// on a file being saved as the result of data being handled
|
||||
// by a method handler.
|
||||
FileExtension string `json:"fileExtension" yaml:"fileExtension"`
|
||||
FileName string `json:"fileName" yaml:"fileName"`
|
||||
// operation are used to give an opCmd and opArg's.
|
||||
Operation Operation `json:"operation"`
|
||||
// PreviousMessage are used for example if a reply message is
|
||||
|
|
|
@ -192,6 +192,7 @@ func (s startup) pubREQHello(p process) {
|
|||
d := fmt.Sprintf("Hello from %v\n", p.node)
|
||||
|
||||
m := Message{
|
||||
FileName: "hello.log",
|
||||
Directory: "hello-messages",
|
||||
ToNode: Node(p.configuration.CentralNodeName),
|
||||
FromNode: Node(p.node),
|
||||
|
|
|
@ -157,6 +157,7 @@ func convertBytesToSAM(b []byte) ([]subjectAndMessage, error) {
|
|||
|
||||
err := json.Unmarshal(b, &MsgSlice)
|
||||
if err != nil {
|
||||
//fmt.Printf(" *** %v", string(b))
|
||||
return nil, fmt.Errorf("error: unmarshal of file failed: %#v", err)
|
||||
}
|
||||
|
||||
|
|
12
server.go
12
server.go
|
@ -297,12 +297,12 @@ func createErrorMsgContent(FromNode Node, theError error) subjectAndMessage {
|
|||
sam := subjectAndMessage{
|
||||
Subject: newSubject(REQErrorLog, "errorCentral"),
|
||||
Message: Message{
|
||||
Directory: "errorLog",
|
||||
ToNode: "errorCentral",
|
||||
FromNode: FromNode,
|
||||
FileExtension: ".log",
|
||||
Data: []string{er},
|
||||
Method: REQErrorLog,
|
||||
Directory: "errorLog",
|
||||
ToNode: "errorCentral",
|
||||
FromNode: FromNode,
|
||||
FileName: "error.log",
|
||||
Data: []string{er},
|
||||
Method: REQErrorLog,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ func messageSlide(app *tview.Application) tview.Primitive {
|
|||
case "Directory":
|
||||
value := "/some-dir/"
|
||||
p.msgInputForm.AddInputField(fieldName, value, 30, nil, nil)
|
||||
case "FileExtension":
|
||||
case "FileName":
|
||||
value := ".log"
|
||||
p.msgInputForm.AddInputField(fieldName, value, 30, nil, nil)
|
||||
case "Operation":
|
||||
|
@ -383,8 +383,8 @@ func messageSlide(app *tview.Application) tview.Primitive {
|
|||
m.MethodTimeout = v
|
||||
case "Directory":
|
||||
m.Directory = value
|
||||
case "FileExtension":
|
||||
m.FileExtension = value
|
||||
case "FileName":
|
||||
m.FileName = value
|
||||
case "Operation":
|
||||
// We need to check what type of operation it is, and pick
|
||||
// the correct struct type, and fill it with values
|
||||
|
@ -584,10 +584,10 @@ type msg struct {
|
|||
// For example "syslog","metrics", or "metrics/mysensor"
|
||||
// The type is typically used in the handler of a method.
|
||||
Directory string `json:"directory" yaml:"directory"`
|
||||
// FileExtension is used to be able to set a wanted extension
|
||||
// FileName is used to be able to set a wanted extension
|
||||
// on a file being saved as the result of data being handled
|
||||
// by a method handler.
|
||||
FileExtension string `json:"fileExtension" yaml:"fileExtension"`
|
||||
FileName string `json:"fileName" yaml:"fileName"`
|
||||
// operation are used to give an opCmd and opArg's.
|
||||
Operation interface{} `json:"operation,omitempty"`
|
||||
}
|
||||
|
|
|
@ -44,9 +44,10 @@ func TestStewardServer(t *testing.T) {
|
|||
// Create the config to run a steward instance.
|
||||
tempdir := "./tmp"
|
||||
conf := &Configuration{
|
||||
SocketFolder: filepath.Join(tempdir, "tmp"),
|
||||
DatabaseFolder: filepath.Join(tempdir, "var/lib"),
|
||||
SubscribersDataFolder: filepath.Join(tempdir, "data"),
|
||||
SocketFolder: filepath.Join(tempdir, "tmp"),
|
||||
DatabaseFolder: filepath.Join(tempdir, "var/lib"),
|
||||
//SubscribersDataFolder: filepath.Join(tempdir, "data"),
|
||||
SubscribersDataFolder: "./tmp/",
|
||||
BrokerAddress: "127.0.0.1:40222",
|
||||
PromHostAndPort: ":2112",
|
||||
NodeName: "central",
|
||||
|
@ -119,8 +120,8 @@ func TestStewardServer(t *testing.T) {
|
|||
func checkREQOpCommandTest(stewardServer *server, conf *Configuration, t *testing.T) error {
|
||||
m := `[
|
||||
{
|
||||
"directory":"commands-executed",
|
||||
"fileExtension": ".result",
|
||||
"directory":"opCommand",
|
||||
"fileName": "fileName.result",
|
||||
"toNode": "central",
|
||||
"data": [],
|
||||
"method":"REQOpCommand",
|
||||
|
@ -138,7 +139,7 @@ func checkREQOpCommandTest(stewardServer *server, conf *Configuration, t *testin
|
|||
|
||||
writeToSocketTest(conf, m, t)
|
||||
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "commands-executed", "central", "central.REQOpCommand.result")
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "opCommand", "central", "central", "REQOpCommand", "fileName.result")
|
||||
_, err := findStringInFileTest("central.REQOpCommand.CommandACK", resultFile, conf, t)
|
||||
if err != nil {
|
||||
return fmt.Errorf(" [FAILED] : checkREQOpCommandTest: %v", err)
|
||||
|
@ -153,7 +154,7 @@ func checkREQCliCommandTest(stewardServer *server, conf *Configuration, t *testi
|
|||
m := `[
|
||||
{
|
||||
"directory":"commands-executed",
|
||||
"fileExtension":".result",
|
||||
"fileName":"fileName.result",
|
||||
"toNode": "central",
|
||||
"data": ["bash","-c","echo apekatt"],
|
||||
"replyMethod":"REQToFileAppend",
|
||||
|
@ -166,7 +167,7 @@ func checkREQCliCommandTest(stewardServer *server, conf *Configuration, t *testi
|
|||
|
||||
writeToSocketTest(conf, m, t)
|
||||
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "commands-executed", "central", "central.REQCliCommand.result")
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "commands-executed", "central", "central", "REQCliCommand", "fileName.result")
|
||||
_, err := findStringInFileTest("apekatt", resultFile, conf, t)
|
||||
if err != nil {
|
||||
return fmt.Errorf(" [FAILED] : checkREQCliCommandTest: %v", err)
|
||||
|
@ -181,7 +182,7 @@ func checkREQnCliCommandTest(stewardServer *server, conf *Configuration, t *test
|
|||
m := `[
|
||||
{
|
||||
"directory":"commands-executed",
|
||||
"fileExtension":".result",
|
||||
"fileName":"fileName.result",
|
||||
"toNode": "central",
|
||||
"data": ["bash","-c","echo apekatt"],
|
||||
"replyMethod":"REQToFileAppend",
|
||||
|
@ -194,7 +195,7 @@ func checkREQnCliCommandTest(stewardServer *server, conf *Configuration, t *test
|
|||
|
||||
writeToSocketTest(conf, m, t)
|
||||
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "commands-executed", "central", "central.REQnCliCommand.result")
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "commands-executed", "central", "central", "REQnCliCommand", "fileName.result")
|
||||
_, err := findStringInFileTest("apekatt", resultFile, conf, t)
|
||||
if err != nil {
|
||||
return fmt.Errorf(" [FAILED] : checkREQnCliCommandTest: %v", err)
|
||||
|
@ -209,7 +210,7 @@ func checkREQnCliCommandContTest(stewardServer *server, conf *Configuration, t *
|
|||
m := `[
|
||||
{
|
||||
"directory":"commands-executed",
|
||||
"fileExtension":".result",
|
||||
"fileName":"fileName.result",
|
||||
"toNode": "central",
|
||||
"data": ["bash","-c","echo apekatt && sleep 5 && echo gris"],
|
||||
"replyMethod":"REQToFileAppend",
|
||||
|
@ -222,7 +223,7 @@ func checkREQnCliCommandContTest(stewardServer *server, conf *Configuration, t *
|
|||
|
||||
writeToSocketTest(conf, m, t)
|
||||
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "commands-executed", "central", "central.REQnCliCommandCont.result")
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "commands-executed", "central", "central", "REQnCliCommandCont", "fileName.result")
|
||||
_, err := findStringInFileTest("apekatt", resultFile, conf, t)
|
||||
if err != nil {
|
||||
return fmt.Errorf(" [FAILED] : checkREQnCliCommandContTest: %v", err)
|
||||
|
@ -237,7 +238,7 @@ func checkREQHelloTest(stewardServer *server, conf *Configuration, t *testing.T)
|
|||
m := `[
|
||||
{
|
||||
"directory":"commands-executed",
|
||||
"fileExtension":".result",
|
||||
"fileName":"fileName.result",
|
||||
"toNode": "central",
|
||||
"data": [],
|
||||
"method":"REQHello"
|
||||
|
@ -246,7 +247,7 @@ func checkREQHelloTest(stewardServer *server, conf *Configuration, t *testing.T)
|
|||
|
||||
writeToSocketTest(conf, m, t)
|
||||
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "commands-executed", "central", "central.REQHello.result")
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "commands-executed", "central", "central", "REQHello", "fileName.result")
|
||||
_, err := findStringInFileTest("Received hello from", resultFile, conf, t)
|
||||
if err != nil {
|
||||
return fmt.Errorf(" [FAILED] : checkREQHelloTest: %v", err)
|
||||
|
@ -261,7 +262,7 @@ func checkREQErrorLogTest(stewardServer *server, conf *Configuration, t *testing
|
|||
m := `[
|
||||
{
|
||||
"directory": "errorLog",
|
||||
"fileExtension":".result",
|
||||
"fileName":"fileName.result",
|
||||
"toNode": "errorCentral",
|
||||
"data": ["some error"],
|
||||
"method": "REQErrorLog"
|
||||
|
@ -270,7 +271,7 @@ func checkREQErrorLogTest(stewardServer *server, conf *Configuration, t *testing
|
|||
|
||||
writeToSocketTest(conf, m, t)
|
||||
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "errorLog", "central", "errorCentral.REQErrorLog.result")
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "errorLog", "central", "errorCentral", "REQErrorLog", "fileName.result")
|
||||
_, err := findStringInFileTest("some error", resultFile, conf, t)
|
||||
if err != nil {
|
||||
return fmt.Errorf(" [FAILED] : checkREQErrorLogTest: %v", err)
|
||||
|
@ -297,7 +298,7 @@ func checkREQHttpGetTest(stewardServer *server, conf *Configuration, t *testing.
|
|||
m := `[
|
||||
{
|
||||
"directory": "httpget",
|
||||
"fileExtension":".result",
|
||||
"fileName":"fileName.result",
|
||||
"toNode": "central",
|
||||
"data": ["http://127.0.0.1:10080/"],
|
||||
"method": "REQHttpGet",
|
||||
|
@ -309,7 +310,7 @@ func checkREQHttpGetTest(stewardServer *server, conf *Configuration, t *testing.
|
|||
|
||||
writeToSocketTest(conf, m, t)
|
||||
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "httpget", "central", "central.REQHttpGet.result")
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "httpget", "central", "central", "REQHttpGet", "fileName.result")
|
||||
_, err := findStringInFileTest("web page content", resultFile, conf, t)
|
||||
if err != nil {
|
||||
return fmt.Errorf(" [FAILED] : checkREQHttpGetTest: %v", err)
|
||||
|
@ -363,7 +364,7 @@ func checkREQTailFileTest(stewardServer *server, conf *Configuration, t *testing
|
|||
[
|
||||
{
|
||||
"directory": "tail-files",
|
||||
"fileExtension": ".result",
|
||||
"fileName": "fileName.result",
|
||||
"toNode": "central",
|
||||
"data": ["` + file + `"],
|
||||
"method":"REQTailFile",
|
||||
|
@ -377,7 +378,7 @@ func checkREQTailFileTest(stewardServer *server, conf *Configuration, t *testing
|
|||
|
||||
// time.Sleep(time.Second * 5)
|
||||
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "tail-files", "central", "central.REQTailFile.result")
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "tail-files", "central", "central", "REQTailFile", "fileName.result")
|
||||
|
||||
// Wait n times for result file to be created.
|
||||
n := 5
|
||||
|
@ -411,13 +412,12 @@ func checkREQTailFileTest(stewardServer *server, conf *Configuration, t *testing
|
|||
|
||||
// Check errorKernel
|
||||
func checkErrorKernelMalformedJSONtest(stewardServer *server, conf *Configuration, t *testing.T) error {
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "errorLog", "central", "errorCentral.REQErrorLog.log")
|
||||
|
||||
// JSON message with error, missing brace.
|
||||
m := `[
|
||||
{
|
||||
"directory": "some dir",
|
||||
"fileExtension":"someext",
|
||||
"fileName":"someext",
|
||||
"toNode": "somenode",
|
||||
"data": ["some data"],
|
||||
"method": "REQErrorLog"
|
||||
|
@ -426,6 +426,8 @@ func checkErrorKernelMalformedJSONtest(stewardServer *server, conf *Configuratio
|
|||
|
||||
writeToSocketTest(conf, m, t)
|
||||
|
||||
resultFile := filepath.Join(conf.SubscribersDataFolder, "errorLog", "central", "errorCentral", "REQErrorLog", "error.log")
|
||||
|
||||
// Wait n times for error file to be created.
|
||||
n := 5
|
||||
for i := 0; i <= n; i++ {
|
||||
|
@ -483,19 +485,19 @@ func checkMetricValuesTest(stewardServer *server, conf *Configuration, t *testin
|
|||
|
||||
found := false
|
||||
for _, mf := range mfs {
|
||||
if mf.GetName() == "total_running_processes" {
|
||||
if mf.GetName() == "processes_total" {
|
||||
found = true
|
||||
|
||||
m := mf.GetMetric()
|
||||
|
||||
if m[0].Gauge.GetValue() <= 0 {
|
||||
return fmt.Errorf("error: promRegistry.gathering: did not find any running processes in metric for total_running_processes : %v", m[0].Gauge.GetValue())
|
||||
return fmt.Errorf("error: promRegistry.gathering: did not find any running processes in metric for processes_total : %v", m[0].Gauge.GetValue())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return fmt.Errorf("error: promRegistry.gathering: did not find specified metric total_running_processes")
|
||||
return fmt.Errorf("error: promRegistry.gathering: did not find specified metric processes_total")
|
||||
}
|
||||
|
||||
t.Logf(" [SUCCESS] : checkMetricValuesTest")
|
||||
|
|
|
@ -496,14 +496,14 @@ func (m methodREQToFileAppend) handler(proc process, message Message, node strin
|
|||
case message.PreviousMessage == nil:
|
||||
// If this was a direct request there are no previous message to take
|
||||
// information from, so we use the one that are in the current mesage.
|
||||
fileName = fmt.Sprintf("%v.%v%v", message.ToNode, message.Method, message.FileExtension)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.FromNode))
|
||||
fileName = message.FileName
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.FromNode), string(message.ToNode), string(message.Method))
|
||||
case message.PreviousMessage.ToNode != "":
|
||||
fileName = fmt.Sprintf("%v.%v%v", message.PreviousMessage.ToNode, message.PreviousMessage.Method, message.PreviousMessage.FileExtension)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
fileName = message.PreviousMessage.FileName
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode), string(message.PreviousMessage.ToNode), string(message.PreviousMessage.Method))
|
||||
case message.PreviousMessage.ToNode == "":
|
||||
fileName = fmt.Sprintf("%v.%v%v", message.FromNode, message.Method, message.PreviousMessage.FileExtension)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
fileName = message.PreviousMessage.FileName
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode), string(message.FromNode), string(message.Method))
|
||||
}
|
||||
|
||||
// Check if folder structure exist, if not create it.
|
||||
|
@ -565,14 +565,14 @@ func (m methodREQToFile) handler(proc process, message Message, node string) ([]
|
|||
case message.PreviousMessage == nil:
|
||||
// If this was a direct request there are no previous message to take
|
||||
// information from, so we use the one that are in the current mesage.
|
||||
fileName = fmt.Sprintf("%v.%v%v", message.ToNode, message.Method, message.FileExtension)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.FromNode))
|
||||
fileName = message.FileName
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.FromNode), string(message.ToNode), string(message.Method))
|
||||
case message.PreviousMessage.ToNode != "":
|
||||
fileName = fmt.Sprintf("%v.%v%v", message.PreviousMessage.ToNode, message.PreviousMessage.Method, message.PreviousMessage.FileExtension)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
fileName = message.PreviousMessage.FileName
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode), string(message.PreviousMessage.ToNode), string(message.PreviousMessage.Method))
|
||||
case message.PreviousMessage.ToNode == "":
|
||||
fileName = fmt.Sprintf("%v.%v%v", message.FromNode, message.Method, message.PreviousMessage.FileExtension)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
fileName = message.PreviousMessage.FileName
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode), string(message.FromNode), string(message.Method))
|
||||
}
|
||||
|
||||
// Check if folder structure exist, if not create it.
|
||||
|
@ -627,8 +627,8 @@ func (m methodREQHello) getKind() CommandOrEvent {
|
|||
func (m methodREQHello) handler(proc process, message Message, node string) ([]byte, error) {
|
||||
data := fmt.Sprintf("Received hello from %#v\n", message.FromNode)
|
||||
|
||||
fileName := fmt.Sprintf("%v.%v%v", message.FromNode, message.Method, message.FileExtension)
|
||||
folderTree := filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.ToNode))
|
||||
fileName := message.FileName
|
||||
folderTree := filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.ToNode), string(message.FromNode), string(message.Method))
|
||||
|
||||
// Check if folder structure exist, if not create it.
|
||||
if _, err := os.Stat(folderTree); os.IsNotExist(err) {
|
||||
|
@ -688,14 +688,14 @@ func (m methodREQErrorLog) handler(proc process, message Message, node string) (
|
|||
case message.PreviousMessage == nil:
|
||||
// If this was a direct request there are no previous message to take
|
||||
// information from, so we use the one that are in the current mesage.
|
||||
fileName = fmt.Sprintf("%v.%v%v", message.ToNode, message.Method, message.FileExtension)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.FromNode))
|
||||
fileName = message.FileName
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.Directory, string(message.FromNode), string(message.ToNode), string(message.Method))
|
||||
case message.PreviousMessage.ToNode != "":
|
||||
fileName = fmt.Sprintf("%v.%v%v", message.PreviousMessage.ToNode, message.PreviousMessage.Method, message.PreviousMessage.FileExtension)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
fileName = message.PreviousMessage.FileName
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode), string(message.PreviousMessage.ToNode), string(message.PreviousMessage.Method))
|
||||
case message.PreviousMessage.ToNode == "":
|
||||
fileName = fmt.Sprintf("%v.%v%v", message.FromNode, message.Method, message.PreviousMessage.FileExtension)
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode))
|
||||
fileName = message.PreviousMessage.FileName
|
||||
folderTree = filepath.Join(proc.configuration.SubscribersDataFolder, message.PreviousMessage.Directory, string(message.PreviousMessage.ToNode), string(message.FromNode), string(message.Method))
|
||||
}
|
||||
|
||||
// Check if folder structure exist, if not create it.
|
||||
|
|
Loading…
Reference in a new issue