ironic-tempest-plugin/ironic_tempest_plugin/services/introspection_client.py
Masayuki Igawa 51266a5ed2
Enable tempest run -l without credential setting
This commit moves the admin credential code to the initialization phase
of Manager class. This change enables to run `tempest run -l` without
credential settings. We shouldn't require like that settings to just
list tests.

Change-Id: Ib202880e7039113a58dc1596de54be4167c5307d
2019-02-04 17:17:35 +09:00

85 lines
3.0 KiB
Python

# 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 ironic_tempest_plugin.services.baremetal import base
from tempest import clients
from tempest.common import credentials_factory as common_creds
from tempest import config
CONF = config.CONF
class Manager(clients.Manager):
def __init__(self,
credentials=None,
api_microversions=None):
if not credentials:
credentials = common_creds.get_configured_admin_credentials()
super(Manager, self).__init__(credentials)
self.introspection_client = BaremetalIntrospectionClient(
self.auth_provider,
CONF.baremetal_introspection.catalog_type,
CONF.identity.region,
endpoint_type=CONF.baremetal_introspection.endpoint_type)
class BaremetalIntrospectionClient(base.BaremetalClient):
"""Base Tempest REST client for Ironic Inspector API v1."""
version = '1'
uri_prefix = 'v1'
@base.handle_errors
def purge_rules(self):
"""Purge all existing rules."""
return self._delete_request('rules', uuid=None)
@base.handle_errors
def create_rules(self, rules):
"""Create introspection rules."""
if not isinstance(rules, list):
rules = [rules]
for rule in rules:
self._create_request('rules', rule)
@base.handle_errors
def get_status(self, uuid):
"""Get introspection status for a node."""
return self._show_request('introspection', uuid=uuid)
@base.handle_errors
def get_data(self, uuid):
"""Get introspection data for a node."""
return self._show_request('introspection', uuid=uuid,
uri='/%s/introspection/%s/data' %
(self.uri_prefix, uuid))
@base.handle_errors
def start_introspection(self, uuid):
"""Start introspection for a node."""
resp, _body = self.post(url=('/%s/introspection/%s' %
(self.uri_prefix, uuid)),
body=None)
self.expected_success(202, resp.status)
return resp
@base.handle_errors
def abort_introspection(self, uuid):
"""Abort introspection for a node."""
resp, _body = self.post(url=('/%s/introspection/%s/abort' %
(self.uri_prefix, uuid)),
body=None)
self.expected_success(202, resp.status)
return resp