forked from coreos/ignition
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds initial support for the Microsoft HyperV platform. It uses HyperV and MS WMI to read key/value pairs as provided by the Windows host. Because the size allocation of the value is quite small, the ignition values will likely be split into at least 2 and more like more parts which must be read and reassembled in ignition. Supports: * coreos/fedora-coreos-tracker#1411 * coreos/fedora-coreos-tracker#1424 Signed-off-by: Brent Baude <[email protected]>
- Loading branch information
Showing
10 changed files
with
570 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ nav_order: 9 | |
|
||
|
||
### Features | ||
|
||
- Support HyperV platform | ||
|
||
### Changes | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2023 Red Hat | ||
// | ||
// 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 hyperv | ||
|
||
import ( | ||
"github.com/coreos/ignition/v2/internal/platform" | ||
"os/exec" | ||
|
||
"github.com/containers/libhvee/pkg/kvp" | ||
"github.com/coreos/ignition/v2/config/v3_5_experimental/types" | ||
"github.com/coreos/ignition/v2/internal/providers/util" | ||
"github.com/coreos/ignition/v2/internal/resource" | ||
"github.com/coreos/vcontext/report" | ||
) | ||
|
||
// key represents the prefix key name for finding kvp file parts | ||
// in the key value pairs. it normally will have an integer added to the | ||
// end when looking up keys sequentially | ||
const key = "ignition.config." | ||
|
||
func init() { | ||
platform.Register(platform.Provider{ | ||
Name: "hyperv", | ||
Fetch: fetchConfig, | ||
}) | ||
} | ||
|
||
func fetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { | ||
f.Logger.Info("attempting to read from kvp") | ||
|
||
// To read key-value pairs from the Windows host, the hv_util kernel module | ||
// must be loaded to create the kernel device itself. | ||
_, err := f.Logger.LogCmd(exec.Command("modprobe", "hv_utils"), "loading hyperv kernel device module") | ||
if err != nil { | ||
return types.Config{}, report.Report{}, err | ||
} | ||
|
||
keyValuePairs, err := kvp.GetKeyValuePairs() | ||
if err != nil { | ||
return types.Config{}, report.Report{}, err | ||
} | ||
|
||
ign, _, err := keyValuePairs.GetSplitKeyValues(key, kvp.DefaultKVPPoolID) | ||
if err != nil { | ||
return types.Config{}, report.Report{}, err | ||
} | ||
|
||
return util.ParseConfig(f.Logger, []byte(ign)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.