1#!/usr/bin/env python3
2
3r"""
4Variable constants applicable to all OpenBMC test.
5"""
6
7import os
8
9from robot.libraries.BuiltIn import BuiltIn
10
11OPENBMC_BASE_URI = "/xyz/openbmc_project/"
12OPENBMC_BASE_DBUS = "xyz.openbmc_project."
13
14# Generic Dbus commands.
15OPENBMC_DBUS_GET_PROPERTY = "busctl get-property "
16OPENBMC_DBUS_SET_PROPERTY = "busctl set-property "
17
18# org open power base URI.
19OPENPOWER_BASE_URI = "/org/open_power/"
20OPENPOWER_CONTROL = OPENPOWER_BASE_URI + "control/"
21OPENPOWER_SENSORS = OPENPOWER_BASE_URI + "sensors/"
22
23# REST URI base endpoint paths.
24CONTROL_URI = OPENBMC_BASE_URI + "control/"
25# Continue to keep to support legacy code.
26SETTINGS_URI = "/org/openbmc/settings/"
27WATCHDOG_URI = OPENBMC_BASE_URI + "watchdog/"
28TIME_MANAGER_URI = OPENBMC_BASE_URI + "time/"
29NETWORK_MANAGER = OPENBMC_BASE_URI + "network/"
30NETWORK_RESOURCE = "xyz.openbmc_project.Network.IP.Protocol.IPv4"
31# SNMP
32SNMP_MANAGER_URI = NETWORK_MANAGER + "snmp/manager/"
33# Sensors base variables.
34SENSORS_URI = OPENBMC_BASE_URI + "sensors/"
35# Thermal Control base variables
36THERMAL_CONTROL_URI = CONTROL_URI + "thermal/0"
37THERMAL_METRICS = "ThermalSubsystem/ThermalMetrics"
38
39COMPONENT_NAME_OF_POWER_SUPPLY = "powersupply"
40
41# State Manager base variables
42BMC_REBOOT_TRANS = "xyz.openbmc_project.State.BMC.Transition.Reboot"
43
44HOST_POWEROFF_TRANS = "xyz.openbmc_project.State.Host.Transition.Off"
45HOST_POWERON_TRANS = "xyz.openbmc_project.State.Host.Transition.On"
46HOST_REBOOT_TRANS = "xyz.openbmc_project.State.Host.Transition.Reboot"
47HOST_POWEROFF_STATE = "xyz.openbmc_project.State.Host.HostState.Off"
48HOST_POWERON_STATE = "xyz.openbmc_project.State.Host.HostState.Running"
49
50CHASSIS_POWEROFF_TRANS = "xyz.openbmc_project.State.Chassis.Transition.Off"
51CHASSIS_POWERON_TRANS = "xyz.openbmc_project.State.Chassis.Transition.On"
52CHASSIS_POWEROFF_STATE = "xyz.openbmc_project.State.Chassis.PowerState.Off"
53CHASSIS_POWERON_STATE = "xyz.openbmc_project.State.Chassis.PowerState.On"
54
55# State Manager URI variables.
56SYSTEM_STATE_URI = OPENBMC_BASE_URI + "state/"
57BMC_STATE_URI = OPENBMC_BASE_URI + "state/bmc0/"
58HOST_STATE_URI = OPENBMC_BASE_URI + "state/host0/"
59CHASSIS_STATE_URI = OPENBMC_BASE_URI + "state/chassis0/"
60HOST_WATCHDOG_URI = OPENBMC_BASE_URI + "watchdog/host0/"
61
62# OS state for x86 architecture
63OS_STATE_URI = OPENBMC_BASE_URI + "state/os/"
64
65# Logging URI variables
66BMC_LOGGING_URI = OPENBMC_BASE_URI + "logging/"
67BMC_LOGGING_ENTRY = BMC_LOGGING_URI + "entry/"
68REDFISH_BMC_LOGGING_ENTRY = (
69    "/redfish/v1/Systems/system/LogServices/EventLog/Entries/"
70)
71
72
73# Software manager version
74SOFTWARE_VERSION_URI = OPENBMC_BASE_URI + "software/"
75ACTIVE = "xyz.openbmc_project.Software.Activation.Activations.Active"
76READY = "xyz.openbmc_project.Software.Activation.Activations.Ready"
77INVALID = "xyz.openbmc_project.Software.Activation.Activations.Invalid"
78ACTIVATING = "xyz.openbmc_project.Software.Activation.Activations.Activating"
79NOTREADY = "xyz.openbmc_project.Software.Activation.Activations.NotReady"
80FAILED = "xyz.openbmc_project.Software.Activation.Activations.Failed"
81
82SOFTWARE_ACTIVATION = "xyz.openbmc_project.Software.Activation"
83REQUESTED_ACTIVATION = SOFTWARE_ACTIVATION + ".RequestedActivations"
84REQUESTED_ACTIVE = REQUESTED_ACTIVATION + ".Active"
85REQUESTED_NONE = REQUESTED_ACTIVATION + ".None"
86
87SOFTWARE_PURPOSE = "xyz.openbmc_project.Software.Version.VersionPurpose"
88VERSION_PURPOSE_HOST = SOFTWARE_PURPOSE + ".Host"
89VERSION_PURPOSE_BMC = SOFTWARE_PURPOSE + ".BMC"
90VERSION_PURPOSE_SYSTEM = SOFTWARE_PURPOSE + ".System"
91
92# Image Upload Directory Path
93IMAGE_UPLOAD_DIR_PATH = "/tmp/images/"
94
95# Inventory URI variables
96HOST_INVENTORY_URI = OPENBMC_BASE_URI + "inventory/"
97CHASSIS_INVENTORY_URI = HOST_INVENTORY_URI + "system/chassis/"
98MOTHERBOARD_INVENTORY_URI = CHASSIS_INVENTORY_URI + "motherboard/"
99
100# Led URI variable
101LED_GROUPS_URI = OPENBMC_BASE_URI + "led/groups/"
102LED_PHYSICAL_URI = OPENBMC_BASE_URI + "led/physical/"
103LED_LAMP_TEST_ASSERTED_URI = LED_GROUPS_URI + "lamp_test/"
104LED_PHYSICAL_PS0_URI = LED_PHYSICAL_URI + "cffps1_69/"
105LED_PHYSICAL_PS1_URI = LED_PHYSICAL_URI + "cffps1_68/"
106LED_PHYSICAL_FAN0_URI = LED_PHYSICAL_URI + "fan0/"
107LED_PHYSICAL_FAN2_URI = LED_PHYSICAL_URI + "fan2/"
108LED_PHYSICAL_FAN3_URI = LED_PHYSICAL_URI + "fan3/"
109
110# Host control URI variables.
111CONTROL_HOST_URI = OPENBMC_BASE_URI + "control/host0/"
112
113# Power restore variables.
114POWER_RESTORE_URI = CONTROL_HOST_URI + "power_restore_policy"
115CONTROL_DBUS_BASE = "xyz.openbmc_project.Control."
116
117RESTORE_LAST_STATE = CONTROL_DBUS_BASE + "Power.RestorePolicy.Policy.Restore"
118ALWAYS_POWER_ON = CONTROL_DBUS_BASE + "Power.RestorePolicy.Policy.AlwaysOn"
119ALWAYS_POWER_OFF = CONTROL_DBUS_BASE + "Power.RestorePolicy.Policy.AlwaysOff"
120
121# Dump URI variables.
122REST_DUMP_URI = OPENBMC_BASE_URI + "dump/bmc/"
123DUMP_ENTRY_URI = REST_DUMP_URI + "entry/"
124DUMP_DOWNLOAD_URI = "/download/dump/"
125# The path on the BMC where dumps are stored.
126DUMP_DIR_PATH = "/var/lib/phosphor-debug-collector/"
127
128# Boot progress variables.
129STATE_DBUS_BASE = "xyz.openbmc_project.State."
130OS_BOOT_START = STATE_DBUS_BASE + "Boot.Progress.ProgressStages.OSStart"
131OS_BOOT_OFF = STATE_DBUS_BASE + "Boot.Progress.ProgressStages.Unspecified"
132OS_BOOT_PCI = STATE_DBUS_BASE + "Boot.Progress.ProgressStages.PCIInit"
133OS_BOOT_SECPCI = (
134    STATE_DBUS_BASE + "Boot.Progress.ProgressStages.SecondaryProcInit"
135)
136OS_BOOT_MEM = STATE_DBUS_BASE + "Boot.Progress.ProgressStages.MemoryInit"
137OS_BOOT_MOTHERBOARD = (
138    STATE_DBUS_BASE + "Boot.Progress.ProgressStages.MotherboardInit"
139)
140OPENBMC_DBUS_BMC_STATE = STATE_DBUS_BASE + "BMC"
141
142# OperatingSystem status variables.
143OS_BOOT_COMPLETE = (
144    STATE_DBUS_BASE + "OperatingSystem.Status.OSStatus.BootComplete"
145)
146OS_BOOT_CDROM = STATE_DBUS_BASE + "OperatingSystem.Status.OSStatus.CDROMBoot"
147OS_BOOT_ROM = STATE_DBUS_BASE + "OperatingSystem.Status.OSStatus.ROMBoot"
148OS_BOOT_PXE = STATE_DBUS_BASE + "OperatingSystem.Status.OSStatus.PXEBoot"
149OS_BOOT_CBOOT = STATE_DBUS_BASE + "OperatingSystem.Status.OSStatus.CBoot"
150OS_BOOT_DIAGBOOT = STATE_DBUS_BASE + "OperatingSystem.Status.OSStatus.DiagBoot"
151
152# Boot variables.
153BOOT_SOURCE_DEFAULT = "xyz.openbmc_project.Control.Boot.Source.Sources.Default"
154BOOT_SOURCE_NETWORK = "xyz.openbmc_project.Control.Boot.Source.Sources.Network"
155BOOT_SOURCE_DISK = "xyz.openbmc_project.Control.Boot.Source.Sources.Disk"
156BOOT_SOURCE_CDROM = (
157    "xyz.openbmc_project.Control.Boot.Source.Sources.ExternalMedia"
158)
159BOOT_MODE_SAFE = "xyz.openbmc_project.Control.Boot.Mode.Modes.Safe"
160BOOT_MODE_SETUP = "xyz.openbmc_project.Control.Boot.Mode.Modes.Setup"
161BOOT_MODE_REGULAR = "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular"
162BOOT_TYPE_LEGACY = "xyz.openbmc_project.Control.Boot.Type.Types.Legacy"
163BOOT_TYPE_EFI = "xyz.openbmc_project.Control.Boot.Type.Types.EFI"
164
165# Time variables.
166TIME_DBUS_BASE = "xyz.openbmc_project.Time."
167BMC_OWNER = TIME_DBUS_BASE + "Owner.Owners.BMC"
168HOST_OWNER = TIME_DBUS_BASE + "Owner.Owners.Host"
169SPLIT_OWNER = TIME_DBUS_BASE + "Owner.Owners.Split"
170BOTH_OWNER = TIME_DBUS_BASE + "Owner.Owners.Both"
171NTP_MODE = TIME_DBUS_BASE + "Synchronization.Method.NTP"
172MANUAL_MODE = TIME_DBUS_BASE + "Synchronization.Method.Manual"
173
174# User manager variable.
175BMC_USER_URI = OPENBMC_BASE_URI + "user/"
176
177# LDAP User manager variable.
178BMC_LDAP_URI = BMC_USER_URI + "ldap"
179
180# The path on the BMC where signed keys are stored.
181ACTIVATION_DIR_PATH = "/etc/activationdata/"
182
183# Redfish variables.
184REDFISH_BASE_URI = "/redfish/v1/"
185REDFISH_SESSION = REDFISH_BASE_URI + "SessionService/Sessions"
186REDFISH_SESSION_URI = "SessionService/Sessions/"
187REDFISH_MANAGERS_ID = BuiltIn().get_variable_value(
188    "${MANAGER_ID}", default="bmc"
189)
190REDFISH_NW_ETH0 = (
191    "Managers/" + REDFISH_MANAGERS_ID + "/EthernetInterfaces/eth0/"
192)
193REDFISH_NW_ETH0_URI = REDFISH_BASE_URI + REDFISH_NW_ETH0
194REDFISH_NW_ETH_IFACE = (
195    REDFISH_BASE_URI
196    + "Managers/"
197    + REDFISH_MANAGERS_ID
198    + "/EthernetInterfaces/"
199)
200REDFISH_NW_PROTOCOL = "Managers/" + REDFISH_MANAGERS_ID + "/NetworkProtocol"
201REDFISH_NW_PROTOCOL_URI = REDFISH_BASE_URI + REDFISH_NW_PROTOCOL
202REDFISH_ACCOUNTS_SERVICE = "AccountService/"
203REDFISH_ACCOUNTS_SERVICE_URI = REDFISH_BASE_URI + REDFISH_ACCOUNTS_SERVICE
204REDFISH_ACCOUNTS = "AccountService/Accounts/"
205REDFISH_ACCOUNTS_URI = REDFISH_BASE_URI + REDFISH_ACCOUNTS
206REDFISH_HTTPS_CERTIFICATE = (
207    "Managers/" + REDFISH_MANAGERS_ID + "/NetworkProtocol/HTTPS/Certificates"
208)
209REDFISH_HTTPS_CERTIFICATE_URI = REDFISH_BASE_URI + REDFISH_HTTPS_CERTIFICATE
210REDFISH_LDAP_CERTIFICATE = "AccountService/LDAP/Certificates"
211REDFISH_LDAP_CERTIFICATE_URI = REDFISH_BASE_URI + REDFISH_LDAP_CERTIFICATE
212REDFISH_CA_CERTIFICATE = (
213    "Managers/" + REDFISH_MANAGERS_ID + "/Truststore/Certificates"
214)
215REDFISH_CA_CERTIFICATE_URI = REDFISH_BASE_URI + REDFISH_CA_CERTIFICATE
216REDFISH_CHASSIS_ID = BuiltIn().get_variable_value(
217    "${CHASSIS_ID}", default="chassis"
218)
219REDFISH_CHASSIS_URI = REDFISH_BASE_URI + "Chassis/"
220REDFISH_CHASSIS_THERMAL = REDFISH_CHASSIS_ID + "/Thermal/"
221REDFISH_CHASSIS_THERMAL_URI = REDFISH_CHASSIS_URI + REDFISH_CHASSIS_THERMAL
222REDFISH_CHASSIS_POWER = REDFISH_CHASSIS_ID + "/Power/"
223REDFISH_CHASSIS_POWER_URI = REDFISH_CHASSIS_URI + REDFISH_CHASSIS_POWER
224REDFISH_CHASSIS_SENSORS = REDFISH_CHASSIS_ID + "/Sensors"
225REDFISH_CHASSIS_SENSORS_URI = REDFISH_CHASSIS_URI + REDFISH_CHASSIS_SENSORS
226REDFISH_BMC_DUMP = (
227    "Managers/" + REDFISH_MANAGERS_ID + "/LogServices/Dump/Entries"
228)
229REDFISH_DUMP_URI = REDFISH_BASE_URI + REDFISH_BMC_DUMP
230REDFISH_SYSTEM_DUMP = (
231    REDFISH_BASE_URI + "/Systems/system/LogServices/Dump/Entries"
232)
233
234# Boot options and URI variables.
235POWER_ON = "On"
236POWER_GRACEFUL_OFF = "GracefulShutdown"
237POWER_GRACEFUL_RESTART = "GracefulRestart"
238POWER_FORCE_OFF = "ForceOff"
239
240REDFISH_POWER = "Systems/system/Actions/ComputerSystem.Reset"
241REDFISH_POWER_URI = REDFISH_BASE_URI + REDFISH_POWER
242
243# rsyslog variables.
244REMOTE_LOGGING_URI = OPENBMC_BASE_URI + "logging/config/remote/"
245
246# Certificate variables.
247SERVER_CERTIFICATE_URI = OPENBMC_BASE_URI + "certs/server/https"
248CLIENT_CERTIFICATE_URI = OPENBMC_BASE_URI + "certs/client/ldap"
249CA_CERTIFICATE_URI = OPENBMC_BASE_URI + "certs/authority/truststore"
250
251# EventLog variables.
252SYSTEM_BASE_URI = REDFISH_BASE_URI + "Systems/system/"
253EVENT_LOG_URI = SYSTEM_BASE_URI + "LogServices/EventLog/"
254DUMP_URI = SYSTEM_BASE_URI + "LogServices/Dump/"
255
256BIOS_ATTR_URI = SYSTEM_BASE_URI + "Bios"
257BIOS_ATTR_SETTINGS_URI = BIOS_ATTR_URI + "/Settings"
258
259"""
260  QEMU HTTPS variable:
261
262  By default lib/resource.robot AUTH URI construct is as
263  ${AUTH_URI}   https://${OPENBMC_HOST}${AUTH_SUFFIX}
264  ${AUTH_SUFFIX} is populated here by default EMPTY else
265  the port from the OS environment
266"""
267
268AUTH_SUFFIX = ":" + BuiltIn().get_variable_value(
269    "${HTTPS_PORT}", os.getenv("HTTPS_PORT", "443")
270)
271
272# Here contains a list of valid Properties bases on fru_type after a boot.
273INVENTORY_ITEMS = {
274    "CPU": [
275        "Custom Field 1",
276        "Custom Field 2",
277        "Custom Field 3",
278        "Custom Field 4",
279        "Custom Field 5",
280        "Custom Field 6",
281        "Custom Field 7",
282        "Custom Field 8",
283        "FRU File ID",
284        "Manufacturer",
285        "Name",
286        "Part Number",
287        "Serial Number",
288        "fault",
289        "fru_type",
290        "is_fru",
291        "present",
292        "version",
293    ],
294    "DIMM": [
295        "Asset Tag",
296        "Custom Field 1",
297        "Custom Field 2",
298        "Custom Field 3",
299        "Custom Field 4",
300        "Custom Field 5",
301        "Custom Field 6",
302        "Custom Field 7",
303        "Custom Field 8",
304        "FRU File ID",
305        "Manufacturer",
306        "Model Number",
307        "Name",
308        "Serial Number",
309        "Version",
310        "fault",
311        "fru_type",
312        "is_fru",
313        "present",
314        "version",
315    ],
316    "MEMORY_BUFFER": [
317        "Custom Field 1",
318        "Custom Field 2",
319        "Custom Field 3",
320        "Custom Field 4",
321        "Custom Field 5",
322        "Custom Field 6",
323        "Custom Field 7",
324        "Custom Field 8",
325        "FRU File ID",
326        "Manufacturer",
327        "Name",
328        "Part Number",
329        "Serial Number",
330        "fault",
331        "fru_type",
332        "is_fru",
333        "present",
334        "version",
335    ],
336    "FAN": [
337        "fault",
338        "fru_type",
339        "is_fru",
340        "present",
341        "version",
342    ],
343    "DAUGHTER_CARD": [
344        "Custom Field 1",
345        "Custom Field 2",
346        "Custom Field 3",
347        "Custom Field 4",
348        "Custom Field 5",
349        "Custom Field 6",
350        "Custom Field 7",
351        "Custom Field 8",
352        "FRU File ID",
353        "Manufacturer",
354        "Name",
355        "Part Number",
356        "Serial Number",
357        "fault",
358        "fru_type",
359        "is_fru",
360        "present",
361        "version",
362    ],
363    "BMC": [
364        "fault",
365        "fru_type",
366        "is_fru",
367        "manufacturer",
368        "present",
369        "version",
370    ],
371    "MAIN_PLANAR": [
372        "Custom Field 1",
373        "Custom Field 2",
374        "Custom Field 3",
375        "Custom Field 4",
376        "Custom Field 5",
377        "Custom Field 6",
378        "Custom Field 7",
379        "Custom Field 8",
380        "Part Number",
381        "Serial Number",
382        "Type",
383        "fault",
384        "fru_type",
385        "is_fru",
386        "present",
387        "version",
388    ],
389    "SYSTEM": [
390        "Custom Field 1",
391        "Custom Field 2",
392        "Custom Field 3",
393        "Custom Field 4",
394        "Custom Field 5",
395        "Custom Field 6",
396        "Custom Field 7",
397        "Custom Field 8",
398        "FRU File ID",
399        "Manufacturer",
400        "Model Number",
401        "Name",
402        "Serial Number",
403        "Version",
404        "fault",
405        "fru_type",
406        "is_fru",
407        "present",
408        "version",
409    ],
410    "CORE": [
411        "fault",
412        "fru_type",
413        "is_fru",
414        "present",
415        "version",
416    ],
417}
418