Include the "pool" parameter when cloning a VM with the proxmox salt-cloud driver

Fixes #62521
This commit is contained in:
pjcreath 2022-08-23 18:23:41 +00:00 committed by Megan Wilhite
parent 0121e725bb
commit a83504cb34
3 changed files with 29 additions and 0 deletions

1
changelog/62521.fixed Normal file
View file

@ -0,0 +1 @@
Fixed the omitted "pool" parameter when cloning a VM with the proxmox salt-cloud driver

View file

@ -1034,6 +1034,8 @@ def create_node(vm_, newid):
if "clone" in vm_ and vm_["clone"] is True and vm_["technology"] == "qemu": if "clone" in vm_ and vm_["clone"] is True and vm_["technology"] == "qemu":
postParams = {} postParams = {}
postParams["newid"] = newnode["vmid"] postParams["newid"] = newnode["vmid"]
if "pool" in vm_:
postParams["pool"] = vm_["pool"]
for prop in "description", "format", "full", "name": for prop in "description", "format", "full", "name":
if ( if (

View file

@ -6,6 +6,7 @@ import io
import textwrap import textwrap
import requests import requests
from salt import config from salt import config
from salt.cloud.clouds import proxmox from salt.cloud.clouds import proxmox
from tests.support.helpers import TstSuiteLoggingHandler from tests.support.helpers import TstSuiteLoggingHandler
@ -162,6 +163,31 @@ class ProxmoxTest(TestCase, LoaderModuleMockMixin):
) )
assert result == {} assert result == {}
def test_clone_pool(self):
"""
Test that cloning a VM passes the pool parameter if present
"""
mock_query = MagicMock(return_value="")
with patch(
"salt.cloud.clouds.proxmox._get_properties", MagicMock(return_value=[])
), patch("salt.cloud.clouds.proxmox.query", mock_query):
vm_ = {
"technology": "qemu",
"name": "new2",
"host": "myhost",
"clone": True,
"clone_from": 123,
"pool": "mypool",
}
result = proxmox.create_node(vm_, ANY)
mock_query.assert_called_once_with(
"post",
"nodes/myhost/qemu/123/clone",
{"newid": ANY, "pool": "mypool"},
)
assert result == {}
def test_find_agent_ips(self): def test_find_agent_ips(self):
""" """
Test find_agent_ip will return an IP Test find_agent_ip will return an IP