Skip to content

Commit

Permalink
Merge pull request #35 from inexio/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
toberd authored May 12, 2021
2 parents aef93c9 + 2b6f452 commit aa69fd8
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 27 deletions.
12 changes: 7 additions & 5 deletions core/communicator/ekinops.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ type ekinopsCommunicator struct {

// GetInterfaces returns the interfaces of ekinops devices.
func (c *ekinopsCommunicator) GetInterfaces(ctx context.Context) ([]device.Interface, error) {
interfaces, err := c.GetIfTable(ctx)
if err != nil {
return nil, err
}

con, ok := network.DeviceConnectionFromContext(ctx)
if !ok || con.SNMP == nil {
return nil, errors.New("no device connection available")
}

con.SNMP.SnmpClient.UseCache(false)

interfaces, err := c.GetIfTable(ctx)
if err != nil {
return nil, err
}

//get used slots
slotResults, err := con.SNMP.SnmpClient.SNMPWalk(ctx, ".1.3.6.1.4.1.20044.7.8.1.1.2")
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions core/network/connection_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ type ConnectionData struct {
type SNMPConnectionData struct {
// The snmp community string(s) for the device.
//
// example: public
// example: ["public"]
Communities []string `json:"communities" xml:"communities" yaml:"communities"`
// The snmp version(s) of the device.
//
// example: 2c
// example: ["2c"]
Versions []string `json:"versions" xml:"versions" yaml:"versions"`
// The snmp port(s) of the device.
//
// example: 161
// example: [161]
Ports []int `json:"ports" xml:"ports" yaml:"ports"`
// The amount of parallel connection requests used while trying to get a valid SNMP connection.
//
Expand Down Expand Up @@ -99,11 +99,11 @@ type SNMPCredentials struct {
type HTTPConnectionData struct {
// The http port(s) of the device.
//
// example: 80
// example: [80]
HTTPPorts []int `json:"http_ports" xml:"http_ports" yaml:"http_ports"`
// The https port(s) of the device.
//
// example: 443
// example: [443]
HTTPSPorts []int `json:"https_ports" xml:"https_ports" yaml:"https_ports"`
// The username for authorization on the device.
//
Expand Down
51 changes: 36 additions & 15 deletions doc/api_doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1454,21 +1454,11 @@
"format": "double",
"x-go-name": "RXPower"
},
"rx_power_100_g": {
"type": "number",
"format": "double",
"x-go-name": "RXPower100G"
},
"tx_power": {
"type": "number",
"format": "double",
"x-go-name": "TXPower"
},
"tx_power_100_g": {
"type": "number",
"format": "double",
"x-go-name": "TXPower100G"
},
"uncorrected_fec": {
"type": "array",
"items": {
Expand Down Expand Up @@ -1657,7 +1647,9 @@
"format": "int64"
},
"x-go-name": "HTTPPorts",
"example": "80"
"example": [
80
]
},
"https_ports": {
"description": "The https port(s) of the device.",
Expand All @@ -1667,7 +1659,9 @@
"format": "int64"
},
"x-go-name": "HTTPSPorts",
"example": "443"
"example": [
443
]
}
},
"x-go-package": "github.com/inexio/thola/core/network"
Expand Down Expand Up @@ -1964,6 +1958,9 @@
},
"radio": {
"$ref": "#/definitions/RadioInterface"
},
"sap": {
"$ref": "#/definitions/SAPInterface"
}
},
"x-go-package": "github.com/inexio/thola/core/device"
Expand Down Expand Up @@ -2596,6 +2593,24 @@
},
"x-go-package": "github.com/inexio/go-monitoringplugin"
},
"SAPInterface": {
"description": "SAPInterface represents a service access point interface.",
"type": "object",
"title": "SAPInterface",
"properties": {
"inbound": {
"type": "integer",
"format": "uint64",
"x-go-name": "Inbound"
},
"outbound": {
"type": "integer",
"format": "uint64",
"x-go-name": "Outbound"
}
},
"x-go-package": "github.com/inexio/thola/core/device"
},
"SBCComponent": {
"description": "SBCComponent represents a SBC component.",
"type": "object",
Expand Down Expand Up @@ -2754,7 +2769,9 @@
"type": "string"
},
"x-go-name": "Communities",
"example": "public"
"example": [
"public"
]
},
"discoverParallelRequests": {
"description": "The amount of parallel connection requests used while trying to get a valid SNMP connection.",
Expand Down Expand Up @@ -2785,7 +2802,9 @@
"format": "int64"
},
"x-go-name": "Ports",
"example": "161"
"example": [
161
]
},
"versions": {
"description": "The snmp version(s) of the device.",
Expand All @@ -2794,7 +2813,9 @@
"type": "string"
},
"x-go-name": "Versions",
"example": "2c"
"example": [
"2c"
]
}
},
"x-go-package": "github.com/inexio/thola/core/network"
Expand Down
20 changes: 18 additions & 2 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,16 @@ func (t *testDeviceInfoSNMPSim) generateRequest(requestType string) (request.Req
r := request.CheckSBCRequest{}
r.DeviceData = t.requestDeviceData
return &r, nil
case "check server":
r := request.CheckServerRequest{}
r.DeviceData = t.requestDeviceData
return &r, nil
case "check disk":
r := request.CheckDiskRequest{}
r.DeviceData = t.requestDeviceData
return &r, nil
default:
return nil, errors.New("unknown requestType")
return nil, errors.New("unknown requestType: " + requestType)
}
}

Expand Down Expand Up @@ -308,8 +316,16 @@ func (e *DeviceTestDataExpectations) compareExpectations(response request.Respon
if !cmp.Equal(e.CheckSBC, response, metricsTransformer(), metricsRawOutputFilter()) {
return errors.New("difference:\n" + cmp.Diff(e.CheckSBC, response, metricsTransformer(), metricsRawOutputFilter()))
}
case "check server":
if !cmp.Equal(e.CheckServer, response, metricsTransformer(), metricsRawOutputFilter()) {
return errors.New("difference:\n" + cmp.Diff(e.CheckServer, response, metricsTransformer(), metricsRawOutputFilter()))
}
case "check disk":
if !cmp.Equal(e.CheckDisk, response, metricsTransformer(), metricsRawOutputFilter()) {
return errors.New("difference:\n" + cmp.Diff(e.CheckDisk, response, metricsTransformer(), metricsRawOutputFilter()))
}
default:
return errors.New("unknown request type")
return errors.New("unknown request type: " + requestType)
}

return nil
Expand Down

0 comments on commit aa69fd8

Please sign in to comment.