aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os_net_config/__init__.py21
-rw-r--r--os_net_config/impl_eni.py12
-rw-r--r--os_net_config/impl_ifcfg.py16
3 files changed, 49 insertions, 0 deletions
diff --git a/os_net_config/__init__.py b/os_net_config/__init__.py
index 9e451f2..30baac1 100644
--- a/os_net_config/__init__.py
+++ b/os_net_config/__init__.py
@@ -31,6 +31,11 @@ class NetConfig(object):
"""Configure network interfaces using the ifcfg format."""
def add_object(self, obj):
+ """Convenience method to add any type of object to the network config.
+ See objects.py.
+
+ :param obj: The object to add.
+ """
if isinstance(obj, objects.Interface):
self.add_interface(obj)
elif isinstance(obj, objects.Vlan):
@@ -45,15 +50,31 @@ class NetConfig(object):
self.add_object(member)
def add_interface(self, interface):
+ """Add an Interface object to the net config object.
+
+ :param interface: The Interface object to add.
+ """
raise NotImplemented("add_interface is not implemented.")
def add_vlan(self, vlan):
+ """Add a Vlan object to the net config object.
+
+ :param vlan: The vlan object to add.
+ """
raise NotImplemented("add_vlan is not implemented.")
def add_bridge(self, bridge):
+ """Add an OvsBridge object to the net config object.
+
+ :param bridge: The OvsBridge object to add.
+ """
raise NotImplemented("add_bridge is not implemented.")
def add_bond(self, bond):
+ """Add an OvsBond object to the net config object.
+
+ :param bridge: The OvsBond object to add.
+ """
raise NotImplemented("add_bond is not implemented.")
def apply(self, noop=False, cleanup=False):
diff --git a/os_net_config/impl_eni.py b/os_net_config/impl_eni.py
index 2a2e4e1..0553b2f 100644
--- a/os_net_config/impl_eni.py
+++ b/os_net_config/impl_eni.py
@@ -129,6 +129,10 @@ class ENINetConfig(os_net_config.NetConfig):
return data
def add_interface(self, interface):
+ """Add an Interface object to the net config object.
+
+ :param interface: The Interface object to add.
+ """
logger.info('adding interface: %s' % interface.name)
data = self._add_common(interface)
logger.debug('interface data: %s' % data)
@@ -137,6 +141,10 @@ class ENINetConfig(os_net_config.NetConfig):
self._add_routes(interface.name, interface.routes)
def add_bridge(self, bridge):
+ """Add an OvsBridge object to the net config object.
+
+ :param bridge: The OvsBridge object to add.
+ """
logger.info('adding bridge: %s' % bridge.name)
data = self._add_common(bridge)
logger.debug('bridge data: %s' % data)
@@ -145,6 +153,10 @@ class ENINetConfig(os_net_config.NetConfig):
self._add_routes(bridge.name, bridge.routes)
def add_vlan(self, vlan):
+ """Add a Vlan object to the net config object.
+
+ :param vlan: The vlan object to add.
+ """
logger.info('adding vlan: %s' % vlan.name)
data = self._add_common(vlan)
logger.debug('vlan data: %s' % data)
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index 4125017..aa69cb4 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -141,6 +141,10 @@ class IfcfgNetConfig(os_net_config.NetConfig):
logger.debug('route data: %s' % self.routes[interface_name])
def add_interface(self, interface):
+ """Add an Interface object to the net config object.
+
+ :param interface: The Interface object to add.
+ """
logger.info('adding interface: %s' % interface.name)
data = self._add_common(interface)
logger.debug('interface data: %s' % data)
@@ -149,6 +153,10 @@ class IfcfgNetConfig(os_net_config.NetConfig):
self._add_routes(interface.name, interface.routes)
def add_vlan(self, vlan):
+ """Add a Vlan object to the net config object.
+
+ :param vlan: The vlan object to add.
+ """
logger.info('adding vlan: %s' % vlan.name)
data = self._add_common(vlan)
logger.debug('vlan data: %s' % data)
@@ -157,6 +165,10 @@ class IfcfgNetConfig(os_net_config.NetConfig):
self._add_routes(vlan.name, vlan.routes)
def add_bridge(self, bridge):
+ """Add an OvsBridge object to the net config object.
+
+ :param bridge: The OvsBridge object to add.
+ """
logger.info('adding bridge: %s' % bridge.name)
data = self._add_common(bridge)
logger.debug('bridge data: %s' % data)
@@ -165,6 +177,10 @@ class IfcfgNetConfig(os_net_config.NetConfig):
self._add_routes(bridge.name, bridge.routes)
def add_bond(self, bond):
+ """Add an OvsBond object to the net config object.
+
+ :param bridge: The OvsBond object to add.
+ """
logger.info('adding bond: %s' % bond.name)
data = self._add_common(bond)
logger.debug('bond data: %s' % data)