Resolve issues identifies by staticcheck
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
8
Tools.mk
8
Tools.mk
@@ -20,10 +20,10 @@ PROTOC_GEN_GRPC_GATEWAY := $(TOOLS_BIN)/protoc-gen-grpc-gateway
|
||||
|
||||
ifeq ($(ARCH),aarch64)
|
||||
PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v24.0/protoc-24.0-linux-aarch_64.zip
|
||||
PROTOC_GEN_GRPC_GATEWAY_URL := https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v2.16.2/protoc-gen-grpc-gateway-v2.16.2-linux-arm64
|
||||
PROTOC_GEN_GRPC_GATEWAY_URL := https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v2.26.0/protoc-gen-grpc-gateway-v2.26.0-linux-arm64
|
||||
else
|
||||
PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v24.0/protoc-24.0-linux-x86_64.zip
|
||||
PROTOC_GEN_GRPC_GATEWAY_URL := https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v2.16.2/protoc-gen-grpc-gateway-v2.16.2-linux-x86_64
|
||||
PROTOC_GEN_GRPC_GATEWAY_URL := https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v2.26.0/protoc-gen-grpc-gateway-v2.26.0-linux-x86_64
|
||||
endif
|
||||
|
||||
$(TOOLS_DIR):
|
||||
@@ -50,10 +50,10 @@ $(PROTOC_GEN_GRPC_GATEWAY):
|
||||
chmod +x $(PROTOC_GEN_GRPC_GATEWAY)
|
||||
|
||||
$(PROTOC_GEN_GO):
|
||||
GOBIN="$(PWD)/$(TOOLS_BIN)" go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
|
||||
GOBIN="$(PWD)/$(TOOLS_BIN)" go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.5
|
||||
|
||||
$(PROTOC_GEN_GO_GRPC):
|
||||
GOBIN="$(PWD)/$(TOOLS_BIN)" go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
|
||||
GOBIN="$(PWD)/$(TOOLS_BIN)" go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1
|
||||
|
||||
$(GOLANG_LICENSES):
|
||||
GOBIN="$(PWD)/$(TOOLS_BIN)" go install github.com/google/go-licenses@v1.6.0
|
||||
|
||||
@@ -112,7 +112,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
wwlog.Debug("overlay options: %s", options)
|
||||
err = syscall.Mount("overlay", imagePath, "overlay", 0, options)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't create overlay for node render overlay: %s", err)
|
||||
return fmt.Errorf("couldn't create overlay for node render overlay: %s", err)
|
||||
}
|
||||
ps1Str = fmt.Sprintf("[%s|ro|%s] Warewulf> ", imageName, nodename)
|
||||
}
|
||||
|
||||
@@ -186,46 +186,46 @@ type copyFile struct {
|
||||
modTime time.Time
|
||||
}
|
||||
|
||||
func (this *copyFile) imageDest(imageName string) string {
|
||||
return path.Join(image.RootFsDir(imageName), this.fileName)
|
||||
func (cf *copyFile) imageDest(imageName string) string {
|
||||
return path.Join(image.RootFsDir(imageName), cf.fileName)
|
||||
}
|
||||
|
||||
func (this *copyFile) copyToImage(imageName string) error {
|
||||
imageDest := this.imageDest(imageName)
|
||||
func (cf *copyFile) copyToImage(imageName string) error {
|
||||
imageDest := cf.imageDest(imageName)
|
||||
if _, err := os.Stat(path.Dir(imageDest)); err != nil {
|
||||
return err
|
||||
} else if _, err := os.Stat(imageDest); err == nil {
|
||||
return err
|
||||
} else if _, err := os.Stat(this.src); err != nil {
|
||||
} else if _, err := os.Stat(cf.src); err != nil {
|
||||
return err
|
||||
} else if err := util.CopyFile(this.src, imageDest); err != nil {
|
||||
} else if err := util.CopyFile(cf.src, imageDest); err != nil {
|
||||
return err
|
||||
} else if stat, err := os.Stat(imageDest); err != nil {
|
||||
return err
|
||||
} else {
|
||||
this.modTime = stat.ModTime()
|
||||
cf.modTime = stat.ModTime()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (this *copyFile) shouldRemoveFromImage(imageName string) bool {
|
||||
imageDest := this.imageDest(imageName)
|
||||
if this.modTime.IsZero() {
|
||||
wwlog.Debug("file was not previously copied: %s", this.fileName)
|
||||
func (cf *copyFile) shouldRemoveFromImage(imageName string) bool {
|
||||
imageDest := cf.imageDest(imageName)
|
||||
if cf.modTime.IsZero() {
|
||||
wwlog.Debug("file was not previously copied: %s", cf.fileName)
|
||||
return false
|
||||
} else if destStat, err := os.Stat(imageDest); err != nil {
|
||||
wwlog.Verbose("file is no longer present: %s (%s)", this.fileName, err)
|
||||
wwlog.Verbose("file is no longer present: %s (%s)", cf.fileName, err)
|
||||
return false
|
||||
} else if destStat.ModTime() == this.modTime {
|
||||
wwlog.Verbose("don't remove modified file:", this.fileName)
|
||||
} else if destStat.ModTime() == cf.modTime {
|
||||
wwlog.Verbose("don't remove modified file:", cf.fileName)
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (this *copyFile) removeFromImage(imageName string) error {
|
||||
imageDest := this.imageDest(imageName)
|
||||
func (cf *copyFile) removeFromImage(imageName string) error {
|
||||
imageDest := cf.imageDest(imageName)
|
||||
return os.Remove(imageDest)
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ func ImageCopy(cbp *wwapiv1.ImageCopyParameter) (err error) {
|
||||
}
|
||||
|
||||
if !image.DoesSourceExist(cbp.ImageSource) {
|
||||
return fmt.Errorf("image %s does not exists.", cbp.ImageSource)
|
||||
return fmt.Errorf("image %s does not exist", cbp.ImageSource)
|
||||
}
|
||||
|
||||
if !image.ValidName(cbp.ImageDestination) {
|
||||
@@ -32,7 +32,7 @@ func ImageCopy(cbp *wwapiv1.ImageCopyParameter) (err error) {
|
||||
}
|
||||
|
||||
if image.DoesSourceExist(cbp.ImageDestination) {
|
||||
return fmt.Errorf("An other image with the name %s already exists", cbp.ImageDestination)
|
||||
return fmt.Errorf("an other image with the name %s already exists", cbp.ImageDestination)
|
||||
}
|
||||
|
||||
err = image.Duplicate(cbp.ImageSource, cbp.ImageDestination)
|
||||
@@ -47,12 +47,12 @@ func ImageCopy(cbp *wwapiv1.ImageCopyParameter) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("Image %s has been succesfully duplicated as %s", cbp.ImageSource, cbp.ImageDestination)
|
||||
return fmt.Errorf("image %s has been succesfully duplicated as %s", cbp.ImageSource, cbp.ImageDestination)
|
||||
}
|
||||
|
||||
func ImageBuild(cbp *wwapiv1.ImageBuildParameter) (err error) {
|
||||
if cbp == nil {
|
||||
return fmt.Errorf("ImageBuildParameter is nil")
|
||||
return fmt.Errorf("input parameter is nil")
|
||||
}
|
||||
|
||||
var images []string
|
||||
@@ -69,7 +69,7 @@ func ImageBuild(cbp *wwapiv1.ImageBuildParameter) (err error) {
|
||||
|
||||
for _, c := range images {
|
||||
if !image.ValidSource(c) {
|
||||
return fmt.Errorf("Image name does not exist: %s", c)
|
||||
return fmt.Errorf("image name does not exist: %s", c)
|
||||
}
|
||||
|
||||
err = image.Build(c, cbp.Force)
|
||||
@@ -82,7 +82,7 @@ func ImageBuild(cbp *wwapiv1.ImageBuildParameter) (err error) {
|
||||
|
||||
func ImageDelete(cdp *wwapiv1.ImageDeleteParameter) (err error) {
|
||||
if cdp == nil {
|
||||
return fmt.Errorf("ImageDeleteParameter is nil")
|
||||
return fmt.Errorf("input parameter is nil")
|
||||
}
|
||||
|
||||
nodeDB, err := node.New()
|
||||
@@ -101,22 +101,22 @@ ARG_LOOP:
|
||||
imageName := cdp.ImageNames[i]
|
||||
for _, n := range nodes {
|
||||
if n.ImageName == imageName {
|
||||
wwlog.Error("Image is configured for nodes, skipping: %s", imageName)
|
||||
wwlog.Error("image is configured for nodes, skipping: %s", imageName)
|
||||
continue ARG_LOOP
|
||||
}
|
||||
}
|
||||
|
||||
if !image.ValidSource(imageName) {
|
||||
wwlog.Error("Image name is not a valid source: %s", imageName)
|
||||
wwlog.Error("image name is not a valid source: %s", imageName)
|
||||
continue
|
||||
}
|
||||
err := image.DeleteSource(imageName)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not remove source: %s", imageName)
|
||||
wwlog.Error("could not remove source: %s", imageName)
|
||||
}
|
||||
err = image.DeleteImage(imageName)
|
||||
if err != nil {
|
||||
wwlog.Error("Could not remove image files %s", imageName)
|
||||
wwlog.Error("could not remove image files %s", imageName)
|
||||
}
|
||||
|
||||
fmt.Printf("Image has been deleted: %s\n", imageName)
|
||||
@@ -127,7 +127,7 @@ ARG_LOOP:
|
||||
|
||||
func ImageImport(cip *wwapiv1.ImageImportParameter) (imageName string, err error) {
|
||||
if cip == nil {
|
||||
err = fmt.Errorf("NodeAddParameter is nil")
|
||||
err = fmt.Errorf("input parameter is nil")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ func ImageImport(cip *wwapiv1.ImageImportParameter) (imageName string, err error
|
||||
cip.Name = name
|
||||
}
|
||||
if !image.ValidName(cip.Name) {
|
||||
err = fmt.Errorf("Image name contains illegal characters: %s", cip.Name)
|
||||
err = fmt.Errorf("image name contains illegal characters: %s", cip.Name)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ func ImageImport(cip *wwapiv1.ImageImportParameter) (imageName string, err error
|
||||
|
||||
if util.IsDir(fullPath) {
|
||||
if !cip.Update {
|
||||
err = fmt.Errorf("Image name exists, specify --force, --update, or choose a different name: %s", cip.Name)
|
||||
err = fmt.Errorf("image name exists, specify --force, --update, or choose a different name: %s", cip.Name)
|
||||
return
|
||||
}
|
||||
wwlog.Info("Updating existing image")
|
||||
@@ -252,7 +252,7 @@ func ImageList() (imageInfo []*wwapiv1.ImageInfo, err error) {
|
||||
sourceStat, err := os.Stat(image.SourceDir(source))
|
||||
wwlog.Debug("Checking creation time for: %s,%v", image.SourceDir(source), sourceStat.ModTime())
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
wwlog.Error("%s", err)
|
||||
} else {
|
||||
creationTime = uint64(sourceStat.ModTime().Unix())
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func NodeAdd(nap *wwapiv1.NodeAddParameter) (err error) {
|
||||
}
|
||||
err = yaml.Unmarshal([]byte(nap.NodeConfYaml), &n)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to decode nodeConf: %w", err)
|
||||
return fmt.Errorf("failed to decode nodeConf: %w", err)
|
||||
}
|
||||
wwlog.Info("Added node: %s", a)
|
||||
for _, dev := range n.NetDevs {
|
||||
|
||||
@@ -19,7 +19,7 @@ func ProfileAdd(nsp *wwapiv1.NodeAddParameter) error {
|
||||
}
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not open database: %w", err)
|
||||
return fmt.Errorf("could not open database: %w", err)
|
||||
}
|
||||
for _, p := range nsp.NodeNames {
|
||||
if util.InSlice(nodeDB.ListAllProfiles(), p) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,9 @@
|
||||
// Routes for the wwapi (WareWulf API).
|
||||
// TODO: Try protoc-gen-doc for generating documentation.
|
||||
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v4.24.0
|
||||
// source: routes.proto
|
||||
|
||||
@@ -16,12 +19,30 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
WWApi_ImageBuild_FullMethodName = "/wwapi.v1.WWApi/ImageBuild"
|
||||
WWApi_ImageDelete_FullMethodName = "/wwapi.v1.WWApi/ImageDelete"
|
||||
WWApi_ImageCopy_FullMethodName = "/wwapi.v1.WWApi/ImageCopy"
|
||||
WWApi_ImageImport_FullMethodName = "/wwapi.v1.WWApi/ImageImport"
|
||||
WWApi_ImageList_FullMethodName = "/wwapi.v1.WWApi/ImageList"
|
||||
WWApi_ImageShow_FullMethodName = "/wwapi.v1.WWApi/ImageShow"
|
||||
WWApi_ImageRename_FullMethodName = "/wwapi.v1.WWApi/ImageRename"
|
||||
WWApi_NodeAdd_FullMethodName = "/wwapi.v1.WWApi/NodeAdd"
|
||||
WWApi_NodeDelete_FullMethodName = "/wwapi.v1.WWApi/NodeDelete"
|
||||
WWApi_NodeList_FullMethodName = "/wwapi.v1.WWApi/NodeList"
|
||||
WWApi_NodeSet_FullMethodName = "/wwapi.v1.WWApi/NodeSet"
|
||||
WWApi_NodeStatus_FullMethodName = "/wwapi.v1.WWApi/NodeStatus"
|
||||
WWApi_Version_FullMethodName = "/wwapi.v1.WWApi/Version"
|
||||
)
|
||||
|
||||
// WWApiClient is the client API for WWApi service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// WWApi defines the wwapid service web interface.
|
||||
type WWApiClient interface {
|
||||
// ImageBuild builds zero or more images.
|
||||
ImageBuild(ctx context.Context, in *ImageBuildParameter, opts ...grpc.CallOption) (*ImageListResponse, error)
|
||||
@@ -62,8 +83,9 @@ func NewWWApiClient(cc grpc.ClientConnInterface) WWApiClient {
|
||||
}
|
||||
|
||||
func (c *wWApiClient) ImageBuild(ctx context.Context, in *ImageBuildParameter, opts ...grpc.CallOption) (*ImageListResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ImageListResponse)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageBuild", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_ImageBuild_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -71,8 +93,9 @@ func (c *wWApiClient) ImageBuild(ctx context.Context, in *ImageBuildParameter, o
|
||||
}
|
||||
|
||||
func (c *wWApiClient) ImageDelete(ctx context.Context, in *ImageDeleteParameter, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageDelete", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_ImageDelete_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -80,8 +103,9 @@ func (c *wWApiClient) ImageDelete(ctx context.Context, in *ImageDeleteParameter,
|
||||
}
|
||||
|
||||
func (c *wWApiClient) ImageCopy(ctx context.Context, in *ImageCopyParameter, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageCopy", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_ImageCopy_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -89,8 +113,9 @@ func (c *wWApiClient) ImageCopy(ctx context.Context, in *ImageCopyParameter, opt
|
||||
}
|
||||
|
||||
func (c *wWApiClient) ImageImport(ctx context.Context, in *ImageImportParameter, opts ...grpc.CallOption) (*ImageListResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ImageListResponse)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageImport", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_ImageImport_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -98,8 +123,9 @@ func (c *wWApiClient) ImageImport(ctx context.Context, in *ImageImportParameter,
|
||||
}
|
||||
|
||||
func (c *wWApiClient) ImageList(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ImageListResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ImageListResponse)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageList", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_ImageList_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -107,8 +133,9 @@ func (c *wWApiClient) ImageList(ctx context.Context, in *emptypb.Empty, opts ...
|
||||
}
|
||||
|
||||
func (c *wWApiClient) ImageShow(ctx context.Context, in *ImageShowParameter, opts ...grpc.CallOption) (*ImageShowResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ImageShowResponse)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageShow", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_ImageShow_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -116,8 +143,9 @@ func (c *wWApiClient) ImageShow(ctx context.Context, in *ImageShowParameter, opt
|
||||
}
|
||||
|
||||
func (c *wWApiClient) ImageRename(ctx context.Context, in *ImageRenameParameter, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageRename", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_ImageRename_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -125,8 +153,9 @@ func (c *wWApiClient) ImageRename(ctx context.Context, in *ImageRenameParameter,
|
||||
}
|
||||
|
||||
func (c *wWApiClient) NodeAdd(ctx context.Context, in *NodeAddParameter, opts ...grpc.CallOption) (*NodeListResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(NodeListResponse)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/NodeAdd", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_NodeAdd_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -134,8 +163,9 @@ func (c *wWApiClient) NodeAdd(ctx context.Context, in *NodeAddParameter, opts ..
|
||||
}
|
||||
|
||||
func (c *wWApiClient) NodeDelete(ctx context.Context, in *NodeDeleteParameter, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/NodeDelete", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_NodeDelete_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -143,8 +173,9 @@ func (c *wWApiClient) NodeDelete(ctx context.Context, in *NodeDeleteParameter, o
|
||||
}
|
||||
|
||||
func (c *wWApiClient) NodeList(ctx context.Context, in *NodeNames, opts ...grpc.CallOption) (*NodeListResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(NodeListResponse)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/NodeList", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_NodeList_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -152,8 +183,9 @@ func (c *wWApiClient) NodeList(ctx context.Context, in *NodeNames, opts ...grpc.
|
||||
}
|
||||
|
||||
func (c *wWApiClient) NodeSet(ctx context.Context, in *ConfSetParameter, opts ...grpc.CallOption) (*NodeListResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(NodeListResponse)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/NodeSet", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_NodeSet_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -161,8 +193,9 @@ func (c *wWApiClient) NodeSet(ctx context.Context, in *ConfSetParameter, opts ..
|
||||
}
|
||||
|
||||
func (c *wWApiClient) NodeStatus(ctx context.Context, in *NodeNames, opts ...grpc.CallOption) (*NodeStatusResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(NodeStatusResponse)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/NodeStatus", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_NodeStatus_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -170,8 +203,9 @@ func (c *wWApiClient) NodeStatus(ctx context.Context, in *NodeNames, opts ...grp
|
||||
}
|
||||
|
||||
func (c *wWApiClient) Version(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*VersionResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(VersionResponse)
|
||||
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/Version", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, WWApi_Version_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -180,7 +214,9 @@ func (c *wWApiClient) Version(ctx context.Context, in *emptypb.Empty, opts ...gr
|
||||
|
||||
// WWApiServer is the server API for WWApi service.
|
||||
// All implementations must embed UnimplementedWWApiServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
//
|
||||
// WWApi defines the wwapid service web interface.
|
||||
type WWApiServer interface {
|
||||
// ImageBuild builds zero or more images.
|
||||
ImageBuild(context.Context, *ImageBuildParameter) (*ImageListResponse, error)
|
||||
@@ -213,9 +249,12 @@ type WWApiServer interface {
|
||||
mustEmbedUnimplementedWWApiServer()
|
||||
}
|
||||
|
||||
// UnimplementedWWApiServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedWWApiServer struct {
|
||||
}
|
||||
// UnimplementedWWApiServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedWWApiServer struct{}
|
||||
|
||||
func (UnimplementedWWApiServer) ImageBuild(context.Context, *ImageBuildParameter) (*ImageListResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ImageBuild not implemented")
|
||||
@@ -257,6 +296,7 @@ func (UnimplementedWWApiServer) Version(context.Context, *emptypb.Empty) (*Versi
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Version not implemented")
|
||||
}
|
||||
func (UnimplementedWWApiServer) mustEmbedUnimplementedWWApiServer() {}
|
||||
func (UnimplementedWWApiServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeWWApiServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to WWApiServer will
|
||||
@@ -266,6 +306,13 @@ type UnsafeWWApiServer interface {
|
||||
}
|
||||
|
||||
func RegisterWWApiServer(s grpc.ServiceRegistrar, srv WWApiServer) {
|
||||
// If the following call pancis, it indicates UnimplementedWWApiServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&WWApi_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
@@ -279,7 +326,7 @@ func _WWApi_ImageBuild_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/ImageBuild",
|
||||
FullMethod: WWApi_ImageBuild_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).ImageBuild(ctx, req.(*ImageBuildParameter))
|
||||
@@ -297,7 +344,7 @@ func _WWApi_ImageDelete_Handler(srv interface{}, ctx context.Context, dec func(i
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/ImageDelete",
|
||||
FullMethod: WWApi_ImageDelete_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).ImageDelete(ctx, req.(*ImageDeleteParameter))
|
||||
@@ -315,7 +362,7 @@ func _WWApi_ImageCopy_Handler(srv interface{}, ctx context.Context, dec func(int
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/ImageCopy",
|
||||
FullMethod: WWApi_ImageCopy_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).ImageCopy(ctx, req.(*ImageCopyParameter))
|
||||
@@ -333,7 +380,7 @@ func _WWApi_ImageImport_Handler(srv interface{}, ctx context.Context, dec func(i
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/ImageImport",
|
||||
FullMethod: WWApi_ImageImport_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).ImageImport(ctx, req.(*ImageImportParameter))
|
||||
@@ -351,7 +398,7 @@ func _WWApi_ImageList_Handler(srv interface{}, ctx context.Context, dec func(int
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/ImageList",
|
||||
FullMethod: WWApi_ImageList_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).ImageList(ctx, req.(*emptypb.Empty))
|
||||
@@ -369,7 +416,7 @@ func _WWApi_ImageShow_Handler(srv interface{}, ctx context.Context, dec func(int
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/ImageShow",
|
||||
FullMethod: WWApi_ImageShow_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).ImageShow(ctx, req.(*ImageShowParameter))
|
||||
@@ -387,7 +434,7 @@ func _WWApi_ImageRename_Handler(srv interface{}, ctx context.Context, dec func(i
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/ImageRename",
|
||||
FullMethod: WWApi_ImageRename_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).ImageRename(ctx, req.(*ImageRenameParameter))
|
||||
@@ -405,7 +452,7 @@ func _WWApi_NodeAdd_Handler(srv interface{}, ctx context.Context, dec func(inter
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/NodeAdd",
|
||||
FullMethod: WWApi_NodeAdd_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).NodeAdd(ctx, req.(*NodeAddParameter))
|
||||
@@ -423,7 +470,7 @@ func _WWApi_NodeDelete_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/NodeDelete",
|
||||
FullMethod: WWApi_NodeDelete_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).NodeDelete(ctx, req.(*NodeDeleteParameter))
|
||||
@@ -441,7 +488,7 @@ func _WWApi_NodeList_Handler(srv interface{}, ctx context.Context, dec func(inte
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/NodeList",
|
||||
FullMethod: WWApi_NodeList_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).NodeList(ctx, req.(*NodeNames))
|
||||
@@ -459,7 +506,7 @@ func _WWApi_NodeSet_Handler(srv interface{}, ctx context.Context, dec func(inter
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/NodeSet",
|
||||
FullMethod: WWApi_NodeSet_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).NodeSet(ctx, req.(*ConfSetParameter))
|
||||
@@ -477,7 +524,7 @@ func _WWApi_NodeStatus_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/NodeStatus",
|
||||
FullMethod: WWApi_NodeStatus_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).NodeStatus(ctx, req.(*NodeNames))
|
||||
@@ -495,7 +542,7 @@ func _WWApi_Version_Handler(srv interface{}, ctx context.Context, dec func(inter
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/wwapi.v1.WWApi/Version",
|
||||
FullMethod: WWApi_Version_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(WWApiServer).Version(ctx, req.(*emptypb.Empty))
|
||||
|
||||
@@ -33,8 +33,8 @@ type TFTPConf struct {
|
||||
IpxeBinaries map[string]string `yaml:"ipxe,omitempty" default:"{\"00:09\": \"ipxe-snponly-x86_64.efi\",\"00:00\": \"undionly.kpxe\",\"00:0B\": \"arm64-efi/snponly.efi\",\"00:07\": \"ipxe-snponly-x86_64.efi\"}"`
|
||||
}
|
||||
|
||||
func (this TFTPConf) Enabled() bool {
|
||||
return BoolP(this.EnabledP)
|
||||
func (conf TFTPConf) Enabled() bool {
|
||||
return BoolP(conf.EnabledP)
|
||||
}
|
||||
|
||||
// WarewulfConf adds additional Warewulf-specific configuration to
|
||||
@@ -48,20 +48,20 @@ type WarewulfConf struct {
|
||||
GrubBootP *bool `yaml:"grubboot,omitempty" default:"false"`
|
||||
}
|
||||
|
||||
func (this WarewulfConf) Secure() bool {
|
||||
return BoolP(this.SecureP)
|
||||
func (conf WarewulfConf) Secure() bool {
|
||||
return BoolP(conf.SecureP)
|
||||
}
|
||||
|
||||
func (this WarewulfConf) AutobuildOverlays() bool {
|
||||
return BoolP(this.AutobuildOverlaysP)
|
||||
func (conf WarewulfConf) AutobuildOverlays() bool {
|
||||
return BoolP(conf.AutobuildOverlaysP)
|
||||
}
|
||||
|
||||
func (this WarewulfConf) EnableHostOverlay() bool {
|
||||
return BoolP(this.EnableHostOverlayP)
|
||||
func (conf WarewulfConf) EnableHostOverlay() bool {
|
||||
return BoolP(conf.EnableHostOverlayP)
|
||||
}
|
||||
|
||||
func (this WarewulfConf) GrubBoot() bool {
|
||||
return BoolP(this.GrubBootP)
|
||||
func (conf WarewulfConf) GrubBoot() bool {
|
||||
return BoolP(conf.GrubBootP)
|
||||
}
|
||||
|
||||
func (paths BuildConfig) NodesConf() string {
|
||||
|
||||
@@ -10,6 +10,6 @@ type DHCPConf struct {
|
||||
SystemdName string `yaml:"systemd name,omitempty" default:"dhcpd"`
|
||||
}
|
||||
|
||||
func (this DHCPConf) Enabled() bool {
|
||||
return BoolP(this.EnabledP)
|
||||
func (conf DHCPConf) Enabled() bool {
|
||||
return BoolP(conf.EnabledP)
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ type MountEntry struct {
|
||||
CopyP *bool `yaml:"copy,omitempty"` // temporarily copy the file into the image
|
||||
}
|
||||
|
||||
func (this MountEntry) ReadOnly() bool {
|
||||
return BoolP(this.ReadOnlyP)
|
||||
func (mount MountEntry) ReadOnly() bool {
|
||||
return BoolP(mount.ReadOnlyP)
|
||||
}
|
||||
|
||||
func (this MountEntry) Copy() bool {
|
||||
return BoolP(this.CopyP)
|
||||
func (mount MountEntry) Copy() bool {
|
||||
return BoolP(mount.CopyP)
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ type NFSConf struct {
|
||||
SystemdName string `yaml:"systemd name,omitempty" default:"nfsd"`
|
||||
}
|
||||
|
||||
func (this NFSConf) Enabled() bool {
|
||||
return BoolP(this.EnabledP)
|
||||
func (conf NFSConf) Enabled() bool {
|
||||
return BoolP(conf.EnabledP)
|
||||
}
|
||||
|
||||
// An NFSExportConf reprents a single NFS export / mount.
|
||||
|
||||
@@ -34,7 +34,7 @@ func Build(name string, buildForce bool) error {
|
||||
var err error
|
||||
ignore, err = util.ReadFile(excludes_file)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed creating directory: %s: %w", imagePath, err)
|
||||
return fmt.Errorf("failed creating directory: %s: %w", imagePath, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ type Initramfs struct {
|
||||
imageName string
|
||||
}
|
||||
|
||||
func (this *Initramfs) version() *version.Version {
|
||||
matches := versionPattern.FindAllString(this.Path, -1)
|
||||
func (initrd *Initramfs) version() *version.Version {
|
||||
matches := versionPattern.FindAllString(initrd.Path, -1)
|
||||
for i := len(matches) - 1; i >= 0; i-- {
|
||||
if version_, err := version.NewVersion(strings.TrimSuffix(matches[i], ".")); err == nil {
|
||||
return version_
|
||||
@@ -38,8 +38,8 @@ func (this *Initramfs) version() *version.Version {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *Initramfs) Version() string {
|
||||
version := this.version()
|
||||
func (initrd *Initramfs) Version() string {
|
||||
version := initrd.version()
|
||||
if version == nil {
|
||||
return ""
|
||||
} else {
|
||||
@@ -47,9 +47,9 @@ func (this *Initramfs) Version() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Initramfs) FullPath() string {
|
||||
root := RootFsDir(this.imageName)
|
||||
return filepath.Join(root, this.Path)
|
||||
func (initrd *Initramfs) FullPath() string {
|
||||
root := RootFsDir(initrd.imageName)
|
||||
return filepath.Join(root, initrd.Path)
|
||||
}
|
||||
|
||||
func FindInitramfsFromPattern(imageName string, version string, pattern string) (initramfs *Initramfs) {
|
||||
|
||||
@@ -126,12 +126,12 @@ func FindAllKernels() (kernels collection) {
|
||||
return kernels
|
||||
}
|
||||
|
||||
func (this *Kernel) version() *version.Version {
|
||||
return util.ParseVersion(this.Path)
|
||||
func (kernel *Kernel) version() *version.Version {
|
||||
return util.ParseVersion(kernel.Path)
|
||||
}
|
||||
|
||||
func (this *Kernel) Version() string {
|
||||
version := this.version()
|
||||
func (kernel *Kernel) Version() string {
|
||||
version := kernel.version()
|
||||
if version == nil {
|
||||
return ""
|
||||
} else {
|
||||
@@ -139,15 +139,15 @@ func (this *Kernel) Version() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Kernel) IsDebug() bool {
|
||||
return strings.Contains(this.Path, "+debug")
|
||||
func (kernel *Kernel) IsDebug() bool {
|
||||
return strings.Contains(kernel.Path, "+debug")
|
||||
}
|
||||
|
||||
func (this *Kernel) IsRescue() bool {
|
||||
return strings.Contains(this.Path, "-rescue")
|
||||
func (kernel *Kernel) IsRescue() bool {
|
||||
return strings.Contains(kernel.Path, "-rescue")
|
||||
}
|
||||
|
||||
func (this *Kernel) FullPath() string {
|
||||
root := image.RootFsDir(this.ImageName)
|
||||
return filepath.Join(root, this.Path)
|
||||
func (kernel *Kernel) FullPath() string {
|
||||
root := image.RootFsDir(kernel.ImageName)
|
||||
return filepath.Join(root, kernel.Path)
|
||||
}
|
||||
|
||||
@@ -35,54 +35,54 @@ type WarewulfYaml struct {
|
||||
WWClient *WWClientConf `yaml:"wwclient"`
|
||||
}
|
||||
|
||||
func (this *WarewulfYaml) Upgrade() (upgraded *config.WarewulfYaml) {
|
||||
func (legacy *WarewulfYaml) Upgrade() (upgraded *config.WarewulfYaml) {
|
||||
upgraded = new(config.WarewulfYaml)
|
||||
if this.WWInternal != "" {
|
||||
logIgnore("WW_INTERNAL", this.WWInternal, "obsolete")
|
||||
if legacy.WWInternal != "" {
|
||||
logIgnore("WW_INTERNAL", legacy.WWInternal, "obsolete")
|
||||
}
|
||||
upgraded.Comment = this.Comment
|
||||
upgraded.Ipaddr = this.Ipaddr
|
||||
upgraded.Ipaddr6 = this.Ipaddr6
|
||||
upgraded.Netmask = this.Netmask
|
||||
upgraded.Network = this.Network
|
||||
upgraded.Ipv6net = this.Ipv6net
|
||||
upgraded.Fqdn = this.Fqdn
|
||||
if this.Warewulf != nil {
|
||||
upgraded.Warewulf = this.Warewulf.Upgrade()
|
||||
upgraded.Comment = legacy.Comment
|
||||
upgraded.Ipaddr = legacy.Ipaddr
|
||||
upgraded.Ipaddr6 = legacy.Ipaddr6
|
||||
upgraded.Netmask = legacy.Netmask
|
||||
upgraded.Network = legacy.Network
|
||||
upgraded.Ipv6net = legacy.Ipv6net
|
||||
upgraded.Fqdn = legacy.Fqdn
|
||||
if legacy.Warewulf != nil {
|
||||
upgraded.Warewulf = legacy.Warewulf.Upgrade()
|
||||
}
|
||||
if this.DHCP != nil {
|
||||
upgraded.DHCP = this.DHCP.Upgrade()
|
||||
if legacy.DHCP != nil {
|
||||
upgraded.DHCP = legacy.DHCP.Upgrade()
|
||||
}
|
||||
if this.TFTP != nil {
|
||||
upgraded.TFTP = this.TFTP.Upgrade()
|
||||
if legacy.TFTP != nil {
|
||||
upgraded.TFTP = legacy.TFTP.Upgrade()
|
||||
}
|
||||
if this.NFS != nil {
|
||||
upgraded.NFS = this.NFS.Upgrade()
|
||||
if legacy.NFS != nil {
|
||||
upgraded.NFS = legacy.NFS.Upgrade()
|
||||
}
|
||||
if this.SSH != nil {
|
||||
upgraded.SSH = this.SSH.Upgrade()
|
||||
if legacy.SSH != nil {
|
||||
upgraded.SSH = legacy.SSH.Upgrade()
|
||||
}
|
||||
upgraded.MountsImage = make([]*config.MountEntry, 0)
|
||||
for _, mount := range this.MountsImage {
|
||||
for _, mount := range legacy.MountsImage {
|
||||
upgraded.MountsImage = append(upgraded.MountsImage, mount.Upgrade())
|
||||
}
|
||||
if len(upgraded.MountsImage) == 0 {
|
||||
for _, mount := range this.MountsContainer {
|
||||
for _, mount := range legacy.MountsContainer {
|
||||
upgraded.MountsImage = append(upgraded.MountsImage, mount.Upgrade())
|
||||
}
|
||||
}
|
||||
if this.Paths != nil {
|
||||
upgraded.Paths = this.Paths.Upgrade()
|
||||
if legacy.Paths != nil {
|
||||
upgraded.Paths = legacy.Paths.Upgrade()
|
||||
}
|
||||
if this.WWClient != nil {
|
||||
upgraded.WWClient = this.WWClient.Upgrade()
|
||||
if legacy.WWClient != nil {
|
||||
upgraded.WWClient = legacy.WWClient.Upgrade()
|
||||
}
|
||||
if this.Warewulf != nil && this.Warewulf.DataStore != "" {
|
||||
if legacy.Warewulf != nil && legacy.Warewulf.DataStore != "" {
|
||||
if upgraded.Paths == nil {
|
||||
upgraded.Paths = new(config.BuildConfig)
|
||||
}
|
||||
if upgraded.Paths.Datadir == "" {
|
||||
upgraded.Paths.Datadir = this.Warewulf.DataStore
|
||||
upgraded.Paths.Datadir = legacy.Warewulf.DataStore
|
||||
}
|
||||
}
|
||||
return upgraded
|
||||
@@ -99,17 +99,17 @@ type WarewulfConf struct {
|
||||
GrubBoot *bool `yaml:"grubboot"`
|
||||
}
|
||||
|
||||
func (this *WarewulfConf) Upgrade() (upgraded *config.WarewulfConf) {
|
||||
func (legacy *WarewulfConf) Upgrade() (upgraded *config.WarewulfConf) {
|
||||
upgraded = new(config.WarewulfConf)
|
||||
upgraded.Port = this.Port
|
||||
upgraded.SecureP = this.Secure
|
||||
upgraded.UpdateInterval = this.UpdateInterval
|
||||
upgraded.AutobuildOverlaysP = this.AutobuildOverlays
|
||||
upgraded.EnableHostOverlayP = this.EnableHostOverlay
|
||||
if this.Syslog != nil {
|
||||
upgraded.Port = legacy.Port
|
||||
upgraded.SecureP = legacy.Secure
|
||||
upgraded.UpdateInterval = legacy.UpdateInterval
|
||||
upgraded.AutobuildOverlaysP = legacy.AutobuildOverlays
|
||||
upgraded.EnableHostOverlayP = legacy.EnableHostOverlay
|
||||
if legacy.Syslog != nil {
|
||||
wwlog.Warn("syslog configuration ignored: all logs now go to stdout/stderr")
|
||||
}
|
||||
upgraded.GrubBootP = this.GrubBoot
|
||||
upgraded.GrubBootP = legacy.GrubBoot
|
||||
return upgraded
|
||||
}
|
||||
|
||||
@@ -121,13 +121,13 @@ type DHCPConf struct {
|
||||
SystemdName string `yaml:"systemd name"`
|
||||
}
|
||||
|
||||
func (this *DHCPConf) Upgrade() (upgraded *config.DHCPConf) {
|
||||
func (legacy *DHCPConf) Upgrade() (upgraded *config.DHCPConf) {
|
||||
upgraded = new(config.DHCPConf)
|
||||
upgraded.EnabledP = this.Enabled
|
||||
upgraded.Template = this.Template
|
||||
upgraded.RangeStart = this.RangeStart
|
||||
upgraded.RangeEnd = this.RangeEnd
|
||||
upgraded.SystemdName = this.SystemdName
|
||||
upgraded.EnabledP = legacy.Enabled
|
||||
upgraded.Template = legacy.Template
|
||||
upgraded.RangeStart = legacy.RangeStart
|
||||
upgraded.RangeEnd = legacy.RangeEnd
|
||||
upgraded.SystemdName = legacy.SystemdName
|
||||
return upgraded
|
||||
}
|
||||
|
||||
@@ -138,13 +138,13 @@ type TFTPConf struct {
|
||||
IpxeBinaries map[string]string `yaml:"ipxe"`
|
||||
}
|
||||
|
||||
func (this *TFTPConf) Upgrade() (upgraded *config.TFTPConf) {
|
||||
func (legacy *TFTPConf) Upgrade() (upgraded *config.TFTPConf) {
|
||||
upgraded = new(config.TFTPConf)
|
||||
upgraded.EnabledP = this.Enabled
|
||||
upgraded.TftpRoot = this.TftpRoot
|
||||
upgraded.SystemdName = this.SystemdName
|
||||
upgraded.EnabledP = legacy.Enabled
|
||||
upgraded.TftpRoot = legacy.TftpRoot
|
||||
upgraded.SystemdName = legacy.SystemdName
|
||||
upgraded.IpxeBinaries = make(map[string]string)
|
||||
for name, binary := range this.IpxeBinaries {
|
||||
for name, binary := range legacy.IpxeBinaries {
|
||||
upgraded.IpxeBinaries[name] = binary
|
||||
}
|
||||
return upgraded
|
||||
@@ -157,19 +157,19 @@ type NFSConf struct {
|
||||
SystemdName string `yaml:"systemd name"`
|
||||
}
|
||||
|
||||
func (this *NFSConf) Upgrade() (upgraded *config.NFSConf) {
|
||||
func (legacy *NFSConf) Upgrade() (upgraded *config.NFSConf) {
|
||||
upgraded = new(config.NFSConf)
|
||||
upgraded.EnabledP = this.Enabled
|
||||
upgraded.EnabledP = legacy.Enabled
|
||||
upgraded.ExportsExtended = make([]*config.NFSExportConf, 0)
|
||||
for _, export := range this.Exports {
|
||||
for _, export := range legacy.Exports {
|
||||
extendedExport := new(config.NFSExportConf)
|
||||
extendedExport.Path = export
|
||||
upgraded.ExportsExtended = append(upgraded.ExportsExtended, extendedExport)
|
||||
}
|
||||
for _, export := range this.ExportsExtended {
|
||||
for _, export := range legacy.ExportsExtended {
|
||||
upgraded.ExportsExtended = append(upgraded.ExportsExtended, export.Upgrade())
|
||||
}
|
||||
upgraded.SystemdName = this.SystemdName
|
||||
upgraded.SystemdName = legacy.SystemdName
|
||||
return upgraded
|
||||
}
|
||||
|
||||
@@ -180,12 +180,12 @@ type NFSExportConf struct {
|
||||
Mount *bool `yaml:"mount"`
|
||||
}
|
||||
|
||||
func (this *NFSExportConf) Upgrade() (upgraded *config.NFSExportConf) {
|
||||
func (legacy *NFSExportConf) Upgrade() (upgraded *config.NFSExportConf) {
|
||||
upgraded = new(config.NFSExportConf)
|
||||
upgraded.Path = this.Path
|
||||
upgraded.ExportOptions = this.ExportOptions
|
||||
if this.Mount != nil && *(this.Mount) {
|
||||
wwlog.Warn("Legacy mount configured for NFS export %s: use `wwctl upgrade nodes --with-warewulfconf=<original file>` to port to nodes.conf", this.Path)
|
||||
upgraded.Path = legacy.Path
|
||||
upgraded.ExportOptions = legacy.ExportOptions
|
||||
if legacy.Mount != nil && *(legacy.Mount) {
|
||||
wwlog.Warn("Legacy mount configured for NFS export %s: use `wwctl upgrade nodes --with-warewulfconf=<original file>` to port to nodes.conf", legacy.Path)
|
||||
}
|
||||
return upgraded
|
||||
}
|
||||
@@ -194,9 +194,9 @@ type SSHConf struct {
|
||||
KeyTypes []string `yaml:"key types"`
|
||||
}
|
||||
|
||||
func (this *SSHConf) Upgrade() (upgraded *config.SSHConf) {
|
||||
func (legacy *SSHConf) Upgrade() (upgraded *config.SSHConf) {
|
||||
upgraded = new(config.SSHConf)
|
||||
upgraded.KeyTypes = append([]string{}, this.KeyTypes...)
|
||||
upgraded.KeyTypes = append([]string{}, legacy.KeyTypes...)
|
||||
return upgraded
|
||||
}
|
||||
|
||||
@@ -208,13 +208,13 @@ type MountEntry struct {
|
||||
Copy *bool `yaml:"copy"`
|
||||
}
|
||||
|
||||
func (this *MountEntry) Upgrade() (upgraded *config.MountEntry) {
|
||||
func (legacy *MountEntry) Upgrade() (upgraded *config.MountEntry) {
|
||||
upgraded = new(config.MountEntry)
|
||||
upgraded.Source = this.Source
|
||||
upgraded.Dest = this.Dest
|
||||
upgraded.ReadOnlyP = this.ReadOnly
|
||||
upgraded.Options = this.Options
|
||||
upgraded.CopyP = this.Copy
|
||||
upgraded.Source = legacy.Source
|
||||
upgraded.Dest = legacy.Dest
|
||||
upgraded.ReadOnlyP = legacy.ReadOnly
|
||||
upgraded.Options = legacy.Options
|
||||
upgraded.CopyP = legacy.Copy
|
||||
return upgraded
|
||||
}
|
||||
|
||||
@@ -234,20 +234,20 @@ type BuildConfig struct {
|
||||
WWClientdir string
|
||||
}
|
||||
|
||||
func (this *BuildConfig) Upgrade() (upgraded *config.BuildConfig) {
|
||||
func (legacy *BuildConfig) Upgrade() (upgraded *config.BuildConfig) {
|
||||
upgraded = new(config.BuildConfig)
|
||||
upgraded.Bindir = this.Bindir
|
||||
upgraded.Sysconfdir = this.Sysconfdir
|
||||
upgraded.Localstatedir = this.Localstatedir
|
||||
upgraded.Cachedir = this.Cachedir
|
||||
upgraded.Ipxesource = this.Ipxesource
|
||||
upgraded.Srvdir = this.Srvdir
|
||||
upgraded.Firewallddir = this.Firewallddir
|
||||
upgraded.Datadir = this.Datadir
|
||||
upgraded.WWOverlaydir = this.WWOverlaydir
|
||||
upgraded.WWChrootdir = this.WWChrootdir
|
||||
upgraded.WWProvisiondir = this.WWProvisiondir
|
||||
upgraded.WWClientdir = this.WWClientdir
|
||||
upgraded.Bindir = legacy.Bindir
|
||||
upgraded.Sysconfdir = legacy.Sysconfdir
|
||||
upgraded.Localstatedir = legacy.Localstatedir
|
||||
upgraded.Cachedir = legacy.Cachedir
|
||||
upgraded.Ipxesource = legacy.Ipxesource
|
||||
upgraded.Srvdir = legacy.Srvdir
|
||||
upgraded.Firewallddir = legacy.Firewallddir
|
||||
upgraded.Datadir = legacy.Datadir
|
||||
upgraded.WWOverlaydir = legacy.WWOverlaydir
|
||||
upgraded.WWChrootdir = legacy.WWChrootdir
|
||||
upgraded.WWProvisiondir = legacy.WWProvisiondir
|
||||
upgraded.WWClientdir = legacy.WWClientdir
|
||||
return upgraded
|
||||
}
|
||||
|
||||
@@ -255,8 +255,8 @@ type WWClientConf struct {
|
||||
Port uint16 `yaml:"port"`
|
||||
}
|
||||
|
||||
func (this *WWClientConf) Upgrade() (upgraded *config.WWClientConf) {
|
||||
func (legacy *WWClientConf) Upgrade() (upgraded *config.WWClientConf) {
|
||||
upgraded = new(config.WWClientConf)
|
||||
upgraded.Port = this.Port
|
||||
upgraded.Port = legacy.Port
|
||||
return upgraded
|
||||
}
|
||||
|
||||
@@ -51,17 +51,17 @@ type NodesYaml struct {
|
||||
Nodes map[string]*Node
|
||||
}
|
||||
|
||||
func (this *NodesYaml) Upgrade(addDefaults bool, replaceOverlays bool, warewulfconf *WarewulfYaml) (upgraded *node.NodesYaml) {
|
||||
func (legacy *NodesYaml) Upgrade(addDefaults bool, replaceOverlays bool, warewulfconf *WarewulfYaml) (upgraded *node.NodesYaml) {
|
||||
upgraded = new(node.NodesYaml)
|
||||
upgraded.NodeProfiles = make(map[string]*node.Profile)
|
||||
upgraded.Nodes = make(map[string]*node.Node)
|
||||
if this.WWInternal != "" {
|
||||
logIgnore("WW_INTERNAL", this.WWInternal, "obsolete")
|
||||
if legacy.WWInternal != "" {
|
||||
logIgnore("WW_INTERNAL", legacy.WWInternal, "obsolete")
|
||||
}
|
||||
for name, profile := range this.NodeProfiles {
|
||||
for name, profile := range legacy.NodeProfiles {
|
||||
upgraded.NodeProfiles[name] = profile.Upgrade(addDefaults, replaceOverlays)
|
||||
}
|
||||
for name, node := range this.Nodes {
|
||||
for name, node := range legacy.Nodes {
|
||||
upgraded.Nodes[name] = node.Upgrade(addDefaults, replaceOverlays)
|
||||
if addDefaults && !util.InSlice(upgraded.Nodes[name].Profiles, "default") {
|
||||
wwlog.Warn("node %s does not include the default profile: verify default settings manually", name)
|
||||
@@ -142,7 +142,7 @@ type Node struct {
|
||||
Profile `yaml:"-,inline"`
|
||||
}
|
||||
|
||||
func (this *Node) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *node.Node) {
|
||||
func (legacy *Node) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *node.Node) {
|
||||
upgraded = new(node.Node)
|
||||
upgraded.Tags = make(map[string]string)
|
||||
upgraded.Disks = make(map[string]*node.Disk)
|
||||
@@ -150,80 +150,80 @@ func (this *Node) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *nod
|
||||
upgraded.Ipmi = new(node.IpmiConf)
|
||||
upgraded.Kernel = new(node.KernelConf)
|
||||
upgraded.NetDevs = make(map[string]*node.NetDev)
|
||||
upgraded.AssetKey = this.AssetKey
|
||||
upgraded.ClusterName = this.ClusterName
|
||||
upgraded.Comment = this.Comment
|
||||
upgraded.ImageName = this.ImageName
|
||||
upgraded.AssetKey = legacy.AssetKey
|
||||
upgraded.ClusterName = legacy.ClusterName
|
||||
upgraded.Comment = legacy.Comment
|
||||
upgraded.ImageName = legacy.ImageName
|
||||
if upgraded.ImageName == "" {
|
||||
upgraded.ImageName = this.ContainerName
|
||||
upgraded.ImageName = legacy.ContainerName
|
||||
}
|
||||
if this.Disabled != "" {
|
||||
logIgnore("Disabled", this.Disabled, "obsolete")
|
||||
if legacy.Disabled != "" {
|
||||
logIgnore("Disabled", legacy.Disabled, "obsolete")
|
||||
}
|
||||
if this.Discoverable != "" {
|
||||
warnError(upgraded.Discoverable.Set(this.Discoverable))
|
||||
if legacy.Discoverable != "" {
|
||||
warnError(upgraded.Discoverable.Set(legacy.Discoverable))
|
||||
}
|
||||
if this.Disks != nil {
|
||||
for name, disk := range this.Disks {
|
||||
if legacy.Disks != nil {
|
||||
for name, disk := range legacy.Disks {
|
||||
upgraded.Disks[name] = disk.Upgrade()
|
||||
}
|
||||
}
|
||||
if this.FileSystems != nil {
|
||||
for name, fileSystem := range this.FileSystems {
|
||||
if legacy.FileSystems != nil {
|
||||
for name, fileSystem := range legacy.FileSystems {
|
||||
upgraded.FileSystems[name] = fileSystem.Upgrade()
|
||||
}
|
||||
}
|
||||
upgraded.Init = this.Init
|
||||
if this.Ipmi != nil {
|
||||
upgraded.Ipmi = this.Ipmi.Upgrade()
|
||||
upgraded.Init = legacy.Init
|
||||
if legacy.Ipmi != nil {
|
||||
upgraded.Ipmi = legacy.Ipmi.Upgrade()
|
||||
} else {
|
||||
upgraded.Ipmi = new(node.IpmiConf)
|
||||
}
|
||||
if upgraded.Ipmi.EscapeChar == "" {
|
||||
upgraded.Ipmi.EscapeChar = this.IpmiEscapeChar
|
||||
upgraded.Ipmi.EscapeChar = legacy.IpmiEscapeChar
|
||||
}
|
||||
if upgraded.Ipmi.Gateway.Equal(net.IP{}) {
|
||||
upgraded.Ipmi.Gateway = net.ParseIP(this.IpmiGateway)
|
||||
upgraded.Ipmi.Gateway = net.ParseIP(legacy.IpmiGateway)
|
||||
}
|
||||
if upgraded.Ipmi.Interface == "" {
|
||||
upgraded.Ipmi.Interface = this.IpmiInterface
|
||||
upgraded.Ipmi.Interface = legacy.IpmiInterface
|
||||
}
|
||||
if upgraded.Ipmi.Ipaddr.Equal(net.IP{}) {
|
||||
upgraded.Ipmi.Ipaddr = net.ParseIP(this.IpmiIpaddr)
|
||||
upgraded.Ipmi.Ipaddr = net.ParseIP(legacy.IpmiIpaddr)
|
||||
}
|
||||
if upgraded.Ipmi.Netmask.Equal(net.IP{}) {
|
||||
upgraded.Ipmi.Netmask = net.ParseIP(this.IpmiNetmask)
|
||||
upgraded.Ipmi.Netmask = net.ParseIP(legacy.IpmiNetmask)
|
||||
}
|
||||
if upgraded.Ipmi.Password == "" {
|
||||
upgraded.Ipmi.Password = this.IpmiPassword
|
||||
upgraded.Ipmi.Password = legacy.IpmiPassword
|
||||
}
|
||||
if upgraded.Ipmi.Port == "" {
|
||||
upgraded.Ipmi.Port = this.IpmiPort
|
||||
upgraded.Ipmi.Port = legacy.IpmiPort
|
||||
}
|
||||
if upgraded.Ipmi.UserName == "" {
|
||||
upgraded.Ipmi.UserName = this.IpmiUserName
|
||||
upgraded.Ipmi.UserName = legacy.IpmiUserName
|
||||
}
|
||||
if upgraded.Ipmi.Write == "" && this.IpmiWrite != "" {
|
||||
warnError(upgraded.Ipmi.Write.Set(this.IpmiWrite))
|
||||
if upgraded.Ipmi.Write == "" && legacy.IpmiWrite != "" {
|
||||
warnError(upgraded.Ipmi.Write.Set(legacy.IpmiWrite))
|
||||
}
|
||||
upgraded.Ipxe = this.Ipxe
|
||||
if this.Kernel != nil {
|
||||
upgraded.Kernel = this.Kernel.Upgrade(upgraded.ImageName)
|
||||
upgraded.Ipxe = legacy.Ipxe
|
||||
if legacy.Kernel != nil {
|
||||
upgraded.Kernel = legacy.Kernel.Upgrade(upgraded.ImageName)
|
||||
} else {
|
||||
inlineKernel := &KernelConf{
|
||||
Args: this.KernelArgs,
|
||||
Version: this.KernelVersion,
|
||||
Override: this.KernelOverride,
|
||||
Args: legacy.KernelArgs,
|
||||
Version: legacy.KernelVersion,
|
||||
Override: legacy.KernelOverride,
|
||||
}
|
||||
upgraded.Kernel = inlineKernel.Upgrade(upgraded.ImageName)
|
||||
}
|
||||
if this.Keys != nil {
|
||||
for key, value := range this.Keys {
|
||||
if legacy.Keys != nil {
|
||||
for key, value := range legacy.Keys {
|
||||
upgraded.Tags[key] = value
|
||||
}
|
||||
}
|
||||
if this.NetDevs != nil {
|
||||
for name, netDev := range this.NetDevs {
|
||||
if legacy.NetDevs != nil {
|
||||
for name, netDev := range legacy.NetDevs {
|
||||
upgraded.NetDevs[name] = netDev.Upgrade(false)
|
||||
if addDefaults {
|
||||
if upgraded.NetDevs[name].Type == "" {
|
||||
@@ -235,10 +235,10 @@ func (this *Node) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *nod
|
||||
}
|
||||
}
|
||||
}
|
||||
if this.PrimaryNetDev != "" {
|
||||
upgraded.PrimaryNetDev = this.PrimaryNetDev
|
||||
if legacy.PrimaryNetDev != "" {
|
||||
upgraded.PrimaryNetDev = legacy.PrimaryNetDev
|
||||
} else {
|
||||
for name, netDev := range this.NetDevs {
|
||||
for name, netDev := range legacy.NetDevs {
|
||||
if b, _ := strconv.ParseBool(netDev.Primary); b {
|
||||
upgraded.PrimaryNetDev = name
|
||||
break
|
||||
@@ -248,15 +248,15 @@ func (this *Node) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *nod
|
||||
}
|
||||
}
|
||||
}
|
||||
upgraded.Profiles = append(upgraded.Profiles, this.Profiles...)
|
||||
upgraded.Profiles = append(upgraded.Profiles, legacy.Profiles...)
|
||||
if addDefaults {
|
||||
if len(upgraded.Profiles) == 0 {
|
||||
upgraded.Profiles = append(upgraded.Profiles, "default")
|
||||
}
|
||||
}
|
||||
upgraded.Root = this.Root
|
||||
if this.RuntimeOverlay != nil {
|
||||
switch overlay := this.RuntimeOverlay.(type) {
|
||||
upgraded.Root = legacy.Root
|
||||
if legacy.RuntimeOverlay != nil {
|
||||
switch overlay := legacy.RuntimeOverlay.(type) {
|
||||
case string:
|
||||
upgraded.RuntimeOverlay = append(upgraded.RuntimeOverlay, strings.Split(overlay, ",")...)
|
||||
case []interface{}:
|
||||
@@ -267,8 +267,8 @@ func (this *Node) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *nod
|
||||
wwlog.Error("unparsable RuntimeOverlay: %v", overlay)
|
||||
}
|
||||
}
|
||||
if this.SystemOverlay != nil {
|
||||
switch overlay := this.SystemOverlay.(type) {
|
||||
if legacy.SystemOverlay != nil {
|
||||
switch overlay := legacy.SystemOverlay.(type) {
|
||||
case string:
|
||||
upgraded.SystemOverlay = append(upgraded.SystemOverlay, strings.Split(overlay, ",")...)
|
||||
case []interface{}:
|
||||
@@ -293,12 +293,12 @@ func (this *Node) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *nod
|
||||
genericSplitOverlays)
|
||||
}
|
||||
}
|
||||
if this.Tags != nil {
|
||||
for key, value := range this.Tags {
|
||||
if legacy.Tags != nil {
|
||||
for key, value := range legacy.Tags {
|
||||
upgraded.Tags[key] = value
|
||||
}
|
||||
}
|
||||
for _, tag := range this.TagsDel {
|
||||
for _, tag := range legacy.TagsDel {
|
||||
delete(upgraded.Tags, tag)
|
||||
}
|
||||
return
|
||||
@@ -341,97 +341,97 @@ type Profile struct {
|
||||
TagsDel []string `yaml:"tagsdel,omitempty"`
|
||||
}
|
||||
|
||||
func (this *Profile) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *node.Profile) {
|
||||
func (legacy *Profile) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *node.Profile) {
|
||||
upgraded = new(node.Profile)
|
||||
upgraded.Tags = make(map[string]string)
|
||||
upgraded.Disks = make(map[string]*node.Disk)
|
||||
upgraded.FileSystems = make(map[string]*node.FileSystem)
|
||||
upgraded.Kernel = new(node.KernelConf)
|
||||
upgraded.NetDevs = make(map[string]*node.NetDev)
|
||||
if this.AssetKey != "" {
|
||||
logIgnore("AssetKey", this.AssetKey, "invalid for profiles")
|
||||
if legacy.AssetKey != "" {
|
||||
logIgnore("AssetKey", legacy.AssetKey, "invalid for profiles")
|
||||
}
|
||||
upgraded.ClusterName = this.ClusterName
|
||||
upgraded.Comment = this.Comment
|
||||
upgraded.ImageName = this.ImageName
|
||||
upgraded.ClusterName = legacy.ClusterName
|
||||
upgraded.Comment = legacy.Comment
|
||||
upgraded.ImageName = legacy.ImageName
|
||||
if upgraded.ImageName == "" {
|
||||
upgraded.ImageName = this.ContainerName
|
||||
upgraded.ImageName = legacy.ContainerName
|
||||
}
|
||||
if this.Disabled != "" {
|
||||
logIgnore("Disabled", this.Disabled, "obsolete")
|
||||
if legacy.Disabled != "" {
|
||||
logIgnore("Disabled", legacy.Disabled, "obsolete")
|
||||
}
|
||||
if this.Discoverable != "" {
|
||||
logIgnore("Discoverable", this.Discoverable, "invalid for profiles")
|
||||
if legacy.Discoverable != "" {
|
||||
logIgnore("Discoverable", legacy.Discoverable, "invalid for profiles")
|
||||
}
|
||||
if this.Disks != nil {
|
||||
for name, disk := range this.Disks {
|
||||
if legacy.Disks != nil {
|
||||
for name, disk := range legacy.Disks {
|
||||
upgraded.Disks[name] = disk.Upgrade()
|
||||
}
|
||||
}
|
||||
if this.FileSystems != nil {
|
||||
for name, fileSystem := range this.FileSystems {
|
||||
if legacy.FileSystems != nil {
|
||||
for name, fileSystem := range legacy.FileSystems {
|
||||
upgraded.FileSystems[name] = fileSystem.Upgrade()
|
||||
}
|
||||
}
|
||||
upgraded.Init = this.Init
|
||||
upgraded.Init = legacy.Init
|
||||
upgraded.Ipmi = new(node.IpmiConf)
|
||||
if this.Ipmi != nil {
|
||||
upgraded.Ipmi = this.Ipmi.Upgrade()
|
||||
if legacy.Ipmi != nil {
|
||||
upgraded.Ipmi = legacy.Ipmi.Upgrade()
|
||||
} else {
|
||||
upgraded.Ipmi = new(node.IpmiConf)
|
||||
}
|
||||
if upgraded.Ipmi.EscapeChar == "" {
|
||||
upgraded.Ipmi.EscapeChar = this.IpmiEscapeChar
|
||||
upgraded.Ipmi.EscapeChar = legacy.IpmiEscapeChar
|
||||
}
|
||||
if upgraded.Ipmi.Gateway.Equal(net.IP{}) {
|
||||
upgraded.Ipmi.Gateway = net.ParseIP(this.IpmiGateway)
|
||||
upgraded.Ipmi.Gateway = net.ParseIP(legacy.IpmiGateway)
|
||||
}
|
||||
if upgraded.Ipmi.Interface == "" {
|
||||
upgraded.Ipmi.Interface = this.IpmiInterface
|
||||
upgraded.Ipmi.Interface = legacy.IpmiInterface
|
||||
}
|
||||
if upgraded.Ipmi.Ipaddr.Equal(net.IP{}) {
|
||||
upgraded.Ipmi.Ipaddr = net.ParseIP(this.IpmiIpaddr)
|
||||
upgraded.Ipmi.Ipaddr = net.ParseIP(legacy.IpmiIpaddr)
|
||||
}
|
||||
if upgraded.Ipmi.Netmask.Equal(net.IP{}) {
|
||||
upgraded.Ipmi.Netmask = net.ParseIP(this.IpmiNetmask)
|
||||
upgraded.Ipmi.Netmask = net.ParseIP(legacy.IpmiNetmask)
|
||||
}
|
||||
if upgraded.Ipmi.Password == "" {
|
||||
upgraded.Ipmi.Password = this.IpmiPassword
|
||||
upgraded.Ipmi.Password = legacy.IpmiPassword
|
||||
}
|
||||
if upgraded.Ipmi.Port == "" {
|
||||
upgraded.Ipmi.Port = this.IpmiPort
|
||||
upgraded.Ipmi.Port = legacy.IpmiPort
|
||||
}
|
||||
if upgraded.Ipmi.UserName == "" {
|
||||
upgraded.Ipmi.UserName = this.IpmiUserName
|
||||
upgraded.Ipmi.UserName = legacy.IpmiUserName
|
||||
}
|
||||
if upgraded.Ipmi.Write == "" && this.IpmiWrite != "" {
|
||||
warnError(upgraded.Ipmi.Write.Set(this.IpmiWrite))
|
||||
if upgraded.Ipmi.Write == "" && legacy.IpmiWrite != "" {
|
||||
warnError(upgraded.Ipmi.Write.Set(legacy.IpmiWrite))
|
||||
}
|
||||
upgraded.Ipxe = this.Ipxe
|
||||
if this.Kernel != nil {
|
||||
upgraded.Kernel = this.Kernel.Upgrade(upgraded.ImageName)
|
||||
upgraded.Ipxe = legacy.Ipxe
|
||||
if legacy.Kernel != nil {
|
||||
upgraded.Kernel = legacy.Kernel.Upgrade(upgraded.ImageName)
|
||||
} else {
|
||||
inlineKernel := &KernelConf{
|
||||
Args: this.KernelArgs,
|
||||
Version: this.KernelVersion,
|
||||
Override: this.KernelOverride,
|
||||
Args: legacy.KernelArgs,
|
||||
Version: legacy.KernelVersion,
|
||||
Override: legacy.KernelOverride,
|
||||
}
|
||||
upgraded.Kernel = inlineKernel.Upgrade(upgraded.ImageName)
|
||||
}
|
||||
if this.Keys != nil {
|
||||
for key, value := range this.Keys {
|
||||
if legacy.Keys != nil {
|
||||
for key, value := range legacy.Keys {
|
||||
upgraded.Tags[key] = value
|
||||
}
|
||||
}
|
||||
if this.NetDevs != nil {
|
||||
for name, netDev := range this.NetDevs {
|
||||
if legacy.NetDevs != nil {
|
||||
for name, netDev := range legacy.NetDevs {
|
||||
upgraded.NetDevs[name] = netDev.Upgrade(addDefaults)
|
||||
}
|
||||
}
|
||||
if this.PrimaryNetDev != "" {
|
||||
upgraded.PrimaryNetDev = this.PrimaryNetDev
|
||||
if legacy.PrimaryNetDev != "" {
|
||||
upgraded.PrimaryNetDev = legacy.PrimaryNetDev
|
||||
} else {
|
||||
for name, netDev := range this.NetDevs {
|
||||
for name, netDev := range legacy.NetDevs {
|
||||
if b, _ := strconv.ParseBool(netDev.Primary); b {
|
||||
upgraded.PrimaryNetDev = name
|
||||
break
|
||||
@@ -442,11 +442,11 @@ func (this *Profile) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *
|
||||
}
|
||||
}
|
||||
if upgraded.Profiles == nil {
|
||||
upgraded.Profiles = append(upgraded.Profiles, this.Profiles...)
|
||||
upgraded.Profiles = append(upgraded.Profiles, legacy.Profiles...)
|
||||
}
|
||||
upgraded.Root = this.Root
|
||||
if this.RuntimeOverlay != nil {
|
||||
switch overlay := this.RuntimeOverlay.(type) {
|
||||
upgraded.Root = legacy.Root
|
||||
if legacy.RuntimeOverlay != nil {
|
||||
switch overlay := legacy.RuntimeOverlay.(type) {
|
||||
case string:
|
||||
upgraded.RuntimeOverlay = append(upgraded.RuntimeOverlay, strings.Split(overlay, ",")...)
|
||||
case []interface{}:
|
||||
@@ -457,8 +457,8 @@ func (this *Profile) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *
|
||||
wwlog.Error("unparsable RuntimeOverlay: %v", overlay)
|
||||
}
|
||||
}
|
||||
if this.SystemOverlay != nil {
|
||||
switch overlay := this.SystemOverlay.(type) {
|
||||
if legacy.SystemOverlay != nil {
|
||||
switch overlay := legacy.SystemOverlay.(type) {
|
||||
case string:
|
||||
upgraded.SystemOverlay = append(upgraded.SystemOverlay, strings.Split(overlay, ",")...)
|
||||
case []interface{}:
|
||||
@@ -483,12 +483,12 @@ func (this *Profile) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *
|
||||
genericSplitOverlays)
|
||||
}
|
||||
}
|
||||
if this.Tags != nil {
|
||||
for key, value := range this.Tags {
|
||||
if legacy.Tags != nil {
|
||||
for key, value := range legacy.Tags {
|
||||
upgraded.Tags[key] = value
|
||||
}
|
||||
}
|
||||
for _, tag := range this.TagsDel {
|
||||
for _, tag := range legacy.TagsDel {
|
||||
delete(upgraded.Tags, tag)
|
||||
}
|
||||
return
|
||||
@@ -508,27 +508,27 @@ type IpmiConf struct {
|
||||
Write string `yaml:"write,omitempty"`
|
||||
}
|
||||
|
||||
func (this *IpmiConf) Upgrade() (upgraded *node.IpmiConf) {
|
||||
func (legacy *IpmiConf) Upgrade() (upgraded *node.IpmiConf) {
|
||||
upgraded = new(node.IpmiConf)
|
||||
upgraded.Tags = make(map[string]string)
|
||||
upgraded.EscapeChar = this.EscapeChar
|
||||
upgraded.Gateway = net.ParseIP(this.Gateway)
|
||||
upgraded.Interface = this.Interface
|
||||
upgraded.Ipaddr = net.ParseIP(this.Ipaddr)
|
||||
upgraded.Netmask = net.ParseIP(this.Netmask)
|
||||
upgraded.Password = this.Password
|
||||
upgraded.Port = this.Port
|
||||
if this.Tags != nil {
|
||||
for key, value := range this.Tags {
|
||||
upgraded.EscapeChar = legacy.EscapeChar
|
||||
upgraded.Gateway = net.ParseIP(legacy.Gateway)
|
||||
upgraded.Interface = legacy.Interface
|
||||
upgraded.Ipaddr = net.ParseIP(legacy.Ipaddr)
|
||||
upgraded.Netmask = net.ParseIP(legacy.Netmask)
|
||||
upgraded.Password = legacy.Password
|
||||
upgraded.Port = legacy.Port
|
||||
if legacy.Tags != nil {
|
||||
for key, value := range legacy.Tags {
|
||||
upgraded.Tags[key] = value
|
||||
}
|
||||
}
|
||||
for _, tag := range this.TagsDel {
|
||||
for _, tag := range legacy.TagsDel {
|
||||
delete(upgraded.Tags, tag)
|
||||
}
|
||||
upgraded.UserName = this.UserName
|
||||
if this.Write != "" {
|
||||
warnError(upgraded.Write.Set(this.Write))
|
||||
upgraded.UserName = legacy.UserName
|
||||
if legacy.Write != "" {
|
||||
warnError(upgraded.Write.Set(legacy.Write))
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -539,9 +539,9 @@ type KernelConf struct {
|
||||
Version string `yaml:"version,omitempty"`
|
||||
}
|
||||
|
||||
func (this *KernelConf) Upgrade(imageName string) (upgraded *node.KernelConf) {
|
||||
func (legacy *KernelConf) Upgrade(imageName string) (upgraded *node.KernelConf) {
|
||||
upgraded = new(node.KernelConf)
|
||||
switch args := this.Args.(type) {
|
||||
switch args := legacy.Args.(type) {
|
||||
case []string:
|
||||
upgraded.Args = args
|
||||
case string:
|
||||
@@ -549,32 +549,32 @@ func (this *KernelConf) Upgrade(imageName string) (upgraded *node.KernelConf) {
|
||||
upgraded.Args = strings.Fields(args)
|
||||
}
|
||||
default:
|
||||
wwlog.Warn("unable to parse Kernel.Args: %v", this.Args)
|
||||
wwlog.Warn("unable to parse Kernel.Args: %v", legacy.Args)
|
||||
}
|
||||
kernels := kernel.FindKernels(imageName)
|
||||
wwlog.Debug("referencing kernels: %v (imageName: %v)", kernels, imageName)
|
||||
if this.Override != "" {
|
||||
if version := util.ParseVersion(legacyKernelVersion(this.Override)); version != nil {
|
||||
if legacy.Override != "" {
|
||||
if version := util.ParseVersion(legacyKernelVersion(legacy.Override)); version != nil {
|
||||
for _, kernel_ := range kernels {
|
||||
wwlog.Debug("checking if kernel '%v' version '%v' from image '%v' matches override '%v'", kernel_, kernel_.Version(), imageName, this.Override)
|
||||
wwlog.Debug("checking if kernel '%v' version '%v' from image '%v' matches override '%v'", kernel_, kernel_.Version(), imageName, legacy.Override)
|
||||
if kernel_.Version() == version.String() {
|
||||
upgraded.Version = kernel_.Path
|
||||
wwlog.Info("kernel override %v -> version %v (image %v)", this.Override, upgraded.Version, imageName)
|
||||
wwlog.Info("kernel override %v -> version %v (image %v)", legacy.Override, upgraded.Version, imageName)
|
||||
}
|
||||
}
|
||||
} else if util.IsFile((&kernel.Kernel{ImageName: imageName, Path: this.Override}).FullPath()) {
|
||||
upgraded.Version = this.Override
|
||||
} else if util.IsFile((&kernel.Kernel{ImageName: imageName, Path: legacy.Override}).FullPath()) {
|
||||
upgraded.Version = legacy.Override
|
||||
}
|
||||
if upgraded.Version == "" {
|
||||
imageDisplay := "unknown"
|
||||
if imageName != "" {
|
||||
imageDisplay = imageName
|
||||
}
|
||||
wwlog.Warn("unable to resolve kernel override %v (image %v)", this.Override, imageDisplay)
|
||||
wwlog.Warn("unable to resolve kernel override %v (image %v)", legacy.Override, imageDisplay)
|
||||
}
|
||||
}
|
||||
if upgraded.Version == "" {
|
||||
upgraded.Version = this.Version
|
||||
upgraded.Version = legacy.Version
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -597,20 +597,20 @@ type NetDev struct {
|
||||
Type string `yaml:"type,omitempty"`
|
||||
}
|
||||
|
||||
func (this *NetDev) Upgrade(addDefaults bool) (upgraded *node.NetDev) {
|
||||
func (legacy *NetDev) Upgrade(addDefaults bool) (upgraded *node.NetDev) {
|
||||
upgraded = new(node.NetDev)
|
||||
upgraded.Tags = make(map[string]string)
|
||||
upgraded.Device = this.Device
|
||||
upgraded.Gateway = net.ParseIP(this.Gateway)
|
||||
upgraded.Hwaddr = this.Hwaddr
|
||||
upgraded.Ipaddr = net.ParseIP(this.Ipaddr)
|
||||
upgraded.Ipaddr6 = net.ParseIP(this.Ipaddr6)
|
||||
upgraded.MTU = this.MTU
|
||||
upgraded.Netmask = net.ParseIP(this.Netmask)
|
||||
if this.IpCIDR != "" {
|
||||
cidrIP, cidrIPNet, err := net.ParseCIDR(this.IpCIDR)
|
||||
upgraded.Device = legacy.Device
|
||||
upgraded.Gateway = net.ParseIP(legacy.Gateway)
|
||||
upgraded.Hwaddr = legacy.Hwaddr
|
||||
upgraded.Ipaddr = net.ParseIP(legacy.Ipaddr)
|
||||
upgraded.Ipaddr6 = net.ParseIP(legacy.Ipaddr6)
|
||||
upgraded.MTU = legacy.MTU
|
||||
upgraded.Netmask = net.ParseIP(legacy.Netmask)
|
||||
if legacy.IpCIDR != "" {
|
||||
cidrIP, cidrIPNet, err := net.ParseCIDR(legacy.IpCIDR)
|
||||
if err != nil {
|
||||
wwlog.Error("%v is not a valid CIDR address: %s", this.IpCIDR, err)
|
||||
wwlog.Error("%v is not a valid CIDR address: %s", legacy.IpCIDR, err)
|
||||
} else {
|
||||
if upgraded.Ipaddr == nil {
|
||||
upgraded.Ipaddr = cidrIP
|
||||
@@ -620,19 +620,19 @@ func (this *NetDev) Upgrade(addDefaults bool) (upgraded *node.NetDev) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if this.OnBoot != "" {
|
||||
warnError(upgraded.OnBoot.Set(this.OnBoot))
|
||||
if legacy.OnBoot != "" {
|
||||
warnError(upgraded.OnBoot.Set(legacy.OnBoot))
|
||||
}
|
||||
upgraded.Prefix = net.ParseIP(this.Prefix)
|
||||
if this.Tags != nil {
|
||||
for key, value := range this.Tags {
|
||||
upgraded.Prefix = net.ParseIP(legacy.Prefix)
|
||||
if legacy.Tags != nil {
|
||||
for key, value := range legacy.Tags {
|
||||
upgraded.Tags[key] = value
|
||||
}
|
||||
}
|
||||
for _, tag := range this.TagsDel {
|
||||
for _, tag := range legacy.TagsDel {
|
||||
delete(upgraded.Tags, tag)
|
||||
}
|
||||
upgraded.Type = this.Type
|
||||
upgraded.Type = legacy.Type
|
||||
if addDefaults {
|
||||
if upgraded.Type == "" {
|
||||
upgraded.Type = "ethernet"
|
||||
@@ -649,15 +649,15 @@ type Disk struct {
|
||||
WipeTable string `yaml:"wipe_table,omitempty"`
|
||||
}
|
||||
|
||||
func (this *Disk) Upgrade() (upgraded *node.Disk) {
|
||||
func (legacy *Disk) Upgrade() (upgraded *node.Disk) {
|
||||
upgraded = new(node.Disk)
|
||||
upgraded.Partitions = make(map[string]*node.Partition)
|
||||
if this.Partitions != nil {
|
||||
for name, partition := range this.Partitions {
|
||||
if legacy.Partitions != nil {
|
||||
for name, partition := range legacy.Partitions {
|
||||
upgraded.Partitions[name] = partition.Upgrade()
|
||||
}
|
||||
}
|
||||
upgraded.WipeTable, _ = strconv.ParseBool(this.WipeTable)
|
||||
upgraded.WipeTable, _ = strconv.ParseBool(legacy.WipeTable)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -672,16 +672,16 @@ type Partition struct {
|
||||
WipePartitionEntry string `yaml:"wipe_partition_entry,omitempty"`
|
||||
}
|
||||
|
||||
func (this *Partition) Upgrade() (upgraded *node.Partition) {
|
||||
func (legacy *Partition) Upgrade() (upgraded *node.Partition) {
|
||||
upgraded = new(node.Partition)
|
||||
upgraded.Guid = this.Guid
|
||||
upgraded.Number = this.Number
|
||||
upgraded.Resize, _ = strconv.ParseBool(this.Resize)
|
||||
upgraded.ShouldExist, _ = strconv.ParseBool(this.ShouldExist)
|
||||
upgraded.SizeMiB = this.SizeMiB
|
||||
upgraded.StartMiB = this.StartMiB
|
||||
upgraded.TypeGuid = this.TypeGuid
|
||||
upgraded.WipePartitionEntry, _ = strconv.ParseBool(this.WipePartitionEntry)
|
||||
upgraded.Guid = legacy.Guid
|
||||
upgraded.Number = legacy.Number
|
||||
upgraded.Resize, _ = strconv.ParseBool(legacy.Resize)
|
||||
upgraded.ShouldExist, _ = strconv.ParseBool(legacy.ShouldExist)
|
||||
upgraded.SizeMiB = legacy.SizeMiB
|
||||
upgraded.StartMiB = legacy.StartMiB
|
||||
upgraded.TypeGuid = legacy.TypeGuid
|
||||
upgraded.WipePartitionEntry, _ = strconv.ParseBool(legacy.WipePartitionEntry)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -695,13 +695,13 @@ type FileSystem struct {
|
||||
WipeFileSystem string `yaml:"wipe_filesystem,omitempty"`
|
||||
}
|
||||
|
||||
func (this *FileSystem) Upgrade() (upgraded *node.FileSystem) {
|
||||
func (legacy *FileSystem) Upgrade() (upgraded *node.FileSystem) {
|
||||
upgraded = new(node.FileSystem)
|
||||
upgraded.Options = make([]string, 0)
|
||||
upgraded.Format = this.Format
|
||||
upgraded.Label = this.Label
|
||||
if this.MountOptions != nil {
|
||||
switch mountOptions := this.MountOptions.(type) {
|
||||
upgraded.Format = legacy.Format
|
||||
upgraded.Label = legacy.Label
|
||||
if legacy.MountOptions != nil {
|
||||
switch mountOptions := legacy.MountOptions.(type) {
|
||||
case string:
|
||||
upgraded.MountOptions = mountOptions
|
||||
case []interface{}:
|
||||
@@ -714,9 +714,9 @@ func (this *FileSystem) Upgrade() (upgraded *node.FileSystem) {
|
||||
wwlog.Error("unparsable MountOptions: %v", mountOptions)
|
||||
}
|
||||
}
|
||||
upgraded.Options = append(upgraded.Options, this.Options...)
|
||||
upgraded.Path = this.Path
|
||||
upgraded.Uuid = this.Uuid
|
||||
upgraded.WipeFileSystem, _ = strconv.ParseBool(this.WipeFileSystem)
|
||||
upgraded.Options = append(upgraded.Options, legacy.Options...)
|
||||
upgraded.Path = legacy.Path
|
||||
upgraded.Uuid = legacy.Uuid
|
||||
upgraded.WipeFileSystem, _ = strconv.ParseBool(legacy.WipeFileSystem)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user