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