Introduces internal/provider/kvm with the side-effect-free pieces of the provider: providerID format/parse, the namespaced <metadata> element that carries the GC contract, q35 domain XML over pool volumes, volume XML for overlays and raw seeds, the NoCloud seed ISO built with kdomanski/iso9660, and config defaults. All unit-tested. Step 2 of docs/plans/2026-09-04-1404-kvm-provider.md. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
22 lines
667 B
Go
22 lines
667 B
Go
package kvm
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// The providerID carries the host, so Get/Delete stay correct after a
|
|
// placement.zone edit mid-replacement — re-reading the spec then would look
|
|
// at the wrong hypervisor.
|
|
func formatProviderID(host, name string) string {
|
|
return fmt.Sprintf("hosts/%s/domains/%s", host, name)
|
|
}
|
|
|
|
func parseProviderID(id string) (host, name string, err error) {
|
|
parts := strings.Split(id, "/")
|
|
if len(parts) != 4 || parts[0] != "hosts" || parts[2] != "domains" || parts[1] == "" || parts[3] == "" {
|
|
return "", "", fmt.Errorf("malformed kvm providerID %q, want hosts/<host>/domains/<name>", id)
|
|
}
|
|
return parts[1], parts[3], nil
|
|
}
|