remove unneeded libraries
[testsuite.git] / robot / resources / aai / service_instance.robot
1 *** Settings ***
2 Documentation     Validate A&AI Serivce Instance
3 ...
4 ...                   Validate A&AI Serivce Instance
5
6 Resource          aai_interface.robot
7 Library    Collections
8 Library    OperatingSystem
9 Library    RequestsLibrary
10 Library    JSONUtils
11 Library    StringTemplater
12 Resource          ../json_templater.robot
13 Resource          ../stack_validation/validate_vlb.robot
14 Resource          ../stack_validation/validate_vfw.robot
15 Resource          ../stack_validation/validate_vvg.robot
16 Resource          ../aai/aai_interface.robot
17
18 *** Variables ***
19 ${INDEX PATH}     /aai/v11
20 ${GENERIC_QUERY_PATH}  /search/generic-query?
21 ${SYSTEM USER}    robot-ete
22 ${CUSTOMER SPEC PATH}    /business/customers/customer/
23 ${SERVICE SUBSCRIPTIONS}    /service-subscriptions/service-subscription/
24 ${SERVICE INSTANCE}    /service-instances?service-instance-id=
25 ${SERVCE INSTANCE TEMPLATE}    robot/assets/templates/aai/service_subscription.template
26
27 ${GENERIC_VNF_PATH_TEMPLATE}   /network/generic-vnfs/generic-vnf/\${vnf_id}/vf-modules/vf-module/\${vf_module_id}
28 ${GENERIC_VNF_QUERY_TEMPLATE}   /network/generic-vnfs/generic-vnf/\${vnf_id}/vf-modules/vf-module?vf-module-name=\${vf_module_name}
29 ${VLB_CLOSED_LOOP_HACK_BODY}    robot/assets/templates/aai/vlb_closed_loop_hack.template
30
31 #*************** Test Case Variables *************
32 ${VLB_CLOSED_LOOP_DELETE}
33 ${VLB_CLOSED_LOOP_VNF_ID}
34
35 *** Keywords ***
36 Validate Service Instance
37     [Documentation]    Query and Validates A&AI Service Instance
38     [Arguments]    ${service_instance_name}    ${service_type}  ${customer_name}
39     ${cust_resp}=    Run A&AI Get Request      ${INDEX PATH}/business/customers?subscriber-name=${customer_name}
40         ${resp}=    Run A&AI Get Request      ${INDEX PATH}${CUSTOMER SPEC PATH}${cust_resp.json()['customer'][0]['global-customer-id']}${SERVICE SUBSCRIPTIONS}${service_type}${SERVICE INSTANCE}${service_instance_name}
41     Dictionary Should Contain Value     ${resp.json()['service-instance'][0]}    ${service_instance_name}
42     #Dictionary Should Contain Key      ${resp.json()['service-instance'][0]}    persona-model-id
43     #Dictionary Should Contain Key      ${resp.json()['service-instance'][0]}    persona-model-version
44
45 Validate Generic VNF
46     [Documentation]    Query and Validates A&AI Service Instance
47     [Arguments]    ${vnf_name}  ${vnf_type}    ${service_instance_id}
48     ${generic_vnf}=    Run A&AI Get Request      ${INDEX PATH}/network/generic-vnfs/generic-vnf?vnf-name=${vnf_name}
49     Dictionary Should Contain Value     ${generic_vnf.json()}    ${vnf_name}
50     ${returned_vnf_type}=    Get From Dictionary    ${generic_vnf.json()}    vnf-type
51     Should Contain      ${returned_vnf_type}    ${vnf_type}
52     ${vnf_id}=    Get From Dictionary    ${generic_vnf.json()}    vnf-id
53     ${generic_vnf}=    Run A&AI Get Request      ${INDEX PATH}/network/generic-vnfs/generic-vnf/${vnf_id}?depth=all
54     [Return]    ${generic_vnf.json()}
55
56 VLB Closed Loop Hack
57     [Arguments]    ${service}    ${generic_vnf}   ${closedloop_vf_module}
58     Return From Keyword If    '${service}' != 'vLB'
59     ${vnf_id}=     Get From Dictionary    ${generic_vnf}    vnf-id
60     ${vf_modules}=    Get From Dictionary    ${generic_vnf}    vf-modules
61     ${list}=    Get From Dictionary    ${vf_modules}   vf-module
62     ${vfmodule}=    Get From List    ${list}    0
63     ${persona_model_id}=    Get From Dictionary    ${closedloop_vf_module}    invariantUUID
64     ${persona_model_version}=   Get From Dictionary    ${closedloop_vf_module}    version
65     ${dummy}=    Catenate   dummy_${vnf_id}
66     ${dict}=    Create Dictionary   vnf_id=${vnf_id}   vf_module_id=${dummy}   persona_model_id=${persona_model_id}   persona_model_version=${persona_model_version}
67     ${datapath}=    Template String    ${GENERIC_VNF_PATH_TEMPLATE}    ${dict}
68     ${data}=    Fill JSON Template File    ${VLB_CLOSED_LOOP_HACK_BODY}    ${dict}
69         ${put_resp}=    Run A&AI Put Request     ${INDEX PATH}${datapath}   ${data}
70     ${status_string}=    Convert To String    ${put_resp.status_code}
71     Should Match Regexp    ${status_string}    ^(201|412)$
72     Set Test Variable   ${VLB_CLOSED_LOOP_DELETE}    ${datapath}
73     Set Test Variable   ${VLB_CLOSED_LOOP_VNF_ID}    ${vnf_id}
74
75
76 VLB Closed Loop Hack Update
77     [Documentation]   Update the A&AI vDNS scaling vf module to have persona-model-version 1 rather than 1.0
78     [Arguments]   ${stack_name}
79     ${dict}=    Create Dictionary   vnf_id=${VLB_CLOSED_LOOP_VNF_ID}   vf_module_name=${stack_name}
80     ${query}=   Template String   ${GENERIC_VNF_QUERY_TEMPLATE}   ${dict}
81     ${get_resp}=    Run A&AI Get Request     ${INDEX_PATH}${query}
82     ${json}=   Set Variable   ${get_resp.json()}
83     Set to Dictionary    ${json}   persona-model-version   1
84     ${vf_module_id}=   Get From Dictionary   ${json}   vf-module-id
85     Set to Dictionary   ${dict}   vf_module_id=${vf_module_id}
86     ${uri}=   Template String   ${GENERIC_VNF_PATH_TEMPLATE}   ${dict}
87     ${resp}=   Run A&AI Put Request    ${INDEX_PATH}${uri}   ${json}
88     ${get_resp}=    Run A&AI Get Request     ${INDEX_PATH}${query}
89
90
91 Teardown VLB Closed Loop Hack
92     Return From Keyword If    ' ${VLB_CLOSED_LOOP_DELETE}' == ''
93         Delete A&AI Entity    ${VLB_CLOSED_LOOP_DELETE}
94
95
96 Validate VF Module
97     [Documentation]    Query and Validates A&AI Service Instance
98     [Arguments]    ${vf_module_name}    ${stack_type}
99         Run Keyword If    '${stack_type}'=='vLB'    Validate vLB Stack    ${vf_module_name}
100         Run Keyword If    '${stack_type}'=='vFW'    Validate Firewall Stack    ${vf_module_name}
101         Run Keyword If    '${stack_type}'=='vVG'    Validate vVG Stack    ${vf_module_name}
102
103 *** Keywords ***
104 Create AAI Service Instance
105     [Documentation]    Query and Validates A&AI Service Instance
106     [Arguments]    ${customer_id}    ${service_type}    ${service_instance_id}    ${service_instance_name}
107     ${json_string}=    Catenate     { "service-type": "VDNS" , "service-subscriptions":[{"service-instance-id":"instanceid123","service-instance-name":"VDNS"}]}
108         ${put_resp}=    Run A&AI Put Request     ${INDEX PATH}${CUSTOMER SPEC PATH}${CUSTOMER ID}${SERVICE SUBSCRIPTIONS}/{service_type}   ${json_string}
109     Should Be Equal As Strings  ${put_resp.status_code}         201
110         [Return]  ${put_resp.status_code}
111