Commit Graph

707 Commits

Author SHA1 Message Date
Christian Goll
242276bba9 fixed tests and added explcit error handling
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-25 22:35:49 -06:00
Christian Goll
e90616cafb calling the overlay build functions direclty
The warewulfd process called `wwctl build -O [system|runtime] node`
if autobuild was set. This created [system|runtime].img which isn't
supported with the build model. Calling now BuildOverlay directly

Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-25 22:35:45 -06:00
Jonathon Anderson
42842aeee1 Format entire source code using make fmt
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2023-10-23 17:56:20 -06:00
Christian Goll
539002088c check if entry has real value in recursive getter
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-14 02:52:53 -06:00
Christian Goll
951dd13866 no error if images for containers don't exist
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-14 02:26:03 -06:00
Christian Goll
a7056e2bb8 mtu can be set via command line
added also a test for this

Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-14 02:09:06 -06:00
Jonathon Anderson
6c344cd5b0 Refactor ww4test to testenv
- Remove global state
- Remove redundant data
- Remove unused functionality (e.g., file permissions)
- Separate directory creation from file writing
- Additional helper functions for file reading and cleanup

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-13 14:35:28 +02:00
Christian Goll
b5979e41d2 added general testing framework
framework creates all the necessary configuration file for warewulf
under a temporary directory. Individual warewulf.conf and nodes.conf
can be provided.

Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-11 12:07:28 +02:00
Jonathon Anderson
f9cdda1ee9 Add tests for FindDiscoverableNode
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2023-10-10 22:40:23 -06:00
Christian Goll
84d2389aaf return the primary network interface for discoverd
close #775

Signed-off-by: Christian Goll <cgoll@suse.com>
2023-10-10 22:40:02 -06:00
Christian Goll
ff7608251a advanced command line completion for wwctl overlay
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-09-13 12:03:43 +02:00
Christian Goll
c3a4eba514 Disable per-netdev primary flag
Primary network devices are now identified by a per-node attribute,
rather than a per-netdev boolean. While the legacy data can still be
parsed, the argument for setting the per-netdev boolean at the
command-line is no longer available.
Correct behavior is tested.

Signed-off-by: Christian Goll <cgoll@suse.com>
2023-09-13 11:31:04 +02:00
Christian Goll
e27aa9cbd4 Merge pull request #903 from anderbubble/896-overlay-names
Fix warewulfd for new contextual overlay names
2023-09-11 10:12:42 +02:00
Christian Goll
c98be14fe6 Merge branch 'development' into fixBuildNoNetwork 2023-09-07 12:21:12 +02:00
Christian Goll
bb0c37763b Revert "add error handling to dynamic network configuration" 2023-09-07 12:09:23 +02:00
Matt Jolly
0364f1c9ca add error handling to dynamic network configuration 2023-09-07 19:54:17 +10:00
Jonathon Anderson
9cf47da963 Fix warewulfd for new contextual overlay names
The recent PR #883 replaced the standard overlay naming convention with
static names for each of the runtime and wwinit/system contexts; but the
method by which it left the "legacy" naming convention in place led to a
bug where warewulfd was still attempting to serve overlays with the
previous naming convention, though this name wasn't being built.

This PR refactors contextual overlay image naming to be, I think, a more
typical golang pattern, and updates affected code to match.

This PR also included tests for all functions modified by this change.

Fixes #896

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2023-09-02 11:18:38 -06:00
Arnaud Lecomte
f2392f6e37 Updating documentation & API endpoint for container copy 2023-08-28 08:39:15 +02:00
Arnaud Lecomte
b56f024e6f Core of image's duplication feature 2023-08-25 13:54:39 +02:00
Jonathon Anderson
9058682b18 Add tests for disk data and ignition json
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2023-08-22 14:28:02 -06:00
Christian Goll
a7df560a30 Add json output for ignition
Signed-off-by: Christian Goll <cgoll@suse.com>
2023-08-21 16:19:13 -06:00
Christian Goll
45539a0d1f Recursive handling for command line flags
Every struct in a NodeConf with `lopt:"foo" set is now added as a
command-line flag with the RecursiveCreateFlags call. For maps a struct
with the key UNDEF is added so that it can be parsed out.

As the flags for the command-line need variables which hold the values,
for every map an element map[UNDEF] is added.  When now calling the
internal add, these map element can be filtered out and replace by the
given name. (e.g., --netname)

* rewrote node/profile add for recursive functions
* rewrote node/profile set for recursive functions
* rewrote node/profile list for recursive functions

Signed-off-by: Christian Goll <cgoll@suse.com>
2023-08-21 16:19:13 -06:00
Christian Goll
c55c5a2ac4 Add recursive setter functions
when transforming a NodeInfo struct to a NodeConf (set the NodeConf from
the NodeInfo) nested structures were seperately handled. This means a
there were seperate handles for e.g *Netdevs and *IpmiConfig. The new
getter traverses through the datastucture and sets the right value for a
Entry struct, but calls itself again if a Pointer is detected.

This adds the posiblity to add new nested structures to NodeConf and
NodeInfo without the need of seperately handling them in the transformer
functions.

Signed-off-by: Christian Goll <cgoll@suse.de>
2023-08-21 16:19:13 -06:00
Christian Goll
fdd233a25f Add recursive getter functions
When transforming a NodeConf struct to a NodeInfo (get the NodeInfo from
the Nodconf) nested structures were seperately handled. This means there
were seperate handles for e.g *Netdevs and *IpmiConfig. The new getter
traverses through the datastucture and sets the right value for an Entry
struct, but calls itself again if a Pointer is detected.

This adds the posiblity to add new nested structures to NodeConf and
NodeInfo without the need of seperate handling them in the transformer
functions.

Signed-off-by: Christian Goll <cgoll@suse.de>
2023-08-21 16:19:13 -06:00
Christian Goll
f2bc70ad00 Add structures for devices and filesystems
Signed-off-by: Christian Goll <cgoll@suse.de>
2023-08-21 16:19:13 -06:00
Christian Goll
4d50f053d7 Minor test fixes
Signed-off-by: Christian Goll <cgoll@suse.de>
2023-08-21 16:19:13 -06:00
Matthew Hink
2094533894 Build fixes for API
- Updated the linter from 1.50 to 1.53.2 because the previous version
  was falling over (likely OOM).

- Updated protoc build command for newer version of protobuf.

The make command below should work now:

```shell
make clean setup proto all build wwapid wwapic wwapird ; echo $?
```

Signed-off-by: MatthewHink <matthew_hink@ciq.com>
2023-08-09 11:42:37 -06:00
Jonathon Anderson
7b2f278f94 Refactor and fix bugs in syncuids
Closes #840

* SyncUids can now return applicable errors even during showOnly, so
  updated ContainerImport to ignore errors during showOnly.
* Fixed handling of file gids during SyncUids

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2023-08-08 11:25:09 -06:00
griznog
13c426de1c Add an argument to the runtime/system overlay related functions to carry the context to getOverlayFile() for building the img name. 2023-07-27 07:27:20 -05:00
Christian Goll
6e5013a359 fix SIGSEV if build host has no network
Signed-off-by: Christian Goll <cgoll@suse.de>
2023-06-13 11:30:15 +02:00
jason yang
40583b4713 fix kernelargs are not printing properly in node list output
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
2023-05-25 01:21:49 +00:00
jason yang
911cb4a3b9 squash commits
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
2023-05-15 10:34:36 +00:00
jason yang
15d4ccb34d add sort support for returned slice
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
2023-05-12 02:47:53 +00:00
Jonathon Anderson
ab52e389f6 Merge pull request #781 from anderbubble/config-refactor
Refactor package that handles warewulf.conf
2023-04-26 13:56:03 -06:00
Christian Goll
8b552fe5ca make onboot default for network devices
Signed-off-by: Christian Goll <cgoll@suse.de>
2023-04-21 08:38:15 +02:00
Jonathon Anderson
5923130676 Add tests for config
Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
4622153a82 Support subdirectories in ipxe paths
Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
e2e3a90623 Revert some caps changes
Use in templates means these were an accidental interface change.

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
8321193645 Refactor and document config/datastructure
Also adjusted case for initialisms (e.g., DHCP, TFTP, NFS).

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
cfdf179e16 Remove SetDynamicDefaults from Parse
Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
387cd0f7be Refactor BaseConf Read and Parse
Also refactor New and Get to return pointers to match BaseConf methods.
This makes calling the methods immediately on the return values of the
constructors easier.

Also move config.ConfigFile to buildconfig.go.in. ConfigFile is still
used by wwctl as a default config file to reference; but it is removed
from other locations now.

Removed Persist, as nothing called it.

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
a10fdb3808 Remove config.DataStore()
Comments in the code were already disparaging of config.DataStore(), but
implied that its presence made other code more readable. It was only
used in two places and, imo, how I've refactored it is more explicit and
clear than it was.

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
af6c91ade3 Rename BaseConf.Initialized to BaseConf.InitializedFromFile
Initialized could be interpreted to mean dynamically initialized as
well. This new name removes that ambiguity.

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
70292276e2 Rename BaseConf.New to BaseConf.Get
Since BaseConf.New could return a cached BaseConf, rather than always
constructing a new struct, I've renamed it to Get to more accurately
reflect its use. A new New() method is called by Get and always
initializes a new struct.

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
f78e6b73b1 Rename ControllerConf to BaseConfig
Also moved BaseConfig to a new source file, co-located with its
constructors and methods, and added doc comments.

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
c461e65a98 Rename pkg/warewulfconf to pkg/config
Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-19 14:02:43 -06:00
Jonathon Anderson
e693ca9cd4 Merge remote-tracking branch 'jason/issue/658' into development
Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-16 18:43:59 -06:00
Jonathon Anderson
cc714008ef Add doc comments for two methods
Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-16 07:24:14 -06:00
Jonathon Anderson
2319906d97 Fix writing of nodes.conf
The caching functionality of nodes.conf, and the optional persistence
functionality that came with it, appears to have been preventing
actually writing the configuration to disk in all cases. This change
fixes the ability to write to nodes.conf.

Somewhat opinionatedly, this change removes the caching functionality of
nodes.conf. The tests have also been updated to use real files for i/o
rather than tying into the caching system, making them more accurately
test the ability of Warewulf to actually read and write its
configuration.

Fixes #779

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
2023-04-14 10:53:31 -06:00
jason yang
0faada6aae refactor the profile add
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
2023-04-12 10:27:44 +00:00