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