Skip to content

Commit

Permalink
Include the "pool" parameter when cloning a VM with the proxmox salt-…
Browse files Browse the repository at this point in the history
…cloud driver

Fixes saltstack#62521
  • Loading branch information
pjcreath committed Aug 30, 2022
1 parent 8f0532c commit e6657ce
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/62521.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the omitted "pool" parameter when cloning a VM with the proxmox salt-cloud driver
2 changes: 2 additions & 0 deletions salt/cloud/clouds/proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,8 @@ def create_node(vm_, newid):
if "clone" in vm_ and vm_["clone"] is True and vm_["technology"] == "qemu":
postParams = {}
postParams["newid"] = newnode["vmid"]
if "pool" in vm_:
postParams["pool"] = vm_["pool"]

for prop in "description", "format", "full", "name":
if (
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/cloud/clouds/test_proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import textwrap

import requests

from salt import config
from salt.cloud.clouds import proxmox
from tests.support.helpers import TstSuiteLoggingHandler
Expand Down Expand Up @@ -162,6 +163,31 @@ def test_clone(self):
)
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):
"""
Test find_agent_ip will return an IP
Expand Down

0 comments on commit e6657ce

Please sign in to comment.