Skip to content

Commit

Permalink
Add mac_address to server PrivateNet (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
LKaemmerling authored Jul 22, 2019
1 parent 45a3b05 commit c93b992
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
History
=======

master (XXXX-XX-XX)

* Feature: Add `mac_address` to Server PrivateNet domain

1.3.0 (2019-07-10)
------------------

Expand Down
2 changes: 1 addition & 1 deletion hcloud/servers/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, client, data, complete=True):

private_nets = data.get("private_net")
if private_nets:
private_nets = [PrivateNet(network=BoundNetwork(client._client.networks, {"id": private_net['network']}, complete=False), ip=private_net['ip'], alias_ips=private_net['alias_ips']) for private_net in private_nets]
private_nets = [PrivateNet(network=BoundNetwork(client._client.networks, {"id": private_net['network']}, complete=False), ip=private_net['ip'], alias_ips=private_net['alias_ips'], mac_address=private_net['mac_address']) for private_net in private_nets]
data['private_net'] = private_nets

super(BoundServer, self).__init__(client, data, complete)
Expand Down
7 changes: 6 additions & 1 deletion hcloud/servers/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,23 @@ class PrivateNet(BaseDomain):
The main IP Address of the server in the Network
:param alias_ips: List[str]
The alias ips for a server
:param mac_address: str
The mac address of the interface on the server
"""
__slots__ = (
"network",
"ip",
"alias_ips"
"alias_ips",
"mac_address"
)

def __init__(self,
network, # type: BoundNetwork
ip, # type: str
alias_ips, # type: List[str]
mac_address, # type: str
):
self.network = network
self.ip = ip
self.alias_ips = alias_ips
self.mac_address = mac_address
12 changes: 8 additions & 4 deletions tests/unit/servers/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def response_simple_server():
{
"network": 4711,
"ip": "10.1.1.5",
"alias_ips": ["10.1.1.8"]
"alias_ips": ["10.1.1.8"],
"mac_address": "86:00:ff:2a:7d:e1"
}
],
"server_type": {
Expand Down Expand Up @@ -450,7 +451,8 @@ def response_simple_servers():
{
"network": 4711,
"ip": "10.1.1.5",
"alias_ips": ["10.1.1.8"]
"alias_ips": ["10.1.1.8"],
"mac_address": "86:00:ff:2a:7d:e1"
}
],
"server_type": {
Expand Down Expand Up @@ -570,7 +572,8 @@ def response_simple_servers():
{
"network": 4711,
"ip": "10.1.1.7",
"alias_ips": ["10.1.1.99"]
"alias_ips": ["10.1.1.99"],
"mac_address": "86:00:ff:2a:7d:e1"
}
],
"server_type": {
Expand Down Expand Up @@ -697,7 +700,8 @@ def response_full_server():
{
"network": 4711,
"ip": "10.1.1.5",
"alias_ips": ["10.1.1.8"]
"alias_ips": ["10.1.1.8"],
"mac_address": "86:00:ff:2a:7d:e1"
}
],
"server_type": {
Expand Down
1 change: 1 addition & 0 deletions tests/unit/servers/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def test_bound_server_init(self, response_full_server):
assert isinstance(bound_server.private_net[0], PrivateNet)
assert bound_server.private_net[0].network._client == bound_server._client._client.networks
assert bound_server.private_net[0].ip == "10.1.1.5"
assert bound_server.private_net[0].mac_address == "86:00:ff:2a:7d:e1"
assert len(bound_server.private_net[0].alias_ips) == 1
assert bound_server.private_net[0].alias_ips[0] == "10.1.1.8"

Expand Down

0 comments on commit c93b992

Please sign in to comment.