From 50290b0e45429c207a5640979f3b0eee7aabfe20 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 1 Jul 2014 16:54:25 -0400 Subject: Add os-net-config CLI Adds a new CLI which parses the JSON and calls the configured provider to apply the configuration. --- os_net_config/__init__.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'os_net_config/__init__.py') diff --git a/os_net_config/__init__.py b/os_net_config/__init__.py index e2232e4..484863a 100644 --- a/os_net_config/__init__.py +++ b/os_net_config/__init__.py @@ -15,6 +15,8 @@ import pbr.version +from os_net_config import objects + __version__ = pbr.version.VersionInfo( 'os_net_config').version_string() @@ -26,16 +28,30 @@ class NotImplemented(Exception): class NetConfig(object): """Configure network interfaces using the ifcfg format.""" + def addObject(self, obj): + if isinstance(obj, objects.Interface): + self.addInterface(obj) + elif isinstance(obj, objects.Vlan): + self.addVlan(obj) + elif isinstance(obj, objects.OvsBridge): + self.addBridge(obj) + for member in obj.members: + self.addObject(member) + elif isinstance(obj, objects.OvsBond): + self.addBond(obj) + for member in obj.members: + self.addObject(member) + def addInterface(self, interface): raise NotImplemented("addInterface is not implemented.") - def addVlan(self, bridge): + def addVlan(self, vlan): raise NotImplemented("addVlan is not implemented.") def addBridge(self, bridge): raise NotImplemented("addBridge is not implemented.") - def addBond(self, bridge): + def addBond(self, bond): raise NotImplemented("addBond is not implemented.") def apply(self): -- cgit 1.2.3-korg