Skip to content

Commit 84d2773

Browse files
authored
Release v0.4.3 (#6)
1 parent 8eac34e commit 84d2773

File tree

8 files changed

+40
-20
lines changed

8 files changed

+40
-20
lines changed

docs/changelog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ Changelog
88
Once the library reaches v1.0, it will be considered stable. Please consider giving feedback to
99
help stabilise the API.
1010

11+
Release 0.4.3 (2025-07-25)
12+
==========================
13+
14+
- Added :attr:`~hostedpi.pi.Pi.ipv6_ssh_hostname` and :attr:`~hostedpi.pi.Pi.hostname` properties to
15+
:class:`~hostedpi.pi.Pi`
16+
- Changed :attr:`~hostedpi.pi.Pi.ipv6_ssh_command` and :attr:`~hostedpi.pi.Pi.ipv6_ssh_config` to
17+
use the hostname rather than the IPv6 address
18+
1119
Release 0.4.2 (2025-07-19)
1220
==========================
1321

docs/cli/ssh/command.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Output the IPv6 SSH command for a Pi:
4343
.. code-block:: console
4444
4545
$ hostedpi ssh command mypi --ipv6
46-
ssh root@[2a00:1098:8:5b::1]
46+
ssh root@mypi.hostedpi.com
4747
4848
.. note::
4949

docs/cli/ssh/config.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Output the IPv6 SSH config for a Pi:
6161
$ hostedpi ssh config mypi --ipv6
6262
Host mypi
6363
user root
64-
hostname 2a00:1098:8:5b::1
64+
hostname mypi.hostedpi.com
6565
6666
Output the IPv4 SSH config for multiple Pis:
6767

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sphinx_rtd_theme
88

99

10-
hostedpi_version = "0.4.2"
10+
hostedpi_version = "0.4.3"
1111

1212

1313
# -- General configuration ------------------------------------------------

hostedpi/pi.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,26 +250,40 @@ def provision_status(self) -> str:
250250
"""
251251
return self.info.provision_status
252252

253+
@property
254+
def hostname(self) -> str:
255+
"""
256+
The hostname of the Pi
257+
"""
258+
return f"{self.name}.hostedpi.com"
259+
253260
@property
254261
def ipv4_ssh_hostname(self) -> str:
255262
"""
256-
The hostname to use when connecting to the Pi over IPv4
263+
The hostname to use when connecting to the Pi over SSH using IPv4
264+
"""
265+
return f"ssh.{self.hostname}"
266+
267+
@property
268+
def ipv6_ssh_hostname(self) -> str:
269+
"""
270+
The hostname to use when connecting to the Pi over SSH using IPv6
257271
"""
258-
return f"ssh.{self.name}.hostedpi.com"
272+
return self.hostname
259273

260274
@property
261275
def ipv4_ssh_command(self) -> str:
262276
"""
263-
The SSH command required to connect to the Pi over IPv4
277+
The SSH command required to connect to the Pi over SSH using IPv4
264278
"""
265279
return f"ssh -p {self.ipv4_ssh_port} root@{self.ipv4_ssh_hostname}"
266280

267281
@property
268282
def ipv6_ssh_command(self) -> str:
269283
"""
270-
The SSH command required to connect to the Pi over IPv6
284+
The SSH command required to connect to the Pi over SSH using IPv6
271285
"""
272-
return f"ssh root@[{self.ipv6_address}]"
286+
return f"ssh root@{self.ipv6_ssh_hostname}"
273287

274288
@property
275289
def ipv4_ssh_config(self) -> str:
@@ -280,7 +294,7 @@ def ipv4_ssh_config(self) -> str:
280294
return f"""Host {self.name}
281295
user root
282296
port {self.ipv4_ssh_port}
283-
hostname ssh.{self.name}.hostedpi.com
297+
hostname {self.ipv4_ssh_hostname}
284298
""".strip()
285299

286300
@property
@@ -291,7 +305,7 @@ def ipv6_ssh_config(self) -> str:
291305
"""
292306
return f"""Host {self.name}
293307
user root
294-
hostname {self.ipv6_address}
308+
hostname {self.ipv6_ssh_hostname}
295309
""".strip()
296310

297311
@property
@@ -302,7 +316,7 @@ def url(self) -> str:
302316
.. note::
303317
Note that a web server must be installed on the Pi for the URL to be resolvable.
304318
"""
305-
return f"http://www.{self.name}.hostedpi.com"
319+
return f"http://www.{self.hostname}"
306320

307321
@property
308322
def url_ssl(self) -> str:
@@ -315,7 +329,7 @@ def url_ssl(self) -> str:
315329
316330
See https://letsencrypt.org/
317331
"""
318-
return f"https://www.{self.name}.hostedpi.com"
332+
return f"https://www.{self.hostname}"
319333

320334
@property
321335
def ssh_keys(self) -> set[str]:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "hostedpi"
3-
version = "0.4.2"
3+
version = "0.4.3"
44
description = "Python interface to the Mythic Beasts Hosted Pi API"
55
authors = [
66
{name = "Ben Nuttall", email = "[email protected]"}

tests/test_pi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,14 @@ def test_pi_get_info(pi_name, pi_info_basic, auth, pi_info_response, pi_info_ful
205205
assert pi.memory_gb == 1
206206
assert pi.nic_speed == 100
207207
assert pi.ipv4_ssh_command == "ssh -p 5100 [email protected]"
208-
assert pi.ipv6_ssh_command == "ssh root@[2a00:1098:8:64::1]"
208+
assert pi.ipv6_ssh_command == "ssh root@test-pi.hostedpi.com"
209209
assert pi.ipv6_address == IPv6Address("2a00:1098:8:64::1")
210210
assert pi.ipv6_network == IPv6Network("2a00:1098:0008:6400::/56")
211211
assert pi.initialised_keys is False
212212
assert pi.location == "CLL"
213213
v4c = "Host test-pi\n user root\n port 5100\n hostname ssh.test-pi.hostedpi.com"
214214
assert pi.ipv4_ssh_config == v4c
215-
v6c = "Host test-pi\n user root\n hostname 2a00:1098:8:64::1"
215+
v6c = "Host test-pi\n user root\n hostname test-pi.hostedpi.com"
216216
assert pi.ipv6_ssh_config == v6c
217217
assert pi.status == "Powered on"
218218
assert pi.provision_status == "live"

tests/test_picloud.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,13 @@ def test_get_ipv6_ssh_config(auth, pis_response, pi_info_response, pi_info_respo
543543
pi_info_response_2,
544544
]
545545
ipv6_config = cloud.ipv6_ssh_config
546-
assert auth._api_session.get.call_count == 3
546+
assert auth._api_session.get.call_count == 1
547547
assert auth._api_session.get.call_args_list[0][0][0] == cloud._api_url + "servers"
548-
assert auth._api_session.get.call_args_list[1][0][0] == cloud._api_url + "servers/pi1"
549-
assert auth._api_session.get.call_args_list[2][0][0] == cloud._api_url + "servers/pi2"
550548
assert ipv6_config.count("\n") == 5
551549
lines = ipv6_config.splitlines()
552550
assert lines[0] == "Host pi1"
553551
assert lines[1] == " user root"
554-
assert lines[2] == " hostname 2a00:1098:8:64::1"
552+
assert lines[2] == " hostname pi1.hostedpi.com"
555553
assert lines[3] == "Host pi2"
556554
assert lines[4] == " user root"
557-
assert lines[5] == " hostname 2a00:1098:8:64::2"
555+
assert lines[5] == " hostname pi2.hostedpi.com"

0 commit comments

Comments
 (0)