aboutsummaryrefslogtreecommitdiffstats
path: root/platform-logic/generic-resource-api/src/main/xml/GENERIC-RESOURCE-API_port-mirror-topology-operation-disable.xml
blob: 0be852c83f795e7fd7f7449efd8521f81a7592fe (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
<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='port-mirror-topology-operation-disable' mode='sync'>
        <block atomic="true">
            <set>
                <parameter name='tmp.configuration-id' value='`$port-mirror-topology-operation-input.configuration-information.configuration-id`' />
            </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.pm-configuration`"/>
                <parameter name="outputPath" value="tmp.pmc-url"/>
                <parameter name="target" value="{configuration-id}"/>
                <parameter name="replacement" value="`$tmp.configuration-id`"/>
            </execute>
            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                <parameter name='restapiUrl' value='`$prop.controller.url + $tmp.pmc-url`' />
                <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="pm-mdsal" />
                <outcome value='success'>
                    <switch test='`$pm-mdsal.port-mirror-configuration_length == 1`'>
                        <outcome value='false'>
                            <return status='failure'>
                                <parameter name='error-code' value='500' />
                                <parameter name='error-message' value="`'Cannot find port-mirror-configuration ' + $tmp.configuration-id`" />
                            </return>
                        </outcome>
                    </switch>
                </outcome>
                <outcome value='Other'>
                    <return status='failure'>
                        <parameter name='error-code' value='500' />
                        <parameter name='error-message' value="`'Cannot find port-mirror-configuration ' + $tmp.configuration-id`" />
                    </return>
                </outcome>
            </execute>
            <set>
                <parameter name='pm.configuration-id' value='`$tmp.configuration-id`' />
                <parameter name='pm.configuration-data.' value='`$pm-mdsal.port-mirror-configuration[0].configuration-data.`' />
            </set>
            <switch test="`$pm-mdsal.port-mirror-configuration[0].configuration-data.configuration-oper-status.order-status == 'Active'`">
                <outcome value='false'>
                    <return status='failure'>
                        <parameter name='error-code' value='500' />
                        <parameter name='error-message' value="`'Order status is ' + $mdsal-pmc.port-mirror-configuration[0].configuration-data.configuration-oper-status.order-status + ' but must be Active'`" />
                    </return>
                </outcome>
            </switch>
            <for index='idx' start='0' end='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map_length`' >
                <switch test='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$idx].source-port-id
  == $port-mirror-topology-operation-input.port-mirror-configuration-request-input.source-port.source-port-id`'>
                    <outcome value='true'>
                        <block atomic="true">
                            <set>
                                <parameter name='src-idx' value='`$idx`' />
                            </set>
                            <break/>
                        </block>
                    </outcome>
                </switch>
            </for>
            <switch test='`$src-idx`'>
                <outcome value=''>
                    <return status='failure'>
                        <parameter name='error-code' value='500' />
                        <parameter name='error-message' value="`'Unable to find source port ' + $port-mirror-topology-operation-input.port-mirror-configuration-request-input.source-port.source-port-id + ' in MD-SAL'`" />
                    </return>
                </outcome>
            </switch>
            <switch test='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].dest-ip-addresses.ip-addresses.ipv4-address`'>
                <outcome value='Other'>
                    <set>
                        <parameter name='tmp.analyzer.ip-address'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].dest-ip-addresses.ip-addresses.ipv4-address`' />
                    </set>
                </outcome>
                <outcome value=''>
                    <switch test='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].dest-ip-addresses.ip-addresses.ipv6-address`'>
                        <outcome value='Other'>
                            <set>
                                <parameter name='tmp.analyzer.ip-address'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].dest-ip-addresses.ip-addresses.ipv6-address`' />
                            </set>
                        </outcome>
                        <outcome value=''>
                            <switch test='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].dest-ip-addresses.ip-addresses.vipv4-address`'>
                                <outcome value='Other'>
                                    <set>
                                        <parameter name='tmp.analyzer.ip-address'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].dest-ip-addresses.ip-addresses.vipv4-address`' />
                                    </set>
                                </outcome>
                                <outcome value=''>
                                    <switch test='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].dest-ip-addresses.ip-addresses.vipv6-address`'>
                                        <outcome value='Other'>
                                            <set>
                                                <parameter name='tmp.analyzer.ip-address'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].dest-ip-addresses.ip-addresses.vipv6-address`' />
                                            </set>
                                        </outcome>
                                        <outcome value=''>
                                            <return status='failure'>
                                                <parameter name='error-code' value='500' />
                                                <parameter name='error-message' value="`'No dest addresses stored for source port ' + $pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].source-port-name`" />
                                            </return>
                                        </outcome>
                                    </switch>
                                </outcome>
                            </switch>
                        </outcome>
                    </switch>
                </outcome>
            </switch>
            <execute plugin='org.onap.ccsdk.sli.plugins.contrail.ContrailAdaptor' method='sendContrailRequest' emitsOutcome='true' >
                <parameter name='api-name' value='port-mirroring' />
                <parameter name='api-action' value='disable' />
                <parameter name='resp-prefix' value='contrailResp' />
                <parameter name='display-name'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].source-port-name`' />
                <parameter name='contrail-virtual-machine-interface-name'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].source-port-name`' />
                <parameter name='contrail-virtual-machine-interface-id'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].source-port-id`' />
                <parameter name='default-domain' value='default-domain' />
                <parameter name='default-project'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.tenant`' />
                <parameter name='traffic-direction' value='both' />
                <parameter name='analyzer-ip-address'
  value='`$tmp.analyzer.ip-address`' />
                <parameter name='udp-port' value='8099' />
                <parameter name='routing-instance'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.dest-network-fqdn`' />
                <parameter name='local-preference' value='1' />
                <parameter name='cloud-region-id'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.cloud-region-id`' />
                <parameter name='cloud-owner'
  value='`$pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.cloud-owner`' />
                <outcome value='success'>
                    <set>
                        <parameter name='contrail-set[$src-idx]' value='true' />
                    </set>
                </outcome>
                <outcome value='failure'>
                    <return status='failure'>
                        <parameter name='error-code' value='500' />
                        <parameter name='error-message' value="`'Failed to update policy in Contrail. '+ $contrailResp.resp-code + ':' +$contrailResp.resp-message `" />
                    </return>
                </outcome>
            </execute>
            <update plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService"
   resource="l-interface"
   key="cloud-region.cloud-region-id = $pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.cloud-region-id
     AND cloud-region.cloud-owner = $pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.cloud-owner
     AND tenant.tenant-id = $pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.tenant-id
     AND vserver.vserver-id = $pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].source-vserver-id
     AND l-interface.interface-name = $pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].source-port-name"
   force="true" pfx="tmp.AnAI-data">
                <parameter name="is-port-mirrored" value="false" />
                <outcome value='not-found'>
                    <return status='failure'>
                        <parameter name='error-code' value='500' />
                        <parameter name='error-message' value="`'Failed to update l-interface object in AAI for interface ' + $pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].source-port-name`" />
                    </return>
                </outcome>
                <outcome value='failure'>
                    <return status='failure'>
                        <parameter name='error-code' value='500' />
                        <parameter name='error-message' value="`'Failed to update l-interface object in AAI for interface ' + $pm.configuration-data.port-mirror-configuration-topology.port-mirror-configuration-assignments.source-to-dest-maps.source-to-dest-map[$src-idx].source-port-name`" />
                    </return>
                </outcome>
            </update>
            <return status='success'>
                <parameter name='error-code' value='200' />
                <parameter name='ack-final' value='Y' />
            </return>
        </block>
    </method>
</service-logic>