summaryrefslogtreecommitdiff
path: root/src/conf_mode/interface-loopback.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf_mode/interface-loopback.py')
-rwxr-xr-xsrc/conf_mode/interface-loopback.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/conf_mode/interface-loopback.py b/src/conf_mode/interface-loopback.py
index a1a807868..10722d137 100755
--- a/src/conf_mode/interface-loopback.py
+++ b/src/conf_mode/interface-loopback.py
@@ -13,9 +13,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-from os import environ
+import os
+
from sys import exit
from copy import deepcopy
@@ -38,7 +38,7 @@ def get_config():
# determine tagNode instance
try:
- loopback['intf'] = environ['VYOS_TAGNODE_VALUE']
+ loopback['intf'] = os.environ['VYOS_TAGNODE_VALUE']
except KeyError as E:
print("Interface not specified")
@@ -72,21 +72,20 @@ def generate(loopback):
return None
def apply(loopback):
- lo = LoopbackIf(loopback['intf'])
- if not loopback['deleted']:
+ l = LoopbackIf(loopback['intf'])
+ if loopback['deleted']:
+ l.remove()
+ else:
# update interface description used e.g. within SNMP
- # update interface description used e.g. within SNMP
- lo.ifalias = loopback['description']
+ l.set_alias(loopback['description'])
# Configure interface address(es)
# - not longer required addresses get removed first
# - newly addresses will be added second
+ for addr in loopback['address_remove']:
+ l.del_addr(addr)
for addr in loopback['address']:
- lo.add_addr(addr)
-
- # remove interface address(es)
- for addr in loopback['address_remove']:
- lo.del_addr(addr)
+ l.add_addr(addr)
return None