Fix osc command issue

If you have installed openstackclient and masakariclient on your
machine, then none of the openstack commands work as it fails to
load the masakari plugin.

Added 'API_NAME' global constants which osc clientmanager expects
during initialization of masakari plugin.

Change-Id: Id33bd45ee1625a23ae43090a45d8b0f9ff2bf56a
Closes-Bug: #1801689
This commit is contained in:
tpatil 2018-11-06 16:14:51 +09:00
parent dd72283e1e
commit 71ce1fbb4a
2 changed files with 30 additions and 15 deletions

View File

@ -12,20 +12,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from openstack import connection
import logging
from osc_lib import utils
LOG = logging.getLogger(__name__)
DEFAULT_HA_API_VERSION = '1'
API_VERSION_OPTION = 'os_ha_api_version'
API_NAME = 'ha'
API_VERSIONS = {
'1': 'masakariclient.v1.client.Client',
}
def make_client(instance):
"""Returns a instance_ha proxy"""
conn = connection.Connection(session=instance.session,
interface=instance.interface,
region_name=instance.region_name)
return conn.instance_ha
version = instance._api_version[API_NAME]
masakari_client = utils.get_client_class(
API_NAME,
version,
API_VERSIONS)
LOG.debug('Instantiating masakari service client: %s', masakari_client)
client = masakari_client(session=instance.session,
interface=instance.interface,
region_name=instance.region_name)
return client.service
def build_option_parser(parser):

View File

@ -20,18 +20,20 @@ from openstack import connection
class Client(object):
def __init__(self, **kwargs):
session = kwargs.get('session')
if session is None:
auth = ks_password.Password(
auth_url=kwargs.get('auth_url'),
username=kwargs.get('username'),
password=kwargs.get('password'),
user_domain_id=kwargs.get('user_domain_id'),
project_name=kwargs.get('project_name'),
project_domain_id=kwargs.get('project_domain_id'))
auth = ks_password.Password(
auth_url=kwargs.get('auth_url'),
username=kwargs.get('username'),
password=kwargs.get('password'),
user_domain_id=kwargs.get('user_domain_id'),
project_name=kwargs.get('project_name'),
project_domain_id=kwargs.get('project_domain_id'))
session = ks_session.Session(auth=auth)
session = ks_session.Session(auth=auth)
self.con = connection.Connection(
con = connection.Connection(
session=session,
interface=kwargs.get('interface'),
region_name=kwargs.get('region_name'))
self.service = self.con.instance_ha
self.service = con.instance_ha