aboutsummaryrefslogtreecommitdiffstats
path: root/platform-logic/generic-resource-api/src/main/xml/GENERIC-RESOURCE-API_self-serve-vf-module-generate-name.xml
blob: 01ec0d4bbc1e965e6f737863f5cd50fbf1addcc1 (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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<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='self-serve-vf-module-generate-name' mode='sync'>
        <block atomic='true'>
            <set>
                <parameter name='pathname' 
	value="`'/var/tmp/ss-gen-name-' + 
	$ss.capability-type + '-' + $ss.capability-action + '-' + 
	$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-information.vf-module-id + '.log'`" />
            </set>
            <switch test="`$ss.capability-action`">
                <outcome value='unassign'>
                    <block atomic='true'>
                        <set>
                            <parameter name='tmp.naming-data-payload' value='{&quot;elements&quot;:[' />
                        </set>
                        <for index='i' start='0' end='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param_length`' >
                            <switch test='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.capability-name == $ss.capability-name`'>
                                <outcome value='true'>
                                    <block atomic='true'>
                                        <set>
                                            <parameter name='tmp.naming-data-payload' value="`$tmp.naming-data-payload + '{'`" />
                                            <parameter name='tmp.gen-name_length' value='1' />
                                        </set>
                                        <for index='j' start='0' end='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key_length`' >
                                            <switch test="`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key[$j].name == 'external-key'`">
                                                <outcome value='true'>
                                                    <set>
                                                        <parameter name="tmp.naming-data-payload" value="`$tmp.naming-data-payload + '&quot;' + $service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key[$j].name + '&quot;:' + '&quot;' + $service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key[$j].value + '&quot;,'`"/>
                                                        <parameter name="`tmp.gen-name[0].element[$j].name`" value="`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key[$j].name`"/>
                                                        <parameter name="`tmp.gen-name[0].element[$j].value`" value="`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key[$j].value`"/>
                                                        <parameter name="`tmp.gen-name[0].element_length`" value='`$j + 1`' />
                                                    </set>
                                                </outcome>
                                            </switch>
                                        </for>
                                        <set>
                                            <parameter name='tmp.naming-data-payload' value="`$tmp.naming-data-payload + '},'`" />
                                        </set>
                                        <set>
                                            <parameter name='tmp.naming-data-payload' value="`$tmp.naming-data-payload + ']}'`" />
                                        </set>
                                        <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace'>
                                            <parameter name='outputPath' value='tmp.naming-data-payload' />
                                            <parameter name='source' value='`$tmp.naming-data-payload`' />
                                            <parameter name='target' value=',}' />
                                            <parameter name='replacement' value='}' />
                                        </execute>
                                        <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace'>
                                            <parameter name='outputPath' value='tmp.naming-data-payload' />
                                            <parameter name='source' value='`$tmp.naming-data-payload`' />
                                            <parameter name='target' value=',]' />
                                            <parameter name='replacement' value=']' />
                                        </execute>
                                        <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
                                            <parameter name="logger" value="message-log"/>
                                            <parameter name="field1" value="BEFORE namegeneration.node.UnAssignNameNode"/>
                                        </record>
                                        <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                                            <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.naming.gen-name.templatefile`" />
                                            <parameter name='restapiUrl' value='`$prop.naming.gen-name.url + $prop.restapi.naming.gen-name.service`' />
                                            <parameter name='restapiUser' value='`$prop.naming.gen-name.user`' />
                                            <parameter name='restapiPassword' value='`$prop.naming.gen-name.pwd`' />
                                            <parameter name='format' value='json' />
                                            <parameter name='httpMethod' value='DELETE' />
                                            <parameter name="responsePrefix" value="nameGenResponse" />
                                            <outcome value='failure'>
                                                <block atomic='true'>
                                                    <set>
                                                        <parameter name='`service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.status`' value='FAILED' />
                                                    </set>
                                                    <return status='failure'>
                                                        <parameter name='ack-final' value='Y'/>
                                                        <parameter name="error-code" value="500" />
                                                        <parameter name="error-message" value="Error from NameGenerationNode Unassign" />
                                                    </return>
                                                </block>
                                            </outcome>
                                            <outcome value='not-found'>
                                                <block atomic='true'>
                                                    <set>
                                                        <parameter name='`service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.status`' value='FAILED' />
                                                    </set>
                                                    <return status='failure'>
                                                        <parameter name='ack-final' value='Y'/>
                                                        <parameter name="error-code" value="500" />
                                                        <parameter name="error-message" value="Error from NameGenerationNode Unassign" />
                                                    </return>
                                                </block>
                                            </outcome>
                                        </execute>
                                        <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
                                            <parameter name="logger" value="message-log"/>
                                            <parameter name="field1" value="AFTER namegeneration.node.UnAssignNameNode"/>
                                        </record>
                                        <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils" method="jsonStringToCtx">
                                            <parameter name="source" value="nameGenResponse.httpResponse" />
                                            <parameter name="outputPath" value="jsonContextPrefix" />
                                            <parameter name="isEscaped" value="false" />
                                        </execute>
                                        <set>
                                            <parameter name='`service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.status`' value='DELETED' />
                                        </set>
                                        <for index='n' start='0' end='`$jsonContextPrefix.elements_length`' >
                                            <switch test='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].name == $jsonContextPrefix.elements[$n].resource-name`'>
                                                <outcome value='true'>
                                                    <set>
                                                        <parameter name='`service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].value`' value="`$jsonContextPrefix.elements[$n].resource-value`" />
                                                    </set>
                                                </outcome>
                                            </switch>
                                        </for>
                                    </block>
                                </outcome>
                            </switch>
                        </for>
                    </block>
                </outcome>
                <outcome value='assign'>
                    <block atomic='true'>
                        <set>
                            <parameter name='tmp.naming-data-payload' value='{&quot;elements&quot;:[' />
                            <parameter name='tmp.gen-name_length' value='0' />
                        </set>
                        <for index='i' start='0' end='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param_length`' >
                            <switch test='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.capability-name == $ss.capability-name`'>
                                <outcome value='true'>
                                    <block atomic='true'>
                                        <set>
                                            <parameter name='tmp.naming-data-payload' value="`$tmp.naming-data-payload + '{'`" />
                                        </set>
                                        <for index='j' start='0' end='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key_length`' >
                                            <set>
                                                <parameter name="tmp.naming-data-payload" value="`$tmp.naming-data-payload + '&quot;' + $service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key[$j].name + '&quot;:' + '&quot;' + $service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key[$j].value + '&quot;,'`"/>
                                                <parameter name="`tmp.gen-name[$tmp.gen-name_length].element[$j].name`" value="`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key[$j].name`"/>
                                                <parameter name="`tmp.gen-name[$tmp.gen-name_length].element[$j].value`" value="`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.resource-key[$j].value`"/>
                                                <parameter name="`tmp.gen-name[$tmp.gen-name_length].element_length`" value='`$j + 1`' />
                                            </set>
                                        </for>
                                        <set>
                                            <parameter name='tmp.naming-data-payload' value="`$tmp.naming-data-payload + '},'`" />
                                            <parameter name='tmp.gen-name_length' value='`$tmp.gen-name_length + 1`' />
                                        </set>
                                    </block>
                                </outcome>
                            </switch>
                        </for>
                        <switch test="`$tmp.naming-data-payload == ''`">
                            <outcome value='false'>
                                <block atomic='true'>
                                    <set>
                                        <parameter name='tmp.naming-data-payload' value="`$tmp.naming-data-payload + ']}'`" />
                                    </set>
                                    <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace'>
                                        <parameter name='outputPath' value='tmp.naming-data-payload' />
                                        <parameter name='source' value='`$tmp.naming-data-payload`' />
                                        <parameter name='target' value=',}' />
                                        <parameter name='replacement' value='}' />
                                    </execute>
                                    <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace'>
                                        <parameter name='outputPath' value='tmp.naming-data-payload' />
                                        <parameter name='source' value='`$tmp.naming-data-payload`' />
                                        <parameter name='target' value=',]' />
                                        <parameter name='replacement' value=']' />
                                    </execute>
                                    <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
                                        <parameter name="logger" value="message-log"/>
                                        <parameter name="field1" value="BEFORE namegeneration.node.AssignNameNode"/>
                                    </record>
                                    <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                                        <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.naming.gen-name.templatefile`" />
                                        <parameter name='restapiUrl' value='`$prop.naming.gen-name.url + $prop.restapi.naming.gen-name.service`' />
                                        <parameter name='restapiUser' value='`$prop.naming.gen-name.user`' />
                                        <parameter name='restapiPassword' value='`$prop.naming.gen-name.pwd`' />
                                        <parameter name='format' value='json' />
                                        <parameter name='httpMethod' value='POST' />
                                        <parameter name="responsePrefix" value="nameGenResponse" />
                                        <outcome value='failure'>
                                            <block atomic='true'>
                                                <set>
                                                    <parameter name='`service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.status`' value='FAILED' />
                                                </set>
                                                <return status='failure'>
                                                    <parameter name='ack-final' value='Y'/>
                                                    <parameter name="error-code" value="500" />
                                                    <parameter name="error-message" value="Error from NameGenerationNode Assign" />
                                                </return>
                                            </block>
                                        </outcome>
                                        <outcome value='not-found'>
                                            <block atomic='true'>
                                                <set>
                                                    <parameter name='`service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$i].resource-resolution-data.status`' value='FAILED' />
                                                </set>
                                                <return status='failure'>
                                                    <parameter name='ack-final' value='Y'/>
                                                    <parameter name="error-code" value="500" />
                                                    <parameter name="error-message" value="Error from NameGenerationNode Assign" />
                                                </return>
                                            </block>
                                        </outcome>
                                    </execute>
                                    <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
                                        <parameter name="logger" value="message-log"/>
                                        <parameter name="field1" value="AFTER namegeneration.node.AssignNameNode"/>
                                    </record>
                                    <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils" method="jsonStringToCtx">
                                        <parameter name="source" value="nameGenResponse.httpResponse" />
                                        <parameter name="outputPath" value="jsonContextPrefix" />
                                        <parameter name="isEscaped" value="false" />
                                    </execute>
                                    <for index='n' start='0' end='`$jsonContextPrefix.elements_length`' >
                                        <for index='l' start='0' end='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param_length`' >
                                            <switch test='`$service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$l].name == $jsonContextPrefix.elements[$n].resource-name`'>
                                                <outcome value='true'>
                                                    <set>
                                                        <parameter name='`service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$l].value`' value="`$jsonContextPrefix.elements[$n].resource-value`" />
                                                        <parameter name='`service-data.vnfs.vnf[$vnf-index].vnf-data.vf-modules.vf-module[$vf-module-index].vf-module-data.vf-module-topology.vf-module-parameters.param[$l].resource-resolution-data.status`' value='SUCCESS' />
                                                    </set>
                                                </outcome>
                                            </switch>
                                        </for>
                                    </for>
                                </block>
                            </outcome>
                        </switch>
                    </block>
                </outcome>
            </switch>
        </block>
    </method>
</service-logic>