blob: c95c25ad6fa75f58f82dacea2e24d96bd8ed7a9c [file] [log] [blame]
Sushil Singhc5e9ebc2020-04-09 03:32:57 -05001*** Settings ***
2Documentation Management console utilities keywords.
3
Sushil Singh87e984c2020-10-20 01:43:47 -05004Resource ../../lib/bmc_redfish_utils.robot
Sushil Singh84c80152023-02-06 02:02:48 -06005Resource ../../lib/common_utils.robot
Sushil Singhc5e9ebc2020-04-09 03:32:57 -05006Library ../../lib/gen_robot_valid.py
7Library Collections
8Library ../../lib/bmc_ssh_utils.py
9Library SSHLibrary
10
11*** Variables ***
12&{daemon_command} start=systemctl start avahi-daemon
13 ... stop=systemctl stop avahi-daemon
14 ... status=systemctl status avahi-daemon -l
15&{daemon_message} start=Active: active (running)
16 ... stop=Active: inactive (dead)
17
18*** Keywords ***
19
20Set AvahiDaemon Service
21 [Documentation] To enable or disable avahi service.
22 [Arguments] ${command}
23
24 # Description of argument(s):
George Keishing1faaa462020-04-16 10:27:20 -050025 # command Get command from dictionary.
Sushil Singhc5e9ebc2020-04-09 03:32:57 -050026
27 ${service_command}= Get From Dictionary ${daemon_command} ${command}
28 ${resp} ${stderr} ${rc}= BMC Execute Command ${service_command} print_out=1
29 Should Be Equal As Integers ${rc} 0
30
31
32Verify AvahiDaemon Service Status
33 [Documentation] To check for avahi service.
34 [Arguments] ${message}
35
36 # Description of argument(s):
George Keishing1faaa462020-04-16 10:27:20 -050037 # message Get status message from dictionary.
Sushil Singhc5e9ebc2020-04-09 03:32:57 -050038
39 ${service_command}= Get From Dictionary ${daemon_command} status
40 ${service_message}= Get From Dictionary ${daemon_message} ${message}
41 ${resp} ${stderr} ${rc}= BMC Execute Command ${service_command} print_out=1
42 Should Contain ${resp} ${service_message}
Sushil Singhd03f2ce2020-09-17 08:54:41 -050043
44
Sushil Singh87e984c2020-10-20 01:43:47 -050045Create Session With ClientID
46 [Documentation] Create redifish session with client id.
47 [Arguments] ${client_id}
48
49 # Description of argument(s):
50 # client_id This client id can contain string value
51 # (e.g. 12345, "EXTERNAL-CLIENT").
52
53 ${session_info}= Create Dictionary
54 ${session_resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
55
56 Set To Dictionary ${session_info} SessionIDs ${session_resp['Id']}
57 Set To Dictionary ${session_info} ClientID ${session_resp["Oem"]["OpenBMC"]["ClientID"]}
58 Set To Dictionary ${session_info} SessionToken ${XAUTH_TOKEN}
59 Set To Dictionary ${session_info} SessionResp ${session_resp}
60
61 [Return] ${session_info}
62
63
64Create Session With List Of ClientID
65 [Documentation] Create redifish session with client id.
66 [Arguments] ${client_id}
67
68 # Description of argument(s):
69 # client_id This client id can contain string value
70 # (e.g. 12345, "EXTERNAL-CLIENT").
71
72 @{session_dict_list}= Create List
73 &{session_dict}= Create Dictionary
74
75 FOR ${client} IN @{client_id}
76 ${session_dict}= Create Session With ClientID ${client}
77 Append To List ${session_dict_list} ${session_dict}
78 END
79
80 [Return] ${session_dict_list}
81
82
83Verify A Session Created With ClientID
Sushil Singh5166ebd2021-05-31 01:24:16 -050084 [Documentation] Verify the session is created.
Sushil Singh87e984c2020-10-20 01:43:47 -050085 [Arguments] ${client_id} ${session_ids}
86
87 # Description of argument(s):
88 # client_id External client name.
89 # session_id This value is a session id.
90
91 # {
92 # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ",
93 # "@odata.type": "#Session.v1_0_2.Session",
94 # "Description": "Manager User Session",
95 # "Id": "H8q2ZKucSJ",
96 # "Name": "User Session",
97 # "Oem": {
98 # "OpenBMC": {
99 # "@odata.type": "#OemSession.v1_0_0.Session",
100 # "ClientID": "",
101 # "ClientOriginIP": "::ffff:x.x.x.x"
102 # }
103 # },
104 # "UserName": "root"
105 # }
106
107 FOR ${client} ${session} IN ZIP ${client_id} ${session_ids}
108 ${session_resp}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session["SessionIDs"]}
109 Rprint Vars session_resp
110 @{words} = Split String ${session_resp["ClientOriginIPAddress"]} :
111 ${ip_address}= Get Running System IP
112 Set Test Variable ${temp_ipaddr} ${words}[-1]
113 Valid Value client ['${session_resp["Oem"]["OpenBMC"]["ClientID"]}']
114 Valid Value session["SessionIDs"] ['${session_resp["Id"]}']
115 Valid Value temp_ipaddr ${ip_address}
116 END
117
118
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500119Get Lock Resource Information
120 [Documentation] Get lock resource information.
121
122 ${code_base_dir_path}= Get Code Base Dir Path
123 ${resource_lock_json}= Evaluate
124 ... json.load(open('${code_base_dir_path}data/resource_lock_table.json')) modules=json
125 Rprint Vars resource_lock_json
126
127 [Return] ${resource_lock_json}
Sushil Singhb79142c2022-09-15 01:04:11 -0500128