Remove masakariclient's proxy class

Change I9b2d140065390d94dda532c39777cf691775e21e has added masakari
commands to openstacksdk and those are available in openstacksdk
version 0.13.0. So the respective sdk resource proxy class implemented
in masakariclient is no longer required.

This patch fixes below:
- Removes the proxy class from masakariclient, and modifies to use the
  proxy class implemented in openstacksdk.
- Related bug: #1756047

Closes-Bug: #1756047
Change-Id: I5ecc4f8edc283e16cc7a1bd83a0a21735135199c
This commit is contained in:
Kengo Takahara 2018-03-29 16:24:45 +09:00 committed by Dinesh Bhor
parent ac2fa48113
commit 6d61f0a103
17 changed files with 71 additions and 633 deletions

View File

@ -227,18 +227,3 @@ def get_uuid_by_name(manager, name, segment=None):
uuid = getattr(item, 'uuid')
break
return uuid
def is_new_sdk(sdk_version):
"""Returns whether the openstacksdk version is new.
:param version: Version of openstacksdk
:return: Returns False if the version is 0.9.19 or 0.10.0.
Otherwise returns True.
"""
# NOTE(Takahara): This sdk version check will be removed once the minimum
# openstacksdk version is bumped > 0.10.0.
if sdk_version.find('0.9.19') == 0 or sdk_version.find('0.10.0') == 0:
return False
else:
return True

View File

@ -246,7 +246,7 @@ class UpdateHost(command.ShowOne):
try:
masakari_client.update_host(
segment_id=segment_id, host=uuid, **attrs)
uuid, segment_id=segment_id, **attrs)
except sdk_exc.NotFoundException:
# Reraise. To unify exceptions with other functions.
LOG.debug(_("Segment host is not found: %s"), parsed_args)
@ -284,13 +284,14 @@ class DeleteHost(command.Command):
masakari_client,
parsed_args.host,
segment=segment_id)
masakari_client.delete_host(segment_id, uuid, False)
masakari_client.delete_host(
uuid, segment_id=segment_id, ignore_missing=False)
print('Host deleted: %s' % parsed_args.host)
def _show_host(masakari_client, segment_id, uuid):
try:
host = masakari_client.get_host(segment_id, uuid)
host = masakari_client.get_host(uuid, segment_id=segment_id)
except sdk_exc.ResourceNotFound:
raise exceptions.CommandError(_('Segment host is not found: %s'
) % uuid)

View File

@ -12,73 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from openstack import connection
from openstack import version
from osc_lib import utils
from masakariclient.common import utils as masakariclient_utils
from masakariclient.sdk.ha import ha_service
from masakariclient.sdk.ha.v1 import _proxy
if masakariclient_utils.is_new_sdk(version.__version__):
from openstack import service_description
_new_sdk = True
else:
from openstack import profile
_new_sdk = False
LOG = logging.getLogger(__name__)
DEFAULT_HA_API_VERSION = '1'
API_VERSION_OPTION = 'os_ha_api_version'
API_NAME = 'ha'
API_VERSIONS = {
'1': 'masakariclient.client.Client',
}
def make_client(instance):
"""Returns a ha proxy"""
if _new_sdk:
return _make_client_new(instance)
else:
return _make_client_old(instance)
def _make_client_new(instance):
desc = service_description.ServiceDescription(
service_type='ha', proxy_class=_proxy.Proxy)
conn = connection.Connection(
session=instance.session, extra_services=[desc])
conn.add_service(desc)
if version.__version__.find('0.11.0') == 0:
client = conn.ha
else:
client = conn.ha.proxy_class(
session=instance.session, service_type='ha')
return client
def _make_client_old(instance):
prof = profile.Profile()
prof._add_service(ha_service.HAService(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 using OpenStack SDK: %s', conn.ha)
return conn.ha
conn = connection.Connection(session=instance.session)
return conn.instance_ha
def build_option_parser(parser):

View File

@ -1,54 +0,0 @@
# 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 masakariclient.sdk.ha import ha_service
LOG = logging.getLogger(__name__)
# TODO(mordred) This will need to be updated, which will be an API break.
# Not sure what the best way to deal with that is. Perhaps just add a
# config argument and use it if it's there. I mean, a human can't create
# a Profile once they've installed a new enough SDK.
def create_connection(prof=None, user_agent=None, **kwargs):
"""Create connection to masakari_api."""
if not prof:
prof = profile.Profile()
prof._add_service(ha_service.HAService(version="v1"))
interface = kwargs.pop('interface', None)
region_name = kwargs.pop('region_name', None)
if interface:
prof.set_interface('ha', interface)
if region_name:
prof.set_region('ha', region_name)
prof.set_api_version('ha', '1')
try:
conn = connection.Connection(profile=prof,
user_agent=user_agent,
**kwargs)
LOG.debug('Connection: %s', conn)
LOG.debug('masakari client initialized: %s', conn.ha)
except Exception as e:
raise e
return conn

View File

@ -1,26 +0,0 @@
# 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.
from openstack import service_filter
class HAService(service_filter.ServiceFilter):
"""The HA service."""
valid_versions = [service_filter.ValidVersion('v1')]
def __init__(self, version=None):
"""Create an ha service."""
super(HAService, self).__init__(service_type='ha',
version=version)

View File

@ -1,208 +0,0 @@
# 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.
from openstack import version
from masakariclient.common import utils as masakariclient_utils
from masakariclient.sdk.ha.v1 import host as _host
from masakariclient.sdk.ha.v1 import notification as _notification
from masakariclient.sdk.ha.v1 import segment as _segment
if masakariclient_utils.is_new_sdk(version.__version__):
from openstack import proxy
from openstack import resource
else:
from openstack import proxy2 as proxy
from openstack import resource2 as resource
class Proxy(proxy.BaseProxy):
"""Proxy class for ha resource handling.
Create method for each action of each API.
"""
def notifications(self, **query):
"""Return a generator of notifications.
:param kwargs \*\*query: Optional query parameters to be sent to
limit the notifications being returned.
:returns: A generator of notifications
"""
return self._list(_notification.Notification, paginated=False, **query)
def get_notification(self, notification):
"""Get a single notification.
:param notification: The value can be the ID of a notification or a
:class:
`~masakariclient.sdk.ha.v1
.notification.Notification` instance.
:returns: One :class:`~masakariclient.sdk.ha.v1
.notification.Notification`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_notification.Notification, notification)
def create_notification(self, **attrs):
"""Create a new notification.
:param dict attrs: Keyword arguments which will be used to create
a :class:
`masakariclient.sdk.ha.v1
.notification.Notification`,
comprised of the propoerties on the Notification
class.
:returns: The result of notification creation
:rtype: :class: `masakariclient.sdk.ha.v1
.notification.Notification`
"""
return self._create(_notification.Notification, **attrs)
def segments(self, **query):
"""Return a generator of segments.
:param kwargs \*\*query: Optional query parameters to be sent to
limit the segments being returned.
:returns: A generator of segments
"""
return self._list(_segment.Segment, paginated=False, **query)
def get_segment(self, segment):
"""Get a single segment.
:param segment: The value can be the ID of a segment or a
:class:
`~masakariclient.sdk.ha.v1.segment.Segment` instance.
:returns: One :class:`~masakariclient.sdk.ha.v1.segment.Segment`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_segment.Segment, segment)
def create_segment(self, **attrs):
"""Create a new segment.
:param dict attrs: Keyword arguments which will be used to create
a :class:
`masakariclient.sdk.ha.v1.segment.Segment`,
comprised of the propoerties on the Segment class.
:returns: The result of segment creation
:rtype: :class: `masakariclient.sdk.ha.v1.segment.Segment`
"""
return self._create(_segment.Segment, **attrs)
def update_segment(self, segment, **attrs):
"""Update a segment.
:param segment: The value can be the ID of a segment or a
:class:
`~masakariclient.sdk.ha.v1.segment.Segment` instance.
:param dict attrs: Keyword arguments which will be used to update
a :class:
`masakariclient.sdk.ha.v1.segment.Segment`,
comprised of the propoerties on the Segment class.
:returns: The updated segment.
:rtype: :class: `masakariclient.sdk.ha.v1.segment.Segment`
"""
return self._update(_segment.Segment, segment, **attrs)
def delete_segment(self, segment, ignore_missing=True):
"""Delete a segment.
:param segment:
The value can be either the ID of a segment or a
:class:`~masakariclient.sdk.ha.v1.segment.Segment` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the segment does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent segment.
:returns: ``None``
"""
return self._delete(_segment.Segment, segment,
ignore_missing=ignore_missing)
def hosts(self, segment_id, **query):
"""Return a generator of hosts.
:param segment_id: The ID of a failover segment.
:param kwargs \*\*query: Optional query parameters to be sent to
limit the hosts being returned.
:returns: A generator of hosts
"""
return self._list(_host.Host, segment_id=segment_id, paginated=False,
**query)
def create_host(self, segment_id, **attrs):
"""Create a new host.
:param segment_id: The ID of a failover segment.
:param dict attrs: Keyword arguments which will be used to create
a :class: `masakariclient.sdk.ha.v1.host.Host`,
comprised of the propoerties on the Host class.
:returns: The results of host creation
"""
return self._create(_host.Host, segment_id=segment_id, **attrs)
def get_host(self, segment_id, host):
"""Get a single host.
:param segment_id: The ID of a failover segment.
:param host: The value can be the ID of a host or a :class:
`~masakariclient.sdk.ha.v1.host.Host` instance.
:returns: One :class:`~masakariclient.sdk.ha.v1.host.Host`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
host_id = resource.Resource._get_id(host)
return self._get(_host.Host, host_id, segment_id=segment_id)
def update_host(self, segment_id, host, **attrs):
"""Update the host.
:param segment_id: The ID of a failover segment.
:param host: The value can be the ID of a host or a :class:
`~masakariclient.sdk.ha.v1.host.Host` instance.
:param dict attrs: The attributes to update on the host represented.
:returns: The updated host
"""
host_id = resource.Resource._get_id(host)
return self._update(_host.Host, host_id, segment_id=segment_id,
**attrs)
def delete_host(self, segment_id, host, ignore_missing=True):
"""Delete the host.
:param segment_id: The ID of a failover segment.
:param host: The value can be the ID of a host or a :class:
`~masakariclient.sdk.ha.v1.host.Host` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the host does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent host.
:returns: ``None``
"""
host_id = resource.Resource._get_id(host)
return self._delete(_host.Host, host_id, segment_id=segment_id,
ignore_missing=ignore_missing)

View File

@ -1,91 +0,0 @@
# 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.
from openstack import version
from masakariclient.common import utils as masakariclient_utils
from masakariclient.sdk.ha import ha_service
if masakariclient_utils.is_new_sdk(version.__version__):
from openstack import resource
_new_sdk = True
else:
from openstack import resource2 as resource
_new_sdk = False
class Host(resource.Resource):
resource_key = "host"
resources_key = "hosts"
base_path = "/segments/%(segment_id)s/hosts"
service = ha_service.HAService()
# capabilities
# 1] GET /v1/segments/<segment_uuid>/hosts
# 2] GET /v1/segments/<segment_uuid>/hosts/<host_uuid>
# 3] POST /v1/segments/<segment_uuid>/hosts
# 4] PUT /v1/segments/<segment_uuid>/hosts
# 5] DELETE /v1/segments/<segment_uuid>/hosts
allow_list = True
allow_get = True
allow_create = True
allow_update = True
allow_delete = True
# Properties
# Refer "https://github.com/openstack/masakari/blob/
# master/masakari/api/openstack/ha/schemas/hosts.py"
# for properties of host API
#: A ID of representing this host
id = resource.URI("id")
#: A Uuid of representing this host
uuid = resource.Body("uuid")
#: A failover segment ID of this host(in URI)
segment_id = resource.URI("segment_id")
#: A created time of this host
created_at = resource.Body("created_at")
#: A latest updated time of this host
updated_at = resource.Body("updated_at")
#: A name of this host
name = resource.Body("name")
#: A type of this host
type = resource.Body("type")
#: A control attributes of this host
control_attributes = resource.Body("control_attributes")
#: A maintenance status of this host
on_maintenance = resource.Body("on_maintenance")
#: A reservation status of this host
reserved = resource.Body("reserved")
#: A failover segment ID of this host(in Body)
failover_segment_id = resource.Body("failover_segment_id")
_query_mapping = resource.QueryParameters(
"sort_key", "sort_dir", failover_segment_id="failover_segment_id",
type="type", on_maintenance="on_maintenance", reserved="reserved")
def update(self, session, prepend_key=False, has_body=True):
"""Update a host."""
request = self._prepare_request(prepend_key=prepend_key)
del request.body['id']
request_body = {"host": request.body}
if _new_sdk:
res = session.put(request.url, endpoint_filter=self.service,
json=request_body, headers=request.headers)
else:
res = session.put(request.uri, endpoint_filter=self.service,
json=request_body, headers=request.headers)
self._translate_response(res, has_body=has_body)
return self

View File

@ -1,72 +0,0 @@
# 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.
from openstack import version
from masakariclient.common import utils as masakariclient_utils
from masakariclient.sdk.ha import ha_service
if masakariclient_utils.is_new_sdk(version.__version__):
from openstack import resource
else:
from openstack import resource2 as resource
class Notification(resource.Resource):
resource_key = "notification"
resources_key = "notifications"
base_path = "/notifications"
service = ha_service.HAService()
# capabilities
# 1] GET /v1/notifications
# 2] GET /v1/notifications/<notification_uuid>
# 3] POST /v1/notifications
allow_list = True
allow_get = True
allow_create = True
allow_update = False
allow_delete = False
# Properties
# Refer "https://github.com/openstack/masakari/tree/
# master/masakari/api/openstack/ha/schemas/notificaions.py"
# for properties of notifications API
#: A ID of representing this notification.
id = resource.Body("id")
#: A Uuid of representing this notification.
notification_uuid = resource.Body("notification_uuid")
#: A created time of representing this notification.
created_at = resource.Body("created_at")
#: A latest updated time of representing this notification.
updated_at = resource.Body("updated_at")
#: The type of failure. Valuse values include ''COMPUTE_HOST'',
#: ''VM'', ''PROCESS''
type = resource.Body("type")
#: The hostname of this notification.
hostname = resource.Body("hostname")
#: The status for this notitication.
status = resource.Body("status")
#: The generated_time for this notitication.
generated_time = resource.Body("generated_time")
#: The payload of this notification.
payload = resource.Body("payload")
#: The source host uuid of this notification.
source_host_uuid = resource.Body("source_host_uuid")
_query_mapping = resource.QueryParameters(
"sort_key", "sort_dir", source_host_uuid="source_host_uuid",
type="type", status="status", generated_since="generated-since")

View File

@ -1,85 +0,0 @@
# 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.
from openstack import version
from masakariclient.common import utils as masakariclient_utils
from masakariclient.sdk.ha import ha_service
if masakariclient_utils.is_new_sdk(version.__version__):
from openstack import resource
_new_sdk = True
else:
from openstack import resource2 as resource
_new_sdk = False
class Segment(resource.Resource):
resource_key = "segment"
resources_key = "segments"
base_path = "/segments"
service = ha_service.HAService()
# capabilities
# 1] GET /v1/segments
# 2] GET /v1/segments/<segment_uuid>
# 3] POST /v1/segments
# 4] PUT /v1/segments/<segment_uuid>
# 5] DELETE /v1/segments/<segment_uuid>
allow_list = True
allow_get = True
allow_create = True
allow_update = True
allow_delete = True
# Properties
# Refer "https://github.com/openstack/masakari/tree/
# master/masakari/api/openstack/ha/schemas"
# for properties of each API
#: A ID of representing this segment.
id = resource.Body("id")
#: A Uuid of representing this segment.
uuid = resource.Body("uuid")
#: A created time of representing this segment.
created_at = resource.Body("created_at")
#: A latest updated time of representing this segment.
updated_at = resource.Body("updated_at")
#: The name of this segment.
name = resource.Body("name")
#: The description of this segment.
description = resource.Body("description")
#: The recovery method of this segment.
recovery_method = resource.Body("recovery_method")
#: The service type of this segment.
service_type = resource.Body("service_type")
_query_mapping = resource.QueryParameters(
"sort_key", "sort_dir", recovery_method="recovery_method",
service_type="service_type")
def update(self, session, prepend_key=False, has_body=True):
"""Update a segment."""
request = self._prepare_request(prepend_key=prepend_key)
del request.body['id']
request_body = {"segment": request.body}
if _new_sdk:
ret = session.put(request.url, endpoint_filter=self.service,
json=request_body, headers=request.headers)
else:
ret = session.put(request.uri, endpoint_filter=self.service,
json=request_body, headers=request.headers)
self._translate_response(ret, has_body=has_body)
return self

View File

@ -135,6 +135,8 @@ class TestV1ShowHost(BaseV1Host):
# show the host specified by uuid
self.show_host.take_action(parsed_args)
self.app.client_manager.ha.get_host.assert_called_once_with(
HOST_ID, segment_id=SEGMENT_ID)
mock_get_dict_properties.assert_called_once_with(
self.dummy_host.to_dict(), self.columns, formatters={})
@ -169,6 +171,10 @@ class TestV1UpdateHost(BaseV1Host):
self.app.client_manager.ha.get_host.return_value = self.dummy_host
# show the host specified by uuid
self.update_host.take_action(parsed_args)
self.app.client_manager.ha.update_host.assert_called_once_with(
HOST_ID, segment_id=SEGMENT_ID, reserved=True)
self.app.client_manager.ha.get_host.assert_called_once_with(
HOST_ID, segment_id=SEGMENT_ID)
mock_get_dict_properties.assert_called_once_with(
self.dummy_host.to_dict(), self.columns, formatters={})
@ -202,4 +208,4 @@ class TestV1DeleteHost(BaseV1Host):
self.delete_host.take_action(parsed_args)
self.app.client_manager.ha.delete_host.assert_called_once_with(
SEGMENT_ID, HOST_ID, False)
HOST_ID, segment_id=SEGMENT_ID, ignore_missing=False)

View File

@ -19,7 +19,10 @@ Tests for `masakariclient` module.
"""
import mock
from masakariclient.sdk.ha import connection
from keystoneauth1.identity.generic import password as ks_password
from keystoneauth1 import session as ks_session
from openstack import connection
from masakariclient.tests import base
import masakariclient.v1.client as mc
@ -35,16 +38,42 @@ class TestV1Client(base.TestCase):
def setUp(self):
super(TestV1Client, self).setUp()
self.auth = mock.Mock()
self.session = mock.Mock()
self.conn = mock.Mock()
self.service = mock.Mock()
self.conn.ha = self.service
self.conn.instance_ha = self.service
def test_client_init(self):
with mock.patch.object(connection,
'create_connection') as mock_connection:
mock_connection.return_value = self.conn
@mock.patch.object(connection, 'Connection')
@mock.patch.object(ks_session, 'Session')
@mock.patch.object(ks_password, 'Password')
def test_client_init(self, mock_password, mock_session, mock_connection):
res = mc.Client()
mock_password.return_value = self.auth
mock_session.return_value = self.session
mock_connection.return_value = self.conn
self.assertEqual(self.conn.ha, res.service)
mock_connection.assert_called_once_with(prof=None, user_agent=None)
fake_auth_url = 'fake_auth_url'
fake_username = 'fake_username'
fake_password = 'fake_password'
fake_user_domain_id = 'fake_user_domain_id'
fake_project_name = 'fake_project_name'
fake_project_domain_id = 'fake_project_domain_id'
res = mc.Client(auth_url=fake_auth_url,
username=fake_username,
password=fake_password,
user_domain_id=fake_user_domain_id,
project_name=fake_project_name,
project_domain_id=fake_project_domain_id)
self.assertEqual(self.conn.instance_ha, res.service)
mock_password.assert_called_once_with(
auth_url=fake_auth_url,
username=fake_username,
password=fake_password,
user_domain_id=fake_user_domain_id,
project_name=fake_project_name,
project_domain_id=fake_project_domain_id)
mock_session.assert_called_once_with(auth=self.auth)
mock_connection.assert_called_once_with(session=self.session)

View File

@ -12,16 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from masakariclient.sdk.ha import connection
from keystoneauth1.identity.generic import password as ks_password
from keystoneauth1 import session as ks_session
from openstack import connection
class Client(object):
# TODO(mordred) This will need to be updated, which will be an API break.
# Not sure what the best way to deal with that is. Perhaps just add a
# config argument and use it if it's there. I mean, a human can't create
# a Profile once they've installed a new enough SDK.
def __init__(self, prof=None, user_agent=None, **kwargs):
self.con = connection.create_connection(
prof=prof, user_agent=user_agent, **kwargs)
self.service = self.con.ha
def __init__(self, **kwargs):
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)
self.con = connection.Connection(session=session)
self.service = self.con.instance_ha

View File

@ -196,7 +196,7 @@ def do_host_show(service, args):
service, args.segment_id)
host_id = utils.get_uuid_by_name(
service, args.id, segment=segment_id)
host = service.get_host(segment_id, host_id)
host = service.get_host(host_id, segment_id=segment_id)
utils.print_dict(host.to_dict())
except Exception as e:
print(e)
@ -268,7 +268,7 @@ def do_host_update(service, args):
'on_maintenance': args.on_maintenance,
}
attrs = utils.remove_unspecified_items(attrs)
host = service.update_host(segment_id, host_id, **attrs)
host = service.update_host(host_id, segment_id=segment_id, **attrs)
utils.print_dict(host.to_dict())
except Exception as e:
print(e)
@ -285,7 +285,7 @@ def do_host_delete(service, args):
service, args.segment_id)
host_id = utils.get_uuid_by_name(
service, args.id, segment=segment_id)
host = service.delete_host(segment_id, host_id)
host = service.delete_host(host_id, segment_id=segment_id)
if host:
utils.print_dict(host.to_dict())
except Exception as e:

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
openstacksdk>=0.11.2 # Apache-2.0
openstacksdk>=0.13.0 # Apache-2.0
osc-lib>=1.8.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0