use list of resources in profiles/nodes

access the resource not at node or profile level but
in the templates as global variable

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2024-11-26 10:58:23 +01:00
committed by Jonathon Anderson
parent 5ff27061a3
commit 07c77a63d5
9 changed files with 34 additions and 17 deletions

View File

@@ -229,7 +229,7 @@ get the given resource
*/
func (config *NodesYaml) GetResource(id string) (res RemoteRes, err error) {
if found, ok := config.Resource[id]; ok {
return *found, nil
return found, nil
}
return res, ErrNotFound
}

View File

@@ -22,6 +22,8 @@ nodes:
network devices:
net0:
device: eth0
resource_list:
- NFSHOME
test_node2:
primary network: net1
network devices:
@@ -51,7 +53,10 @@ nodes:
network devices:
override:
device: ib1
`
resource:
NFSHOME:
mountpoint: /home
`
var ret NodesYaml
err := yaml.Unmarshal([]byte(data), &ret)
assert.NoError(t, err)
@@ -117,6 +122,12 @@ func Test_Primary_Network(t *testing.T) {
assert.Equal(t, "ib1", test_node6.NetDevs["override"].Device)
assert.Equal(t, "profile", test_node6.NetDevs["override"].Type)
})
t.Run("resource is defined", func(t *testing.T) {
assert.Contains(t, test_node1.ResourceList, "NFSHOME")
res, err := c.GetResource(test_node1.ResourceList[0])
assert.NoError(t, err)
assert.Contains(t, res, "mountpoint")
})
}
var findDiscoverableNodeTests = []struct {

View File

@@ -17,7 +17,7 @@ Structure of which goes to disk
type NodesYaml struct {
NodeProfiles map[string]*Profile
Nodes map[string]*Node
Resource map[string]*RemoteRes `yaml:"resource,omitempty"`
Resource map[string]RemoteRes `yaml:"resource,omitempty"`
}
/*
@@ -54,8 +54,7 @@ type Profile struct {
PrimaryNetDev string `yaml:"primary network,omitempty" lopt:"primarynet" sopt:"p" comment:"Set the primary network interface"`
Disks map[string]*Disk `yaml:"disks,omitempty"`
FileSystems map[string]*FileSystem `yaml:"filesystems,omitempty"`
resource map[string]*RemoteRes `yaml:"omitempty"`
Resources []string `yaml:"resources,omitempty" lopt:"resources" comment:"Set the resources available to the node or profile"`
ResourceList []string `yaml:"resource_list,omitempty" lopt:"resources" comment:"Set the resources available to the node or profile"`
}
type IpmiConf struct {

View File

@@ -103,7 +103,6 @@ func EmptyNode() (nodeconf Node) {
nodeconf.Ipmi.Tags = map[string]string{}
nodeconf.Kernel = new(KernelConf)
nodeconf.NetDevs = make(map[string]*NetDev)
nodeconf.resource = make(map[string]*RemoteRes)
nodeconf.Tags = map[string]string{}
return nodeconf
}