From 63e5a106b34a5971ca8ab81d0b415c2648f820f9 Mon Sep 17 00:00:00 2001 From: dougiteixeira <31328123+dougiteixeira@users.noreply.github.com> Date: Wed, 10 May 2023 17:41:30 -0300 Subject: [PATCH] =?UTF-8?q?limpeza=20do=20fluxo=20de=20configura=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/proxmoxve/config_flow.py | 99 ---------------------- 1 file changed, 99 deletions(-) diff --git a/custom_components/proxmoxve/config_flow.py b/custom_components/proxmoxve/config_flow.py index da017ad..e415018 100644 --- a/custom_components/proxmoxve/config_flow.py +++ b/custom_components/proxmoxve/config_flow.py @@ -149,105 +149,6 @@ async def async_step_host_auth(self, user_input: dict[str, Any]) -> FlowResult: errors=errors, ) - async def async_step_add_node( - self, - user_input: dict[str, Any] | None = None, - ) -> FlowResult: - """Handle the node selection step.""" - - errors: dict[str, str] = {} - - current_nodes = [] - for node in self.config_entry.data[CONF_NODES]: - current_nodes.append(node) - - if user_input: - node = user_input.get(CONF_NODE) - if node in current_nodes: - return self.async_abort(reason="node_already_exists") - - config_data: dict[str, Any] = ( - self.config_entry.data.copy() - if self.config_entry.data is not None - else {} - ) - - current_nodes.append(node) - config_data.update( - { - CONF_NODES: current_nodes, - } - ) - - self.hass.config_entries.async_update_entry( - self.config_entry, data=config_data - ) - - await self.hass.config_entries.async_reload(self.config_entry.entry_id) - - return self.async_abort(reason="changes_successful") - - # return await self.async_step_selection_qemu_lxc(node=node) - - host = self.config_entry.data[CONF_HOST] - port = self.config_entry.data[CONF_PORT] - user = self.config_entry.data[CONF_USERNAME] - realm = self.config_entry.data[CONF_REALM] - password = self.config_entry.data[CONF_PASSWORD] - verify_ssl = self.config_entry.data[CONF_VERIFY_SSL] - - try: - self._proxmox_client = ProxmoxClient( - host=host, - port=port, - user=user, - realm=realm, - password=password, - verify_ssl=verify_ssl, - ) - - await self.hass.async_add_executor_job(self._proxmox_client.build_client) - - except ( - proxmoxer.AuthenticationError, - SSLError, - ConnectTimeout, - Exception, - ) as err: - raise (err) - - proxmox = self._proxmox_client.get_api_client() - - nodes = [] - - if (proxmox_cliente := self._proxmox_client) is not None: - if proxmox := (proxmox_cliente.get_api_client()): - proxmox_nodes = await self.hass.async_add_executor_job( - proxmox.nodes.get - ) - - for node in proxmox_nodes: - nodes.append(node[CONF_NODE]) - - for current_node in current_nodes: - if current_node in nodes: - nodes.remove(current_node) - - if len(nodes) == 0: - return self.async_abort(reason="no_nodes_to_add") - - return self.async_show_form( - step_id="add_node", - data_schema=vol.Schema( - { - vol.Required(CONF_NODE): vol.In(nodes), - } - ), - errors=errors, - ) - - return self.async_abort(reason="no_nodes") - async def async_step_change_expose( self, user_input: dict[str, Any] | None = None,