|
@@ -36,7 +36,7 @@ class ConfigDrive:
|
36
|
36
|
def set_hostname(self, hostname):
|
37
|
37
|
self._hostname = hostname
|
38
|
38
|
|
39
|
|
- def conf_network(self, interface, address=None, gateway=None):
|
|
39
|
+ def conf_network(self, interface, address=None, gateway=None, *extra_routes):
|
40
|
40
|
if not address and gateway:
|
41
|
41
|
raise ValueError("You cannot define a gateway, but supply no address")
|
42
|
42
|
|
|
@@ -66,6 +66,16 @@ class ConfigDrive:
|
66
|
66
|
if gateway:
|
67
|
67
|
self._interfaces.append(" gateway %s" % str(ipaddress.ip_address(gateway)))
|
68
|
68
|
|
|
69
|
+ for routedef in extra_routes:
|
|
70
|
+ if "-" not in routedef:
|
|
71
|
+ raise ValueError("Route {} is missing a gateway separated by a -".format(routedef))
|
|
72
|
+ route, gw = routedef.split('-')
|
|
73
|
+ if "/" not in route:
|
|
74
|
+ raise ValueError("Route {} is not a subnet".format(route))
|
|
75
|
+ route = ipaddress.ip_interface(route)
|
|
76
|
+ gw = ipaddress.ip_address(gw)
|
|
77
|
+ self._interfaces.append(" up ip route add {} via {}".format(route, gw))
|
|
78
|
+
|
69
|
79
|
def conf_resolve(self, resolvers):
|
70
|
80
|
if not self._hostname:
|
71
|
81
|
raise ValueError("Please set a hostname before calling this function")
|
|
@@ -263,9 +273,11 @@ def main():
|
263
|
273
|
parser.add_argument("-o", "--output", required=True, help="Path to write iso to")
|
264
|
274
|
parser.add_argument("-n", "--nameservers", "--ns", default=["1.1.1.1", "8.8.8.8"], nargs="+", help="Nameservers")
|
265
|
275
|
parser.add_argument("-i", "--networks", "--net", default=[], nargs="+",
|
266
|
|
- help="Specify all networks, in format of interface[:address:[gateway]]. "
|
|
276
|
+ help="Specify all networks, in format of interface[:address[:gateway[:route-gateway[:...]]]]. "
|
267
|
277
|
"Both : and ; can be used as delimiter (but only one per net config). "
|
268
|
|
- "Address MUST be a network in CIDR notation")
|
|
278
|
+ "Address MUST be a network in CIDR notation. Additional "
|
|
279
|
+ "routes can be added in the form of cidr-gateway, e.g. "
|
|
280
|
+ "10.0.0.0/8-10.0.0.1")
|
269
|
281
|
parser.add_argument("-u", "--disable-upgrades", action="store_true", default=False)
|
270
|
282
|
parser.add_argument("-v", "--verbose", action="store_true", default=False)
|
271
|
283
|
parser.add_argument("--no-debian-cleanup", "--ndc", action="store_true", default=False)
|