Add Octavia python client for Magnum

Adding the client enables the manipulation of Octavia
resources with Magnum such as during cluster deletion,
being able to clean up non-heat created resouces.

Change-Id: I976ab136e24b98d447d61028ce07d0f5dd9d255a
story: 2004259
task: 27795
This commit is contained in:
Jim Bach 2018-11-05 07:57:58 -08:00
parent 83fa9d1b4e
commit 9a6698fb45
6 changed files with 84 additions and 0 deletions

View File

@ -121,6 +121,7 @@ python-keystoneclient==3.8.0
python-mimeparse==1.6.0
python-neutronclient==6.7.0
python-novaclient==9.1.0
python-octaviaclient==1.6.0
python-subunit==1.0.0
python-swiftclient==3.5.0
pytz==2013.6

View File

@ -18,6 +18,7 @@ from heatclient import client as heatclient
from keystoneauth1.exceptions import catalog
from neutronclient.v2_0 import client as neutronclient
from novaclient import client as novaclient
from octaviaclient.api.v2 import octavia
from oslo_log import log as logging
from magnum.common import exception
@ -39,6 +40,7 @@ class OpenStackClients(object):
self._barbican = None
self._nova = None
self._neutron = None
self._octavia = None
def url_for(self, **kwargs):
return self.keystone().session.get_endpoint(**kwargs)
@ -80,6 +82,21 @@ class OpenStackClients(object):
def _get_client_option(self, client, option):
return getattr(getattr(CONF, '%s_client' % client), option)
@exception.wrap_keystone_exception
def octavia(self):
if self._octavia:
return self._octavia
region_name = self._get_client_option('octavia', 'region_name')
endpoint_type = self._get_client_option('octavia', 'endpoint_type')
endpoint = self.url_for(service_type='load-balancer',
interface=endpoint_type,
region_name=region_name)
session = self.keystone().session
return octavia.OctaviaAPI(session=session,
service_type='load-balancer',
endpoint=endpoint)
@exception.wrap_keystone_exception
def heat(self):
if self._heat:

View File

@ -33,6 +33,7 @@ from magnum.conf import keystone
from magnum.conf import magnum_client
from magnum.conf import neutron
from magnum.conf import nova
from magnum.conf import octavia
from magnum.conf import paths
from magnum.conf import profiler
from magnum.conf import quota
@ -62,6 +63,7 @@ keystone.register_opts(CONF)
magnum_client.register_opts(CONF)
neutron.register_opts(CONF)
nova.register_opts(CONF)
octavia.register_opts(CONF)
paths.register_opts(CONF)
quota.register_opts(CONF)
rpc.register_opts(CONF)

58
magnum/conf/octavia.py Normal file
View File

@ -0,0 +1,58 @@
# 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.
import itertools
from oslo_config import cfg
from magnum.i18n import _
octavia_group = cfg.OptGroup(name='octavia_client',
title='Options for the Octavia client')
octavia_client_opts = [
cfg.StrOpt('region_name',
help=_('Region in Identity service catalog to use for '
'communication with the OpenStack service.')),
cfg.StrOpt('endpoint_type',
default='publicURL',
help=_('Type of endpoint in Identity service catalog to use '
'for communication with the OpenStack service.'))]
common_security_opts = [
cfg.StrOpt('ca_file',
help=_('Optional CA cert file to use in SSL connections.')),
cfg.StrOpt('cert_file',
help=_('Optional PEM-formatted certificate chain file.')),
cfg.StrOpt('key_file',
help=_('Optional PEM-formatted file that contains the '
'private key.')),
cfg.BoolOpt('insecure',
default=False,
help=_("If set, then the server's certificate will not "
"be verified."))]
ALL_OPTS = list(itertools.chain(
octavia_client_opts,
common_security_opts
))
def register_opts(conf):
conf.register_group(octavia_group)
conf.register_opts(ALL_OPTS, group=octavia_group)
def list_opts():
return {
octavia_group: ALL_OPTS
}

View File

@ -0,0 +1,5 @@
---
features:
- |
This will add the octavia client code for client to interact with
the Octavia component of OpenStack

View File

@ -46,6 +46,7 @@ python-heatclient>=1.10.0 # Apache-2.0
python-neutronclient>=6.7.0 # Apache-2.0
python-novaclient>=9.1.0 # Apache-2.0
python-keystoneclient>=3.8.0 # Apache-2.0
python-octaviaclient>=1.6.0 # Apache-2.0
requests>=2.14.2 # Apache-2.0
setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,>=21.0.0 # PSF/ZPL
six>=1.10.0 # MIT