From: Radek Pazdera <rpazdera(a)redhat.com>
This commit merges type_init() function with add_interface_config() and
type_cleanup() with remove_interface_config().
These functions had too dangerous preconditions, which was not very
obvious. The preconditions disappear after the merge.
Also an info entry will be written to the log when a device class is
initialized or cleaned up.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
NetConfig/NetConfig.py | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/NetConfig/NetConfig.py b/NetConfig/NetConfig.py
index 57903cd..6e97478 100644
--- a/NetConfig/NetConfig.py
+++ b/NetConfig/NetConfig.py
@@ -58,23 +58,24 @@ class NetConfig:
types.add(netdev["type"])
return types
- def _type_init(self, dev_type):
+ def add_interface_config(self, if_id, config):
+ dev_type = config["type"]
if not dev_type in self._get_used_types():
+ logging.info("Initializing '%s' device class", dev_type)
NetConfigDeviceType(dev_type).type_init()
- def _type_cleanup(self, dev_type):
- if not dev_type in self._get_used_types():
- NetConfigDeviceType(dev_type).type_cleanup()
-
- def add_interface_config(self, if_id, config):
- self._type_init(config["type"])
self._config[if_id] = config
self._devnames.assign_name(if_id, self._config)
def remove_interface_config(self, if_id):
config = self._config[if_id]
del self._config[if_id]
- self._type_cleanup(config["type"])
+ print self._config
+
+ dev_type = config["type"]
+ if not dev_type in self._get_used_types():
+ logging.info("Cleaning up '%s' device class.", dev_type)
+ NetConfigDeviceType(dev_type).type_cleanup()
def get_interface_config(self, if_id):
return self._config[if_id]
--
1.7.7.6
Show replies by date
From: Radek Pazdera <rpazdera(a)redhat.com>
I forgot to remove one more line in NetConfig in the previous cleanup
commit (2587cd9176895a27e13dc10558f1e00847edab05).
This commit fixes that.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
NetConfig/NetConfig.py | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/NetConfig/NetConfig.py b/NetConfig/NetConfig.py
index 6e97478..41a99d8 100644
--- a/NetConfig/NetConfig.py
+++ b/NetConfig/NetConfig.py
@@ -70,7 +70,6 @@ class NetConfig:
def remove_interface_config(self, if_id):
config = self._config[if_id]
del self._config[if_id]
- print self._config
dev_type = config["type"]
if not dev_type in self._get_used_types():
--
1.7.7.6