| 1 |
# 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 |
|
| 13 |
from http import client as http_client |
| 14 |
|
| 15 |
from ironic_tempest_plugin.services.baremetal import base |
| 16 |
|
| 17 |
|
| 18 |
class BaremetalClient(base.BaremetalClient): |
| 19 |
"""Base Tempest REST client for Ironic API v1.""" |
| 20 |
version = '1' |
| 21 |
uri_prefix = 'v1' |
| 22 |
|
| 23 |
node_attributes = ( |
| 24 |
'properties/cpu_arch', |
| 25 |
'properties/cpus', |
| 26 |
'properties/local_gb', |
| 27 |
'properties/memory_mb', |
| 28 |
'driver', |
| 29 |
'instance_uuid', |
| 30 |
'resource_class', |
| 31 |
'protected', |
| 32 |
'protected_reason', |
| 33 |
# TODO(dtantsur): maintenance is set differently |
| 34 |
# in newer API versions. |
| 35 |
'maintenance', |
| 36 |
'description', |
| 37 |
'shard' |
| 38 |
) + tuple( |
| 39 |
f'{iface}_interface' |
| 40 |
for iface in base.SUPPORTED_INTERFACES |
| 41 |
) |
| 42 |
|
| 43 |
@classmethod |
| 44 |
def _get_headers(cls, api_version): |
| 45 |
"""Return headers for a request. |
| 46 |
|
| 47 |
Currently supports a header specifying the API version to use. |
| 48 |
|
| 49 |
:param api_version: Ironic API version to use. |
| 50 |
:return: a 2-tuple of (extra_headers, headers), where 'extra_headers' |
| 51 |
is whether to use headers, and 'headers' is a list of headers to |
| 52 |
use in the request. |
| 53 |
""" |
| 54 |
extra_headers = False |
| 55 |
headers = None |
| 56 |
if api_version is not None: |
| 57 |
extra_headers = True |
| 58 |
headers = {cls.api_microversion_header_name: api_version} |
| 59 |
return extra_headers, headers |
| 60 |
|
| 61 |
@base.handle_errors |
| 62 |
def list_nodes(self, **kwargs): |
| 63 |
"""List all existing nodes.""" |
| 64 |
return self._list_request('nodes', **kwargs) |
| 65 |
|
| 66 |
@base.handle_errors |
| 67 |
def list_nodes_detail(self, **kwargs): |
| 68 |
"""Detailed list of all existing nodes.""" |
| 69 |
return self._list_request('/nodes/detail', **kwargs) |
| 70 |
|
| 71 |
@base.handle_errors |
| 72 |
def list_chassis(self): |
| 73 |
"""List all existing chassis.""" |
| 74 |
return self._list_request('chassis') |
| 75 |
|
| 76 |
@base.handle_errors |
| 77 |
def list_chassis_nodes(self, chassis_uuid): |
| 78 |
"""List all nodes associated with a chassis.""" |
| 79 |
return self._list_request('/chassis/%s/nodes' % chassis_uuid) |
| 80 |
|
| 81 |
@base.handle_errors |
| 82 |
def list_ports(self, **kwargs): |
| 83 |
"""List all existing ports.""" |
| 84 |
return self._list_request('ports', **kwargs) |
| 85 |
|
| 86 |
@base.handle_errors |
| 87 |
def list_portgroups(self, **kwargs): |
| 88 |
"""List all existing port groups.""" |
| 89 |
return self._list_request('portgroups', **kwargs) |
| 90 |
|
| 91 |
@base.handle_errors |
| 92 |
def list_volume_connectors(self, **kwargs): |
| 93 |
"""List all existing volume connectors.""" |
| 94 |
return self._list_request('volume/connectors', **kwargs) |
| 95 |
|
| 96 |
@base.handle_errors |
| 97 |
def list_volume_targets(self, **kwargs): |
| 98 |
"""List all existing volume targets.""" |
| 99 |
return self._list_request('volume/targets', **kwargs) |
| 100 |
|
| 101 |
@base.handle_errors |
| 102 |
def list_node_ports(self, uuid): |
| 103 |
"""List all ports associated with the node.""" |
| 104 |
return self._list_request('/nodes/%s/ports' % uuid) |
| 105 |
|
| 106 |
@base.handle_errors |
| 107 |
def list_node_ports_detail(self, uuid): |
| 108 |
"""List ports detail associated with the node.""" |
| 109 |
return self._list_request('/nodes/%s/ports/detail' % uuid) |
| 110 |
|
| 111 |
@base.handle_errors |
| 112 |
def list_nodestates(self, uuid): |
| 113 |
"""List all existing states.""" |
| 114 |
return self._list_request('/nodes/%s/states' % uuid) |
| 115 |
|
| 116 |
@base.handle_errors |
| 117 |
def list_node_bios_settings(self, uuid): |
| 118 |
"""List node bios settings.""" |
| 119 |
return self._list_request('/nodes/%s/bios' % uuid) |
| 120 |
|
| 121 |
@base.handle_errors |
| 122 |
def list_ports_detail(self, **kwargs): |
| 123 |
"""Details list all existing ports.""" |
| 124 |
return self._list_request('/ports/detail', **kwargs) |
| 125 |
|
| 126 |
@base.handle_errors |
| 127 |
def list_drivers(self): |
| 128 |
"""List all existing drivers.""" |
| 129 |
return self._list_request('drivers') |
| 130 |
|
| 131 |
@base.handle_errors |
| 132 |
def list_conductors(self, **kwargs): |
| 133 |
"""List all registered conductors.""" |
| 134 |
return self._list_request('conductors', **kwargs) |
| 135 |
|
| 136 |
@base.handle_errors |
| 137 |
def list_allocations(self, **kwargs): |
| 138 |
"""List all registered allocations.""" |
| 139 |
return self._list_request('allocations', **kwargs) |
| 140 |
|
| 141 |
@base.handle_errors |
| 142 |
def list_deploy_templates(self, **kwargs): |
| 143 |
"""List all deploy templates.""" |
| 144 |
return self._list_request('deploy_templates', **kwargs) |
| 145 |
|
| 146 |
@base.handle_errors |
| 147 |
def list_runbooks(self, **kwargs): |
| 148 |
"""List all runbooks.""" |
| 149 |
return self._list_request('runbooks', **kwargs) |
| 150 |
|
| 151 |
@base.handle_errors |
| 152 |
def show_node(self, uuid, api_version=None): |
| 153 |
"""Gets a specific node. |
| 154 |
|
| 155 |
:param uuid: Unique identifier of the node in UUID format. |
| 156 |
:param api_version: Ironic API version to use. |
| 157 |
:return: Serialized node as a dictionary. |
| 158 |
|
| 159 |
""" |
| 160 |
extra_headers, headers = self._get_headers(api_version) |
| 161 |
return self._show_request('nodes', uuid, headers=headers, |
| 162 |
extra_headers=extra_headers) |
| 163 |
|
| 164 |
@base.handle_errors |
| 165 |
def show_node_by_instance_uuid(self, instance_uuid, api_version=None): |
| 166 |
"""Gets a node associated with given instance uuid. |
| 167 |
|
| 168 |
:param instance_uuid: Unique identifier of the instance in UUID format. |
| 169 |
:param api_version: Ironic API version to use. |
| 170 |
:return: Serialized node as a dictionary. |
| 171 |
|
| 172 |
""" |
| 173 |
uri = '/nodes/detail?instance_uuid=%s' % instance_uuid |
| 174 |
extra_headers, headers = self._get_headers(api_version) |
| 175 |
return self._show_request('nodes', |
| 176 |
uuid=None, |
| 177 |
uri=uri, headers=headers, |
| 178 |
extra_headers=extra_headers) |
| 179 |
|
| 180 |
@base.handle_errors |
| 181 |
def show_chassis(self, uuid): |
| 182 |
"""Gets a specific chassis. |
| 183 |
|
| 184 |
:param uuid: Unique identifier of the chassis in UUID format. |
| 185 |
:return: Serialized chassis as a dictionary. |
| 186 |
|
| 187 |
""" |
| 188 |
return self._show_request('chassis', uuid) |
| 189 |
|
| 190 |
@base.handle_errors |
| 191 |
def show_port(self, uuid): |
| 192 |
"""Gets a specific port. |
| 193 |
|
| 194 |
:param uuid: Unique identifier of the port in UUID format. |
| 195 |
:return: Serialized port as a dictionary. |
| 196 |
|
| 197 |
""" |
| 198 |
return self._show_request('ports', uuid) |
| 199 |
|
| 200 |
@base.handle_errors |
| 201 |
def show_portgroup(self, portgroup_ident): |
| 202 |
"""Gets a specific port group. |
| 203 |
|
| 204 |
:param portgroup_ident: Name or UUID of the port group. |
| 205 |
:return: Serialized port group as a dictionary. |
| 206 |
""" |
| 207 |
return self._show_request('portgroups', portgroup_ident) |
| 208 |
|
| 209 |
@base.handle_errors |
| 210 |
def show_volume_connector(self, volume_connector_ident): |
| 211 |
"""Gets a specific volume connector. |
| 212 |
|
| 213 |
:param volume_connector_ident: UUID of the volume connector. |
| 214 |
:return: Serialized volume connector as a dictionary. |
| 215 |
""" |
| 216 |
return self._show_request('volume/connectors', volume_connector_ident) |
| 217 |
|
| 218 |
@base.handle_errors |
| 219 |
def show_volume_target(self, volume_target_ident): |
| 220 |
"""Gets a specific volume target. |
| 221 |
|
| 222 |
:param volume_target_ident: UUID of the volume target. |
| 223 |
:return: Serialized volume target as a dictionary. |
| 224 |
""" |
| 225 |
return self._show_request('volume/targets', volume_target_ident) |
| 226 |
|
| 227 |
@base.handle_errors |
| 228 |
def show_port_by_address(self, address): |
| 229 |
"""Gets a specific port by address. |
| 230 |
|
| 231 |
:param address: MAC address of the port. |
| 232 |
:return: Serialized port as a dictionary. |
| 233 |
|
| 234 |
""" |
| 235 |
uri = '/ports/detail?address=%s' % address |
| 236 |
|
| 237 |
return self._show_request('ports', uuid=None, uri=uri) |
| 238 |
|
| 239 |
def show_driver(self, driver_name): |
| 240 |
"""Gets a specific driver. |
| 241 |
|
| 242 |
:param driver_name: Name of driver. |
| 243 |
:return: Serialized driver as a dictionary. |
| 244 |
""" |
| 245 |
return self._show_request('drivers', driver_name) |
| 246 |
|
| 247 |
def show_conductor(self, hostname): |
| 248 |
"""Gets a specific conductor. |
| 249 |
|
| 250 |
:param hostname: Hostname of conductor. |
| 251 |
:return: Serialized conductor as a dictionary. |
| 252 |
""" |
| 253 |
return self._show_request('conductors', hostname) |
| 254 |
|
| 255 |
def show_allocation(self, allocation_ident): |
| 256 |
"""Gets a specific allocation. |
| 257 |
|
| 258 |
:param allocation_ident: UUID or name of allocation. |
| 259 |
:return: Serialized allocation as a dictionary. |
| 260 |
""" |
| 261 |
return self._show_request('allocations', allocation_ident) |
| 262 |
|
| 263 |
def show_node_allocation(self, node_ident): |
| 264 |
"""Gets an allocation for the node. |
| 265 |
|
| 266 |
:param node_ident: Node UUID or name. |
| 267 |
:return: Serialized allocation as a dictionary. |
| 268 |
""" |
| 269 |
uri = '/nodes/%s/allocation' % node_ident |
| 270 |
return self._show_request('nodes', uuid=None, uri=uri) |
| 271 |
|
| 272 |
def show_deploy_template(self, deploy_template_ident): |
| 273 |
"""Gets a specific deploy template. |
| 274 |
|
| 275 |
:param deploy_template_ident: Name or UUID of deploy template. |
| 276 |
:return: Serialized deploy template as a dictionary. |
| 277 |
""" |
| 278 |
return self._show_request('deploy_templates', deploy_template_ident) |
| 279 |
|
| 280 |
def show_runbook(self, runbook_ident): |
| 281 |
"""Gets a specific runbook. |
| 282 |
|
| 283 |
:param runbook_ident: Name or UUID of runbook. |
| 284 |
:return: Serialized runbook as a dictionary. |
| 285 |
""" |
| 286 |
return self._show_request('runbooks', runbook_ident) |
| 287 |
|
| 288 |
@base.handle_errors |
| 289 |
def create_node(self, chassis_id=None, **kwargs): |
| 290 |
"""Create a baremetal node with the specified parameters. |
| 291 |
|
| 292 |
:param chassis_id: The unique identifier of the chassis. |
| 293 |
:param cpu_arch: CPU architecture of the node. Default: x86_64. |
| 294 |
:param cpus: Number of CPUs. Default: 8. |
| 295 |
:param local_gb: Disk size. Default: 1024. |
| 296 |
:param memory_mb: Available RAM. Default: 4096. |
| 297 |
:param driver: Driver name. Default: "fake" |
| 298 |
:return: A tuple with the server response and the created node. |
| 299 |
|
| 300 |
""" |
| 301 |
node = {} |
| 302 |
# Explicitly allow definition of network interface, deploy |
| 303 |
# interface, and console interface to allow tests to specify |
| 304 |
# the required values as they hold a great deal of logic which |
| 305 |
# is executed upon and they can ultimately impact test behavior. |
| 306 |
for field in ('resource_class', 'name', 'description', 'shard', |
| 307 |
'network_interface', 'deploy_interface', |
| 308 |
'console_interface'): |
| 309 |
if kwargs.get(field): |
| 310 |
node[field] = kwargs[field] |
| 311 |
|
| 312 |
node.update( |
| 313 |
{'chassis_uuid': chassis_id, |
| 314 |
'properties': {'cpu_arch': kwargs.get('cpu_arch', 'x86_64'), |
| 315 |
'cpus': kwargs.get('cpus', 8), |
| 316 |
'local_gb': kwargs.get('local_gb', 1024), |
| 317 |
'memory_mb': kwargs.get('memory_mb', 4096)}, |
| 318 |
'driver': kwargs.get('driver', 'fake-hardware')} |
| 319 |
) |
| 320 |
|
| 321 |
return self._create_request('nodes', node) |
| 322 |
|
| 323 |
@base.handle_errors |
| 324 |
def create_node_raw(self, **kwargs): |
| 325 |
"""Create a baremetal node from the given body.""" |
| 326 |
return self._create_request('nodes', kwargs) |
| 327 |
|
| 328 |
@base.handle_errors |
| 329 |
def create_chassis(self, **kwargs): |
| 330 |
"""Create a chassis with the specified parameters. |
| 331 |
|
| 332 |
:param description: The description of the chassis. |
| 333 |
Default: test-chassis |
| 334 |
:return: A tuple with the server response and the created chassis. |
| 335 |
""" |
| 336 |
chassis = {'description': kwargs.get('description', 'test-chassis')} |
| 337 |
|
| 338 |
if 'uuid' in kwargs: |
| 339 |
chassis.update({'uuid': kwargs.get('uuid')}) |
| 340 |
|
| 341 |
return self._create_request('chassis', chassis) |
| 342 |
|
| 343 |
@base.handle_errors |
| 344 |
def create_port(self, node_id, **kwargs): |
| 345 |
"""Create a port with the specified parameters. |
| 346 |
|
| 347 |
:param node_id: The ID of the node which owns the port. |
| 348 |
:param address: MAC address of the port. |
| 349 |
:param extra: Meta data of the port. Default: {'foo': 'bar'}. |
| 350 |
:param uuid: UUID of the port. |
| 351 |
:param portgroup_uuid: The UUID of a portgroup of which this port is a |
| 352 |
member. |
| 353 |
:param physical_network: The physical network to which the port is |
| 354 |
attached. |
| 355 |
:return: A tuple with the server response and the created port. |
| 356 |
|
| 357 |
""" |
| 358 |
port = {'extra': kwargs.get('extra', {'foo': 'bar'})} |
| 359 |
|
| 360 |
if node_id is not None: |
| 361 |
port['node_uuid'] = node_id |
| 362 |
|
| 363 |
for key in ('uuid', 'address', 'physical_network', 'portgroup_uuid'): |
| 364 |
if kwargs.get(key) is not None: |
| 365 |
port[key] = kwargs[key] |
| 366 |
|
| 367 |
return self._create_request('ports', port) |
| 368 |
|
| 369 |
@base.handle_errors |
| 370 |
def create_portgroup(self, node_uuid, **kwargs): |
| 371 |
"""Create a port group with the specified parameters. |
| 372 |
|
| 373 |
:param node_uuid: The UUID of the node which owns the port group. |
| 374 |
:param kwargs: |
| 375 |
address: MAC address of the port group. Optional. |
| 376 |
extra: Meta data of the port group. Default: {'foo': 'bar'}. |
| 377 |
name: Name of the port group. Optional. |
| 378 |
uuid: UUID of the port group. Optional. |
| 379 |
:return: A tuple with the server response and the created port group. |
| 380 |
""" |
| 381 |
portgroup = {'extra': kwargs.get( |
| 382 |
'extra', {'foo': 'bar', 'open': 'stack'}), 'node_uuid': node_uuid} |
| 383 |
|
| 384 |
if kwargs.get('address'): |
| 385 |
portgroup['address'] = kwargs['address'] |
| 386 |
|
| 387 |
if kwargs.get('name'): |
| 388 |
portgroup['name'] = kwargs['name'] |
| 389 |
|
| 390 |
return self._create_request('portgroups', portgroup) |
| 391 |
|
| 392 |
@base.handle_errors |
| 393 |
def update_portgroup(self, uuid, patch): |
| 394 |
"""Update the specified port group. |
| 395 |
|
| 396 |
:param uuid: The unique identifier of the port group. |
| 397 |
:param patch: List of dicts representing json patches. |
| 398 |
:return: A tuple with the server response and the updated port group. |
| 399 |
""" |
| 400 |
|
| 401 |
return self._patch_request('portgroups', uuid, patch) |
| 402 |
|
| 403 |
@base.handle_errors |
| 404 |
def create_volume_connector(self, node_uuid, **kwargs): |
| 405 |
"""Create a volume connector with the specified parameters. |
| 406 |
|
| 407 |
:param node_uuid: The UUID of the node which owns the volume connector. |
| 408 |
:param kwargs: |
| 409 |
type: type of the volume connector. |
| 410 |
connector_id: connector_id of the volume connector. |
| 411 |
uuid: UUID of the volume connector. Optional. |
| 412 |
extra: meta data of the volume connector; a dictionary. Optional. |
| 413 |
:return: A tuple with the server response and the created volume |
| 414 |
connector. |
| 415 |
""" |
| 416 |
volume_connector = {'node_uuid': node_uuid} |
| 417 |
|
| 418 |
for arg in ('type', 'connector_id', 'uuid', 'extra'): |
| 419 |
if arg in kwargs: |
| 420 |
volume_connector[arg] = kwargs[arg] |
| 421 |
|
| 422 |
return self._create_request('volume/connectors', volume_connector) |
| 423 |
|
| 424 |
@base.handle_errors |
| 425 |
def create_volume_target(self, node_uuid, **kwargs): |
| 426 |
"""Create a volume target with the specified parameters. |
| 427 |
|
| 428 |
:param node_uuid: The UUID of the node which owns the volume target. |
| 429 |
:param kwargs: |
| 430 |
volume_type: type of the volume target. |
| 431 |
volume_id: volume_id of the volume target. |
| 432 |
boot_index: boot index of the volume target. |
| 433 |
uuid: UUID of the volume target. Optional. |
| 434 |
extra: meta data of the volume target; a dictionary. Optional. |
| 435 |
properties: properties related to the type of the volume target; |
| 436 |
a dictionary. Optional. |
| 437 |
:return: A tuple with the server response and the created volume |
| 438 |
target. |
| 439 |
""" |
| 440 |
volume_target = {'node_uuid': node_uuid} |
| 441 |
|
| 442 |
for arg in ('volume_type', 'volume_id', 'boot_index', 'uuid', 'extra', |
| 443 |
'properties'): |
| 444 |
if arg in kwargs: |
| 445 |
volume_target[arg] = kwargs[arg] |
| 446 |
|
| 447 |
return self._create_request('volume/targets', volume_target) |
| 448 |
|
| 449 |
@base.handle_errors |
| 450 |
def create_deploy_template(self, name, **kwargs): |
| 451 |
"""Create a deploy template with the specified parameters. |
| 452 |
|
| 453 |
:param name: The name of the deploy template. |
| 454 |
:param kwargs: |
| 455 |
steps: deploy steps of the template. |
| 456 |
uuid: UUID of the deploy template. Optional. |
| 457 |
extra: meta-data of the deploy template. Optional. |
| 458 |
:return: A tuple with the server response and the created deploy |
| 459 |
template. |
| 460 |
""" |
| 461 |
kwargs['name'] = name |
| 462 |
return self._create_request('deploy_templates', kwargs) |
| 463 |
|
| 464 |
@base.handle_errors |
| 465 |
def create_runbook(self, name, **kwargs): |
| 466 |
"""Create a runbook with the specified parameters. |
| 467 |
|
| 468 |
:param name: The name of the runbook. |
| 469 |
:param kwargs: |
| 470 |
steps: steps of the runbook. |
| 471 |
uuid: UUID of the runbook. Optional. |
| 472 |
public: An optional boolean value indicating whether the runbook |
| 473 |
is public (accessible to others) |
| 474 |
or private (restricted to the owner). |
| 475 |
extra: meta-data of the runbook. Optional. |
| 476 |
:return: A tuple with the server response and the created runbook. |
| 477 |
""" |
| 478 |
kwargs['name'] = name |
| 479 |
return self._create_request('runbooks', kwargs) |
| 480 |
|
| 481 |
@base.handle_errors |
| 482 |
def delete_node(self, uuid): |
| 483 |
"""Deletes a node having the specified UUID. |
| 484 |
|
| 485 |
:param uuid: The unique identifier of the node. |
| 486 |
:return: A tuple with the server response and the response body. |
| 487 |
|
| 488 |
""" |
| 489 |
return self._delete_request('nodes', uuid) |
| 490 |
|
| 491 |
@base.handle_errors |
| 492 |
def delete_chassis(self, uuid): |
| 493 |
"""Deletes a chassis having the specified UUID. |
| 494 |
|
| 495 |
:param uuid: The unique identifier of the chassis. |
| 496 |
:return: A tuple with the server response and the response body. |
| 497 |
|
| 498 |
""" |
| 499 |
return self._delete_request('chassis', uuid) |
| 500 |
|
| 501 |
@base.handle_errors |
| 502 |
def delete_port(self, uuid): |
| 503 |
"""Deletes a port having the specified UUID. |
| 504 |
|
| 505 |
:param uuid: The unique identifier of the port. |
| 506 |
:return: A tuple with the server response and the response body. |
| 507 |
|
| 508 |
""" |
| 509 |
return self._delete_request('ports', uuid) |
| 510 |
|
| 511 |
@base.handle_errors |
| 512 |
def delete_portgroup(self, portgroup_ident): |
| 513 |
"""Deletes a port group having the specified UUID or name. |
| 514 |
|
| 515 |
:param portgroup_ident: Name or UUID of the port group. |
| 516 |
:return: A tuple with the server response and the response body. |
| 517 |
""" |
| 518 |
return self._delete_request('portgroups', portgroup_ident) |
| 519 |
|
| 520 |
@base.handle_errors |
| 521 |
def delete_volume_connector(self, volume_connector_ident): |
| 522 |
"""Deletes a volume connector having the specified UUID. |
| 523 |
|
| 524 |
:param volume_connector_ident: UUID of the volume connector. |
| 525 |
:return: A tuple with the server response and the response body. |
| 526 |
""" |
| 527 |
return self._delete_request('volume/connectors', |
| 528 |
volume_connector_ident) |
| 529 |
|
| 530 |
@base.handle_errors |
| 531 |
def delete_volume_target(self, volume_target_ident): |
| 532 |
"""Deletes a volume target having the specified UUID. |
| 533 |
|
| 534 |
:param volume_target_ident: UUID of the volume target. |
| 535 |
:return: A tuple with the server response and the response body. |
| 536 |
""" |
| 537 |
return self._delete_request('volume/targets', volume_target_ident) |
| 538 |
|
| 539 |
@base.handle_errors |
| 540 |
def delete_deploy_template(self, deploy_template_ident): |
| 541 |
"""Deletes a deploy template having the specified name or UUID. |
| 542 |
|
| 543 |
:param deploy_template_ident: Name or UUID of the deploy template. |
| 544 |
:return: A tuple with the server response and the response body. |
| 545 |
""" |
| 546 |
return self._delete_request('deploy_templates', deploy_template_ident) |
| 547 |
|
| 548 |
@base.handle_errors |
| 549 |
def delete_runbook(self, runbook_ident): |
| 550 |
"""Deletes a runbook having the specified name or UUID. |
| 551 |
|
| 552 |
:param runbook_ident: Name or UUID of the runbook. |
| 553 |
:return: A tuple with the server response and the response body. |
| 554 |
""" |
| 555 |
return self._delete_request('runbooks', runbook_ident) |
| 556 |
|
| 557 |
@base.handle_errors |
| 558 |
def update_node(self, uuid, patch=None, **kwargs): |
| 559 |
"""Update the specified node. |
| 560 |
|
| 561 |
:param uuid: The unique identifier of the node. |
| 562 |
:param patch: A JSON path that sets values of the specified attributes |
| 563 |
to the new ones. |
| 564 |
:param **kwargs: Attributes and new values for them, used only when |
| 565 |
patch param is not set. |
| 566 |
:return: A tuple with the server response and the updated node. |
| 567 |
|
| 568 |
""" |
| 569 |
if 'reset_interfaces' in kwargs: |
| 570 |
params = {'reset_interfaces': str(kwargs.pop('reset_interfaces'))} |
| 571 |
else: |
| 572 |
params = {} |
| 573 |
|
| 574 |
if not patch: |
| 575 |
patch = self._make_patch(self.node_attributes, **kwargs) |
| 576 |
|
| 577 |
return self._patch_request('nodes', uuid, patch, params=params) |
| 578 |
|
| 579 |
@base.handle_errors |
| 580 |
def update_chassis(self, uuid, **kwargs): |
| 581 |
"""Update the specified chassis. |
| 582 |
|
| 583 |
:param uuid: The unique identifier of the chassis. |
| 584 |
:return: A tuple with the server response and the updated chassis. |
| 585 |
|
| 586 |
""" |
| 587 |
chassis_attributes = ('description',) |
| 588 |
patch = self._make_patch(chassis_attributes, **kwargs) |
| 589 |
|
| 590 |
return self._patch_request('chassis', uuid, patch) |
| 591 |
|
| 592 |
@base.handle_errors |
| 593 |
def update_port(self, uuid, patch): |
| 594 |
"""Update the specified port. |
| 595 |
|
| 596 |
:param uuid: The unique identifier of the port. |
| 597 |
:param patch: List of dicts representing json patches. |
| 598 |
:return: A tuple with the server response and the updated port. |
| 599 |
|
| 600 |
""" |
| 601 |
|
| 602 |
return self._patch_request('ports', uuid, patch) |
| 603 |
|
| 604 |
@base.handle_errors |
| 605 |
def update_volume_connector(self, uuid, patch): |
| 606 |
"""Update the specified volume connector. |
| 607 |
|
| 608 |
:param uuid: The unique identifier of the volume connector. |
| 609 |
:param patch: List of dicts representing json patches. Each dict |
| 610 |
has keys 'path', 'op' and 'value'; to update a field. |
| 611 |
:return: A tuple with the server response and the updated volume |
| 612 |
connector. |
| 613 |
""" |
| 614 |
|
| 615 |
return self._patch_request('volume/connectors', uuid, patch) |
| 616 |
|
| 617 |
@base.handle_errors |
| 618 |
def update_volume_target(self, uuid, patch): |
| 619 |
"""Update the specified volume target. |
| 620 |
|
| 621 |
:param uuid: The unique identifier of the volume target. |
| 622 |
:param patch: List of dicts representing json patches. Each dict |
| 623 |
has keys 'path', 'op' and 'value'; to update a field. |
| 624 |
:return: A tuple with the server response and the updated volume |
| 625 |
target. |
| 626 |
""" |
| 627 |
|
| 628 |
return self._patch_request('volume/targets', uuid, patch) |
| 629 |
|
| 630 |
@base.handle_errors |
| 631 |
def update_deploy_template(self, deploy_template_ident, patch): |
| 632 |
"""Update the specified deploy template. |
| 633 |
|
| 634 |
:param deploy_template_ident: Name or UUID of the deploy template. |
| 635 |
:param patch: List of dicts representing json patches. Each dict |
| 636 |
has keys 'path', 'op' and 'value'; to update a field. |
| 637 |
:return: A tuple with the server response and the updated deploy |
| 638 |
template. |
| 639 |
""" |
| 640 |
|
| 641 |
return self._patch_request('deploy_templates', deploy_template_ident, |
| 642 |
patch) |
| 643 |
|
| 644 |
@base.handle_errors |
| 645 |
def update_runbook(self, runbook_ident, patch): |
| 646 |
"""Update the specified runbook. |
| 647 |
|
| 648 |
:param runbook_ident: Name or UUID of the runbook. |
| 649 |
:param patch: List of dicts representing json patches. Each dict |
| 650 |
has keys 'path', 'op' and 'value'; to update a field. |
| 651 |
:return: A tuple with the server response and the updated runbook. |
| 652 |
""" |
| 653 |
|
| 654 |
return self._patch_request('runbooks', runbook_ident, patch) |
| 655 |
|
| 656 |
@base.handle_errors |
| 657 |
def set_node_power_state(self, node_uuid, state): |
| 658 |
"""Set power state of the specified node. |
| 659 |
|
| 660 |
:param node_uuid: The unique identifier of the node. |
| 661 |
:param state: desired state to set (on/off/reboot). |
| 662 |
|
| 663 |
""" |
| 664 |
target = {'target': state} |
| 665 |
return self._put_request('nodes/%s/states/power' % node_uuid, |
| 666 |
target) |
| 667 |
|
| 668 |
@base.handle_errors |
| 669 |
def set_node_state(self, node_uuid, state, target): |
| 670 |
"""Set state for the specified node. |
| 671 |
|
| 672 |
:param node_uuid: The unique identifier of the node. |
| 673 |
:param state: The desired state to set. |
| 674 |
:param target: The target state |
| 675 |
|
| 676 |
""" |
| 677 |
target = {'target': target} |
| 678 |
return self._put_request('nodes/%s/states/%s' % (node_uuid, state), |
| 679 |
target) |
| 680 |
|
| 681 |
@base.handle_errors |
| 682 |
def set_node_provision_state(self, node_uuid, state, configdrive=None, |
| 683 |
clean_steps=None, rescue_password=None, |
| 684 |
runbook=None): |
| 685 |
"""Set provision state of the specified node. |
| 686 |
|
| 687 |
:param node_uuid: The unique identifier of the node. |
| 688 |
:param state: desired state to set |
| 689 |
(active/rebuild/deleted/inspect/manage/provide). |
| 690 |
:param configdrive: A gzipped, base64-encoded |
| 691 |
configuration drive string. |
| 692 |
:param clean_steps: A list with clean steps to execute. |
| 693 |
:param rescue_password: user password used to rescue. |
| 694 |
:param runbook: The unique identifier of a runbook. |
| 695 |
""" |
| 696 |
data = {'target': state} |
| 697 |
# NOTE (vsaienk0): Add both here if specified, do not check anything. |
| 698 |
# API will return an error in case of invalid parameters. |
| 699 |
if configdrive is not None: |
| 700 |
data['configdrive'] = configdrive |
| 701 |
if clean_steps is not None: |
| 702 |
data['clean_steps'] = clean_steps |
| 703 |
if rescue_password is not None: |
| 704 |
data['rescue_password'] = rescue_password |
| 705 |
if runbook is not None: |
| 706 |
data['runbook'] = runbook |
| 707 |
return self._put_request('nodes/%s/states/provision' % node_uuid, |
| 708 |
data) |
| 709 |
|
| 710 |
@base.handle_errors |
| 711 |
def set_node_raid_config(self, node_uuid, target_raid_config): |
| 712 |
"""Set raid config of the specified node. |
| 713 |
|
| 714 |
:param node_uuid: The unique identifier of the node. |
| 715 |
:param target_raid_config: desired RAID configuration of the node. |
| 716 |
""" |
| 717 |
return self._put_request('nodes/%s/states/raid' % node_uuid, |
| 718 |
target_raid_config) |
| 719 |
|
| 720 |
@base.handle_errors |
| 721 |
def validate_driver_interface(self, node_uuid): |
| 722 |
"""Get all driver interfaces of a specific node. |
| 723 |
|
| 724 |
:param node_uuid: Unique identifier of the node in UUID format. |
| 725 |
|
| 726 |
""" |
| 727 |
|
| 728 |
uri = '{pref}/{res}/{uuid}/{postf}'.format(pref=self.uri_prefix, |
| 729 |
res='nodes', |
| 730 |
uuid=node_uuid, |
| 731 |
postf='validate') |
| 732 |
|
| 733 |
return self._show_request('nodes', node_uuid, uri=uri) |
| 734 |
|
| 735 |
@base.handle_errors |
| 736 |
def set_node_boot_device(self, node_uuid, boot_device, persistent=False): |
| 737 |
"""Set the boot device of the specified node. |
| 738 |
|
| 739 |
:param node_uuid: The unique identifier of the node. |
| 740 |
:param boot_device: The boot device name. |
| 741 |
:param persistent: Boolean value. True if the boot device will |
| 742 |
persist to all future boots, False if not. |
| 743 |
Default: False. |
| 744 |
|
| 745 |
""" |
| 746 |
request = {'boot_device': boot_device, 'persistent': persistent} |
| 747 |
resp, body = self._put_request('nodes/%s/management/boot_device' % |
| 748 |
node_uuid, request) |
| 749 |
self.expected_success(http_client.NO_CONTENT, resp.status) |
| 750 |
return body |
| 751 |
|
| 752 |
@base.handle_errors |
| 753 |
def get_node_boot_device(self, node_uuid): |
| 754 |
"""Get the current boot device of the specified node. |
| 755 |
|
| 756 |
:param node_uuid: The unique identifier of the node. |
| 757 |
|
| 758 |
""" |
| 759 |
path = 'nodes/%s/management/boot_device' % node_uuid |
| 760 |
resp, body = self._list_request(path) |
| 761 |
self.expected_success(http_client.OK, resp.status) |
| 762 |
return body |
| 763 |
|
| 764 |
@base.handle_errors |
| 765 |
def set_node_indicator_state(self, node_uuid, component, ind_ident, state): |
| 766 |
"""Get the current indicator state |
| 767 |
|
| 768 |
:param node_uuid: The unique identifier of the node. |
| 769 |
:param component: The Bare Metal node component. |
| 770 |
:param ind_ident: The indicator of a Bare Metal component. |
| 771 |
:param state: The state of an indicator of the component of the node. |
| 772 |
Possible values are: OFF, ON, BLINKING or UNKNOWN. |
| 773 |
|
| 774 |
""" |
| 775 |
resp, body = self._put_request( |
| 776 |
'nodes/%s/management/indicators/%s@%s' |
| 777 |
% (node_uuid, ind_ident, component), {'state': state}) |
| 778 |
self.expected_success(http_client.OK, resp.status) |
| 779 |
return resp, body |
| 780 |
|
| 781 |
@base.handle_errors |
| 782 |
def get_node_indicator_state(self, node_uuid, component, ind_ident): |
| 783 |
"""Get the current indicator state |
| 784 |
|
| 785 |
:param node_uuid: The unique identifier of the node. |
| 786 |
:param component: The Bare Metal node component. |
| 787 |
:param ind_ident: The indicator of a Bare Metal component. |
| 788 |
|
| 789 |
""" |
| 790 |
path = 'nodes/%s/management/indicators/%s@%s' % (node_uuid, ind_ident, |
| 791 |
component) |
| 792 |
resp, body = self._list_request(path) |
| 793 |
self.expected_success(http_client.OK, resp.status) |
| 794 |
return resp, body |
| 795 |
|
| 796 |
@base.handle_errors |
| 797 |
def get_node_supported_boot_devices(self, node_uuid): |
| 798 |
"""Get the supported boot devices of the specified node. |
| 799 |
|
| 800 |
:param node_uuid: The unique identifier of the node. |
| 801 |
|
| 802 |
""" |
| 803 |
path = 'nodes/%s/management/boot_device/supported' % node_uuid |
| 804 |
resp, body = self._list_request(path) |
| 805 |
self.expected_success(http_client.OK, resp.status) |
| 806 |
return body |
| 807 |
|
| 808 |
@base.handle_errors |
| 809 |
def get_console(self, node_uuid): |
| 810 |
"""Get connection information about the console. |
| 811 |
|
| 812 |
:param node_uuid: Unique identifier of the node in UUID format. |
| 813 |
|
| 814 |
""" |
| 815 |
|
| 816 |
resp, body = self._show_request('nodes/states/console', node_uuid) |
| 817 |
self.expected_success(http_client.OK, resp.status) |
| 818 |
return resp, body |
| 819 |
|
| 820 |
@base.handle_errors |
| 821 |
def set_console_mode(self, node_uuid, enabled): |
| 822 |
"""Start and stop the node console. |
| 823 |
|
| 824 |
:param node_uuid: Unique identifier of the node in UUID format. |
| 825 |
:param enabled: Boolean value; whether to enable or disable the |
| 826 |
console. |
| 827 |
|
| 828 |
""" |
| 829 |
|
| 830 |
enabled = {'enabled': enabled} |
| 831 |
resp, body = self._put_request('nodes/%s/states/console' % node_uuid, |
| 832 |
enabled) |
| 833 |
self.expected_success(http_client.ACCEPTED, resp.status) |
| 834 |
return resp, body |
| 835 |
|
| 836 |
@base.handle_errors |
| 837 |
def vif_list(self, node_uuid, api_version=None): |
| 838 |
"""Get list of attached VIFs. |
| 839 |
|
| 840 |
:param node_uuid: Unique identifier of the node in UUID format. |
| 841 |
:param api_version: Ironic API version to use. |
| 842 |
""" |
| 843 |
extra_headers = False |
| 844 |
headers = None |
| 845 |
if api_version is not None: |
| 846 |
extra_headers = True |
| 847 |
headers = {self.api_microversion_header_name: api_version} |
| 848 |
return self._list_request('nodes/%s/vifs' % node_uuid, |
| 849 |
headers=headers, |
| 850 |
extra_headers=extra_headers) |
| 851 |
|
| 852 |
@base.handle_errors |
| 853 |
def vif_attach(self, node_uuid, vif_id): |
| 854 |
"""Attach a VIF to a node |
| 855 |
|
| 856 |
:param node_uuid: Unique identifier of the node in UUID format. |
| 857 |
:param vif_id: An ID representing the VIF |
| 858 |
""" |
| 859 |
vif = {'id': vif_id} |
| 860 |
resp = self._create_request_no_response_body( |
| 861 |
'nodes/%s/vifs' % node_uuid, vif) |
| 862 |
|
| 863 |
return resp |
| 864 |
|
| 865 |
@base.handle_errors |
| 866 |
def vif_detach(self, node_uuid, vif_id): |
| 867 |
"""Detach a VIF from a node |
| 868 |
|
| 869 |
:param node_uuid: Unique identifier of the node in UUID format. |
| 870 |
:param vif_id: An ID representing the VIF |
| 871 |
""" |
| 872 |
resp, body = self._delete_request('nodes/%s/vifs' % node_uuid, vif_id) |
| 873 |
self.expected_success(http_client.NO_CONTENT, resp.status) |
| 874 |
return resp, body |
| 875 |
|
| 876 |
@base.handle_errors |
| 877 |
def get_driver_properties(self, driver_name): |
| 878 |
"""Get properties information about driver. |
| 879 |
|
| 880 |
:param driver_name: Name of driver. |
| 881 |
:return: tuple of response and serialized properties as a dictionary. |
| 882 |
|
| 883 |
""" |
| 884 |
uri = 'drivers/%s/properties' % driver_name |
| 885 |
resp, body = self.get(uri) |
| 886 |
self.expected_success(200, resp.status) |
| 887 |
return resp, self.deserialize(body) |
| 888 |
|
| 889 |
@base.handle_errors |
| 890 |
def get_driver_logical_disk_properties(self, driver_name): |
| 891 |
"""Get driver logical disk properties. |
| 892 |
|
| 893 |
:param driver_name: Name of driver. |
| 894 |
:return: tuple of response and serialized logical disk properties as |
| 895 |
a dictionary. |
| 896 |
|
| 897 |
""" |
| 898 |
uri = 'drivers/%s/raid/logical_disk_properties' % driver_name |
| 899 |
resp, body = self.get(uri) |
| 900 |
self.expected_success(200, resp.status) |
| 901 |
return resp, self.deserialize(body) |
| 902 |
|
| 903 |
@base.handle_errors |
| 904 |
def list_node_traits(self, node_uuid): |
| 905 |
"""List all traits associated with the node. |
| 906 |
|
| 907 |
:param node_uuid: The unique identifier of the node. |
| 908 |
""" |
| 909 |
return self._list_request('/nodes/%s/traits' % node_uuid) |
| 910 |
|
| 911 |
@base.handle_errors |
| 912 |
def set_node_traits(self, node_uuid, traits): |
| 913 |
"""Set all traits of the specified node. |
| 914 |
|
| 915 |
:param node_uuid: The unique identifier of the node. |
| 916 |
:param traits: A list of traits to set. |
| 917 |
""" |
| 918 |
request = {'traits': traits} |
| 919 |
resp, body = self._put_request('nodes/%s/traits' % |
| 920 |
node_uuid, request) |
| 921 |
self.expected_success(http_client.NO_CONTENT, resp.status) |
| 922 |
return resp, body |
| 923 |
|
| 924 |
@base.handle_errors |
| 925 |
def add_node_trait(self, node_uuid, trait): |
| 926 |
"""Add a trait to the specified node. |
| 927 |
|
| 928 |
:param node_uuid: The unique identifier of the node. |
| 929 |
:param trait: A trait to add. |
| 930 |
""" |
| 931 |
resp, body = self._put_request('nodes/%s/traits/%s' % |
| 932 |
(node_uuid, trait), {}) |
| 933 |
self.expected_success(http_client.NO_CONTENT, resp.status) |
| 934 |
return resp, body |
| 935 |
|
| 936 |
@base.handle_errors |
| 937 |
def remove_node_traits(self, node_uuid): |
| 938 |
"""Remove all traits from the specified node. |
| 939 |
|
| 940 |
:param node_uuid: Unique identifier of the node in UUID format. |
| 941 |
""" |
| 942 |
resp, body = self._delete_request('nodes/%s/traits' % node_uuid, {}) |
| 943 |
self.expected_success(http_client.NO_CONTENT, resp.status) |
| 944 |
return resp, body |
| 945 |
|
| 946 |
@base.handle_errors |
| 947 |
def remove_node_trait(self, node_uuid, trait): |
| 948 |
"""Remove a trait from the specified node. |
| 949 |
|
| 950 |
:param node_uuid: Unique identifier of the node in UUID format. |
| 951 |
:param trait: A trait to remove. |
| 952 |
""" |
| 953 |
resp, body = self._delete_request('nodes/%s/traits/%s' % |
| 954 |
(node_uuid, trait), {}) |
| 955 |
self.expected_success(http_client.NO_CONTENT, resp.status) |
| 956 |
return resp, body |
| 957 |
|
| 958 |
@base.handle_errors |
| 959 |
def create_allocation(self, resource_class, **kwargs): |
| 960 |
"""Create a baremetal allocation with the specified parameters. |
| 961 |
|
| 962 |
:param resource_class: Resource class to request. |
| 963 |
:param kwargs: Other fields to pass. |
| 964 |
:return: A tuple with the server response and the created allocation. |
| 965 |
|
| 966 |
""" |
| 967 |
if resource_class: |
| 968 |
kwargs['resource_class'] = resource_class |
| 969 |
return self._create_request('allocations', kwargs) |
| 970 |
|
| 971 |
@base.handle_errors |
| 972 |
def delete_allocation(self, allocation_ident): |
| 973 |
"""Deletes an allocation. |
| 974 |
|
| 975 |
:param allocation_ident: UUID or name of the allocation. |
| 976 |
:return: A tuple with the server response and the response body. |
| 977 |
|
| 978 |
""" |
| 979 |
return self._delete_request('allocations', allocation_ident) |
| 980 |
|
| 981 |
@base.handle_errors |
| 982 |
def list_node_history(self, node_uuid): |
| 983 |
"""List history entries for a node. |
| 984 |
|
| 985 |
:param node_uuid: The unique identifier of the node. |
| 986 |
""" |
| 987 |
return self._list_request('/nodes/%s/history' % node_uuid) |
| 988 |
|
| 989 |
@base.handle_errors |
| 990 |
def list_vendor_passthru_methods(self, node_uuid): |
| 991 |
"""List vendor-specific extensions (passthru) methods for a node |
| 992 |
|
| 993 |
:param node_uuid: The unique identifier of the node. |
| 994 |
""" |
| 995 |
return self._list_request('/nodes/%s/vendor_passthru/methods' |
| 996 |
% node_uuid) |
| 997 |
|
| 998 |
@base.handle_errors |
| 999 |
def ipa_heartbeat(self, node_uuid, callback_url, agent_token, |
| 1000 |
agent_version): |
| 1001 |
"""Create a IPA heartbeat from the given body. |
| 1002 |
|
| 1003 |
:param node_uuid: The unique identifier of the node. |
| 1004 |
:param callback_url: The URL of an active ironic-python-agent ramdisk |
| 1005 |
:param agent_token: The token of the ironic-python-agent ramdisk |
| 1006 |
:param agent_version: The version of the ironic-python-agent ramdisk |
| 1007 |
""" |
| 1008 |
kwargs = { |
| 1009 |
'node_ident': node_uuid, |
| 1010 |
'callback_url': callback_url, |
| 1011 |
'agent_version': agent_version, |
| 1012 |
'agent_token': agent_token, |
| 1013 |
} |
| 1014 |
|
| 1015 |
return self._create_request_no_response_body('heartbeat', kwargs) |
| 1016 |
|
| 1017 |
@base.handle_errors |
| 1018 |
def show_inventory(self, uuid, api_version='1.81'): |
| 1019 |
"""Gets hardware inventory for the specific node. |
| 1020 |
|
| 1021 |
:param uuid: Unique identifier of the node in UUID format. |
| 1022 |
:param api_version: Ironic API version to use. |
| 1023 |
:return: Inventory as a dictionary. |
| 1024 |
|
| 1025 |
""" |
| 1026 |
extra_headers, headers = self._get_headers(api_version) |
| 1027 |
resp, body = self._show_request( |
| 1028 |
'inventory', uuid, headers=headers, extra_headers=extra_headers, |
| 1029 |
uri=f'{self.uri_prefix}/nodes/{uuid}/inventory') |
| 1030 |
self.expected_success(http_client.OK, resp.status) |
| 1031 |
return body |
| 1032 |
|
| 1033 |
@base.handle_errors |
| 1034 |
def get_shards(self, api_version='1.82'): |
| 1035 |
"""Get all shards.""" |
| 1036 |
|
| 1037 |
extra_headers, headers = self._get_headers(api_version) |
| 1038 |
return self._list_request('shards', headers=headers, |
| 1039 |
extra_headers=extra_headers) |
| 1040 |
|
| 1041 |
@base.handle_errors |
| 1042 |
def list_node_firmware(self, node_uuid): |
| 1043 |
"""List firmware for a node. |
| 1044 |
|
| 1045 |
:param node_uuid: The unique identifier of the node. |
| 1046 |
""" |
| 1047 |
return self._list_request('/nodes/%s/firmware' % node_uuid) |
| 1048 |
|
| 1049 |
@base.handle_errors |
| 1050 |
def list_portgroups_detail(self): |
| 1051 |
"""List detailed portgroups.""" |
| 1052 |
return self._list_request('portgroups/detail') |
| 1053 |
|
| 1054 |
@base.handle_errors |
| 1055 |
def list_portgroups_by_node(self, node_ident): |
| 1056 |
"""List portgroups filtered by node.""" |
| 1057 |
return self._list_request(f'nodes/{node_ident}/portgroups') |
| 1058 |
|
| 1059 |
@base.handle_errors |
| 1060 |
def list_portgroups_details_by_node(self, node_ident): |
| 1061 |
"""List detailed portgroups filtered by node.""" |
| 1062 |
return self._list_request(f'nodes/{node_ident}/portgroups/detail') |
| 1063 |
|
| 1064 |
@base.handle_errors |
| 1065 |
def create_inspection_rule(self, payload): |
| 1066 |
"""Create Inspection rule. |
| 1067 |
|
| 1068 |
:param payload: Inspection rule JSON |
| 1069 |
""" |
| 1070 |
return self._create_request('inspection_rules', payload) |
| 1071 |
|
| 1072 |
@base.handle_errors |
| 1073 |
def show_inspection_rule(self, rule_uuid): |
| 1074 |
"""Show Inspection rule.""" |
| 1075 |
return self._show_request('inspection_rules', rule_uuid) |
| 1076 |
|
| 1077 |
@base.handle_errors |
| 1078 |
def list_inspection_rule(self, **kwargs): |
| 1079 |
"""List all Inspection rules.""" |
| 1080 |
return self._list_request('inspection_rules', **kwargs) |
| 1081 |
|
| 1082 |
@base.handle_errors |
| 1083 |
def update_inspection_rule(self, rule_uuid, patch): |
| 1084 |
"""Update the specified Inspection rule. |
| 1085 |
|
| 1086 |
:param rule_uuid: The unique identifier of the inspection rule. |
| 1087 |
:param patch: List of dicts representing json patches. |
| 1088 |
""" |
| 1089 |
return self._patch_request('inspection_rules', rule_uuid, patch) |
| 1090 |
|
| 1091 |
@base.handle_errors |
| 1092 |
def delete_inspection_rule(self, rule_uuid): |
| 1093 |
"""Delete Inspection rule. |
| 1094 |
|
| 1095 |
:param rule_uuid: uuid of the inspection rule. |
| 1096 |
""" |
| 1097 |
return self._delete_request('inspection_rules', rule_uuid) |