Skip to content

Commit

Permalink
Fix missing IP address attributes in output
Browse files Browse the repository at this point in the history
  • Loading branch information
g3kk0 committed May 30, 2017
1 parent a5c0af8 commit 4b1b621
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion c_network_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

package main

import "strings"
import (
"strings"
)

// NetworkInterface : ...
type NetworkInterface struct {
Expand All @@ -28,6 +30,7 @@ func (n *NetworkInterface) Handle(subject string, c component, lines []Message)
}

func (n *NetworkInterface) getSingleDetail(c component, prefix string) (lines []Message) {
ip, _ := c["private_ip_address"].(string)
name, _ := c["name"].(string)
if prefix != "" {
name = prefix + " " + name
Expand All @@ -41,6 +44,7 @@ func (n *NetworkInterface) getSingleDetail(c component, prefix string) (lines []
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: ""})
Expand Down
13 changes: 10 additions & 3 deletions c_virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

package main

import "strings"
import (
"strings"
)

// VirtualNetwork : ...
type VirtualNetwork struct {
Expand All @@ -28,7 +30,12 @@ func (n *VirtualNetwork) Handle(subject string, c component, lines []Message) []
}

func (n *VirtualNetwork) getSingleDetail(c component, prefix string) (lines []Message) {
ip, _ := c["address_space"].(string)
address_space := c["address_space"].([]interface{})
var netlist []string
for _, a := range address_space {
netlist = append(netlist, a.(string))
}
networks := strings.Join(netlist, ", ")
name, _ := c["name"].(string)
if prefix != "" {
name = prefix + " " + name
Expand All @@ -42,7 +49,7 @@ func (n *VirtualNetwork) getSingleDetail(c component, prefix string) (lines []Me
return lines
}
lines = append(lines, Message{Body: " " + name, Level: level})
lines = append(lines, Message{Body: " Address Space : " + ip, Level: ""})
lines = append(lines, Message{Body: " Address Space : " + networks, Level: ""})
id, _ := c["id"].(string)
if id != "" {
lines = append(lines, Message{Body: " ID : " + id, Level: ""})
Expand Down

0 comments on commit 4b1b621

Please sign in to comment.