mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-11-02 19:02:31 +00:00
feat(oci): VLAN tag and updates that keep Proxmox changes
This commit is contained in:
@@ -42,8 +42,9 @@ def environment(config):
|
||||
entries.extend(line.split(': ', 1)[1].split('\0'))
|
||||
for entry in entries:
|
||||
name, sep, value = entry.partition('=')
|
||||
if not sep or name in result:
|
||||
if not sep:
|
||||
raise ValueError(translate('Duplicate variable in the contract; review it before editing'))
|
||||
# A variable set twice takes its last value, as it does in LXC.
|
||||
result[name] = value
|
||||
return result
|
||||
|
||||
@@ -129,7 +130,7 @@ def plan(record, candidate, config):
|
||||
values[native] = str(value)
|
||||
if 'network' in changed:
|
||||
network = new['network']
|
||||
if set(network) - {'bridge', 'ipv4', 'gateway', 'firewall', 'host_managed', 'mac_address'}:
|
||||
if set(network) - {'bridge', 'ipv4', 'gateway', 'firewall', 'host_managed', 'mac_address', 'vlan_tag'}:
|
||||
raise ValueError(translate('Unsupported network settings'))
|
||||
if not re.fullmatch(r'[A-Za-z0-9_.:-]+', network['bridge']):
|
||||
raise ValueError(translate('Invalid bridge'))
|
||||
@@ -146,6 +147,11 @@ def plan(record, candidate, config):
|
||||
fields.update(bridge=network['bridge'], ip=address)
|
||||
if gateway: fields['gw'] = gateway
|
||||
else: fields.pop('gw', None)
|
||||
vlan_tag = network.get('vlan_tag')
|
||||
if vlan_tag is not None and (isinstance(vlan_tag, bool) or not isinstance(vlan_tag, int) or not 1 <= vlan_tag <= 4094):
|
||||
raise ValueError(translate('The VLAN tag must be a number from 1 to 4094'))
|
||||
if vlan_tag: fields['tag'] = str(vlan_tag)
|
||||
elif 'vlan_tag' in old['network']: fields.pop('tag', None)
|
||||
for key, native in (('firewall', 'firewall'), ('host_managed', 'host-managed')):
|
||||
if old['network'].get(key) != network.get(key):
|
||||
fields[native] = '1' if network.get(key) else '0'
|
||||
|
||||
Reference in New Issue
Block a user