Skip to content

Commit

Permalink
Merge pull request #35 from ernestio/feature/458
Browse files Browse the repository at this point in the history
added azure components
  • Loading branch information
adriacidre authored Apr 27, 2017
2 parents 5a5db5a + f156345 commit dc391fa
Show file tree
Hide file tree
Showing 14 changed files with 789 additions and 0 deletions.
58 changes: 58 additions & 0 deletions c_loadbalancer.go
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
}
58 changes: 58 additions & 0 deletions c_local_network_gateway.go
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
}
56 changes: 56 additions & 0 deletions c_network_interface.go
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
}
58 changes: 58 additions & 0 deletions c_network_security_group.go
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
}
58 changes: 58 additions & 0 deletions c_public_ip.go
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
}
56 changes: 56 additions & 0 deletions c_resource_group.go
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
}
Loading

0 comments on commit dc391fa

Please sign in to comment.