From a560b76c7b46f067637a79b01f923d377339a5c3 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Thu, 20 Feb 2014 18:28:29 +0200 Subject: model: allow different representation of choices in MF and PM --- acf2/modules/network.lua | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'acf2/modules/network.lua') diff --git a/acf2/modules/network.lua b/acf2/modules/network.lua index 32b9d20..186da13 100644 --- a/acf2/modules/network.lua +++ b/acf2/modules/network.lua @@ -46,8 +46,13 @@ M.defer(iface_aug_addr) local IPv4 = M.new() IPv4.method = M.String{ required=true, - default='manual', - choice={{'dhcp', 'DHCP'}, {'loopback', enabled=false}, 'manual', 'static'} + choice={ + {'dhcp', 'DHCP'}, + {'loopback', enabled=false}, + {'unconfigured', be_value='manual'}, + 'static' + }, + default='unconfigured' } IPv4.address = M.net.IPv4Address{ condition={method='static'}, required=true, cidr=true, mask_addr='netmask' @@ -58,8 +63,10 @@ IPv4.gateway = M.net.IPv4Address{condition={method='static'}} local IPv6 = M.new() IPv6.method = M.String{ required=true, - choice={{'loopback', enabled=false}, 'manual', 'static'}, - default='manual' + choice={ + {'loopback', enabled=false}, {'unconfigured', be_value='manual'}, 'static' + }, + default='unconfigured' } IPv6.address = M.net.IPv6Address{ condition={method='static'}, required=true, cidr=true, mask_addr='netmask' @@ -74,7 +81,7 @@ function Interface:validate() if self.status == 'attached' then for _, version in ipairs{4, 6} do self['ipv'..version].method = - self.class == 'loopback' and 'loopback' or 'manual' + self.class == 'loopback' and 'loopback' or 'unconfigured' end end end @@ -158,7 +165,7 @@ Interface.status = M.String{ end for _, version in ipairs{4, 6} do - if obj['ipv'..version].method ~= 'manual' then + if obj['ipv'..version].method ~= 'unconfigured' then return 'configured' end end @@ -262,7 +269,7 @@ return function(txn) if ifaces[name].class == 'logical' then ifaces[name] = nil else for _, version in ipairs{4, 6} do - ifaces[name]['ipv'..version].method = 'manual' + ifaces[name]['ipv'..version].method = 'unconfigured' end end end -- cgit v1.2.3