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:
parent
dd72283e1e
commit
71ce1fbb4a
@ -12,20 +12,33 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from openstack import connection
|
import logging
|
||||||
|
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_HA_API_VERSION = '1'
|
DEFAULT_HA_API_VERSION = '1'
|
||||||
API_VERSION_OPTION = 'os_ha_api_version'
|
API_VERSION_OPTION = 'os_ha_api_version'
|
||||||
|
API_NAME = 'ha'
|
||||||
|
API_VERSIONS = {
|
||||||
|
'1': 'masakariclient.v1.client.Client',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def make_client(instance):
|
def make_client(instance):
|
||||||
"""Returns a instance_ha proxy"""
|
"""Returns a instance_ha proxy"""
|
||||||
conn = connection.Connection(session=instance.session,
|
version = instance._api_version[API_NAME]
|
||||||
interface=instance.interface,
|
masakari_client = utils.get_client_class(
|
||||||
region_name=instance.region_name)
|
API_NAME,
|
||||||
return conn.instance_ha
|
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):
|
def build_option_parser(parser):
|
||||||
|
@ -20,18 +20,20 @@ from openstack import connection
|
|||||||
class Client(object):
|
class Client(object):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
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(
|
session = ks_session.Session(auth=auth)
|
||||||
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)
|
|
||||||
|
|
||||||
self.con = connection.Connection(
|
con = connection.Connection(
|
||||||
session=session,
|
session=session,
|
||||||
interface=kwargs.get('interface'),
|
interface=kwargs.get('interface'),
|
||||||
region_name=kwargs.get('region_name'))
|
region_name=kwargs.get('region_name'))
|
||||||
self.service = self.con.instance_ha
|
self.service = con.instance_ha
|
||||||
|
Loading…
Reference in New Issue
Block a user