-
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.
- Loading branch information
1 parent
be8a8e9
commit 9a07c4a
Showing
4 changed files
with
183 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package main | ||
|
||
import "strings" | ||
|
||
// LbBackendAddressPool : ... | ||
type LbBackendAddressPool struct { | ||
} | ||
|
||
// Handle : ... | ||
func (n *LbBackendAddressPool) Handle(subject string, c component, lines []Message) []Message { | ||
parts := strings.Split(subject, ".") | ||
subject = parts[0] + "." + parts[1] | ||
switch subject { | ||
case "lb_backend_address_pool.create": | ||
lines = n.getSingleDetail(c, "Created Loadbalancer") | ||
case "lb_backend_address_pool.update": | ||
lines = n.getSingleDetail(c, "Updated Loadbalancer") | ||
case "lb_backend_address_pool.delete": | ||
lines = n.getSingleDetail(c, "Deleted Loadbalancer") | ||
case "lb_backend_address_pools.find": | ||
for _, cx := range c.getFoundComponents() { | ||
lines = append(lines, n.getSingleDetail(cx, "Found Loadbalancer backend address pool")...) | ||
} | ||
} | ||
return lines | ||
} | ||
|
||
func (n *LbBackendAddressPool) getSingleDetail(c component, prefix string) (lines []Message) { | ||
name, _ := c["name"].(string) | ||
if prefix != "" { | ||
name = prefix + " " + name | ||
} | ||
status, _ := c["_state"].(string) | ||
level := "INFO" | ||
if status == "errored" { | ||
level = "ERROR" | ||
} | ||
if status != "errored" && status != "completed" && status != "" { | ||
return lines | ||
} | ||
lines = append(lines, Message{Body: " " + name, Level: level}) | ||
id, _ := c["id"].(string) | ||
if id != "" { | ||
lines = append(lines, Message{Body: " ID : " + id, Level: ""}) | ||
} | ||
if status != "" { | ||
lines = append(lines, Message{Body: " Status : " + status, Level: ""}) | ||
} | ||
if status == "errored" { | ||
err, _ := c["error"].(string) | ||
lines = append(lines, Message{Body: " Error : " + err, Level: ""}) | ||
} | ||
return lines | ||
} |
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,58 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package main | ||
|
||
import "strings" | ||
|
||
// LbProbe : ... | ||
type LbProbe struct { | ||
} | ||
|
||
// Handle : ... | ||
func (n *LbProbe) Handle(subject string, c component, lines []Message) []Message { | ||
parts := strings.Split(subject, ".") | ||
subject = parts[0] + "." + parts[1] | ||
switch subject { | ||
case "lb_probe.create": | ||
lines = n.getSingleDetail(c, "Created Loadbalancer") | ||
case "lb_probe.update": | ||
lines = n.getSingleDetail(c, "Updated Loadbalancer") | ||
case "lb_probe.delete": | ||
lines = n.getSingleDetail(c, "Deleted Loadbalancer") | ||
case "lb_probes.find": | ||
for _, cx := range c.getFoundComponents() { | ||
lines = append(lines, n.getSingleDetail(cx, "Found Loadbalancer probe")...) | ||
} | ||
} | ||
return lines | ||
} | ||
|
||
func (n *LbProbe) getSingleDetail(c component, prefix string) (lines []Message) { | ||
name, _ := c["name"].(string) | ||
if prefix != "" { | ||
name = prefix + " " + name | ||
} | ||
status, _ := c["_state"].(string) | ||
level := "INFO" | ||
if status == "errored" { | ||
level = "ERROR" | ||
} | ||
if status != "errored" && status != "completed" && status != "" { | ||
return lines | ||
} | ||
lines = append(lines, Message{Body: " " + name, Level: level}) | ||
id, _ := c["id"].(string) | ||
if id != "" { | ||
lines = append(lines, Message{Body: " ID : " + id, Level: ""}) | ||
} | ||
if status != "" { | ||
lines = append(lines, Message{Body: " Status : " + status, Level: ""}) | ||
} | ||
if status == "errored" { | ||
err, _ := c["error"].(string) | ||
lines = append(lines, Message{Body: " Error : " + err, Level: ""}) | ||
} | ||
return lines | ||
} |
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,58 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package main | ||
|
||
import "strings" | ||
|
||
// LbRule : ... | ||
type LbRule struct { | ||
} | ||
|
||
// Handle : ... | ||
func (n *LbRule) Handle(subject string, c component, lines []Message) []Message { | ||
parts := strings.Split(subject, ".") | ||
subject = parts[0] + "." + parts[1] | ||
switch subject { | ||
case "lb_rule.create": | ||
lines = n.getSingleDetail(c, "Created Loadbalancer") | ||
case "lb_rule.update": | ||
lines = n.getSingleDetail(c, "Updated Loadbalancer") | ||
case "lb_rule.delete": | ||
lines = n.getSingleDetail(c, "Deleted Loadbalancer") | ||
case "lb_rules.find": | ||
for _, cx := range c.getFoundComponents() { | ||
lines = append(lines, n.getSingleDetail(cx, "Found Loadbalancer Rule")...) | ||
} | ||
} | ||
return lines | ||
} | ||
|
||
func (n *LbRule) getSingleDetail(c component, prefix string) (lines []Message) { | ||
name, _ := c["name"].(string) | ||
if prefix != "" { | ||
name = prefix + " " + name | ||
} | ||
status, _ := c["_state"].(string) | ||
level := "INFO" | ||
if status == "errored" { | ||
level = "ERROR" | ||
} | ||
if status != "errored" && status != "completed" && status != "" { | ||
return lines | ||
} | ||
lines = append(lines, Message{Body: " " + name, Level: level}) | ||
id, _ := c["id"].(string) | ||
if id != "" { | ||
lines = append(lines, Message{Body: " ID : " + id, Level: ""}) | ||
} | ||
if status != "" { | ||
lines = append(lines, Message{Body: " Status : " + status, Level: ""}) | ||
} | ||
if status == "errored" { | ||
err, _ := c["error"].(string) | ||
lines = append(lines, Message{Body: " Error : " + err, Level: ""}) | ||
} | ||
return lines | ||
} |
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