Skip to content

Commit

Permalink
Redirect to Master AP if host is member
Browse files Browse the repository at this point in the history
  • Loading branch information
ms264556 committed Sep 4, 2023
1 parent eea5000 commit 44dc6a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions aioruckus/ajaxsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Any, TYPE_CHECKING

import aiohttp
from urllib.parse import urlparse
import xmltodict

from .abcsession import AbcSession, ConfigItem
Expand Down Expand Up @@ -59,13 +60,21 @@ async def login(self) -> None:
async with self.websession.head(
f"https://{self.host}", timeout=3, allow_redirects=False
) as head:
self.__login_url = head.headers["Location"]
self.base_url, login_page = self.__login_url.rsplit("/", 1)
if login_page in ("index.html", "wizard.jsp"):
# Unleashed Rebuilding or Setup Wizard
raise ConnectionRefusedError(ERROR_CONNECT_TEMPORARY)
self.cmdstat_url = self.base_url + "/_cmdstat.jsp"
self.conf_url = self.base_url + "/_conf.jsp"
redirect_to = head.headers["Location"]
if urlparse(redirect_to).path:
self.__login_url = redirect_to
else:
# Unleashed Member has redirected to Unleashed Master
async with self.websession.head(
redirect_to, timeout=3, allow_redirects=False
) as head:
self.__login_url = head.headers["Location"]
self.base_url, login_page = self.__login_url.rsplit("/", 1)
if login_page in ("index.html", "wizard.jsp"):
# Unleashed Rebuilding or Setup Wizard
raise ConnectionRefusedError(ERROR_CONNECT_TEMPORARY)
self.cmdstat_url = self.base_url + "/_cmdstat.jsp"
self.conf_url = self.base_url + "/_conf.jsp"
except aiohttp.client_exceptions.ClientConnectorError as cerr:
raise ConnectionError(ERROR_CONNECT_EOF) from cerr
except asyncio.exceptions.TimeoutError as terr:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = aioruckus
version = 0.32
version = 0.33
author = ms264556
author_email = [email protected]
description = Python API to interact with Ruckus Unleashed and ZoneDirector devices.
Expand Down

0 comments on commit 44dc6a8

Please sign in to comment.