-
-
Save aszlig/84e9bf4c8c2a06e77e43d64f89a5c2fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/nix/hetzner-bootstrap.nix b/nix/hetzner-bootstrap.nix | |
index b4c80d0..035e6f9 100644 | |
--- a/nix/hetzner-bootstrap.nix | |
+++ b/nix/hetzner-bootstrap.nix | |
@@ -5,7 +5,6 @@ let | |
nixpart = python2Packages.nixpart0.override { | |
useNixUdev = false; | |
- udevSoMajor = 0; | |
}; | |
generateConfig = (import <nixpkgs/nixos> { | |
diff --git a/nixops/backends/hetzner.py b/nixops/backends/hetzner.py | |
index 6e7f9a0..811fe04 100644 | |
--- a/nixops/backends/hetzner.py | |
+++ b/nixops/backends/hetzner.py | |
@@ -499,8 +499,6 @@ class HetznerState(MachineState): | |
""" | |
udev_rules = [] | |
iface_attrs = {} | |
- extra_routes = [] | |
- ipv6_commands = [] | |
server = self._get_server_by_ip(self.main_ipv4) | |
@@ -519,10 +517,11 @@ class HetznerState(MachineState): | |
udev_rules.append(self._get_udev_rule_for(iface)) | |
- ipv4, prefix = result | |
+ ipv4addr, prefix = result | |
iface_attrs[iface] = { | |
- 'ipAddress': ipv4, | |
- 'prefixLength': int(prefix), | |
+ ('ipv4', 'addresses'): [ | |
+ {'address': ipv4addr, 'prefixLength': int(prefix)} | |
+ ], | |
} | |
# We can't handle Hetzner-specific networking info in test mode. | |
@@ -530,30 +529,30 @@ class HetznerState(MachineState): | |
continue | |
# Extra route for accessing own subnet | |
- net = self._calculate_ipv4_subnet(ipv4, int(prefix)) | |
- extra_routes.append(("{0}/{1}".format(net, prefix), defgw, iface)) | |
+ net = self._calculate_ipv4_subnet(ipv4addr, int(prefix)) | |
+ iface_attrs[iface][('ipv4', 'routes')] = [{ | |
+ 'address': net, | |
+ 'prefixLength': int(prefix), | |
+ 'via': defgw | |
+ }] | |
- # IPv6 subnets only for eth0 (XXX: more flexibility here?) | |
- v6addr_command = "ip -6 addr add '{0}' dev '{1}' || true" | |
+ # IPv6 subnets only for eth0 | |
+ v6subnets = [] | |
for subnet in server.subnets: | |
if "." in subnet.net_ip: | |
# skip IPv4 addresses | |
continue | |
- v6addr = "{0}/{1}".format(subnet.net_ip, subnet.mask) | |
- ipv6_commands.append(v6addr_command.format(v6addr, iface)) | |
- assert v6defgw is None or v6defgw == subnet.gateway | |
- v6defgw = subnet.gateway | |
- | |
- # Extra routes | |
- route4_cmd = "ip -4 route change '{0}' via '{1}' dev '{2}' || true" | |
- route_commands = [route4_cmd.format(network, gw, iface) | |
- for network, gw, iface in extra_routes] | |
- | |
- # IPv6 configuration | |
- route6_cmd = "ip -6 route add default via '{0}' dev eth0 || true" | |
- route_commands.append(route6_cmd.format(v6defgw)) | |
- | |
- local_commands = '\n'.join(ipv6_commands + route_commands) + '\n' | |
+ v6subnets.append({ | |
+ 'address': subnet.net_ip, | |
+ 'prefixLength': int(subnet.mask) | |
+ }) | |
+ assert (v6defgw is None or | |
+ v6defgw.get('address') == subnet.gateway) | |
+ v6defgw = { | |
+ 'address': subnet.gateway, | |
+ 'prefixLength': int(subnet.mask), | |
+ } | |
+ iface_attrs[iface][('ipv6', 'addresses')] = v6subnets | |
self.net_info = { | |
'services': { | |
@@ -562,8 +561,8 @@ class HetznerState(MachineState): | |
'networking': { | |
'interfaces': iface_attrs, | |
'defaultGateway': defgw, | |
+ 'defaultGateway6': v6defgw, | |
'nameservers': self._get_nameservers(), | |
- 'localCommands': local_commands, | |
} | |
} | |
diff --git a/tests/hetzner-backend/default.nix b/tests/hetzner-backend/default.nix | |
index 614eae0..6b89060 100644 | |
--- a/tests/hetzner-backend/default.nix | |
+++ b/tests/hetzner-backend/default.nix | |
@@ -1,7 +1,7 @@ | |
{ system, nixops }: | |
with import <nixpkgs/nixos/lib/testing.nix> { inherit system; }; | |
-with import <nixpkgs/nixos/lib/qemu-flags.nix>; | |
+with import <nixpkgs/nixos/lib/qemu-flags.nix> { inherit pkgs; }; | |
with pkgs.lib; | |
let |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment