Skip to content

Commit

Permalink
Merge pull request #54 from ubccr/v0.0.12
Browse files Browse the repository at this point in the history
V0.0.12
  • Loading branch information
aebruno authored Aug 5, 2024
2 parents 9a563e5 + c2cc6f5 commit 8673135
Show file tree
Hide file tree
Showing 26 changed files with 1,193 additions and 3,257 deletions.
18 changes: 10 additions & 8 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# Grendel goreleaser configs
# See here: https://goreleaser.com

version: 1

before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
- CGO_ENABLED=1
goarch:
- amd64
goos:
- linux
ldflags:
- -s -w -X github.com/ubccr/grendel/api.Version={{.Version}}
- -extldflags=-static
tags:
- sqlite_omit_load_extension
- osusergo
- netgo
archives:
- format: tar.gz
wrap_in_directory: true
Expand Down Expand Up @@ -64,7 +66,7 @@ nfpms:
- src: ./scripts/nfpm/grendel.service
dst: /usr/lib/systemd/system/grendel.service
checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-SNAPSHOT-{{.ShortCommit}}"
changelog:
Expand All @@ -73,12 +75,12 @@ changelog:
- title: Features
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: 'Bug fixes'
- title: "Bug fixes"
regexp: "^.*fix[(\\w)]*:+.*$"
order: 1
- title: Other
order: 999
filters:
exclude:
- '^docs:'
- 'typo'
- "^docs:"
- "typo"
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Grendel Changelog

## [0.0.12] - 2024-08-05

- Update echo, fiber deps
- Fix provision - tftp segfault when starting with bind port permission error
- Feat: provision - added "proxmox" tag DHCP 250 response code for Proxmox Automated Installs
- Fix: frontend - segfault when non nodeset hostname is added
- Fix: frontend - rack selection checkboxes not preserving state after submitting an action
- Fix: frontend - sqlite session storage
- Feat: fronend - added Nodes page
- Feat: frontend - added Bond support in Host page
- Feat: frontend - added status page

## [0.0.11] - 2024-02-27

- Add prometheus service discovery.
Expand Down Expand Up @@ -130,4 +142,5 @@
[0.0.9]: https://github.com/ubccr/grendel/releases/tag/v0.0.9
[0.0.10]: https://github.com/ubccr/grendel/releases/tag/v0.0.10
[0.0.11]: https://github.com/ubccr/grendel/releases/tag/v0.0.11
[Unreleased]: https://github.com/ubccr/grendel/compare/v0.0.11...HEAD
[0.0.12]: https://github.com/ubccr/grendel/releases/tag/v0.0.12
[Unreleased]: https://github.com/ubccr/grendel/compare/v0.0.12...HEAD
17 changes: 17 additions & 0 deletions dhcp/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ func (s *Server) setZTD(host *model.Host, nic *model.NetInterface, serverIP net.
resp.UpdateOption(dhcpv4.Option{Code: dhcpv4.GenericOptionCode(240), Value: dhcpv4.String(provisionURL)})
}

if host.HasTags("proxmox") {
// Proxmox Automated Installation
// See: https://pve.proxmox.com/wiki/Automated_Installation

log.WithFields(logrus.Fields{
"ip": nic.AddrString(),
"name": host.Name,
}).Info("Host tagged with proxmox. Setting automated install answer file url")

token, _ := model.NewBootToken(host.ID.String(), nic.MAC.String())
endpoints := model.NewEndpoints(serverIP.String(), token)

proxmoxURL := endpoints.ProxmoxURL()
log.Debugf("Proxmox Answer file url: %s", proxmoxURL)
resp.UpdateOption(dhcpv4.Option{Code: dhcpv4.GenericOptionCode(250), Value: dhcpv4.String(proxmoxURL)})
}

if req.ClassIdentifier() == "NVIDIA" || req.ClassIdentifier() == "Mellanox" {
// MLNXOS ZTP
// See: https://docs.nvidia.com/networking/display/MLNXOSv3103100/Getting+Started#heading-Zero-touchProvisioning
Expand Down
34 changes: 34 additions & 0 deletions frontend/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ type FormData struct {
BootImage string `form:"BootImage"`
Tags string `form:"Tags"`
Interfaces string `form:"Interfaces"`
Bonds string `form:"Bonds"`
}
type InterfacesString struct {
FQDN string `json:"Fqdn"`
Expand All @@ -154,6 +155,10 @@ type InterfacesString struct {
VLAN string `json:"Vlan"`
MTU string `json:"Mtu"`
}
type BondsString struct {
InterfacesString
Peers string `json:"Peers"`
}

func (h *Handler) EditHost(f *fiber.Ctx) error {
formHost := new(FormData)
Expand All @@ -172,8 +177,11 @@ func (h *Handler) EditHost(f *fiber.Ctx) error {

var ifaces []InterfacesString
json.Unmarshal([]byte(formHost.Interfaces), &ifaces)
var bondsStr []BondsString
json.Unmarshal([]byte(formHost.Bonds), &bondsStr)

var interfaces []*model.NetInterface
var bonds []*model.Bond

for i, iface := range ifaces {
mac, _ := net.ParseMAC(iface.MAC)
Expand All @@ -197,6 +205,31 @@ func (h *Handler) EditHost(f *fiber.Ctx) error {
MTU: uint16(mtu),
})
}
for i, bond := range bondsStr {
mac, _ := net.ParseMAC(bond.MAC)
ip, _ := netip.ParsePrefix(bond.IP)
bmc, err := strconv.ParseBool(bond.BMC)
if err != nil {
return ToastError(f, err, fmt.Sprintf("Failed to parse BMC boolean on interface %d", i))
}
mtu, err := strconv.Atoi(bond.MTU)
if err != nil {
return ToastError(f, err, fmt.Sprintf("Failed to parse MTU on interface %d", i))
}

bonds = append(bonds, &model.Bond{
NetInterface: model.NetInterface{
Name: bond.Name,
FQDN: bond.FQDN,
MAC: mac,
IP: ip,
BMC: bmc,
VLAN: bond.VLAN,
MTU: uint16(mtu),
},
Peers: strings.Split(bond.Peers, ","),
})
}

newHost := model.Host{
ID: id,
Expand All @@ -206,6 +239,7 @@ func (h *Handler) EditHost(f *fiber.Ctx) error {
BootImage: formHost.BootImage,
Tags: strings.Split(formHost.Tags, ","),
Interfaces: interfaces,
Bonds: bonds,
}

err = h.DB.StoreHost(&newHost)
Expand Down
31 changes: 31 additions & 0 deletions frontend/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package frontend

import (
"fmt"
"os"

"github.com/gofiber/fiber/v2"
"github.com/ubccr/grendel/api"
)

func (h *Handler) Index(f *fiber.Ctx) error {
Expand Down Expand Up @@ -38,6 +40,12 @@ func (h *Handler) Rack(f *fiber.Ctx) error {
})
}

func (h *Handler) nodes(f *fiber.Ctx) error {
return f.Render("nodes", fiber.Map{
"Title": "Grendel - Nodes",
})
}

func (h *Handler) Host(f *fiber.Ctx) error {
host := f.Params("host")
return f.Render("host", fiber.Map{
Expand All @@ -51,3 +59,26 @@ func (h *Handler) Users(f *fiber.Ctx) error {
"Title": "Grendel - Users",
})
}

func (h *Handler) status(f *fiber.Ctx) error {
hosts, err := h.DB.Hosts()
if err != nil {
return err
}
b, err := h.DB.BootImages()
if err != nil {
return err
}
hostName, err := os.Hostname()
if err != nil {
return err
}

return f.Render("status", fiber.Map{
"Title": "Grendel - Status",
"HostName": hostName,
"Version": api.Version,
"Hosts": len(hosts),
"BootImages": len(b),
})
}
Loading

0 comments on commit 8673135

Please sign in to comment.