-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MTV-1366 | Add virt-customize to warm migration and OVA
Issue: Right now we run the virt-customize only on the cold local migration. But we would wanted to run it on all vmware migrations. Fix: This commit adds a new stage to the converison pod which scans the guest to get the operating system. It is using the tool `virt-v2v-inspector` which generates inspection xml file. This file contains lot of information about guest, including the OS. This tool is run after the `virt-v2v` step because for the OVA and cold local migration we dont have the disk available before that step. Additionally this patch adds a new `inspection` endpoint to the conversion pod. The controller requests the endpoint to get the operating system so it could be set as a preference to the kubevirt. New known issues: The OVA won't be able to preserve static IP addresses as we get the IP adress configuration by form the vmware guest agent when the VM is running. There might be some information inside the ova file but right now this is not fixed. Signed-off-by: Martin Necas <mnecas@redhat.com>
- Loading branch information
Showing
11 changed files
with
297 additions
and
281 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package vsphere | ||
|
||
import ( | ||
"encoding/xml" | ||
"fmt" | ||
|
||
"github.com/konveyor/forklift-controller/pkg/lib/logging" | ||
) | ||
|
||
const ( | ||
// Name. | ||
Name = "virt-v2v-parser" | ||
) | ||
|
||
// Package logger. | ||
var log = logging.WithName(Name) | ||
|
||
// Map of osinfo ids to vmware guest ids. | ||
var osV2VMap = map[string]string{ | ||
"centos6": "centos6_64Guest", | ||
"centos7": "centos7_64Guest", | ||
"centos8": "centos8_64Guest", | ||
"centos9": "centos9_64Guest", | ||
"rhel7": "rhel7_64Guest", | ||
"rhel8": "rhel8_64Guest", | ||
"rhel9": "rhel9_64Guest", | ||
"rocky": "rockylinux_64Guest", | ||
"sles10": "sles10_64Guest", | ||
"sles11": "sles11_64Guest", | ||
"sles12": "sles12_64Guest", | ||
"sles15": "sles15_64Guest", | ||
"sles16": "sles16_64Guest", | ||
"opensuse": "opensuse64Guest", | ||
"debian4": "debian4_64Guest", | ||
"debian5": "debian5_64Guest", | ||
"debian6": "debian6_64Guest", | ||
"debian7": "debian7_64Guest", | ||
"debian8": "debian8_64Guest", | ||
"debian9": "debian9_64Guest", | ||
"debian10": "debian10_64Guest", | ||
"debian11": "debian11_64Guest", | ||
"debian12": "debian12_64Guest", | ||
"ubuntu": "ubuntu64Guest", | ||
"fedora": "fedora64Guest", | ||
"win7": "windows7Server64Guest", | ||
"win8": "windows8Server64Guest", | ||
"win10": "windows9Server64Guest", | ||
"win11": "windows11_64Guest", | ||
"win12": "windows12_64Guest", | ||
"win2k19": "windows2019srv_64Guest", | ||
"win2k22": "windows2022srvNext_64Guest", | ||
} | ||
|
||
type InspectionOS struct { | ||
Name string `xml:"name"` | ||
Distro string `xml:"distro"` | ||
Osinfo string `xml:"osinfo"` | ||
Arch string `xml:"arch"` | ||
} | ||
|
||
type InspectionV2V struct { | ||
OS InspectionOS `xml:"operatingsystem"` | ||
} | ||
|
||
func ParseInspectionFromString(xmlData string) (InspectionV2V, error) { | ||
var xmlConf InspectionV2V | ||
err := xml.Unmarshal([]byte(xmlData), &xmlConf) | ||
if err != nil { | ||
return InspectionV2V{}, fmt.Errorf("Error unmarshalling XML: %v\n", err) | ||
} | ||
return xmlConf, nil | ||
} | ||
|
||
func GetOperationSystemFromConfig(vmConfigXML string) (string, error) { | ||
inspection, err := ParseInspectionFromString(vmConfigXML) | ||
if err != nil { | ||
return "", err | ||
} | ||
os, ok := osV2VMap[inspection.OS.Osinfo] | ||
if !ok { | ||
log.Info(fmt.Sprintf("Received %s, mapped to: %s", os, os)) | ||
os = "otherGuest64" | ||
} | ||
return os, nil | ||
} |
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
Oops, something went wrong.