From fcc108626bca5feefe276fc3f5a94c1740e3b8f2 Mon Sep 17 00:00:00 2001 From: Adam Gandelman Date: Thu, 15 Jan 2015 15:02:12 -0800 Subject: [PATCH] Create a neutron client Creates a neutron_client property using token and endpoint from keystone session. Change-Id: I07199a272969c53610347f3ff05e60b0b3b8d317 --- requirements.txt | 2 +- shade/__init__.py | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 66116f3ba..10fd9c9cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ python-novaclient python-keystoneclient>=0.11.0 python-glanceclient python-cinderclient -python-neutronclient +python-neutronclient>=2.3.10 python-troveclient python-ironicclient python-swiftclient diff --git a/shade/__init__.py b/shade/__init__.py index a64018a1c..d08b77523 100644 --- a/shade/__init__.py +++ b/shade/__init__.py @@ -25,6 +25,7 @@ from keystoneclient import auth as ksc_auth from keystoneclient import session as ksc_session from novaclient import client as nova_client from novaclient.v1_1 import floating_ips +from neutronclient.v2_0 import client as neutron_client import os_client_config import pbr.version import swiftclient.client as swift_client @@ -138,13 +139,14 @@ class OpenStackCloud(object): self._keystone_session = None - self._nova_client = None + self._cinder_client = None self._glance_client = None self._glance_endpoint = None self._ironic_client = None - self._cinder_client = None - self._trove_client = None + self._neutron_client = None + self._nova_client = None self._swift_client = None + self._trove_client = None self.log = logging.getLogger('shade') log_level = logging.INFO @@ -324,6 +326,15 @@ class OpenStackCloud(object): return self._trove_client + @property + def neutron_client(self): + if self._neutron_client is None: + self._neutron_client = neutron_client.Client( + token=self.auth_token, + session=self.keystone_session, + region_name=self.region_name) + return self._neutron_client + def get_name(self): return self.name