mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-08 04:36:21 +00:00
python: Various fixes to the python scripts
This fixes a few issues uncovered by the recent C module fix. In lxc-start-ephemeral, the hwaddr code wasn't actually working. Replace by code that properly iterates through the network interfaces and sets a new MAC address for each entry. In the python overlay, catch the newly emitted KeyError when in set_config_item (or setting any previously unset variable would fail). Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
2ebec36f27
commit
6c5db2af1f
@ -134,7 +134,9 @@ dest = lxc.Container(os.path.basename(dest_path), args.lxcpath)
|
|||||||
dest.load_config(orig.config_file_name)
|
dest.load_config(orig.config_file_name)
|
||||||
dest.set_config_item("lxc.utsname", dest.name)
|
dest.set_config_item("lxc.utsname", dest.name)
|
||||||
dest.set_config_item("lxc.rootfs", os.path.join(dest_path, "rootfs"))
|
dest.set_config_item("lxc.rootfs", os.path.join(dest_path, "rootfs"))
|
||||||
dest.set_config_item("lxc.network.hwaddr", randomMAC())
|
for nic in dest.network:
|
||||||
|
if hasattr(nic, 'hwaddr'):
|
||||||
|
nic.hwaddr = randomMAC()
|
||||||
|
|
||||||
overlay_dirs = [(orig.get_config_item("lxc.rootfs"), "%s/rootfs/" % dest_path)]
|
overlay_dirs = [(orig.get_config_item("lxc.rootfs"), "%s/rootfs/" % dest_path)]
|
||||||
|
|
||||||
|
@ -412,7 +412,10 @@ class Container(_lxc.Container):
|
|||||||
Set a config key to a provided value.
|
Set a config key to a provided value.
|
||||||
The value can be a list for the keys supporting multiple values.
|
The value can be a list for the keys supporting multiple values.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
old_value = self.get_config_item(key)
|
old_value = self.get_config_item(key)
|
||||||
|
except KeyError:
|
||||||
|
old_value = None
|
||||||
|
|
||||||
# Check if it's a list
|
# Check if it's a list
|
||||||
def set_key(key, value):
|
def set_key(key, value):
|
||||||
|
Loading…
Reference in New Issue
Block a user