Set iface mode to manual when no address is specified
Also dhcp is allowed as address to enable dhcp mode
This commit is contained in:
parent
f01ed10db7
commit
b6a47783b6
|
@ -47,12 +47,16 @@ class ConfigDrive:
|
||||||
])
|
])
|
||||||
|
|
||||||
if address:
|
if address:
|
||||||
if "/" not in address:
|
if address == "dhcp":
|
||||||
raise ValueError("IP Interface is not a subnet")
|
address = None
|
||||||
|
method = "dhcp"
|
||||||
|
elif "/" in address:
|
||||||
address = ipaddress.ip_interface(address)
|
address = ipaddress.ip_interface(address)
|
||||||
method = "static"
|
method = "static"
|
||||||
else:
|
else:
|
||||||
method = "dhcp"
|
raise ValueError("IP Interface is not a subnet")
|
||||||
|
else:
|
||||||
|
method = "manual"
|
||||||
|
|
||||||
self._interfaces.extend([
|
self._interfaces.extend([
|
||||||
"",
|
"",
|
||||||
|
@ -275,8 +279,8 @@ def main():
|
||||||
parser.add_argument("-i", "--networks", "--net", default=[], nargs="+",
|
parser.add_argument("-i", "--networks", "--net", default=[], nargs="+",
|
||||||
help="Specify all networks, in format of interface[:address[:gateway[:route-gateway[:...]]]]. "
|
help="Specify all networks, in format of interface[:address[:gateway[:route-gateway[:...]]]]. "
|
||||||
"Both : and ; can be used as delimiter (but only one per net config). "
|
"Both : and ; can be used as delimiter (but only one per net config). "
|
||||||
"Address MUST be a network in CIDR notation. Additional "
|
"Address MUST be a network in CIDR notation or dhcp for DHCP mode. "
|
||||||
"routes can be added in the form of cidr-gateway, e.g. "
|
"Additional routes can be added in the form of cidr-gateway, e.g. "
|
||||||
"10.0.0.0/8-10.0.0.1")
|
"10.0.0.0/8-10.0.0.1")
|
||||||
parser.add_argument("-u", "--disable-upgrades", action="store_true", default=False)
|
parser.add_argument("-u", "--disable-upgrades", action="store_true", default=False)
|
||||||
parser.add_argument("-v", "--verbose", action="store_true", default=False)
|
parser.add_argument("-v", "--verbose", action="store_true", default=False)
|
||||||
|
|
Loading…
Reference in New Issue