diff --git a/controller/topology/ports/configuration/configuration.go b/controller/topology/ports/configuration/configuration.go index f97abf5265e148a11d246d60ceadc6f23115b431..38314e773b97372163e4fca14d9dc1e754cb5914 100644 --- a/controller/topology/ports/configuration/configuration.go +++ b/controller/topology/ports/configuration/configuration.go @@ -5,16 +5,18 @@ import ( "net" ) +// IPConfig represents an interface configuration for a cEOS instance type IPConfig struct { - IP net.IP `json:"ip,omitempty"` - PrefixLength int `json:"prefix_length,omitempty"` + IP net.IP `bson:"ip,omitempty"` + PrefixLength int `bson:"prefix_length,omitempty"` } +// New creates a new IPConfig func New(ip string, prefixLength int) (IPConfig, error) { newIPConfig := IPConfig{} parsedIP := net.ParseIP(ip) if parsedIP == nil { - return newIPConfig, fmt.Errorf("%s can not be parsed to an IP.", ip) + return newIPConfig, fmt.Errorf("%s can not be parsed to an IP", ip) } newIPConfig.IP = parsedIP diff --git a/controller/topology/ports/port.go b/controller/topology/ports/port.go index 466292408989947de59077e255b14cf679f5bef3..e7456af6f65a9857b78b34262a4bd524a4bc7247 100644 --- a/controller/topology/ports/port.go +++ b/controller/topology/ports/port.go @@ -7,9 +7,9 @@ import ( // Port is a representation of physical port on a network element type Port struct { - ID uuid.UUID `bson:"_id"` - Name string `bson:"name,omitempty"` - Configuration configuration.IPConfig + ID uuid.UUID `bson:"_id"` + Name string `bson:"name,omitempty"` + Configuration configuration.IPConfig `bson:"configuration,omitempty"` } // GetID returns the id of a port