Switch to a new service type "container-infra"
After this patch [1], Magnum is no longer the "Container Service", it became the "Container Infrastructure Management Service". Based on the decision, this patch proposed to rename Magnum service type from "container" to "container-infra". The old service type will be deprecated and eventually not supported. There is another patch [2] on Magnum server side for the renaming. This patch should land first, then the server patch. [1] https://review.openstack.org/#/c/311476/ [2] https://review.openstack.org/#/c/319300/ Change-Id: I55205ff2b304678d2b53bbd4d66403078c6baac8 Closes-Bug: #1584251
This commit is contained in:
parent
68e301fc8d
commit
e0966ebe60
|
@ -58,7 +58,7 @@ from magnumclient import version
|
|||
|
||||
DEFAULT_API_VERSION = '1'
|
||||
DEFAULT_ENDPOINT_TYPE = 'publicURL'
|
||||
DEFAULT_SERVICE_TYPE = 'container'
|
||||
DEFAULT_SERVICE_TYPE = 'container-infra'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ class ShellTest(utils.TestCase):
|
|||
self.make_env()
|
||||
self.shell('bay-list')
|
||||
_, client_kwargs = mock_client.call_args_list[0]
|
||||
self.assertEqual('container', client_kwargs['service_type'])
|
||||
self.assertEqual('container-infra', client_kwargs['service_type'])
|
||||
|
||||
@mock.patch('magnumclient.v1.bays_shell.do_bay_list')
|
||||
@mock.patch('magnumclient.v1.client.ksa_session')
|
||||
|
@ -238,7 +238,7 @@ class ShellTest(utils.TestCase):
|
|||
username='username', api_key='password',
|
||||
endpoint_type='publicURL', project_id='',
|
||||
project_name='tenant_name', auth_url=self.AUTH_URL,
|
||||
service_type='container', region_name=expected_region_name,
|
||||
service_type='container-infra', region_name=expected_region_name,
|
||||
project_domain_id='', project_domain_name='',
|
||||
user_domain_id='', user_domain_name='',
|
||||
magnum_url=None, insecure=False)
|
||||
|
@ -265,7 +265,7 @@ class ShellTest(utils.TestCase):
|
|||
username='username', api_key='password',
|
||||
endpoint_type='publicURL', project_id='',
|
||||
project_name='tenant_name', auth_url=self.AUTH_URL,
|
||||
service_type='container', region_name=None,
|
||||
service_type='container-infra', region_name=None,
|
||||
project_domain_id='', project_domain_name='',
|
||||
user_domain_id='', user_domain_name='',
|
||||
magnum_url=None, insecure=False)
|
||||
|
@ -278,7 +278,7 @@ class ShellTest(utils.TestCase):
|
|||
username='username', api_key='password',
|
||||
endpoint_type='internalURL', project_id='',
|
||||
project_name='tenant_name', auth_url=self.AUTH_URL,
|
||||
service_type='container', region_name=None,
|
||||
service_type='container-infra', region_name=None,
|
||||
project_domain_id='', project_domain_name='',
|
||||
user_domain_id='', user_domain_name='',
|
||||
magnum_url=None, insecure=False)
|
||||
|
@ -308,7 +308,7 @@ class ShellTestKeystoneV3(ShellTest):
|
|||
username='username', api_key='password',
|
||||
endpoint_type='publicURL', project_id='tenant_id',
|
||||
project_name='', auth_url=self.AUTH_URL,
|
||||
service_type='container', region_name=None,
|
||||
service_type='container-infra', region_name=None,
|
||||
project_domain_id='', project_domain_name='Default',
|
||||
user_domain_id='', user_domain_name='Default',
|
||||
magnum_url=None, insecure=False)
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
import mock
|
||||
import testtools
|
||||
|
||||
from keystoneauth1.exceptions import catalog
|
||||
|
||||
from magnumclient.v1 import client
|
||||
|
||||
|
||||
|
@ -30,7 +32,7 @@ class ClientTest(testtools.TestCase):
|
|||
interface='public',
|
||||
region_name=None,
|
||||
service_name=None,
|
||||
service_type='container',
|
||||
service_type='container-infra',
|
||||
session=session)
|
||||
|
||||
@mock.patch('magnumclient.common.httpclient.SessionClient')
|
||||
|
@ -50,7 +52,7 @@ class ClientTest(testtools.TestCase):
|
|||
interface='public',
|
||||
region_name=None,
|
||||
service_name=None,
|
||||
service_type='container',
|
||||
service_type='container-infra',
|
||||
session=session)
|
||||
|
||||
@mock.patch('magnumclient.common.httpclient.SessionClient')
|
||||
|
@ -75,7 +77,7 @@ class ClientTest(testtools.TestCase):
|
|||
interface='public',
|
||||
region_name=None,
|
||||
service_name=None,
|
||||
service_type='container',
|
||||
service_type='container-infra',
|
||||
session=mock.ANY)
|
||||
|
||||
@mock.patch('magnumclient.common.httpclient.SessionClient')
|
||||
|
@ -87,6 +89,36 @@ class ClientTest(testtools.TestCase):
|
|||
mock_loader.return_value = mock_plugin
|
||||
client.Client(username='myuser', auth_url='authurl')
|
||||
mock_loader.assert_called_once_with('password')
|
||||
mock_plugin.load_from_options.assert_called_once_with(
|
||||
auth_url='authurl',
|
||||
username='myuser',
|
||||
password=None,
|
||||
project_domain_id=None,
|
||||
project_domain_name=None,
|
||||
user_domain_id=None,
|
||||
user_domain_name=None,
|
||||
project_id=None,
|
||||
project_name=None)
|
||||
http_client.assert_called_once_with(
|
||||
interface='public',
|
||||
region_name=None,
|
||||
service_name=None,
|
||||
service_type='container-infra',
|
||||
session=mock.ANY)
|
||||
|
||||
@mock.patch('magnumclient.common.httpclient.SessionClient')
|
||||
@mock.patch('keystoneauth1.loading.get_plugin_loader')
|
||||
@mock.patch('keystoneauth1.session.Session')
|
||||
def test_init_with_legacy_service_type(
|
||||
self, mock_session, mock_loader, http_client):
|
||||
mock_plugin = mock.Mock()
|
||||
mock_loader.return_value = mock_plugin
|
||||
mock_session_obj = mock.Mock()
|
||||
mock_session.return_value = mock_session_obj
|
||||
mock_session_obj.get_endpoint.side_effect = [
|
||||
catalog.EndpointNotFound(), mock.Mock()]
|
||||
client.Client(username='myuser', auth_url='authurl')
|
||||
mock_loader.assert_called_once_with('password')
|
||||
mock_plugin.load_from_options.assert_called_once_with(
|
||||
auth_url='authurl',
|
||||
username='myuser',
|
||||
|
@ -140,7 +172,7 @@ class ClientTest(testtools.TestCase):
|
|||
interface='public',
|
||||
region_name=None,
|
||||
service_name=None,
|
||||
service_type='container',
|
||||
service_type='container-infra',
|
||||
session=session,
|
||||
endpoint_override='magnumurl')
|
||||
|
||||
|
@ -156,6 +188,6 @@ class ClientTest(testtools.TestCase):
|
|||
interface='public',
|
||||
region_name=None,
|
||||
service_name=None,
|
||||
service_type='container',
|
||||
service_type='container-infra',
|
||||
session=session,
|
||||
endpoint_override='magnumurl')
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from keystoneauth1.exceptions import catalog
|
||||
from keystoneauth1 import loading
|
||||
from keystoneauth1 import session as ksa_session
|
||||
|
||||
|
@ -27,11 +28,15 @@ from magnumclient.v1 import replicationcontrollers as rcs
|
|||
from magnumclient.v1 import services
|
||||
|
||||
|
||||
DEFAULT_SERVICE_TYPE = 'container-infra'
|
||||
LEGACY_DEFAULT_SERVICE_TYPE = 'container'
|
||||
|
||||
|
||||
class Client(object):
|
||||
def __init__(self, username=None, api_key=None, project_id=None,
|
||||
project_name=None, auth_url=None, magnum_url=None,
|
||||
endpoint_type=None, endpoint_override=None,
|
||||
service_type='container',
|
||||
service_type=DEFAULT_SERVICE_TYPE,
|
||||
region_name=None, input_auth_token=None,
|
||||
session=None, password=None, auth_type='password',
|
||||
interface='public', service_name=None, insecure=False,
|
||||
|
@ -103,6 +108,16 @@ class Client(object):
|
|||
service_name=service_name,
|
||||
interface=interface,
|
||||
region_name=region_name)
|
||||
except catalog.EndpointNotFound:
|
||||
service_type = LEGACY_DEFAULT_SERVICE_TYPE
|
||||
try:
|
||||
session.get_endpoint(
|
||||
service_type=service_type,
|
||||
service_name=service_name,
|
||||
interface=interface,
|
||||
region_name=region_name)
|
||||
except Exception:
|
||||
raise RuntimeError("Not Authorized")
|
||||
except Exception:
|
||||
raise RuntimeError("Not Authorized")
|
||||
|
||||
|
|
Loading…
Reference in New Issue