diff options
author | Frederic Lepied <frederic.lepied@enovance.com> | 2015-02-05 22:17:42 +0100 |
---|---|---|
committer | Frederic Lepied <frederic.lepied@redhat.com> | 2015-08-02 18:19:37 +0200 |
commit | 103b87aa82cfd298b664fe1314e987bd953ec20d (patch) | |
tree | e5691490fff33868291a6e8de946b8b8ac427ffe /os_net_config/impl_eni.py | |
parent | cb578ed9b94ff9a34b41d91ada94e3375436b60c (diff) |
Allow to specify the root directory of the filesystem
Change-Id: Ice1b8d17804cf7a0aafd308945a5e960fe927bbc
Diffstat (limited to 'os_net_config/impl_eni.py')
-rw-r--r-- | os_net_config/impl_eni.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/os_net_config/impl_eni.py b/os_net_config/impl_eni.py index 3115e04..7eb69f3 100644 --- a/os_net_config/impl_eni.py +++ b/os_net_config/impl_eni.py @@ -1,6 +1,6 @@ # -*- Coding: utf-8 -*- -# Copyright 2014 Red Hat, Inc. +# Copyright 2014-2015 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -26,8 +26,8 @@ logger = logging.getLogger(__name__) # TODO(?): should move to interfaces.d -def _network_config_path(): - return "/etc/network/interfaces" +def _network_config_path(prefix=''): + return prefix + "/etc/network/interfaces" class ENINetConfig(os_net_config.NetConfig): @@ -37,8 +37,8 @@ class ENINetConfig(os_net_config.NetConfig): /etc/network/interfaces format. """ - def __init__(self, noop=False): - super(ENINetConfig, self).__init__(noop) + def __init__(self, noop=False, root_dir=''): + super(ENINetConfig, self).__init__(noop, root_dir) self.interfaces = {} self.routes = {} self.bridges = {} @@ -214,7 +214,7 @@ class ENINetConfig(os_net_config.NetConfig): iface_data += (route_data or '') new_config += iface_data - if (utils.diff(_network_config_path(), new_config)): + if utils.diff(_network_config_path(self.root_dir), new_config): if activate: for interface in self.interfaces.keys(): self.ifdown(interface) @@ -222,7 +222,7 @@ class ENINetConfig(os_net_config.NetConfig): for bridge in self.bridges.keys(): self.ifdown(bridge, iftype='bridge') - self.write_config(_network_config_path(), new_config) + self.write_config(_network_config_path(self.root_dir), new_config) if activate: for bridge in self.bridges.keys(): @@ -233,4 +233,4 @@ class ENINetConfig(os_net_config.NetConfig): else: logger.info('No interface changes are required.') - return {"/etc/network/interfaces": new_config} + return {_network_config_path(self.root_dir): new_config} |