Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ocp_resources/virtual_machine_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(
annotation_filters=None,
new_mac_addresses=None,
new_smbios_serial=None,
volume_name_policy=None,
**kwargs,
):
"""
Expand All @@ -30,6 +31,7 @@ def __init__(
annotation_filters (list, optional): List of annotation filters, e.g. ["firstKey/*", "secondKey/*"]
new_mac_addresses (dict, optional): Dict of new MAC addresses, {interface_name: mac_address}
new_smbios_serial (str, optional): the clone's new smbios serial
volume_name_policy (str, optional): the clone's volume name policy
"""
super().__init__(**kwargs)
self.source_name = source_name
Expand All @@ -39,6 +41,7 @@ def __init__(
self.annotation_filters = annotation_filters
self.new_mac_addresses = new_mac_addresses
self.new_smbios_serial = new_smbios_serial
self.volume_name_policy = volume_name_policy

def to_dict(self) -> None:
super().to_dict()
Expand All @@ -49,7 +52,7 @@ def to_dict(self) -> None:

source = spec.setdefault("source", {})
source["apiGroup"] = NamespacedResource.ApiGroup.KUBEVIRT_IO
source["kind"] = self.source_kind if self.source_kind else VirtualMachine.kind
source["kind"] = self.source_kind or VirtualMachine.kind
source["name"] = self.source_name

if self.target_name:
Expand All @@ -66,3 +69,5 @@ def to_dict(self) -> None:
spec["newMacAddresses"] = self.new_mac_addresses
if self.new_smbios_serial:
spec["newSMBiosSerial"] = self.new_smbios_serial
if self.volume_name_policy:
spec["volumeNamePolicy"] = self.volume_name_policy
4 changes: 4 additions & 0 deletions ocp_resources/virtual_machine_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(
teardown=True,
yaml_file=None,
delete_timeout=TIMEOUT_4MINUTES,
volume_name_policy=None,
**kwargs,
):
super().__init__(
Expand All @@ -36,6 +37,7 @@ def __init__(
)
self.vm_name = vm_name
self.snapshot_name = snapshot_name
self.volume_name_policy = volume_name_policy

def to_dict(self) -> None:
super().to_dict()
Expand All @@ -45,6 +47,8 @@ def to_dict(self) -> None:
spec["target"]["kind"] = VirtualMachine.kind
spec["target"]["name"] = self.vm_name
spec["virtualMachineSnapshotName"] = self.snapshot_name
if self.volume_name_policy:
spec["volumeNamePolicy"] = self.volume_name_policy

def wait_complete(self, status=True, timeout=TIMEOUT_4MINUTES):
"""
Expand Down