aboutsummaryrefslogtreecommitdiffstats
path: root/platform-logic/generic-resource-api/src/main/xml/GENERIC-RESOURCE-API_sdwan-attachment-topology-operation-delete.xml
blob: 28f6442a8fece879f8d1a022dc62d7c7f99602b5 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<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='sdwan-attachment-topology-operation-delete' mode='sync'>
        <block atomic="true">
            <set>
                <parameter name='tmp.ar.allotted-resource-id' value='`$connection-attachment-topology-operation-input.allotted-resource-information.allotted-resource-id`' />
                <parameter name='tmp.ar.parent-service-instance-id' value='`$connection-attachment-topology-operation-input.allotted-resource-information.parent-service-instance-id`' />
            </set>
            <set>
                <parameter name='tmp.ar.self-link' value="`'restconf/config/GENERIC-RESOURCE-API:connection-attachment-allotted-resources/connection-attachment-allotted-resource/'
 + $tmp.ar.allotted-resource-id
 + '/allotted-resource-data/connection-attachment-topology/'` " />
            </set>
            <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>
            <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                <parameter name="source" value="`$prop.restapi.connection-attachment-allottedresource`"/>
                <parameter name="outputPath" value="tmp.ar-url"/>
                <parameter name="target" value="{allotted-resource-id}"/>
                <parameter name="replacement" value="`$tmp.ar.allotted-resource-id`"/>
            </execute>
            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                <parameter name='restapiUrl' value='`$prop.controller.url + $tmp.ar-url`' />
                <parameter name='restapiUser' value='`$prop.controller.user`' />
                <parameter name='restapiPassword' value='`$prop.controller.pwd`' />
                <parameter name='format' value='json' />
                <parameter name='httpMethod' value='Delete' />
                <parameter name="responsePrefix" value="mdsal-ar" />
                <outcome value='success'>
                    <block></block>
                </outcome>
                <outcome value='failure'>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="Error updating md-sal for connection-attachment-allotted-resource" />
                    </return>
                </outcome>
                <outcome value='not-found'>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="Error updating md-sal for connection-attachment-allotted-resource" />
                    </return>
                </outcome>
            </execute>
            <switch test='`$service-data.consumed-allotted-resources.consumed-allotted-resource_length`'>
                <outcome value=''>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="Resource to be deleted doesn't exist in MDSAL." />
                    </return>
                </outcome>
                <outcome value='Other'>
                    <block atomic="true">
                        <for index='cidx' start='0' end='`$service-data.consumed-allotted-resources.consumed-allotted-resource_length`' >
                            <switch test="`$service-data.consumed-allotted-resources.consumed-allotted-resource[$cidx].allotted-resource-id == $tmp.ar.allotted-resource-id`">
                                <outcome value='true'>
                                    <block atomic="true">
                                        <set>
                                            <parameter name='tmp.cidx' value='`$cidx`' />
                                        </set>
                                    </block>
                                </outcome>
                            </switch>
                        </for>
                        <switch test="`$tmp.cidx`">
                            <outcome value=''>
                                <return status='failure'>
                                    <parameter name='ack-final' value='Y'/>
                                    <parameter name="error-code" value="500" />
                                    <parameter name="error-message" value="resource to be deleted is not available in mdsal" />
                                </return>
                            </outcome>
                        </switch>
                    </block>
                </outcome>
            </switch>
            <set>
                <parameter name="service-data.consumed-allotted-resources.consumed-allotted-resource[$cidx]." value="" />
                <parameter name='service-data.consumed-allotted-resources.consumed-allotted-resource_length' value='`$service-data.consumed-allotted-resources.consumed-allotted-resource_length - 1`' />
            </set>
            <set>
                <parameter name='tmp.ar.parent-service-instance-id' value="`$connection-attachment-topology-operation-input.allotted-resource-information.parent-service-instance-id` " />
            </set>
            <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                <parameter name="source" value="/restconf/config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data"/>
                <parameter name="outputPath" value="tmp.ar-url-psd"/>
                <parameter name="target" value="{service-instance-id}"/>
                <parameter name="replacement" value="`$tmp.ar.parent-service-instance-id`"/>
            </execute>
            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                <parameter name='restapiUrl' value='`$prop.controller.url + $tmp.ar-url-psd`' />
                <parameter name='restapiUser' value='`$prop.controller.user`' />
                <parameter name='restapiPassword' value='`$prop.controller.pwd`' />
                <parameter name='format' value='json' />
                <parameter name='httpMethod' value='GET' />
                <parameter name="responsePrefix" value="mdsal-psd" />
                <outcome value='success'>
                    <block></block>
                </outcome>
                <outcome value='Other'>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="404" />
                        <parameter name="error-message" value="Error: SOTN resource not found" />
                    </return>
                </outcome>
            </execute>
            <switch test='`$mdsal-psd.service-data.provided-allotted-resources.provided-allotted-resource_length`'>
                <outcome value=''>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="Resource to be deleted doesn't exist in MDSAL." />
                    </return>
                </outcome>
                <outcome value='Other'>
                    <block atomic="true">
                        <for index='pidx' start='0' end='`$mdsal-psd.service-data.provided-allotted-resources.provided-allotted-resource_length`' >
                            <switch test="`$mdsal-psd.service-data.provided-allotted-resources.provided-allotted-resource[$pidx].allotted-resource-id == $tmp.ar.allotted-resource-id`">
                                <outcome value='true'>
                                    <block atomic="true">
                                        <set>
                                            <parameter name='tmp.pidx' value='`$pidx`' />
                                        </set>
                                    </block>
                                </outcome>
                            </switch>
                        </for>
                        <switch test="`$tmp.pidx`">
                            <outcome value=''>
                                <return status='failure'>
                                    <parameter name='ack-final' value='Y'/>
                                    <parameter name="error-code" value="500" />
                                    <parameter name="error-message" value="resource to be deleted is not available in mdsal" />
                                </return>
                            </outcome>
                        </switch>
                    </block>
                </outcome>
            </switch>
            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                <parameter name='restapiUrl' value="`$prop.controller.url + $tmp.ar-url-psd + '/provided-allotted-resources/provided-allotted-resource/' + $tmp.ar.allotted-resource-id`" />
                <parameter name='restapiUser' value='`$prop.controller.user`' />
                <parameter name='restapiPassword' value='`$prop.controller.pwd`' />
                <parameter name='format' value='json' />
                <parameter name='httpMethod' value='DELETE' />
                <parameter name="responsePrefix" value="mdsal-psd-delete" />
            </execute>
            <set>
                <parameter name='allotted-resource-id' value='`$tmp.ar.allotted-resource-id`' />
                <parameter name='connection-attachment-object-path' value="`$tmp.ar.self-link`"/>
                <parameter name='service-object-path' value="`'restconf/config/GENERIC-RESOURCE-API:services/service/'
 + $connection-attachment-topology-operation-input.service-information.service-instance-id
 + '/service-data/service-topology/'`"/>
            </set>
            <delete plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" resource='allotted-resource'  
		key="customer.global-customer-id = $connection-attachment-topology-operation-input.service-information.global-customer-id AND
			service-subscription.service-type = $connection-attachment-topology-operation-input.service-information.subscription-service-type AND
			service-instance.service-instance-id = $connection-attachment-topology-operation-input.allotted-resource-information.parent-service-instance-id AND
			allotted-resource.id = $tmp.ar.allotted-resource-id">
                <outcome value='failure'>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="AAI failed" />
                    </return>
                </outcome>
                <outcome value='not-found'>
                    <return status='failure'>
                        <parameter name='ack-final' value='Y'/>
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="AAI failed" />
                    </return>
                </outcome>
            </delete>
            <return status='success'>
                <parameter name="ack-final-indicator" value="Y" />
                <parameter name="error-code" value="200" />
                <parameter name="error-message" value="`$error-message`" />
            </return>
        </block>
    </method>
</service-logic>