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 Signed-off-by: Brent Baude <[email protected]>
- Loading branch information
Showing
9 changed files
with
299 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
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,20 @@ | ||
// 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 | ||
|
||
var ( | ||
// 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 | ||
key = "com_coreos_ignition_kvp_" | ||
) |
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,46 @@ | ||
// 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 ( | ||
"os/exec" | ||
|
||
"github.com/containers/libhvee/pkg/kvp" | ||
"github.com/coreos/ignition/v2/config/v3_4_experimental/types" | ||
"github.com/coreos/ignition/v2/internal/providers/util" | ||
"github.com/coreos/ignition/v2/internal/resource" | ||
"github.com/coreos/vcontext/report" | ||
) | ||
|
||
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 through WMI, 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 | ||
} | ||
|
||
rawKvps, err := kvp.GetKeyValuePairs() | ||
if err != nil { | ||
return types.Config{}, report.Report{}, err | ||
} | ||
|
||
ign, _, err := kvp.GetSplitKeyValues(key, kvp.DefaultKVPPoolID, rawKvps) | ||
if err != nil { | ||
return types.Config{}, report.Report{}, err | ||
} | ||
|
||
return util.ParseConfig(f.Logger, []byte(ign)) | ||
} |
Oops, something went wrong.