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

core: services: beacon: Fix V2->V3 settings migration #1920

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions core/services/beacon/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def get_phys(self) -> List[psutil._common.snicaddr]:

def get_ip_strs(self) -> List[str]:
"""
get ip as a string. this also translates 'ips[n]' to the n-th ip in that interface
returns a list of the interface IPs (IPv4 only) as a list of strings:
- if self.ip is "ips[*]", it returns all ips of that interface
- if self.ip is "ips[n]", it returns the n-th ip of that interface
- if self.ip is a single ipv4 (like "192.168.2.2"), it returns that ip as a string
- if self.ip is (mistakenly) an IPv6 or any other non-IPv4 format, it raises an InvalidIpAddress error
"""
address = str(self.ip)
# Check for 'ips[n]'
Expand Down Expand Up @@ -71,7 +75,7 @@ def get_ip_strs(self) -> List[str]:

def get_ips(self) -> List[bytes]:
"""
returns the ip as 4 bytes
returns a list of the interface IPs (IPv4 only) as a list of 4 bytes
"""
return [socket.inet_aton(ip) for ip in self.get_ip_strs()]

Expand Down Expand Up @@ -172,7 +176,7 @@ def migrate(self, data: Dict[str, Any]) -> None:
try:
if not any(interface["name"] == "uap0" for interface in data["interfaces"]):
data["interfaces"].append(
Interface(name="uap0", domain_names=["blueos-hotspot"], advertise=["_http"], ip="ips[0]").as_dict()
Interface(name="uap0", domain_names=["blueos-hotspot"], advertise=["_http"], ip="ips[0]")._data
)
except Exception as e:
logger.error(f"unable to update SettingsV2 to SettingsV3: {e}")
Expand Down