-
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 #35 from ernestio/feature/458
added azure components
- Loading branch information
Showing
14 changed files
with
789 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" | ||
|
||
// Lb : ... | ||
type Lb struct { | ||
} | ||
|
||
// Handle : ... | ||
func (n *Lb) Handle(subject string, c component, lines []Message) []Message { | ||
parts := strings.Split(subject, ".") | ||
subject = parts[0] + "." + parts[1] | ||
switch subject { | ||
case "lb.create": | ||
lines = n.getSingleDetail(c, "Created Loadbalancer") | ||
case "lb.update": | ||
lines = n.getSingleDetail(c, "Updated Loadbalancer") | ||
case "lb.delete": | ||
lines = n.getSingleDetail(c, "Deleted Loadbalancer") | ||
case "lbs.find": | ||
for _, cx := range c.getFoundComponents() { | ||
lines = append(lines, n.getSingleDetail(cx, "Found Loadbalancer")...) | ||
} | ||
} | ||
return lines | ||
} | ||
|
||
func (n *Lb) 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" | ||
|
||
// LocalNetworkGateway : ... | ||
type LocalNetworkGateway struct { | ||
} | ||
|
||
// Handle : ... | ||
func (n *LocalNetworkGateway) Handle(subject string, c component, lines []Message) []Message { | ||
parts := strings.Split(subject, ".") | ||
subject = parts[0] + "." + parts[1] | ||
switch subject { | ||
case "local_network_gateway.create": | ||
lines = n.getSingleDetail(c, "Created Local Network Gateway") | ||
case "local_network_gateway.update": | ||
lines = n.getSingleDetail(c, "Updated Local Network Gateway") | ||
case "local_network_gateway.delete": | ||
lines = n.getSingleDetail(c, "Deleted Local Network Gateway") | ||
case "local_network_gateways.find": | ||
for _, cx := range c.getFoundComponents() { | ||
lines = append(lines, n.getSingleDetail(cx, "Found Local Network Gateway")...) | ||
} | ||
} | ||
return lines | ||
} | ||
|
||
func (n *LocalNetworkGateway) 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,56 @@ | ||
/* 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" | ||
|
||
// NetworkInterface : ... | ||
type NetworkInterface struct { | ||
} | ||
|
||
// Handle : ... | ||
func (n *NetworkInterface) Handle(subject string, c component, lines []Message) []Message { | ||
parts := strings.Split(subject, ".") | ||
subject = parts[0] + "." + parts[1] | ||
switch subject { | ||
case "network_interface.create": | ||
lines = n.getSingleDetail(c, "Created Network Interface") | ||
case "network_interface.delete": | ||
lines = n.getSingleDetail(c, "Deleted Network Interface") | ||
case "network_interfaces.find": | ||
for _, cx := range c.getFoundComponents() { | ||
lines = append(lines, n.getSingleDetail(cx, "Found Network Interface")...) | ||
} | ||
} | ||
return lines | ||
} | ||
|
||
func (n *NetworkInterface) 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: " AWS 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" | ||
|
||
// NetworkSecurityGroup : ... | ||
type NetworkSecurityGroup struct { | ||
} | ||
|
||
// Handle : ... | ||
func (n *NetworkSecurityGroup) Handle(subject string, c component, lines []Message) []Message { | ||
parts := strings.Split(subject, ".") | ||
subject = parts[0] + "." + parts[1] | ||
switch subject { | ||
case "network_security_group.create": | ||
lines = n.getSingleDetail(c, "Created Network Security Group") | ||
case "network_security_group.update": | ||
lines = n.getSingleDetail(c, "Updated Network Security Group") | ||
case "network_security_group.delete": | ||
lines = n.getSingleDetail(c, "Deleted Network Security Group") | ||
case "network_security_groups.find": | ||
for _, cx := range c.getFoundComponents() { | ||
lines = append(lines, n.getSingleDetail(cx, "Found Network Security Group")...) | ||
} | ||
} | ||
return lines | ||
} | ||
|
||
func (n *NetworkSecurityGroup) 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" | ||
|
||
// PublicIP : ... | ||
type PublicIP struct { | ||
} | ||
|
||
// Handle : ... | ||
func (n *PublicIP) Handle(subject string, c component, lines []Message) []Message { | ||
parts := strings.Split(subject, ".") | ||
subject = parts[0] + "." + parts[1] | ||
switch subject { | ||
case "public_ip.create": | ||
lines = n.getSingleDetail(c, "Created Public IP") | ||
case "public_ip.delete": | ||
lines = n.getSingleDetail(c, "Deleted Public IP") | ||
case "public_ips.find": | ||
for _, cx := range c.getFoundComponents() { | ||
lines = append(lines, n.getSingleDetail(cx, "Found Public IP")...) | ||
} | ||
} | ||
return lines | ||
} | ||
|
||
func (n *PublicIP) getSingleDetail(c component, prefix string) (lines []Message) { | ||
ip, _ := c["ip_address"].(string) | ||
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}) | ||
lines = append(lines, Message{Body: " IP : " + ip, 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,56 @@ | ||
/* 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" | ||
|
||
// ResourceGroup : ... | ||
type ResourceGroup struct { | ||
} | ||
|
||
// Handle : ... | ||
func (n *ResourceGroup) Handle(subject string, c component, lines []Message) []Message { | ||
parts := strings.Split(subject, ".") | ||
subject = parts[0] + "." + parts[1] | ||
switch subject { | ||
case "resource_group.create": | ||
lines = n.getSingleDetail(c, "Created Resource Group") | ||
case "resource_group.delete": | ||
lines = n.getSingleDetail(c, "Deleted Resource Group") | ||
case "resource_groups.find": | ||
for _, cx := range c.getFoundComponents() { | ||
lines = append(lines, n.getSingleDetail(cx, "Found Resource Group")...) | ||
} | ||
} | ||
return lines | ||
} | ||
|
||
func (n *ResourceGroup) 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 | ||
} |
Oops, something went wrong.