blob: 5bb03c2ec0e875e75206be13ba0a6e1b0627afb0 [file] [log] [blame]
Anton Arefiev44f678c2016-03-17 12:11:30 +02001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
Anton Arefievd5998c02016-06-09 17:57:09 +030013from ironic_tempest_plugin.services.baremetal import base
Anton Arefiev44f678c2016-03-17 12:11:30 +020014from tempest import clients
15from tempest.common import credentials_factory as common_creds
16from tempest import config
Anton Arefiev44f678c2016-03-17 12:11:30 +020017
18
19CONF = config.CONF
20ADMIN_CREDS = common_creds.get_configured_admin_credentials()
21
22
23class Manager(clients.Manager):
24 def __init__(self,
25 credentials=ADMIN_CREDS,
26 service=None,
27 api_microversions=None):
28 super(Manager, self).__init__(credentials, service)
29 self.introspection_client = BaremetalIntrospectionClient(
30 self.auth_provider,
31 CONF.baremetal_introspection.catalog_type,
32 CONF.identity.region,
Jim Rollenhagen1611df82016-12-07 10:31:43 -050033 endpoint_type=CONF.baremetal_introspection.endpoint_type)
Anton Arefiev44f678c2016-03-17 12:11:30 +020034
35
36class BaremetalIntrospectionClient(base.BaremetalClient):
37 """Base Tempest REST client for Ironic Inspector API v1."""
38 version = '1'
39 uri_prefix = 'v1'
40
41 @base.handle_errors
42 def purge_rules(self):
43 """Purge all existing rules."""
44 return self._delete_request('rules', uuid=None)
45
46 @base.handle_errors
Anton Arefiev6b003562016-09-13 12:17:29 +030047 def create_rules(self, rules):
48 """Create introspection rules."""
49 if not isinstance(rules, list):
50 rules = [rules]
Anton Arefiev44f678c2016-03-17 12:11:30 +020051 for rule in rules:
52 self._create_request('rules', rule)
53
54 @base.handle_errors
55 def get_status(self, uuid):
56 """Get introspection status for a node."""
57 return self._show_request('introspection', uuid=uuid)
58
59 @base.handle_errors
60 def get_data(self, uuid):
61 """Get introspection data for a node."""
62 return self._show_request('introspection', uuid=uuid,
63 uri='/%s/introspection/%s/data' %
64 (self.uri_prefix, uuid))
Anton Arefiev6b003562016-09-13 12:17:29 +030065
66 @base.handle_errors
67 def start_introspection(self, uuid):
68 """Start introspection for a node."""
69 resp, _body = self.post(url=('/%s/introspection/%s' %
70 (self.uri_prefix, uuid)),
71 body=None)
72 self.expected_success(202, resp.status)
73
74 return resp
Sergii Nozhka1eb13cf2016-11-04 17:15:50 +020075
76 @base.handle_errors
77 def abort_introspection(self, uuid):
78 """Abort introspection for a node."""
79 resp, _body = self.post(url=('/%s/introspection/%s/abort' %
80 (self.uri_prefix, uuid)),
81 body=None)
82 self.expected_success(202, resp.status)
83
84 return resp