Add initial codes
[it/test.git] / ric_robot_suite / robot / resources / e2mgr / e2mgr_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with RIC E2 Manager (E2Mgr) . It handles low level stuff like managing the http request library and E2Mgr required fields
3 Library           RequestsLibrary
4 Library           UUID
5
6 Resource          ../global_properties.robot
7 Resource          ../json_templater.robot
8
9 *** Variables ***
10 ${E2MGR_BASE_PATH}        /v1/nodeb   #/nodeb  /nodeb/setup
11 ${E2MGR_BASE_VERSION}        /v1
12 ${E2MGR_ENDPOINT}     ${GLOBAL_E2MGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_E2MGR_IP_ADDR}:${GLOBAL_E2MGR_SERVER_PORT}
13 ${E2MGR_SETUP_NODEB_TEMPLATE}     robot/assets/templates/e2mgr_setup_nodeb.template
14
15
16 *** Keywords ***
17 Run E2Mgr Health Check
18      [Documentation]    Runs E2Mgr Health check
19      ${data_path}=    Set Variable    /v1/health
20      ${resp}=    Run Keyword    Run E2Mgr Get Request    ${data_path}
21
22 Check NodeB Status
23      [Documentation]    Check NodeB Status
24      [Arguments]      ${ran_name}
25      ${resp}=  Run Keyword   Run E2Mgr Get NodeB Request    ${ran_name}
26      Should Be Equal As Strings        ${resp.json()['connectionStatus']}     CONNECTED
27
28 Run E2Mgr Get NodeB Request
29      [Documentation]    Runs E2Mgr Get NodeB Request
30      [Arguments]      ${ran_name}
31      ${data_path}=    Set Variable    ${E2MGR_BASE_PATH}/${ran_name}
32      ${resp}=    Run Keyword    Run E2Mgr Get Request    ${data_path}
33      Should Be Equal As Strings        ${resp.status_code}     200
34      [Return]    ${resp}
35
36 Run E2Mgr Get All NodeBs Request 
37      [Documentation]    Runs E2Mgr Get All NodeBs Request
38      ${data_path}=    Set Variable    ${E2MGR_BASE_VERSION}/nodeb-ids
39      ${resp}=    Run Keyword    Run E2Mgr Get Request    ${data_path}
40
41 Run E2Mgr Setup NodeB X2
42      [documentation]     Setup X2 NodeB via E2 Manager
43      [Arguments]      ${ran_name}  ${ran_ip}   ${ran_port}
44      ${data_path}=    Set Variable    ${E2MGR_BASE_PATH}/x2-setup
45      ${dict}=    Create Dictionary    ran_name=${ran_name}    ran_ip=${ran_ip}   ran_port=${ran_port}
46      ${data}=   Fill JSON Template File    ${E2MGR_SETUP_NODEB_TEMPLATE}    ${dict}
47      ${auth}=  Create List  ${GLOBAL_INJECTED_E2MGR_USER}    ${GLOBAL_INJECTED_E2MGR_PASSWORD}
48      ${session}=    Create Session      e2mgr      ${E2MGR_ENDPOINT}   auth=${auth}
49      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
50      ${resp}=   Post Request     e2mgr     ${data_path}     data=${data}   headers=${headers}
51      Log    Received response from E2Mgr ${resp.text}
52      Should Be Equal As Strings        ${resp.status_code}     200
53      [Return]    ${resp}
54
55 Run E2Mgr Setup NodeB Endc
56      [documentation]     Setup Endc NodeB via E2 Manager
57      [Arguments]      ${ran_name}  ${ran_ip}   ${ran_port}
58      ${data_path}=    Set Variable    ${E2MGR_BASE_PATH}/endc-setup
59      ${dict}=    Create Dictionary    ran_name=${ran_name}    ran_ip=${ran_ip}   ran_port=${ran_port}
60      ${data}=   Fill JSON Template File    ${E2MGR_SETUP_NODEB_TEMPLATE}    ${dict}
61      ${auth}=  Create List  ${GLOBAL_INJECTED_E2MGR_USER}    ${GLOBAL_INJECTED_E2MGR_PASSWORD}
62      ${session}=    Create Session      e2mgr      ${E2MGR_ENDPOINT}   auth=${auth}
63      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
64      ${resp}=   Post Request     e2mgr     ${data_path}     data=${data}   headers=${headers}
65      Log    Received response from E2Mgr ${resp.text}
66      Should Be Equal As Strings        ${resp.status_code}     200
67      [Return]    ${resp}
68
69 Run E2Mgr Delete NodeB
70      [documentation]     Delete NodeB via E2 Manager
71      [Arguments]      ${ran_name}  
72      ${data_path}=    Set Variable    ${E2MGR_BASE_PATH}/${ran_name}
73      ${resp}=    Run E2Mgr Delete Request    ${data_path}
74      Should Be Equal As Strings        ${resp.status_code}     200
75
76
77 Run E2Mgr Get Request
78      [Documentation]    Runs E2Mgr Get Request
79      [Arguments]    ${data_path}
80      ${auth}=  Create List  ${GLOBAL_INJECTED_E2MGR_USER}    ${GLOBAL_INJECTED_E2MGR_PASSWORD}
81      ${session}=    Create Session      e2mgr      ${E2MGR_ENDPOINT}   auth=${auth}
82      ${uuid}=    Generate UUID
83      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
84      ${resp}=   Get Request     e2mgr     ${data_path}     headers=${headers}
85      Log    Received response from E2Mgr ${resp.text}
86      Should Be Equal As Strings        ${resp.status_code}     200
87      [Return]    ${resp}
88
89 Run E2Mgr Delete Request
90      [Documentation]    Runs E2Mgr Delete Request
91      [Arguments]    ${data_path}
92      ${auth}=  Create List  ${GLOBAL_INJECTED_E2MGR_USER}    ${GLOBAL_INJECTED_E2MGR_PASSWORD}
93      ${session}=    Create Session      e2mgr      ${E2MGR_ENDPOINT}   auth=${auth}
94      ${uuid}=    Generate UUID
95      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json    
96      ${resp}=   Delete Request     e2mgr     ${data_path}     headers=${headers}
97      Log    Received response from E2Mgr ${resp.text}
98      Should Be Equal As Strings        ${resp.status_code}     200
99      [Return]    ${resp}