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:
parent
e182f6fefa
commit
d59e8b967d
0
masakariclient/osc/__init__.py
Normal file
0
masakariclient/osc/__init__.py
Normal file
0
masakariclient/osc/v1/__init__.py
Normal file
0
masakariclient/osc/v1/__init__.py
Normal file
61
masakariclient/plugin.py
Normal file
61
masakariclient/plugin.py
Normal 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
|
@ -3,5 +3,6 @@
|
|||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
|
|
||||||
openstacksdk>=0.9.7 # Apache-2.0
|
openstacksdk>=0.9.7 # Apache-2.0
|
||||||
|
osc-lib>=1.2.0 # Apache-2.0
|
||||||
oslo.i18n>=2.1.0 # Apache-2.0
|
oslo.i18n>=2.1.0 # Apache-2.0
|
||||||
pbr>=1.6 # Apache-2.0
|
pbr>=1.6 # Apache-2.0
|
||||||
|
@ -23,6 +23,10 @@ classifier =
|
|||||||
packages =
|
packages =
|
||||||
masakariclient
|
masakariclient
|
||||||
|
|
||||||
|
[entry_points]
|
||||||
|
openstack.cli.extension =
|
||||||
|
vmha = masakariclient.plugin
|
||||||
|
|
||||||
[build_sphinx]
|
[build_sphinx]
|
||||||
source-dir = doc/source
|
source-dir = doc/source
|
||||||
build-dir = doc/build
|
build-dir = doc/build
|
||||||
|
Loading…
x
Reference in New Issue
Block a user