1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
|
# Copyright 2017 Red Hat, Inc.
# All Rights Reserved.
#
# 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.
# Values come from the Redfish System json-schema 1.0.0:
# http://redfish.dmtf.org/schemas/v1/ComputerSystem.v1_0_0.json#/definitions/ComputerSystem # noqa
import enum
from sushy.resources import constants as res_cons
# Reset action constants
RESET_ON = res_cons.ResetType.ON
RESET_FORCE_OFF = res_cons.ResetType.FORCE_OFF
RESET_GRACEFUL_SHUTDOWN = res_cons.ResetType.GRACEFUL_SHUTDOWN
RESET_GRACEFUL_RESTART = res_cons.ResetType.GRACEFUL_RESTART
RESET_FORCE_RESTART = res_cons.ResetType.FORCE_RESTART
RESET_NMI = res_cons.ResetType.NMI
RESET_FORCE_ON = res_cons.ResetType.FORCE_ON
RESET_PUSH_POWER_BUTTON = res_cons.ResetType.PUSH_POWER_BUTTON
# System' PowerState constants
SYSTEM_POWER_STATE_ON = res_cons.POWER_STATE_ON
"""The system is powered on"""
SYSTEM_POWER_STATE_OFF = res_cons.POWER_STATE_OFF
"""The system is powered off, although some components may continue to
have AUX power such as management controller"""
SYSTEM_POWER_STATE_POWERING_ON = res_cons.POWER_STATE_POWERING_ON
"""A temporary state between Off and On. This temporary state can
be very short"""
SYSTEM_POWER_STATE_POWERING_OFF = res_cons.POWER_STATE_POWERING_OFF
"""A temporary state between On and Off. The power off action can take
time while the OS is in the shutdown process"""
class BootSource(enum.Enum):
"""Boot source target constants"""
NONE = 'None'
"""Boot from the normal boot device."""
PXE = 'Pxe'
"""Boot from the Pre-Boot EXecution (PXE) environment."""
FLOPPY = 'Floppy'
"""Boot from the floppy disk drive."""
CD = 'Cd'
"""Boot from the CD or DVD."""
USB = 'Usb'
"""Boot from a system BIOS-specified USB device."""
HDD = 'Hdd'
"""Boot from a hard drive."""
BIOS_SETUP = 'BiosSetup'
"""Boot to the BIOS setup utility."""
UTILITIES = 'Utilities'
"""Boot to the manufacturer's utilities program or programs."""
DIAGS = 'Diags'
"""Boot to the manufacturer's diagnostics program."""
UEFI_SHELL = 'UefiShell'
"""Boot to the UEFI Shell."""
UEFI_TARGET = 'UefiTarget'
"""Boot to the UEFI device specified in the UefiTargetBootSourceOverride
property."""
SD_CARD = 'SDCard'
"""Boot from an SD card."""
UEFI_HTTP = 'UefiHttp'
"""Boot from a UEFI HTTP network location."""
REMOTE_DRIVE = 'RemoteDrive'
"""Boot from a remote drive, such as an iSCSI target."""
UEFI_BOOT_NEXT = 'UefiBootNext'
"""Boot to the UEFI device that the BootNext property specifies."""
USB_CD = 'UsbCd'
"""Boot from a USB CD device as specified by the system BIOS.
**This is NOT a standard value!**
On SuperMicro X11 and X12 machines, virtual media is presented as an USB CD
drive as opposed to a CD drive. Both are present in the list of boot
devices, however only selecting UsbCd as the boot source results in a
successful boot from vMedia. If CD is selected, boot fails even if vMedia
is inserted."""
# Backward compatibility
BOOT_SOURCE_TARGET_NONE = BootSource.NONE
BOOT_SOURCE_TARGET_PXE = BootSource.PXE
BOOT_SOURCE_TARGET_FLOPPY = BootSource.FLOPPY
BOOT_SOURCE_TARGET_CD = BootSource.CD
BOOT_SOURCE_TARGET_USB = BootSource.USB
BOOT_SOURCE_TARGET_HDD = BootSource.HDD
BOOT_SOURCE_TARGET_BIOS_SETUP = BootSource.BIOS_SETUP
BOOT_SOURCE_TARGET_UTILITIES = BootSource.UTILITIES
BOOT_SOURCE_TARGET_DIAGS = BootSource.DIAGS
BOOT_SOURCE_TARGET_UEFI_SHELL = BootSource.UEFI_SHELL
BOOT_SOURCE_TARGET_UEFI_TARGET = BootSource.UEFI_TARGET
BOOT_SOURCE_TARGET_SD_CARD = BootSource.SD_CARD
BOOT_SOURCE_TARGET_UEFI_HTTP = BootSource.UEFI_HTTP
BOOT_SOURCE_TARGET_USB_CD = BootSource.USB_CD
class BootSourceOverrideMode(enum.Enum):
"""Boot source mode constants"""
LEGACY = 'Legacy'
"""The system boots in non-UEFI boot mode to the boot source override
target."""
UEFI = 'UEFI'
"""The system boots in UEFI boot mode to the boot source override
target."""
# Backward compatibility
BOOT_SOURCE_MODE_BIOS = BootSourceOverrideMode.LEGACY
BOOT_SOURCE_MODE_UEFI = BootSourceOverrideMode.UEFI
class BootSourceOverrideEnabled(enum.Enum):
"""Boot source enabled constants"""
DISABLED = 'Disabled'
"""The system boots normally."""
ONCE = 'Once'
"""On its next boot cycle, the system boots one time to the boot source
override target. Then, the BootSourceOverrideEnabled value is reset
to `Disabled`."""
CONTINUOUS = 'Continuous'
"""The system boots to the target specified in the
BootSourceOverrideTarget property until this property is `Disabled`."""
# Backward compatibility
BOOT_SOURCE_ENABLED_DISABLED = BootSourceOverrideEnabled.DISABLED
BOOT_SOURCE_ENABLED_ONCE = BootSourceOverrideEnabled.ONCE
BOOT_SOURCE_ENABLED_CONTINUOUS = BootSourceOverrideEnabled.CONTINUOUS
class BootProgressStates(enum.Enum):
"""Boot System Progress Indicator constants"""
# Added in ComputerSystem 1.15.0
NONE = 'None'
"""The system is not booting."""
PRIMARY_PROCESSOR = 'PrimaryProcessorInitializationStarted'
"""Initialization of the Primary Processor has started."""
BUS = 'BusInitializationStarted'
"""Initialization of the buses has started."""
MEMORY = 'MemoryInitializationStarted'
"""Initialization of memory has started."""
SECONDARY_PROCESSOR = 'SecondaryProcessorInitializationStarted'
"""Secondary Prcessors have started initialization."""
PCI_RESOURCE_CONFIG = 'PCIResourceConfigStarted'
"""Initalizatoin of PCI Resources has started."""
HARDWARE_COMPLETE = 'SystemHardwareInitializationComplete'
"""Hardware Initialization is completed."""
SETUP = 'SetupEntered'
"""System is in the Setup utility."""
OS_BOOT_STARTED = 'OSBootStarted'
"""Boot of the Operating System has started."""
OS_RUNNING = 'OSRunning'
"""Operating System Running."""
OEM = 'OEM'
"""OEM Defined Boot Progress State."""
class SystemType(enum.Enum):
"""System type constants"""
PHYSICAL = 'Physical'
"""A computer system."""
VIRTUAL = 'Virtual'
"""A virtual machine instance running on this system."""
OS = 'OS'
"""An operating system instance."""
PHYSICALLY_PARTITIONED = 'PhysicallyPartitioned'
"""A hardware-based partition of a computer system."""
VIRTUALLY_PARTITIONED = 'VirtuallyPartitioned'
"""A virtual or software-based partition of a computer system."""
COMPOSED = 'Composed'
"""A computer system constructed by binding resource blocks together."""
DPU = 'DPU'
"""A computer system that performs the functions of a data processing
unit, such as a SmartNIC."""
# Backward compatibility
SYSTEM_TYPE_PHYSICAL = SystemType.PHYSICAL
SYSTEM_TYPE_VIRTUAL = SystemType.VIRTUAL
SYSTEM_TYPE_OS = SystemType.OS
SYSTEM_TYPE_PHYSICALLY_PARTITIONED = SystemType.PHYSICALLY_PARTITIONED
SYSTEM_TYPE_VIRTUALLY_PARTITIONED = SystemType.VIRTUALLY_PARTITIONED
SYSTEM_TYPE_COMPOSED = SystemType.COMPOSED
SYSTEM_TYPE_DPU = SystemType.DPU
# Processor related constants
# Values comes from the Redfish Processor json-schema 1.3.0:
# http://redfish.dmtf.org/schemas/v1/Processor.v1_3_0.json
class ProcessorArchitecture(enum.Enum):
"""Processor Architecture constants"""
X86 = 'x86'
"""x86 or x86-64."""
IA_64 = 'IA-64'
"""Intel Itanium."""
ARM = 'ARM'
"""ARM."""
MIPS = 'MIPS'
"""MIPS."""
POWER = 'Power'
"""Power."""
OEM = 'OEM'
"""OEM-defined."""
# Backward compatibility
PROCESSOR_ARCH_x86 = ProcessorArchitecture.X86
PROCESSOR_ARCH_IA_64 = ProcessorArchitecture.IA_64
PROCESSOR_ARCH_ARM = ProcessorArchitecture.ARM
PROCESSOR_ARCH_MIPS = ProcessorArchitecture.MIPS
PROCESSOR_ARCH_OEM = ProcessorArchitecture.OEM
class ProcessorType(enum.Enum):
"""Processor type constants"""
CPU = 'CPU'
"""A CPU."""
GPU = 'GPU'
"""A GPU."""
FPGA = 'FPGA'
"""An FPGA."""
DSP = 'DSP'
"""A DSP."""
ACCELERATOR = 'Accelerator'
"""An accelerator."""
CORE = 'Core'
"""A core in a processor."""
THREAD = 'Thread'
"""A thread in a processor."""
OEM = 'OEM'
"""An OEM-defined processing unit."""
# Backward compatibility
PROCESSOR_TYPE_CPU = ProcessorType.CPU
PROCESSOR_TYPE_GPU = ProcessorType.GPU
PROCESSOR_TYPE_FPGA = ProcessorType.FPGA
PROCESSOR_TYPE_DSP = ProcessorType.DSP
PROCESSOR_TYPE_ACCELERATOR = ProcessorType.ACCELERATOR
PROCESSOR_TYPE_CORE = ProcessorType.CORE
PROCESSOR_TYPE_THREAD = ProcessorType.THREAD
PROCESSOR_TYPE_OEM = ProcessorType.OEM
class InstructionSet(enum.Enum):
"""Processor InstructionSet constants"""
X86 = 'x86'
"""x86 32-bit."""
X86_64 = 'x86-64'
"""x86 64-bit."""
IA_64 = 'IA-64'
"""Intel IA-64."""
ARM_A32 = 'ARM-A32'
"""ARM 32-bit."""
ARM_A64 = 'ARM-A64'
"""ARM 64-bit."""
MIPS32 = 'MIPS32'
"""MIPS 32-bit."""
MIPS64 = 'MIPS64'
"""MIPS 64-bit."""
POWER_ISA = 'PowerISA'
"""PowerISA-64 or PowerISA-32."""
OEM = 'OEM'
"""OEM-defined."""
PROCESSOR_INSTRUCTIONSET_ARM_A32 = InstructionSet.ARM_A32
PROCESSOR_INSTRUCTIONSET_ARM_A64 = InstructionSet.ARM_A64
PROCESSOR_INSTRUCTIONSET_IA_64 = InstructionSet.IA_64
PROCESSOR_INSTRUCTIONSET_MIPS32 = InstructionSet.MIPS32
PROCESSOR_INSTRUCTIONSET_MIPS64 = InstructionSet.MIPS64
PROCESSOR_INSTRUCTIONSET_OEM = InstructionSet.OEM
PROCESSOR_INSTRUCTIONSET_x86 = InstructionSet.X86
PROCESSOR_INSTRUCTIONSET_x86_64 = InstructionSet.X86_64
# Secure boot constants from SecureBoot schema version 1.1.0
# https://redfish.dmtf.org/schemas/v1/SecureBoot.v1_1_0.json
# Some names were altered for clarity
class SecureBootCurrentBoot(enum.Enum):
ENABLED = 'Enabled'
"""UEFI Secure Boot is currently enabled."""
DISABLED = 'Disabled'
"""UEFI Secure Boot is currently disabled."""
# Backward compatibility
SECURE_BOOT_ENABLED = SecureBootCurrentBoot.ENABLED
SECURE_BOOT_DISABLED = SecureBootCurrentBoot.DISABLED
class SecureBootMode(enum.Enum):
SETUP = 'SetupMode'
"""UEFI Secure Boot is currently in Setup Mode."""
USER = 'UserMode'
"""UEFI Secure Boot is currently in User Mode."""
AUDIT = 'AuditMode'
"""UEFI Secure Boot is currently in Audit Mode."""
DEPLOYED = 'DeployedMode'
"""UEFI Secure Boot is currently in Deployed Mode."""
# Backward compatibility
SECURE_BOOT_MODE_SETUP = SecureBootMode.SETUP
SECURE_BOOT_MODE_USER = SecureBootMode.USER
SECURE_BOOT_MODE_AUDIT = SecureBootMode.AUDIT
SECURE_BOOT_MODE_DEPLOYED = SecureBootMode.DEPLOYED
class SecureBootResetKeysType(enum.Enum):
RESET_ALL_KEYS_TO_DEFAULT = 'ResetAllKeysToDefault'
"""Reset the contents of all UEFI Secure Boot key databases, including
the PK key database, to the default values."""
DELETE_ALL_KEYS = 'DeleteAllKeys'
"""Delete the contents of all UEFI Secure Boot key databases, including
the PK key database. This puts the system in Setup Mode."""
DELETE_PK = 'DeletePK'
"""Delete the contents of the PK UEFI Secure Boot database. This puts
the system in Setup Mode."""
# Internal constant based on
# https://redfish.dmtf.org/schemas/v1/SecureBootDatabase.v1_0_1.json
_SECURE_BOOT_DATABASE_RESET_KEYS = frozenset([
SecureBootResetKeysType.RESET_ALL_KEYS_TO_DEFAULT,
SecureBootResetKeysType.DELETE_ALL_KEYS,
])
# Backward compatibility
SECURE_BOOT_RESET_KEYS_TO_DEFAULT = \
SecureBootResetKeysType.RESET_ALL_KEYS_TO_DEFAULT
SECURE_BOOT_RESET_KEYS_DELETE_ALL = SecureBootResetKeysType.DELETE_ALL_KEYS
SECURE_BOOT_RESET_KEYS_DELETE_PK = SecureBootResetKeysType.DELETE_PK
class SecureBootDatabaseId(enum.Enum):
# This enumeration is hand-written based on the database schema
# https://redfish.dmtf.org/schemas/v1/SecureBootDatabase.v1_0_1.json
# and the UEFI specification.
PLATFORM_KEY = "PK"
KEY_EXCHANGE_KEYS = "KEK"
ALLOWED_KEYS_DATABASE = "db"
DENIED_KEYS_DATABASE = "dbx"
RECOVERY_KEYS_DATABASE = "dbr"
TIMESTAMP_DATABASE = "dbt"
DEFAULT_PLATFORM_KEY = "PKDefault"
DEFAULT_KEY_EXCHANGE_KEYS = "KEKDefault"
DEFAULT_ALLOWED_KEYS_DATABASE = "dbDefault"
DEFAULT_DENIED_KEYS_DATABASE = "dbxDefault"
DEFAULT_RECOVERY_KEYS_DATABASE = "dbrDefault"
DEFAULT_TIMESTAMP_DATABASE = "dbtDefault"
# Backward compatibility
SECURE_BOOT_PLATFORM_KEY = SecureBootDatabaseId.PLATFORM_KEY
SECURE_BOOT_KEY_EXCHANGE_KEYS = SecureBootDatabaseId.KEY_EXCHANGE_KEYS
SECURE_BOOT_ALLOWED_KEYS_DATABASE = SecureBootDatabaseId.ALLOWED_KEYS_DATABASE
SECURE_BOOT_DENIED_KEYS_DATABASE = SecureBootDatabaseId.DENIED_KEYS_DATABASE
SECURE_BOOT_RECOVERY_KEYS_DATABASE = \
SecureBootDatabaseId.RECOVERY_KEYS_DATABASE
SECURE_BOOT_TIMESTAMP_DATABASE = SecureBootDatabaseId.TIMESTAMP_DATABASE
SECURE_BOOT_DEFAULT_PLATFORM_KEY = SecureBootDatabaseId.DEFAULT_PLATFORM_KEY
SECURE_BOOT_DEFAULT_KEY_EXCHANGE_KEYS = \
SecureBootDatabaseId.DEFAULT_KEY_EXCHANGE_KEYS
SECURE_BOOT_DEFAULT_ALLOWED_KEYS_DATABASE = \
SecureBootDatabaseId.DEFAULT_ALLOWED_KEYS_DATABASE
SECURE_BOOT_DEFAULT_DENIED_KEYS_DATABASE = \
SecureBootDatabaseId.DEFAULT_DENIED_KEYS_DATABASE
SECURE_BOOT_DEFAULT_RECOVERY_KEYS_DATABASE = \
SecureBootDatabaseId.DEFAULT_RECOVERY_KEYS_DATABASE
SECURE_BOOT_DEFAULT_TIMESTAMP_DATABASE = \
SecureBootDatabaseId.DEFAULT_TIMESTAMP_DATABASE
|