Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] Deprecate proxmox cloud #64453

Merged
merged 7 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/64224.deprecated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate all Proxmox cloud modules
5 changes: 5 additions & 0 deletions doc/topics/cloud/proxmox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Getting Started With Proxmox
============================

.. warning::
This cloud provider will be removed from Salt in version 3009.0 in favor of
the `saltext.proxmox Salt Extension
<https://github.com/salt-extensions/saltext-proxmox>`_

Proxmox Virtual Environment is a complete server virtualization management solution,
based on OpenVZ(in Proxmox up to 3.4)/LXC(from Proxmox 4.0 and up) and full virtualization with KVM.
Further information can be found at:
Expand Down
44 changes: 26 additions & 18 deletions salt/cloud/clouds/proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
driver: proxmox
verify_ssl: True

.. warning::
This cloud provider will be removed from Salt in version 3009.0 in favor of
the `saltext.proxmox Salt Extension
<https://github.com/salt-extensions/saltext-proxmox>`_

:maintainer: Frank Klaassen <frank@cloudright.nl>
:depends: requests >= 2.2.1
:depends: IPy >= 0.81
Expand Down Expand Up @@ -61,6 +66,11 @@

__virtualname__ = "proxmox"

__deprecated__ = (
3009,
"proxmox",
"https://github.com/salt-extensions/saltext-proxmox"
)

def __virtual__():
"""
Expand Down Expand Up @@ -135,7 +145,7 @@ def _authenticate():
)

connect_data = {"username": username, "password": passwd}
full_url = "https://{}:{}/api2/json/access/ticket".format(url, port)
full_url = f"https://{url}:{port}/api2/json/access/ticket"

response = requests.post(full_url, verify=verify_ssl, data=connect_data)
response.raise_for_status()
Expand All @@ -153,7 +163,7 @@ def query(conn_type, option, post_data=None):
log.debug("Not authenticated yet, doing that now..")
_authenticate()

full_url = "https://{}:{}/api2/json/{}".format(url, port, option)
full_url = f"https://{url}:{port}/api2/json/{option}"

log.debug("%s: %s (%s)", conn_type, full_url, post_data)

Expand Down Expand Up @@ -443,9 +453,7 @@ def avail_images(call=None, location="local"):

ret = {}
for host_name, host_details in avail_locations().items():
for item in query(
"get", "nodes/{}/storage/{}/content".format(host_name, location)
):
for item in query("get", f"nodes/{host_name}/storage/{location}/content"):
ret[item["volid"]] = item
return ret

Expand Down Expand Up @@ -552,7 +560,7 @@ def _dictionary_to_stringlist(input_dict):

setting1=value1,setting2=value2
"""
return ",".join("{}={}".format(k, input_dict[k]) for k in sorted(input_dict.keys()))
return ",".join(f"{k}={input_dict[k]}" for k in sorted(input_dict.keys()))


def _reconfigure_clone(vm_, vmid):
Expand Down Expand Up @@ -708,7 +716,7 @@ def create(vm_):

# wait until the vm has been created so we can start it
if not wait_for_created(data["upid"], timeout=300):
return {"Error": "Unable to create {}, command timed out".format(name)}
return {"Error": f"Unable to create {name}, command timed out"}

if vm_.get("clone") is True:
_reconfigure_clone(vm_, vmid)
Expand All @@ -721,7 +729,7 @@ def create(vm_):
# Wait until the VM has fully started
log.debug('Waiting for state "running" for vm %s on %s', vmid, host)
if not wait_for_state(vmid, "running"):
return {"Error": "Unable to start {}, command timed out".format(name)}
return {"Error": f"Unable to start {name}, command timed out"}

if agent_get_ip is True:
try:
Expand Down Expand Up @@ -861,7 +869,7 @@ def _import_api():
Load this json content into global variable "api"
"""
global api
full_url = "https://{}:{}/pve-docs/api-viewer/apidoc.js".format(url, port)
full_url = f"https://{url}:{port}/pve-docs/api-viewer/apidoc.js"
returned_data = requests.get(full_url, verify=verify_ssl)

re_filter = re.compile(" (?:pveapi|apiSchema) = (.*)^;", re.DOTALL | re.MULTILINE)
Expand Down Expand Up @@ -1095,12 +1103,12 @@ def get_vmconfig(vmid, node=None, node_type="openvz"):
if node is None:
# We need to figure out which node this VM is on.
for host_name, host_details in avail_locations().items():
for item in query("get", "nodes/{}/{}".format(host_name, node_type)):
for item in query("get", f"nodes/{host_name}/{node_type}"):
if item["vmid"] == vmid:
node = host_name

# If we reached this point, we have all the information we need
data = query("get", "nodes/{}/{}/{}/config".format(node, node_type, vmid))
data = query("get", f"nodes/{node}/{node_type}/{vmid}/config")

return data

Expand Down Expand Up @@ -1172,7 +1180,7 @@ def destroy(name, call=None):
__utils__["cloud.fire_event"](
"event",
"destroying instance",
"salt/cloud/{}/destroying".format(name),
f"salt/cloud/{name}/destroying",
args={"name": name},
sock_dir=__opts__["sock_dir"],
transport=__opts__["transport"],
Expand All @@ -1186,7 +1194,7 @@ def destroy(name, call=None):

# wait until stopped
if not wait_for_state(vmobj["vmid"], "stopped"):
return {"Error": "Unable to stop {}, command timed out".format(name)}
return {"Error": f"Unable to stop {name}, command timed out"}

# required to wait a bit here, otherwise the VM is sometimes
# still locked and destroy fails.
Expand All @@ -1196,7 +1204,7 @@ def destroy(name, call=None):
__utils__["cloud.fire_event"](
"event",
"destroyed instance",
"salt/cloud/{}/destroyed".format(name),
f"salt/cloud/{name}/destroyed",
args={"name": name},
sock_dir=__opts__["sock_dir"],
transport=__opts__["transport"],
Expand All @@ -1206,7 +1214,7 @@ def destroy(name, call=None):
name, _get_active_provider_name().split(":")[0], __opts__
)

return {"Destroyed": "{} was destroyed.".format(name)}
return {"Destroyed": f"{name} was destroyed."}


def set_vm_status(status, name=None, vmid=None):
Expand Down Expand Up @@ -1295,7 +1303,7 @@ def start(name, vmid=None, call=None):

# xxx: TBD: Check here whether the status was actually changed to 'started'

return {"Started": "{} was started.".format(name)}
return {"Started": f"{name} was started."}


def stop(name, vmid=None, call=None):
Expand All @@ -1317,7 +1325,7 @@ def stop(name, vmid=None, call=None):

# xxx: TBD: Check here whether the status was actually changed to 'stopped'

return {"Stopped": "{} was stopped.".format(name)}
return {"Stopped": f"{name} was stopped."}


def shutdown(name=None, vmid=None, call=None):
Expand All @@ -1341,4 +1349,4 @@ def shutdown(name=None, vmid=None, call=None):

# xxx: TBD: Check here whether the status was actually changed to 'stopped'

return {"Shutdown": "{} was shutdown.".format(name)}
return {"Shutdown": f"{name} was shutdown."}