Remove IP proxy methods
Remove IP proxy methods in os_vif.internal.command.ip.__init__.py. Both Windows and Linux IP implementations have the same interface, IpCommand. Method calls (set, add, delete, exists) must be the same for both IP classes, making those proxy calls unnecessary. Removed a nesting level for internal IP commands. Now those commands are located in os_vif.internal.ip. Change-Id: Id8b71172fb06b435cf169a7e55c11233f22fa65b Closes-Bug: #1817940
This commit is contained in:
parent
67df883c60
commit
ee124d2e98
@ -1,37 +0,0 @@
|
||||
# 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
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from os_vif.internal.command.ip import api
|
||||
|
||||
|
||||
def set(device, check_exit_code=None, state=None, mtu=None, address=None,
|
||||
promisc=None, master=None):
|
||||
"""Method to set a parameter in an interface."""
|
||||
return api.ip.set(device, check_exit_code=check_exit_code, state=state,
|
||||
mtu=mtu, address=address, promisc=promisc, master=master)
|
||||
|
||||
|
||||
def add(device, dev_type, check_exit_code=None, peer=None, link=None,
|
||||
vlan_id=None):
|
||||
"""Method to add an interface."""
|
||||
return api.ip.add(device, dev_type, check_exit_code=check_exit_code,
|
||||
peer=peer, link=link, vlan_id=vlan_id)
|
||||
|
||||
|
||||
def delete(device, check_exit_code=None):
|
||||
"""Method to delete an interface."""
|
||||
return api.ip.delete(device, check_exit_code=check_exit_code)
|
||||
|
||||
|
||||
def exists(device):
|
||||
"""Method to check if an interface exists."""
|
||||
return api.ip.exists(device)
|
@ -15,10 +15,10 @@ import os
|
||||
from oslo_log import log as logging
|
||||
|
||||
if os.name == 'nt':
|
||||
from os_vif.internal.command.ip.windows.impl_netifaces import \
|
||||
from os_vif.internal.ip.windows.impl_netifaces import \
|
||||
Netifaces as ip_lib_class
|
||||
else:
|
||||
from os_vif.internal.command.ip.linux.impl_pyroute2 import \
|
||||
from os_vif.internal.ip.linux.impl_pyroute2 import \
|
||||
PyRoute2 as ip_lib_class
|
||||
|
||||
|
@ -17,7 +17,7 @@ from pyroute2.netlink import exceptions as ipexc
|
||||
from pyroute2.netlink.rtnl import ifinfmsg
|
||||
|
||||
from os_vif import exception
|
||||
from os_vif.internal.command.ip import ip_command
|
||||
from os_vif.internal.ip import ip_command
|
||||
from os_vif import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
@ -17,7 +17,7 @@ import netifaces
|
||||
from oslo_log import log as logging
|
||||
|
||||
from os_vif import exception
|
||||
from os_vif.internal.command.ip import ip_command
|
||||
from os_vif.internal.ip import ip_command
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -16,7 +16,7 @@ import re
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_utils import excutils
|
||||
|
||||
from os_vif.internal.command import ip as ip_lib
|
||||
from os_vif.internal.ip.api import ip as ip_lib
|
||||
from os_vif.tests.functional import base
|
||||
from os_vif.tests.functional import privsep
|
||||
|
||||
|
@ -16,7 +16,7 @@ from pyroute2.netlink import exceptions as ipexc
|
||||
from pyroute2.netlink.rtnl import ifinfmsg
|
||||
|
||||
from os_vif import exception
|
||||
from os_vif.internal.command.ip.linux import impl_pyroute2
|
||||
from os_vif.internal.ip.linux import impl_pyroute2
|
||||
from os_vif.tests.unit import base
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
import mock
|
||||
from six import moves
|
||||
|
||||
from os_vif.internal.command.ip import api
|
||||
from os_vif.internal.ip import api
|
||||
from os_vif.tests.unit import base
|
||||
|
||||
|
||||
@ -27,12 +27,12 @@ class TestIpApi(base.TestCase):
|
||||
self.addCleanup(self._reload_original_os_module)
|
||||
with mock.patch('os.name', 'nt'):
|
||||
moves.reload_module(api)
|
||||
from os_vif.internal.command.ip.windows import impl_netifaces
|
||||
from os_vif.internal.ip.windows import impl_netifaces
|
||||
self.assertIsInstance(api.ip, impl_netifaces.Netifaces)
|
||||
|
||||
def test_get_impl_linux(self):
|
||||
self.addCleanup(self._reload_original_os_module)
|
||||
with mock.patch('os.name', 'posix'):
|
||||
moves.reload_module(api)
|
||||
from os_vif.internal.command.ip.linux import impl_pyroute2
|
||||
from os_vif.internal.ip.linux import impl_pyroute2
|
||||
self.assertIsInstance(api.ip, impl_pyroute2.PyRoute2)
|
@ -13,7 +13,7 @@
|
||||
import mock
|
||||
import netifaces
|
||||
|
||||
from os_vif.internal.command.ip.windows import impl_netifaces as ip_lib
|
||||
from os_vif.internal.ip.windows import impl_netifaces as ip_lib
|
||||
from os_vif.tests.unit import base
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
import os
|
||||
|
||||
from os_vif.internal.command import ip as ip_lib
|
||||
from os_vif.internal.ip.api import ip as ip_lib
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_log import log as logging
|
||||
|
@ -14,7 +14,7 @@ import mock
|
||||
import testtools
|
||||
|
||||
import fixtures
|
||||
from os_vif.internal.command import ip as ip_lib
|
||||
from os_vif.internal.ip.api import ip as ip_lib
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
|
@ -24,7 +24,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from os_vif.internal.command import ip as ip_lib
|
||||
from os_vif.internal.ip.api import ip as ip_lib
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from os_vif.internal.command import ip as ip_lib
|
||||
from os_vif.internal.ip.api import ip as ip_lib
|
||||
from os_vif import objects
|
||||
from os_vif import plugin
|
||||
from oslo_config import cfg
|
||||
|
@ -15,7 +15,7 @@ import mock
|
||||
import os.path
|
||||
import testtools
|
||||
|
||||
from os_vif.internal.command import ip as ip_lib
|
||||
from os_vif.internal.ip.api import ip as ip_lib
|
||||
|
||||
from vif_plug_ovs import exception
|
||||
from vif_plug_ovs import linux_net
|
||||
|
@ -13,7 +13,7 @@
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
from os_vif.internal.command import ip as ip_lib
|
||||
from os_vif.internal.ip.api import ip as ip_lib
|
||||
from os_vif import objects
|
||||
from os_vif.objects import fields
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user