Add masakari openstackclient plugin base

Commit the following implementation
- Implemented to openstackclient plugin base for masakari.
- In the configuration file has been added an entry point for
  the client module initialization.

Change-Id: I8dbee8929480105eb26d938c50e4e512d887c4a8
This commit is contained in:
Takahiro Izumi 2016-11-03 02:17:09 +00:00
parent e182f6fefa
commit d59e8b967d
5 changed files with 67 additions and 1 deletions

View File

View File

61
masakariclient/plugin.py Normal file
View File

@ -0,0 +1,61 @@
# Copyright(c) 2016 Nippon Telegraph and Telephone Corporation
#
# 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 logging
from openstack import connection
from openstack import profile
from osc_lib import utils
from masakariclient.sdk.vmha import vmha_service
LOG = logging.getLogger(__name__)
DEFAULT_VMHA_API_VERSION = '1'
API_VERSION_OPTION = 'os_vmha_api_version'
API_NAME = 'vmha'
API_VERSIONS = {
'1': 'masakariclient.client.Client',
}
def make_client(instance):
"""Returns a vmha proxy"""
prof = profile.Profile()
prof._add_service(vmha_service.VMHAService(version="v1"))
prof.set_region(API_NAME, instance.region_name)
prof.set_version(API_NAME, instance._api_version[API_NAME])
prof.set_interface(API_NAME, instance.interface)
conn = connection.Connection(authenticator=instance.session.auth,
verify=instance.session.verify,
cert=instance.session.cert,
profile=prof)
LOG.debug('Connection: %s', conn)
LOG.debug('masakari client initialized: %s', conn.vmha)
return conn.vmha
def build_option_parser(parser):
"""Hook to add global options"""
parser.add_argument(
'--os-vmha-api-version',
metavar='<vmha-api-version>',
default=utils.env(
'OS_VMHA_API_VERSION',
default=DEFAULT_VMHA_API_VERSION),
help='vmha API version, default=' +
DEFAULT_VMHA_API_VERSION +
' (Env: OS_VMHA_API_VERSION)')
return parser

View File

@ -3,5 +3,6 @@
# process, which may cause wedges in the gate later.
openstacksdk>=0.9.7 # Apache-2.0
osc-lib>=1.2.0 # Apache-2.0
oslo.i18n>=2.1.0 # Apache-2.0
pbr>=1.6 # Apache-2.0

View File

@ -23,6 +23,10 @@ classifier =
packages =
masakariclient
[entry_points]
openstack.cli.extension =
vmha = masakariclient.plugin
[build_sphinx]
source-dir = doc/source
build-dir = doc/build
@ -48,4 +52,4 @@ output_file = masakariclient/locale/masakariclient.pot
[build_releasenotes]
all_files = 1
build-dir = releasenotes/build
source-dir = releasenotes/source
source-dir = releasenotes/source