Skip to content

Commit

Permalink
Merge pull request #84 from dougiteixeira/fix-error-name-resources
Browse files Browse the repository at this point in the history
fix errors name resources
  • Loading branch information
dougiteixeira authored May 10, 2023
2 parents 280bba7 + 6e01229 commit 9ecff6c
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions custom_components/proxmoxve/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,27 @@ async def async_step_change_expose(
resources = await self.hass.async_add_executor_job(
proxmox.cluster.resources.get
)
LOGGER.debug("Response API - Resources: %s", resources)
resource_qemu = {}
resource_lxc = {}
for resource in resources:
if ("type" in resource) and (resource["type"] == ProxmoxType.Node):
if resource["node"] not in resource_nodes:
resource_nodes.append(resource["node"])
if ("type" in resource) and (resource["type"] == ProxmoxType.QEMU):
resource_qemu[
str(resource["vmid"])
] = f"{resource['vmid']} {resource['name']}"
if "name" in resource:
resource_qemu[
str(resource["vmid"])
] = f"{resource['vmid']} {resource['name']}"
else:
resource_qemu[str(resource["vmid"])] = f"{resource['vmid']}"
if ("type" in resource) and (resource["type"] == ProxmoxType.LXC):
resource_lxc[
str(resource["vmid"])
] = f"{resource['vmid']} {resource['name']}"
if "name" in resource:
resource_lxc[
str(resource["vmid"])
] = f"{resource['vmid']} {resource['name']}"
else:
resource_lxc[str(resource["vmid"])] = f"{resource['vmid']}"

return self.async_show_form(
step_id="change_expose",
Expand Down Expand Up @@ -796,6 +803,7 @@ async def async_step_expose(
resources = await self.hass.async_add_executor_job(
proxmox.cluster.resources.get
)
LOGGER.debug("Response API - Resources: %s", resources)
resource_nodes = []
resource_qemu = {}
resource_lxc = {}
Expand All @@ -806,13 +814,19 @@ async def async_step_expose(
if resource["node"] not in resource_nodes:
resource_nodes.append(resource["node"])
if ("type" in resource) and (resource["type"] == ProxmoxType.QEMU):
resource_qemu[
str(resource["vmid"])
] = f"{resource['vmid']} {resource['name']}"
if "name" in resource:
resource_qemu[
str(resource["vmid"])
] = f"{resource['vmid']} {resource['name']}"
else:
resource_qemu[str(resource["vmid"])] = f"{resource['vmid']}"
if ("type" in resource) and (resource["type"] == ProxmoxType.LXC):
resource_lxc[
str(resource["vmid"])
] = f"{resource['vmid']} {resource['name']}"
if "name" in resource:
resource_lxc[
str(resource["vmid"])
] = f"{resource['vmid']} {resource['name']}"
else:
resource_lxc[str(resource["vmid"])] = f"{resource['vmid']}"

return self.async_show_form(
step_id="expose",
Expand Down

0 comments on commit 9ecff6c

Please sign in to comment.