-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4537d13
Showing
22 changed files
with
6,712 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,30 @@ | ||
name: Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
- name: Lint code | ||
uses: actions-contrib/golangci-lint@master | ||
with: | ||
args: run | ||
- name: Set up Go 1.13 | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.13.x' | ||
- name: Test | ||
run: make test | ||
- name: Build and Push Docker Image | ||
run: | | ||
docker login -u metalstackci -p ${{ secrets.DOCKER_HUB_TOKEN }} | ||
make dockerimage | ||
make dockerpush |
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,3 @@ | ||
bin | ||
metal-api | ||
|
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,12 @@ | ||
FROM metalstack/builder:latest as builder | ||
|
||
FROM registry.fi-ts.io/metal/supermicro:2.4.0 as sum | ||
FROM debian:10 | ||
|
||
RUN apt update \ | ||
&& apt install --yes --no-install-recommends \ | ||
ca-certificates | ||
COPY --from=builder /work/bin/ipmi-catcher / | ||
COPY --from=sum /usr/bin/sum /sum | ||
|
||
CMD ["/ipmi-catcher"] |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 The Metal Stack Authors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,33 @@ | ||
.ONESHELL: | ||
BINARY := ipmi-catcher | ||
COMMONDIR := $(or ${COMMONDIR},../common) | ||
DOCKER_TAG := $(or ${GITHUB_TAG_NAME}, latest) | ||
|
||
include $(COMMONDIR)/Makefile.inc | ||
|
||
release:: clean-local-dirs generate-client test all; | ||
|
||
.PHONY: clean-local-dirs | ||
clean-local-dirs: | ||
rm -rf metal-api | ||
mkdir metal-api | ||
|
||
.PHONY: clean-client | ||
clean-client: clean-local-dirs | ||
cp ../metal-api/spec/metal-api.json metal-api.json | ||
|
||
.PHONY: fmt | ||
fmt: | ||
GO111MODULE=off go fmt ./... | ||
|
||
.PHONY: generate-client | ||
generate-client: clean-local-dirs fmt | ||
GO111MODULE=off swagger generate client --target=metal-api -f metal-api.json --skip-validation | ||
|
||
.PHONY: dockerimage | ||
dockerimage: | ||
docker build -t metalstack/ipmi-catcher:${DOCKER_TAG} . | ||
|
||
.PHONY: dockerpush | ||
dockerpush: | ||
docker push metalstack/ipmi-catcher:${DOCKER_TAG} |
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,7 @@ | ||
# ipmi-catcher | ||
|
||
Reports the ip addresses that are leased to ipmi devices together with their machine uuids to the `metal-api`. | ||
|
||
Therewith it is possible to have knowledge about new machines very early in the `metal-api` and also get knowledge about possibly changing ipmi ip addresses. | ||
|
||
`ipmi-catcher` parses the DHCPD lease file and reports the mapping of machine uuids to ipmi ip address to the `metal-api`. |
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,22 @@ | ||
lease 192.168.2.27 { | ||
starts 4 2019/06/27 06:40:21; | ||
ends 4 2020/06/27 06:50:21; | ||
cltt 4 2020/06/27 06:40:21; | ||
binding state active; | ||
next binding state free; | ||
rewind binding state free; | ||
hardware ethernet ac:1f:6b:35:ac:62; | ||
uid "\001\254\037k5\254b"; | ||
set vendor-class-identifier = "udhcp 1.23.1"; | ||
} | ||
lease 192.168.2.30 { | ||
starts 4 2019/06/27 06:40:06; | ||
ends 4 2020/06/27 06:50:06; | ||
cltt 4 2019/06/27 06:40:06; | ||
binding state active; | ||
next binding state free; | ||
rewind binding state free; | ||
hardware ethernet ac:1f:6b:35:ab:2d; | ||
uid "\001\254\037k5\253-"; | ||
set vendor-class-identifier = "udhcp 1.23.1"; | ||
} |
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,18 @@ | ||
--- | ||
version: '3.7' | ||
|
||
services: | ||
ipmi-catcher: | ||
build: | ||
context: . | ||
image: metalstack/ipmi-catcher:latest | ||
network_mode: host | ||
volumes: | ||
- ${PWD}/dhcpd.leases:/dhcpd.leases | ||
environment: | ||
IPMI_CATCHER_LEASE_FILE: /dhcpd.leases | ||
IPMI_CATCHER_PARTITION_ID: partition | ||
IPMI_CATCHER_METAL_API_URL: http://localhost:8080 | ||
IPMI_CATCHER_METAL_API_HMAC_KEY: test | ||
IPMI_CATCHER_IGNORE_MACS: "aa:aa:aa:aa:aa:aa" | ||
|
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,27 @@ | ||
package domain | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"time" | ||
) | ||
|
||
type Config struct { | ||
// Valid log levels are: DEBUG, INFO, WARN, ERROR, FATAL and PANIC | ||
LogLevel string `required:"false" default:"debug" desc:"set log level" split_words:"true"` | ||
PartitionID string `required:"true" desc:"set the partition ID" envconfig:"partition_id"` | ||
LeaseFile string `required:"false" default:"/var/lib/dhcp/dhcpd.leases" desc:"the dhcp lease file to read" split_words:"true"` | ||
DebounceInterval time.Duration `required:"false" default:"20s" desc:"the duration to debounce dhcp events" split_words:"true"` | ||
ReportInterval time.Duration `required:"false" default:"5m" desc:"the interval for periodical reports" split_words:"true"` | ||
MetalAPIURL *url.URL `required:"true" desc:"endpoint for the metal-api" envconfig:"metal_api_url"` | ||
MetalAPIHMACKey string `required:"true" desc:"the preshared key for the hmac calculation" envconfig:"metal_api_hmac_key"` | ||
IpmiUser string `required:"false" default:"ADMIN" desc:"the ipmi user" split_words:"true"` | ||
IpmiPassword string `required:"false" default:"ADMIN" desc:"the ipmi password" split_words:"true"` | ||
SumBin string `required:"false" default:"/sum" desc:"the sum binary" split_words:"true"` | ||
IgnoreMacs []string `required:"false" desc:"mac addresses to ignore" split_words:"true"` | ||
} | ||
|
||
func (c Config) String() string { | ||
return fmt.Sprintf("loglevel:%s partition:%s leasefile:%s debounce interval:%s report interval:%s metal-api url:%s ipmiuser:%s sum:%s", | ||
c.LogLevel, c.PartitionID, c.LeaseFile, c.DebounceInterval, c.ReportInterval, c.MetalAPIURL, c.IpmiUser, c.SumBin) | ||
} |
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,28 @@ | ||
module github.com/metal-stack/ipmi-catcher | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 // indirect | ||
github.com/go-openapi/analysis v0.19.7 // indirect | ||
github.com/go-openapi/errors v0.19.3 | ||
github.com/go-openapi/runtime v0.19.11 | ||
github.com/go-openapi/spec v0.19.6 // indirect | ||
github.com/go-openapi/strfmt v0.19.4 | ||
github.com/go-openapi/swag v0.19.7 | ||
github.com/go-openapi/validate v0.19.6 | ||
github.com/kelseyhightower/envconfig v1.4.0 | ||
github.com/metal-stack/security v0.0.0-20200207131443-5520f3976826 | ||
github.com/metal-stack/v v1.0.1 | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/stretchr/testify v1.4.0 | ||
go.mongodb.org/mongo-driver v1.3.0 // indirect | ||
go.uber.org/atomic v1.5.1 // indirect | ||
go.uber.org/multierr v1.4.0 // indirect | ||
go.uber.org/zap v1.13.0 | ||
go.universe.tf/netboot v0.0.0-20200205210610-68743c67a60c | ||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367 // indirect | ||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect | ||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 // indirect | ||
golang.org/x/tools v0.0.0-20200211205636-11eff242d136 // indirect | ||
) |
Oops, something went wrong.