onap on kubernetes source files
[oom.git] / kubernetes / config / docker / init / src / config / robot / robot / testsuites / update_onap_page.robot
1 *** Settings ***
2 Documentation     Initializes ONAP Test Web Page and Password
3
4 Library    Collections
5 Library    OperatingSystem
6 Library    StringTemplater
7 Resource          ../resources/openstack/keystone_interface.robot
8 Resource          ../resources/openstack/nova_interface.robot
9
10
11 Test Timeout    1 minutes
12
13 *** Variables ***
14 ${URLS_HTML_TEMPLATE}   robot/assets/templates/web/index.html.template
15
16
17 ${WEB_USER}       test
18 ${WEB_PASSWORD}
19
20 ${URLS_HTML}   html/index.html
21 ${CREDENTIALS_FILE}   /etc/lighttpd/authorization
22 #${CREDENTIALS_FILE}   authorization
23
24 *** Test Cases ***
25 Update ONAP Page
26     [Tags]   UpdateWebPage
27     Run Keyword If   '${WEB_PASSWORD}' == ''   Fail   "WEB Password must not be empty"
28     Run Openstack Auth Request    auth
29     ${server_map}=    Get Openstack Servers    auth
30     ${oam_ip_map}=   Create Dictionary
31     Set To Dictionary    ${oam_ip_map}   10.0.0.1=onapdns
32     Set To Dictionary    ${oam_ip_map}   aai-service.onap-aai=aai
33     Set To Dictionary    ${oam_ip_map}   sdnhost.onap-appc=appc
34     Set To Dictionary    ${oam_ip_map}   10.0.3.1=sdc
35     Set To Dictionary    ${oam_ip_map}   10.0.4.1=dcae_controller
36     Set To Dictionary    ${oam_ip_map}   10.0.4.105=dcae_cdap
37     Set To Dictionary    ${oam_ip_map}   10.0.4.102=dcae_coll
38     Set To Dictionary    ${oam_ip_map}   mso.onap-mso=mso
39     Set To Dictionary    ${oam_ip_map}   drools.onap-policy=policy
40     Set To Dictionary    ${oam_ip_map}   sdnhost.onap-sdnc=sdnc
41     Set To Dictionary    ${oam_ip_map}   vid-server.onap-vid=vid
42     Set To Dictionary    ${oam_ip_map}   portalapps.onap-portal=portal
43     Set To Dictionary    ${oam_ip_map}   robot-openecompete.onap-robot=robot
44     Set To Dictionary    ${oam_ip_map}   dmaap.onap-message-router=message_router
45
46     ${values}=   Create Dictionary
47     ${keys}=    Get Dictionary Keys    ${oam_ip_map}
48     :for   ${oam_ip}   in    @{keys}
49     \    ${value_name}=   Get From Dictionary    ${oam_ip_map}   ${oam_ip}
50     \    Set Public Ip    ${server_map}    ${oam_ip}   ${value_name}   ${values}
51     Log    ${values}
52     Run Keyword If   '${WEB_PASSWORD}' != ''   Create File   ${CREDENTIALS_FILE}   ${WEB_USER}:${WEB_PASSWORD}
53     Create File From Template   ${URLS_HTML_TEMPLATE}   ${URLS_HTML}   ${values}
54
55 *** Keywords ***
56 Create File From Template
57     [Arguments]    ${template}   ${file}   ${values}
58     ${data}    OperatingSystem.Get File   ${template}
59     ${data}=   Template String   ${data}   ${values}
60     Create File     ${file}   ${data}
61
62 Set Public Ip
63     [Arguments]   ${server_map}    ${oam_ip}   ${value_name}   ${values}
64     ${status}   ${public_ip}=   Run Keyword And Ignore Error  Get Public Ip   ${server_map}    ${oam_ip}
65     ${public_ip}=   Set Variable If   '${status}' == 'PASS'   ${public_ip}   ${oam_ip}
66     Set To Dictionary   ${values}   ${value_name}   ${public_ip}
67
68 Get Public Ip
69     [Arguments]   ${server_map}    ${oam_ip}
70     ${servers}   Get Dictionary Values    ${server_map}
71     :for   ${server}   in   @{servers}
72     \    ${status}   ${public_ip}   Run Keyword And Ignore Error   Search Addresses   ${server}   ${oam_ip}
73     \    Return From Keyword If   '${status}' == 'PASS'   ${public_ip}
74     Fail  ${oam_ip} Server Not Found
75
76 Search Addresses
77     [Arguments]   ${server}   ${oam_ip}
78     ${addresses}   Get From Dictionary   ${server}   addresses
79     ${public_ips}   Get From Dictionary   ${addresses}   public
80     ${public_ip}=   Get V4 IP   ${public_ips}
81     ${oam_ips}   Get From Dictionary   ${addresses}   ${GLOBAL_VM_PROPERTIES['network']}
82     ${this_oam_ip}=   Get V4 IP   ${oam_ips}
83     Return From Keyword If   '${this_oam_ip}' == '${oam_ip}'   ${public_ip}
84     Fail  ${oam_ip} Server Not Found
85
86 Get V4 IP
87     [Arguments]   ${ipmaps}
88     :for   ${ipmap}   in   @{ipmaps}
89     \    ${ip}   Get From Dictionary   ${ipmap}   addr
90     \    ${version}   Get From Dictionary   ${ipmap}   version
91     \    Return from Keyword if   '${version}' == '4'   ${ip}
92     Fail  No Version 4 IP