mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
a8092927fc
Change the custom feature source of nfd-worker to use the newly added internal config API for its own configuration. It now uses the internal types for json/yaml unmarshalling but converts them to external nfdv1alpha1 API to do the actual rule matching as the internal API does not duplicate that functionality.
60 lines
1.8 KiB
Go
60 lines
1.8 KiB
Go
/*
|
|
Copyright 2020 The Kubernetes Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package custom
|
|
|
|
import (
|
|
nfdv1alpha1 "sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1"
|
|
)
|
|
|
|
// getStaticRules returns statically configured custom features to discover
|
|
// e.g RMDA related features. NFD configuration file may extend these custom features by adding rules.
|
|
func getStaticRules() []nfdv1alpha1.Rule {
|
|
return []nfdv1alpha1.Rule{
|
|
nfdv1alpha1.Rule{
|
|
Name: "RDMA capable static rule",
|
|
Labels: map[string]string{"rdma.capable": "true"},
|
|
MatchFeatures: nfdv1alpha1.FeatureMatcher{
|
|
nfdv1alpha1.FeatureMatcherTerm{
|
|
Feature: "pci.device",
|
|
MatchExpressions: &nfdv1alpha1.MatchExpressionSet{
|
|
"vendor": &nfdv1alpha1.MatchExpression{
|
|
Op: nfdv1alpha1.MatchIn,
|
|
Value: nfdv1alpha1.MatchValue{"15b3"}},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
nfdv1alpha1.Rule{
|
|
Name: "RDMA available static rule",
|
|
Labels: map[string]string{"rdma.available": "true"},
|
|
MatchFeatures: nfdv1alpha1.FeatureMatcher{
|
|
nfdv1alpha1.FeatureMatcherTerm{
|
|
Feature: "kernel.loadedmodule",
|
|
MatchExpressions: &nfdv1alpha1.MatchExpressionSet{
|
|
"ib_uverbs": &nfdv1alpha1.MatchExpression{
|
|
Op: nfdv1alpha1.MatchExists,
|
|
},
|
|
"rdma_ucm": &nfdv1alpha1.MatchExpression{
|
|
Op: nfdv1alpha1.MatchExists,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
}
|