diff options
author | Dan Prince <dprince@redhat.com> | 2014-08-14 10:28:49 -0400 |
---|---|---|
committer | Dan Prince <dprince@redhat.com> | 2014-08-14 10:28:49 -0400 |
commit | 9e515950c7eb4a73e02a4f4883c223dd24ba93ff (patch) | |
tree | 5d4a8212b8fd41928ad66f373f769ede2b2d7b07 /os_net_config | |
parent | f0ae3282450c2bb1bb35f22414858768f08d2653 (diff) |
Use underscores for provider function names.
Diffstat (limited to 'os_net_config')
-rw-r--r-- | os_net_config/__init__.py | 30 | ||||
-rw-r--r-- | os_net_config/impl_eni.py | 26 | ||||
-rw-r--r-- | os_net_config/impl_ifcfg.py | 28 | ||||
-rw-r--r-- | os_net_config/tests/test_impl_eni.py | 34 | ||||
-rw-r--r-- | os_net_config/tests/test_impl_ifcfg.py | 40 |
5 files changed, 79 insertions, 79 deletions
diff --git a/os_net_config/__init__.py b/os_net_config/__init__.py index a3ea278..bd28bbc 100644 --- a/os_net_config/__init__.py +++ b/os_net_config/__init__.py @@ -30,31 +30,31 @@ class NotImplemented(Exception): class NetConfig(object): """Configure network interfaces using the ifcfg format.""" - def addObject(self, obj): + def add_object(self, obj): if isinstance(obj, objects.Interface): - self.addInterface(obj) + self.add_interface(obj) elif isinstance(obj, objects.Vlan): - self.addVlan(obj) + self.add_vlan(obj) elif isinstance(obj, objects.OvsBridge): - self.addBridge(obj) + self.add_bridge(obj) for member in obj.members: - self.addObject(member) + self.add_object(member) elif isinstance(obj, objects.OvsBond): - self.addBond(obj) + self.add_bond(obj) for member in obj.members: - self.addObject(member) + self.add_object(member) - def addInterface(self, interface): - raise NotImplemented("addInterface is not implemented.") + def add_interface(self, interface): + raise NotImplemented("add_interface is not implemented.") - def addVlan(self, vlan): - raise NotImplemented("addVlan is not implemented.") + def add_vlan(self, vlan): + raise NotImplemented("add_vlan is not implemented.") - def addBridge(self, bridge): - raise NotImplemented("addBridge is not implemented.") + def add_bridge(self, bridge): + raise NotImplemented("add_bridge is not implemented.") - def addBond(self, bond): - raise NotImplemented("addBond is not implemented.") + def add_bond(self, bond): + raise NotImplemented("add_bond is not implemented.") def apply(self, noop=False): """Apply the network configuration. diff --git a/os_net_config/impl_eni.py b/os_net_config/impl_eni.py index b4a64e0..cf09ff3 100644 --- a/os_net_config/impl_eni.py +++ b/os_net_config/impl_eni.py @@ -45,7 +45,7 @@ class ENINetConfig(os_net_config.NetConfig): self.bridges = {} logger.info('Ifcfg net config provider created.') - def _addCommon(self, interface, static_addr=None): + def _add_common(self, interface, static_addr=None): data = "" address_data = "" @@ -55,11 +55,11 @@ class ENINetConfig(os_net_config.NetConfig): else: v4_addresses = interface.v4_addresses() if v4_addresses: - data += self._addCommon(interface, v4_addresses[0]) + data += self._add_common(interface, v4_addresses[0]) v6_addresses = interface.v6_addresses() if v6_addresses: - data += self._addCommon(interface, v6_addresses[0]) + data += self._add_common(interface, v6_addresses[0]) if data: return data @@ -128,31 +128,31 @@ class ENINetConfig(os_net_config.NetConfig): data += " mtu %i\n" % interface.mtu return data - def addInterface(self, interface): + def add_interface(self, interface): logger.info('adding interface: %s' % interface.name) - data = self._addCommon(interface) + data = self._add_common(interface) logger.debug('interface data: %s' % data) self.interfaces[interface.name] = data if interface.routes: - self._addRoutes(interface.name, interface.routes) + self._add_routes(interface.name, interface.routes) - def addBridge(self, bridge): + def add_bridge(self, bridge): logger.info('adding bridge: %s' % bridge.name) - data = self._addCommon(bridge) + data = self._add_common(bridge) logger.debug('bridge data: %s' % data) self.bridges[bridge.name] = data if bridge.routes: - self._addRoutes(bridge.name, bridge.routes) + self._add_routes(bridge.name, bridge.routes) - def addVlan(self, vlan): + def add_vlan(self, vlan): logger.info('adding vlan: %s' % vlan.name) - data = self._addCommon(vlan) + data = self._add_common(vlan) logger.debug('vlan data: %s' % data) self.interfaces[vlan.name] = data if vlan.routes: - self._addRoutes(vlan.name, vlan.routes) + self._add_routes(vlan.name, vlan.routes) - def _addRoutes(self, interface_name, routes=[]): + def _add_routes(self, interface_name, routes=[]): logger.info('adding custom route for interface: %s' % interface_name) data = "" for route in routes: diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 0904943..bd1cf22 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -49,7 +49,7 @@ class IfcfgNetConfig(os_net_config.NetConfig): self.bridges = {} logger.info('Ifcfg net config provider created.') - def _addCommon(self, base_opt): + def _add_common(self, base_opt): data = "DEVICE=%s\n" % base_opt.name data += "ONBOOT=yes\n" data += "HOTPLUG=no\n" @@ -119,7 +119,7 @@ class IfcfgNetConfig(os_net_config.NetConfig): data += "IPV6ADDR=%s\n" % first_v6.ip return data - def _addRoutes(self, interface_name, routes=[]): + def _add_routes(self, interface_name, routes=[]): logger.info('adding custom route for interface: %s' % interface_name) data = "" first_line = "" @@ -134,37 +134,37 @@ class IfcfgNetConfig(os_net_config.NetConfig): self.routes[interface_name] = first_line + data logger.debug('route data: %s' % self.routes[interface_name]) - def addInterface(self, interface): + def add_interface(self, interface): logger.info('adding interface: %s' % interface.name) - data = self._addCommon(interface) + data = self._add_common(interface) logger.debug('interface data: %s' % data) self.interfaces[interface.name] = data if interface.routes: - self._addRoutes(interface.name, interface.routes) + self._add_routes(interface.name, interface.routes) - def addVlan(self, vlan): + def add_vlan(self, vlan): logger.info('adding vlan: %s' % vlan.name) - data = self._addCommon(vlan) + data = self._add_common(vlan) logger.debug('vlan data: %s' % data) self.interfaces[vlan.name] = data if vlan.routes: - self._addRoutes(vlan.name, vlan.routes) + self._add_routes(vlan.name, vlan.routes) - def addBridge(self, bridge): + def add_bridge(self, bridge): logger.info('adding bridge: %s' % bridge.name) - data = self._addCommon(bridge) + data = self._add_common(bridge) logger.debug('bridge data: %s' % data) self.bridges[bridge.name] = data if bridge.routes: - self._addRoutes(bridge.name, bridge.routes) + self._add_routes(bridge.name, bridge.routes) - def addBond(self, bond): + def add_bond(self, bond): logger.info('adding bond: %s' % bond.name) - data = self._addCommon(bond) + data = self._add_common(bond) logger.debug('bond data: %s' % data) self.interfaces[bond.name] = data if bond.routes: - self._addRoutes(bond.name, bond.routes) + self._add_routes(bond.name, bond.routes) def apply(self, noop=False): """Apply the network configuration. diff --git a/os_net_config/tests/test_impl_eni.py b/os_net_config/tests/test_impl_eni.py index 55502b3..a7fba6f 100644 --- a/os_net_config/tests/test_impl_eni.py +++ b/os_net_config/tests/test_impl_eni.py @@ -96,32 +96,32 @@ class TestENINetConfig(base.TestCase): def test_interface_no_ip(self): interface = self._default_interface() - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_v4_IFACE_NO_IP, self.get_interface_config()) def test_add_interface_with_v4(self): v4_addr = objects.Address('192.168.1.2/24') interface = self._default_interface([v4_addr]) - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_V4_IFACE_STATIC_IP, self.get_interface_config()) def test_add_interface_with_v6(self): v6_addr = objects.Address('fe80::2677:3ff:fe7d:4c') interface = self._default_interface([v6_addr]) - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_V6_IFACE_STATIC_IP, self.get_interface_config()) def test_add_interface_dhcp(self): interface = self._default_interface() interface.use_dhcp = True - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_IFACE_DHCP, self.get_interface_config()) def test_add_interface_with_both_v4_and_v6(self): v4_addr = objects.Address('192.168.1.2/24') v6_addr = objects.Address('fe80::2677:3ff:fe7d:4c') interface = self._default_interface([v4_addr, v6_addr]) - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_V4_IFACE_STATIC_IP + _V6_IFACE_STATIC_IP, self.get_interface_config()) @@ -129,14 +129,14 @@ class TestENINetConfig(base.TestCase): interface = self._default_interface() interface.ovs_port = True interface.bridge_name = 'br0' - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_OVS_PORT_IFACE, self.get_interface_config()) def test_network_with_routes(self): route1 = objects.Route('192.168.1.1', '172.19.0.0/24') v4_addr = objects.Address('192.168.1.2/24') interface = self._default_interface([v4_addr], [route1]) - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_V4_IFACE_STATIC_IP, self.get_interface_config()) self.assertEqual(_RTS, self.get_route_config()) @@ -144,8 +144,8 @@ class TestENINetConfig(base.TestCase): interface = self._default_interface() bridge = objects.OvsBridge('br0', use_dhcp=True, members=[interface]) - self.provider.addBridge(bridge) - self.provider.addInterface(interface) + self.provider.add_bridge(bridge) + self.provider.add_interface(interface) self.assertEqual(_OVS_PORT_IFACE, self.get_interface_config()) self.assertEqual(_OVS_BRIDGE_DHCP, self.provider.bridges['br0']) @@ -158,23 +158,23 @@ class TestENINetConfig(base.TestCase): interface = objects.Interface(self.if_name, primary=True) bridge = objects.OvsBridge('br0', use_dhcp=True, members=[interface]) - self.provider.addBridge(bridge) - self.provider.addInterface(interface) + self.provider.add_bridge(bridge) + self.provider.add_interface(interface) self.assertEqual(_OVS_PORT_IFACE, self.get_interface_config()) self.assertEqual(_OVS_BRIDGE_DHCP_PRIMARY_INTERFACE, self.provider.bridges['br0']) def test_vlan(self): vlan = objects.Vlan('eth0', 5) - self.provider.addVlan(vlan) + self.provider.add_vlan(vlan) self.assertEqual(_VLAN_NO_IP, self.get_interface_config('vlan5')) def test_vlan_ovs_bridge_int_port(self): vlan = objects.Vlan('eth0', 5) bridge = objects.OvsBridge('br0', use_dhcp=True, members=[vlan]) - self.provider.addBridge(bridge) - self.provider.addVlan(vlan) + self.provider.add_bridge(bridge) + self.provider.add_vlan(vlan) self.assertEqual(_VLAN_OVS_PORT, self.get_interface_config('vlan5')) @@ -203,7 +203,7 @@ class TestENINetConfigApply(base.TestCase): v4_addr = objects.Address('192.168.1.2/24') interface = objects.Interface('eth0', addresses=[v4_addr], routes=[route]) - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.provider.apply() iface_data = utils.get_file_data(self.temp_config_file.name) @@ -213,8 +213,8 @@ class TestENINetConfigApply(base.TestCase): interface = objects.Interface('eth0') bridge = objects.OvsBridge('br0', use_dhcp=True, members=[interface]) - self.provider.addInterface(interface) - self.provider.addBridge(bridge) + self.provider.add_interface(interface) + self.provider.add_bridge(bridge) self.provider.apply() iface_data = utils.get_file_data(self.temp_config_file.name) self.assertEqual((_OVS_BRIDGE_DHCP + _OVS_PORT_IFACE), iface_data) diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index 2157cd0..aee34d3 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -118,26 +118,26 @@ class TestIfcfgNetConfig(base.TestCase): def test_add_base_interface(self): interface = objects.Interface('em1') - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_NO_IP, self.get_interface_config()) def test_add_ovs_interface(self): interface = objects.Interface('em1') interface.ovs_port = True - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_OVS_IFCFG, self.get_interface_config()) def test_add_interface_with_v4(self): v4_addr = objects.Address('192.168.1.2/24') interface = objects.Interface('em1', addresses=[v4_addr]) - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_V4_IFCFG, self.get_interface_config()) self.assertEqual('', self.get_route_config()) def test_add_interface_with_v6(self): v6_addr = objects.Address('2001:abc:a::/64') interface = objects.Interface('em1', addresses=[v6_addr]) - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_V6_IFCFG, self.get_interface_config()) def test_network_with_routes(self): @@ -146,7 +146,7 @@ class TestIfcfgNetConfig(base.TestCase): v4_addr = objects.Address('192.168.1.2/24') interface = objects.Interface('em1', addresses=[v4_addr], routes=[route1, route2]) - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.assertEqual(_V4_IFCFG, self.get_interface_config()) self.assertEqual(_ROUTES, self.get_route_config()) @@ -154,8 +154,8 @@ class TestIfcfgNetConfig(base.TestCase): interface = objects.Interface('em1') bridge = objects.OvsBridge('br-ctlplane', use_dhcp=True, members=[interface]) - self.provider.addInterface(interface) - self.provider.addBridge(bridge) + self.provider.add_interface(interface) + self.provider.add_bridge(bridge) self.assertEqual(_OVS_INTERFACE, self.get_interface_config()) self.assertEqual(_OVS_BRIDGE_DHCP, self.provider.bridges['br-ctlplane']) @@ -168,29 +168,29 @@ class TestIfcfgNetConfig(base.TestCase): interface = objects.Interface('em1', primary=True) bridge = objects.OvsBridge('br-ctlplane', use_dhcp=True, members=[interface]) - self.provider.addInterface(interface) - self.provider.addBridge(bridge) + self.provider.add_interface(interface) + self.provider.add_bridge(bridge) self.assertEqual(_OVS_INTERFACE, self.get_interface_config()) self.assertEqual(_OVS_BRIDGE_DHCP_PRIMARY_INTERFACE, self.provider.bridges['br-ctlplane']) def test_add_vlan(self): vlan = objects.Vlan('em1', 5) - self.provider.addVlan(vlan) + self.provider.add_vlan(vlan) self.assertEqual(_VLAN_NO_IP, self.get_interface_config('vlan5')) def test_add_vlan_ovs(self): vlan = objects.Vlan('em1', 5) vlan.ovs_port = True - self.provider.addVlan(vlan) + self.provider.add_vlan(vlan) self.assertEqual(_VLAN_OVS, self.get_interface_config('vlan5')) def test_add_ovs_bridge_with_vlan(self): vlan = objects.Vlan('em1', 5) bridge = objects.OvsBridge('br-ctlplane', use_dhcp=True, members=[vlan]) - self.provider.addVlan(vlan) - self.provider.addBridge(bridge) + self.provider.add_vlan(vlan) + self.provider.add_bridge(bridge) self.assertEqual(_VLAN_OVS_BRIDGE, self.get_interface_config('vlan5')) def test_ovs_bond(self): @@ -198,9 +198,9 @@ class TestIfcfgNetConfig(base.TestCase): interface2 = objects.Interface('em2') bond = objects.OvsBond('bond0', use_dhcp=True, members=[interface1, interface2]) - self.provider.addInterface(interface1) - self.provider.addInterface(interface2) - self.provider.addBond(bond) + self.provider.add_interface(interface1) + self.provider.add_interface(interface2) + self.provider.add_bond(bond) self.assertEqual(_NO_IP, self.get_interface_config('em1')) em2_config = """DEVICE=em2 @@ -251,7 +251,7 @@ class TestIfcfgNetConfigApply(base.TestCase): v4_addr = objects.Address('192.168.1.2/24') interface = objects.Interface('em1', addresses=[v4_addr], routes=[route1, route2]) - self.provider.addInterface(interface) + self.provider.add_interface(interface) self.provider.apply() @@ -264,8 +264,8 @@ class TestIfcfgNetConfigApply(base.TestCase): interface = objects.Interface('em1') bridge = objects.OvsBridge('br-ctlplane', use_dhcp=True, members=[interface]) - self.provider.addInterface(interface) - self.provider.addBridge(bridge) + self.provider.add_interface(interface) + self.provider.add_bridge(bridge) self.provider.apply() ifcfg_data = utils.get_file_data(self.temp_ifcfg_file.name) @@ -277,7 +277,7 @@ class TestIfcfgNetConfigApply(base.TestCase): def test_vlan_apply(self): vlan = objects.Vlan('em1', 5) - self.provider.addVlan(vlan) + self.provider.add_vlan(vlan) self.provider.apply() ifcfg_data = utils.get_file_data(self.temp_ifcfg_file.name) |