Browse Source

Set iface mode to manual when no address is specified

Also dhcp is allowed as address to enable dhcp mode
Sebastian Lohff 2 years ago
parent
commit
b6a47783b6
1 changed files with 10 additions and 6 deletions
  1. 10
    6
      genconfdrv/genconfdrv.py

+ 10
- 6
genconfdrv/genconfdrv.py View File

@@ -47,12 +47,16 @@ class ConfigDrive:
47 47
             ])
48 48
 
49 49
         if address:
50
-            if "/" not in address:
50
+            if address == "dhcp":
51
+                address = None
52
+                method = "dhcp"
53
+            elif "/" in address:
54
+                address = ipaddress.ip_interface(address)
55
+                method = "static"
56
+            else:
51 57
                 raise ValueError("IP Interface is not a subnet")
52
-            address = ipaddress.ip_interface(address)
53
-            method = "static"
54 58
         else:
55
-            method = "dhcp"
59
+            method = "manual"
56 60
 
57 61
         self._interfaces.extend([
58 62
             "",
@@ -275,8 +279,8 @@ def main():
275 279
     parser.add_argument("-i", "--networks", "--net", default=[], nargs="+",
276 280
                         help="Specify all networks, in format of interface[:address[:gateway[:route-gateway[:...]]]]. "
277 281
                              "Both : and ; can be used as delimiter (but only one per net config). "
278
-                             "Address MUST be a network in CIDR notation. Additional "
279
-                             "routes can be added in the form of cidr-gateway, e.g. "
282
+                             "Address MUST be a network in CIDR notation or dhcp for DHCP mode. "
283
+                             "Additional routes can be added in the form of cidr-gateway, e.g. "
280 284
                              "10.0.0.0/8-10.0.0.1")
281 285
     parser.add_argument("-u", "--disable-upgrades", action="store_true", default=False)
282 286
     parser.add_argument("-v", "--verbose", action="store_true", default=False)

Loading…
Cancel
Save