aboutsummaryrefslogtreecommitdiffstats
path: root/platform-logic/generic-resource-api/src/main/xml/GENERIC-RESOURCE-API_policy-update-notify-operation.xml
blob: a0d77fdab516a04363818e812a680f88358d8a8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<service-logic
    xmlns='http://www.onap.org/sdnc/svclogic'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='GENERIC-RESOURCE-API' version='${project.version}'>
    <method rpc='policy-update-notify-operation' mode='sync'>
        <block atomic="true">
            <switch test='`$policy-update-notify-operation-input.update-type`'>
                <outcome value='Update'>
                    <block atomic="true">
                        <execute plugin='org.onap.ccsdk.sli.plugins.prop.PropertiesNode' method='readProperties' >
                            <parameter name='fileName' value='%SDNC_CONFIG_DIR%/generic-resource-api-dg.properties' />
                            <parameter name='contextPrefix' value='prop' />
                        </execute>
                        <set>
                            <parameter name='tmp.sql' value="`'insert into POLICY_UPDATE_NOTIFICATION (policy_name,version_id,update_type) values ( '
+ ' $policy-update-notify-operation-input.policy-name , $policy-update-notify-operation-input.version-id , $policy-update-notify-operation-input.update-type )'`" />
                        </set>
                        <save plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.sql`" pfx='pfx'></save>
                        <set>
                            <parameter name='tmp.policy-name' value='`$policy-update-notify-operation-input.policy-name`' />
                        </set>
                        <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                            <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.pm.getpolicy.templatefile`" />
                            <parameter name='restapiUrl' value="`$prop.policy-manager.url + '/pdp/api/getConfig'`" />
                            <parameter name='format' value='json' />
                            <parameter name='httpMethod' value='POST' />
                            <parameter name='responsePrefix' value="policy" />
                            <parameter name='customHttpHeaders'
      value="`'Authorization=Basic ' + $prop.policy-manager.authorization + ',ClientAuth=Basic ' + $prop.policy-manager.clientauth + ',Environment=' + $prop.policy-manager.environment `" />
                            <outcome value='success'>
                                <block atomic="true"></block>
                            </outcome>
                            <outcome value='Other'>
                                <return status='failure'>
                                    <parameter name='error-code' value='500' />
                                    <parameter name='error-message' value='Failed to get policy from Policy Manager' />
                                </return>
                            </outcome>
                        </execute>
                        <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils' method='jsonStringToCtx' >
                            <parameter name='source' value="policy.config" />
                            <parameter name='outputPath' value="tmp.config-ctx" />
                            <parameter name='isEscaped' value='false' />
                            <outcome value='success'>
                                <block atomic="true"></block>
                            </outcome>
                            <outcome value='Other'>
                                <return status='failure'>
                                    <parameter name='error-code' value='500' />
                                    <parameter name='error-message' value='Failed to convert config variable from PolicyManager' />
                                </return>
                            </outcome>
                        </execute>
                        <set>
                            <parameter name='policy-name' value='`$tmp.config-ctx.content.fq_name[2]`' />
                        </set>
                        <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='split' >
                            <parameter name="original_string" value="`$policy-name`" />
                            <parameter name="regex" value="_"/>
                            <parameter name="limit" value="3" />
                            <parameter name="ctx_memory_result_key" value="policy-splits" />
                        </execute>
                        <execute plugin='org.onap.ccsdk.sli.plugins.contrail.ContrailAdaptor' method='sendContrailRequest' emitsOutcome='true' >
                            <parameter name='api-name' value='network-policy' />
                            <parameter name='api-action' value='update' />
                            <parameter name='resp-prefix' value='contrailResp' />
                            <parameter name='cloud-region-id' value='`$policy-splits[1]`' />
                            <parameter name='update-network-policy-json' value='`$policy.config`' />
                            <outcome value='success'>
                                <block atomic="true"></block>
                            </outcome>
                            <outcome value='Other'>
                                <return status='failure'>
                                    <parameter name='error-code' value='500' />
                                    <parameter name='error-message' value="`'Error updating Contrail: ' + $contrailResp.resp-message`" />
                                </return>
                            </outcome>
                        </execute>
                    </block>
                </outcome>
            </switch>
            <return status='success'>
                <parameter name="ack-final-indicator" value="Y" />
                <parameter name="error-code" value="200" />
                <parameter name="error-message" value="success" />
            </return>
        </block>
    </method>
</service-logic>