Remove neutronclient from shade's dependencies

All calls to Neutron API are now done with REST calls made
via keystoneauth1.
Shade don't require python-neutronclient package for now.

Change-Id: I0aa6f32b10986e99d6f86cad9640d9d95b5d2cef
This commit is contained in:
Sławek Kapłoński 2017-05-07 22:15:15 +00:00
parent e00ff9c719
commit 81239f6742
4 changed files with 136 additions and 156 deletions

View File

@ -19,7 +19,6 @@ for lib in \
python-novaclient \
python-keystoneclient \
python-cinderclient \
python-neutronclient \
python-ironicclient \
python-designateclient \
keystoneauth

View File

@ -25,7 +25,6 @@ netifaces>=0.10.4 # MIT
python-novaclient>=7.1.0 # Apache-2.0
python-keystoneclient>=3.8.0 # Apache-2.0
python-cinderclient>=2.0.1 # Apache-2.0
python-neutronclient>=5.1.0 # Apache-2.0
python-ironicclient>=1.11.0 # Apache-2.0
python-designateclient>=1.5.0 # Apache-2.0

View File

@ -25,7 +25,6 @@ import sys
import time
from decorator import decorator
from neutronclient.common import exceptions as neutron_exc
from novaclient import exceptions as nova_exc
from shade import _log
@ -417,25 +416,6 @@ def cache_on_arguments(*cache_on_args, **cache_on_kwargs):
return _inner_cache_on_arguments
@contextlib.contextmanager
def neutron_exceptions(error_message):
try:
yield
except neutron_exc.NotFound as e:
raise exc.OpenStackCloudResourceNotFound(
"{msg}: {exc}".format(msg=error_message, exc=str(e)))
except neutron_exc.NeutronClientException as e:
if e.status_code == 404:
raise exc.OpenStackCloudURINotFound(
"{msg}: {exc}".format(msg=error_message, exc=str(e)))
else:
raise exc.OpenStackCloudException(
"{msg}: {exc}".format(msg=error_message, exc=str(e)))
except Exception as e:
raise exc.OpenStackCloudException(
"{msg}: {exc}".format(msg=error_message, exc=str(e)))
@contextlib.contextmanager
def shade_exceptions(error_message=None):
"""Context manager for dealing with shade exceptions.

View File

@ -1212,6 +1212,17 @@ class OpenStackCloud(_normalize.Normalizer):
@property
def neutron_client(self):
warnings.warn(
'Using shade to get a neutron_client object is deprecated. If you'
' need a raw neutronclient.Client object, please use'
' make_legacy_client in os-client-config instead')
try:
import neutronclient # flake8: noqa
except ImportError:
self.log.error(
'neutronclient is no longer a dependency of shade. You need to'
' install python-neutronclient directly.')
raise
if self._neutron_client is None:
self._neutron_client = self._get_client('network')
return self._neutron_client
@ -4475,7 +4486,6 @@ class OpenStackCloud(_normalize.Normalizer):
# tenant. This is the default behaviour of Nova
project_id = self.current_project_id
with _utils.neutron_exceptions("unable to get available floating IPs"):
if network:
if isinstance(network, six.string_types):
network = [network]
@ -4624,9 +4634,7 @@ class OpenStackCloud(_normalize.Normalizer):
fixed_address=None, nat_destination=None,
port=None,
wait=False, timeout=60, network_id=None):
with _utils.neutron_exceptions(
"unable to create floating IP for net "
"{0}".format(network_name_or_id)):
if not network_id:
if network_name_or_id:
network = self.get_network(network_name_or_id)
@ -4982,9 +4990,6 @@ class OpenStackCloud(_normalize.Normalizer):
def _neutron_attach_ip_to_server(
self, server, floating_ip, fixed_address=None,
nat_destination=None):
with _utils.neutron_exceptions(
"unable to bind a floating ip to server "
"{0}".format(server['id'])):
# Find an available port
(port, fixed_address) = self._nat_destination_port(
@ -5043,9 +5048,6 @@ class OpenStackCloud(_normalize.Normalizer):
server_id=server_id, floating_ip_id=floating_ip_id)
def _neutron_detach_ip_from_server(self, server_id, floating_ip_id):
with _utils.neutron_exceptions(
"unable to detach a floating ip from server "
"{0}".format(server_id)):
f_ip = self.get_floating_ip(id=floating_ip_id)
if f_ip is None or not f_ip['attached']:
return False