mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Merge pull request #1 from OpenCHAMI/rehome
move to OpenCHAMI and update changelog
This commit is contained in:
commit
44e75aee5c
18 changed files with 179 additions and 91 deletions
4
.devcontainer/.env
Normal file
4
.devcontainer/.env
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
POSTGRES_DB=postgres
|
||||
POSTGRES_HOSTNAME=localhost
|
||||
13
.devcontainer/Dockerfile
Normal file
13
.devcontainer/Dockerfile
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
FROM mcr.microsoft.com/devcontainers/go:1-1.20-bullseye
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
||||
|
||||
# [Optional] Uncomment the next lines to use go get to install anything else you need
|
||||
# USER vscode
|
||||
# RUN go get -x <your-dependency-or-tool>
|
||||
# USER root
|
||||
|
||||
# [Optional] Uncomment this line to install global node packages.
|
||||
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
|
||||
28
.devcontainer/devcontainer.json
Normal file
28
.devcontainer/devcontainer.json
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||
// README at: https://github.com/devcontainers/templates/tree/main/src/go-postgres
|
||||
{
|
||||
"name": "Go & PostgreSQL",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"service": "app",
|
||||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
|
||||
"features": {
|
||||
"ghcr.io/marcozac/devcontainer-features/goreleaser:1": {},
|
||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
|
||||
|
||||
}
|
||||
|
||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||
// "features": {},
|
||||
|
||||
// Configure tool-specific properties.
|
||||
// "customizations": {},
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [5432],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
// "postCreateCommand": "go version",
|
||||
|
||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||
// "remoteUser": "root"
|
||||
}
|
||||
38
.devcontainer/docker-compose.yml
Normal file
38
.devcontainer/docker-compose.yml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
version: '3.8'
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
env_file:
|
||||
# Ensure that the variables in .env match the same variables in devcontainer.json
|
||||
- .env
|
||||
|
||||
volumes:
|
||||
- ../..:/workspaces:cached
|
||||
|
||||
# Overrides default command so things don't shut down after the process ends.
|
||||
command: sleep infinity
|
||||
|
||||
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
|
||||
network_mode: service:db
|
||||
|
||||
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
|
||||
# (Adding the "ports" property to this file will not forward from a Codespace.)
|
||||
|
||||
db:
|
||||
image: postgres:latest
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
env_file:
|
||||
# Ensure that the variables in .env match the same variables in devcontainer.json
|
||||
- .env
|
||||
|
||||
|
||||
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
|
||||
# (Adding the "ports" property to this file will not forward from a Codespace.)
|
||||
|
|
@ -10,10 +10,10 @@ builds:
|
|||
- amd64
|
||||
dockers:
|
||||
- image_templates:
|
||||
- bikeshack/{{.ProjectName}}:latest
|
||||
- bikeshack/{{.ProjectName}}:{{ .Tag }}
|
||||
- bikeshack/{{.ProjectName}}:{{ .Major }}
|
||||
- bikeshack/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}
|
||||
- ghcr.io/openchami/{{.ProjectName}}:latest
|
||||
- ghcr.io/openchami/{{.ProjectName}}:{{ .Tag }}
|
||||
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}
|
||||
- ghcr.io/openchami/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--label=org.opencontainers.image.created={{.Date}}"
|
||||
|
|
|
|||
13
CHANGELOG.md
13
CHANGELOG.md
|
|
@ -5,7 +5,18 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
## [0.0.5] - 2023-11-02
|
||||
|
||||
### Added
|
||||
|
||||
* Ability to update firmware
|
||||
* Refactored connection handling for faster scanning
|
||||
* Updated to refelct home at github.com/OpenCHAMI
|
||||
* Updated to reflect ghcr.io as container home
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.0.1] - 2023-09-14
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
magellan "github.com/OpenChami/magellan/internal"
|
||||
"github.com/OpenChami/magellan/internal/api/smd"
|
||||
"github.com/OpenChami/magellan/internal/db/sqlite"
|
||||
"github.com/OpenChami/magellan/internal/log"
|
||||
magellan "github.com/OpenCHAMI/magellan/internal"
|
||||
"github.com/OpenCHAMI/magellan/internal/api/smd"
|
||||
"github.com/OpenCHAMI/magellan/internal/db/sqlite"
|
||||
"github.com/OpenCHAMI/magellan/internal/log"
|
||||
"github.com/cznic/mathutil"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/OpenChami/magellan/internal/db/sqlite"
|
||||
"github.com/OpenCHAMI/magellan/internal/db/sqlite"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
|
||||
magellan "github.com/OpenChami/magellan/internal"
|
||||
"github.com/OpenChami/magellan/internal/db/sqlite"
|
||||
magellan "github.com/OpenCHAMI/magellan/internal"
|
||||
"github.com/OpenCHAMI/magellan/internal/db/sqlite"
|
||||
|
||||
"github.com/cznic/mathutil"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -35,7 +35,7 @@ var scanCmd = &cobra.Command{
|
|||
return
|
||||
}
|
||||
|
||||
if len(subnetMasks) < i + 1 {
|
||||
if len(subnetMasks) < i+1 {
|
||||
subnetMasks = append(subnetMasks, net.IP{255, 255, 255, 0})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
magellan "github.com/OpenChami/magellan/internal"
|
||||
"github.com/OpenChami/magellan/internal/log"
|
||||
magellan "github.com/OpenCHAMI/magellan/internal"
|
||||
"github.com/OpenCHAMI/magellan/internal/log"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
|
@ -22,7 +22,7 @@ var updateCmd = &cobra.Command{
|
|||
Short: "Update BMC node firmware",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
l := log.NewLogger(logrus.New(), logrus.DebugLevel)
|
||||
q := &magellan.UpdateParams {
|
||||
q := &magellan.UpdateParams{
|
||||
FirmwarePath: firmwareUrl,
|
||||
FirmwareVersion: firmwareVersion,
|
||||
Component: component,
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -1,4 +1,4 @@
|
|||
module github.com/OpenChami/magellan
|
||||
module github.com/OpenCHAMI/magellan
|
||||
|
||||
go 1.20
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/OpenChami/magellan/internal/util"
|
||||
"github.com/OpenCHAMI/magellan/internal/util"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package smd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/OpenChami/magellan/internal/util"
|
||||
"github.com/OpenCHAMI/magellan/internal/util"
|
||||
// hms "github.com/alexlovelltroy/hms-smd"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/OpenChami/magellan/internal/log"
|
||||
"github.com/OpenCHAMI/magellan/internal/log"
|
||||
|
||||
"github.com/OpenChami/magellan/internal/api/smd"
|
||||
"github.com/OpenChami/magellan/internal/util"
|
||||
"github.com/OpenCHAMI/magellan/internal/api/smd"
|
||||
"github.com/OpenCHAMI/magellan/internal/util"
|
||||
|
||||
"github.com/Cray-HPE/hms-xname/xnames"
|
||||
bmclib "github.com/bmc-toolbox/bmclib/v2"
|
||||
|
|
@ -33,7 +33,6 @@ const (
|
|||
HTTPS_PORT = 443
|
||||
)
|
||||
|
||||
|
||||
// NOTE: ...params were getting too long...
|
||||
type QueryParams struct {
|
||||
Host string
|
||||
|
|
@ -220,7 +219,7 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
|||
}
|
||||
|
||||
// write JSON data to file
|
||||
err = os.WriteFile(path.Clean(outputPath + "/" + q.Host + ".json"), body, os.ModePerm)
|
||||
err = os.WriteFile(path.Clean(outputPath+"/"+q.Host+".json"), body, os.ModePerm)
|
||||
if err != nil {
|
||||
l.Log.Errorf("could not write data to file: %v", err)
|
||||
}
|
||||
|
|
@ -319,7 +318,6 @@ func CollectInventory(client *bmclib.Client, q *QueryParams) ([]byte, error) {
|
|||
return nil, fmt.Errorf("could not get inventory: %v", err)
|
||||
}
|
||||
|
||||
|
||||
// retrieve inventory data
|
||||
data := map[string]any{"Inventory": inventory}
|
||||
b, err := json.MarshalIndent(data, "", " ")
|
||||
|
|
@ -379,7 +377,7 @@ func CollectUsers(client *bmclib.Client, q *QueryParams) ([]byte, error) {
|
|||
}
|
||||
|
||||
// retrieve inventory data
|
||||
data := map[string]any {"Users": users}
|
||||
data := map[string]any{"Users": users}
|
||||
b, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
|
|
@ -407,7 +405,7 @@ func CollectEthernetInterfaces(c *gofish.APIClient, q *QueryParams, systemID str
|
|||
|
||||
var interfaces []*redfish.EthernetInterface
|
||||
for _, system := range systems {
|
||||
i, err := redfish.ListReferencedEthernetInterfaces(c, "/redfish/v1/Systems/" + system.ID + "/EthernetInterfaces/")
|
||||
i, err := redfish.ListReferencedEthernetInterfaces(c, "/redfish/v1/Systems/"+system.ID+"/EthernetInterfaces/")
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
@ -503,7 +501,7 @@ func CollectRegisteries(c *gofish.APIClient, q *QueryParams) ([]byte, error) {
|
|||
return nil, fmt.Errorf("could not query storage systems (%v:%v): %v", q.Host, q.Port, err)
|
||||
}
|
||||
|
||||
data := map[string]any{"Registries": registries }
|
||||
data := map[string]any{"Registries": registries}
|
||||
b, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not marshal JSON: %v", err)
|
||||
|
|
@ -543,7 +541,7 @@ func CollectProcessors(q *QueryParams) ([]byte, error) {
|
|||
}
|
||||
}
|
||||
|
||||
data := map[string]any{"Processors": procs }
|
||||
data := map[string]any{"Processors": procs}
|
||||
b, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not marshal JSON: %v", err)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package sqlite
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
magellan "github.com/OpenChami/magellan/internal"
|
||||
magellan "github.com/OpenCHAMI/magellan/internal"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/OpenChami/magellan/internal/util"
|
||||
"github.com/OpenCHAMI/magellan/internal/util"
|
||||
)
|
||||
|
||||
type ScannedResult struct {
|
||||
|
|
@ -51,7 +51,6 @@ func rawConnect(host string, ports []int, timeout int, keepOpenOnly bool) []Scan
|
|||
return results
|
||||
}
|
||||
|
||||
|
||||
func GenerateHosts(subnet string, subnetMask *net.IP) []string {
|
||||
if subnet == "" || subnetMask == nil {
|
||||
return nil
|
||||
|
|
@ -82,7 +81,7 @@ func generateHosts(ip *net.IP, mask *net.IPMask) []string {
|
|||
// get all IP addresses in network
|
||||
ones, _ := mask.Size()
|
||||
hosts := []string{}
|
||||
end := int(math.Pow(2, float64((32-ones))))-1
|
||||
end := int(math.Pow(2, float64((32-ones)))) - 1
|
||||
for i := 0; i < end; i++ {
|
||||
// ip[3] = byte(i)
|
||||
ip = util.GetNextIP(ip, 1)
|
||||
|
|
|
|||
|
|
@ -10,15 +10,14 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/OpenChami/magellan/internal/log"
|
||||
"github.com/OpenChami/magellan/internal/util"
|
||||
"github.com/OpenCHAMI/magellan/internal/log"
|
||||
"github.com/OpenCHAMI/magellan/internal/util"
|
||||
bmclib "github.com/bmc-toolbox/bmclib/v2"
|
||||
"github.com/bmc-toolbox/bmclib/v2/constants"
|
||||
bmclibErrs "github.com/bmc-toolbox/bmclib/v2/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
||||
type UpdateParams struct {
|
||||
QueryParams
|
||||
FirmwarePath string
|
||||
|
|
@ -127,7 +126,7 @@ func UpdateFirmware(client *bmclib.Client, l *log.Logger, q *UpdateParams) error
|
|||
|
||||
func UpdateFirmwareRemote(q *UpdateParams) error {
|
||||
url := baseRedfishUrl(&q.QueryParams) + "/redfish/v1/UpdateService/Actions/SimpleUpdate"
|
||||
headers := map[string]string {
|
||||
headers := map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
"cache-control": "no-cache",
|
||||
}
|
||||
|
|
@ -184,8 +183,6 @@ func GetUpdateStatus(q *UpdateParams) error {
|
|||
// return fmt.Errorf("could not read file: %v", err)
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// switch q.TransferProtocol {
|
||||
// case "HTTP":
|
||||
// default:
|
||||
|
|
|
|||
2
main.go
2
main.go
|
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenChami/magellan/cmd"
|
||||
"github.com/OpenCHAMI/magellan/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue