<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='tunnelxconn-topology-operation-create' mode='sync'>
        <block atomic="true">
            <set>
                <parameter name='tmp.ar.allotted-resource-id' value='`$tunnelxconn-topology-operation-input.allotted-resource-information.allotted-resource-id`' />
                <parameter name='tmp.ar.parent-service-instance-id' value='`$tunnelxconn-topology-operation-input.allotted-resource-information.parent-service-instance-id`' />
            </set>
            <set>
                <parameter name='tmp.ar.self-link' value="`'restconf/config/GENERIC-RESOURCE-API:tunnelxconn-allotted-resources/tunnelxconn-allotted-resource/' + $tmp.ar.allotted-resource-id + '/allotted-resource-data/tunnelxconn-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.tx-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='GET' />
                <parameter name="responsePrefix" value="mdsal-ar" />
                <outcome value='success'>
                    <block atomic="true">
                        <set>
                            <parameter name='bk-tx-ar' value='$mdsal-ar.' />
                        </set>
                        <switch test='`$mdsal-ar.tunnelxconn-allotted-resource_length`'>
                            <outcome value='1'>
                                <block atomic='true'>
                                    <set>
                                        <parameter name='tx-ar.' value='$mdsal-ar.tunnelxconn-allotted-resource[0].' />
                                    </set>
                                    <switch test='`$tx-ar.allotted-resource-data.allotted-resource-oper-status.order-status`'>
                                        <outcome value='PendingCreate'>
                                            <block></block>
                                        </outcome>
                                        <outcome value='Other'>
                                            <block></block>
                                        </outcome>
                                    </switch>
                                    <set>
                                        <parameter name='tx-ar.allotted-resource-data.allotted-resource-oper-status.last-action' value='`$tx-ar.allotted-resource-data.allotted-resource-operation-information.request-information.request-action`' />
                                        <parameter name='tx-ar.allotted-resource-data.allotted-resource-oper-status.last-rpc-action' value='`$tx-ar.allotted-resource-status.rpc-action`' />
                                        <parameter name='tx-ar.allotted-resource-data.allotted-resource-oper-status.last-svc-request-id' value='`$tx-ar.allotted-resource-data.allotted-resource-operation-information.sdnc-request-header.svc-request-id`' />
                                    </set>
                                </block>
                            </outcome>
                        </switch>
                    </block>
                </outcome>
                <outcome value='Other'>
                    <block atomic="true"></block>
                </outcome>
            </execute>
            <set>
                <parameter name='tx-ar.allotted-resource-id' value="`$tmp.ar.allotted-resource-id` " />
                <parameter name='tx-ar.allotted-resource-status.action' value="`$tunnelxconn-topology-operation-input.request-information.request-action` " />
                <parameter name='tx-ar.allotted-resource-status.rpc-name' value="tunnelxconn-topology-operation" />
                <parameter name='tx-ar.allotted-resource-status.rpc-action' value="`$tunnelxconn-topology-operation-input.sdnc-request-header.svc-action` " />
                <parameter name='tx-ar.allotted-resource-data.allotted-resource-operation-information.request-information.' value="`$tunnelxconn-topology-operation-input.request-information.` " />
                <parameter name='tx-ar.allotted-resource-data.allotted-resource-operation-information.sdnc-request-header.' value="`$tunnelxconn-topology-operation-input.sdnc-request-header.` " />
                <parameter name='tx-ar.allotted-resource-data.allotted-resource-operation-information.service-information.' value="`$tunnelxconn-topology-operation-input.service-information.` " />
                <parameter name='tx-ar.allotted-resource-data.allotted-resource-operation-information.allotted-resource-information.' value="`$tunnelxconn-topology-operation-input.allotted-resource-information.` " />
                <parameter name='tx-ar.allotted-resource-data.allotted-resource-operation-information.tunnelxconn-request-input.' value="`$tunnelxconn-topology-operation-input.tunnelxconn-request-input.` " />
            </set>
            <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils' method='setTime' >
                <parameter name="outputPath" value="tmp.current-time" />
            </execute>
            <set>
                <parameter name='tx-ar.allotted-resource-data.allotted-resource-oper-status.order-status' value='Created' />
                <parameter name='tx-ar.allotted-resource-data.allotted-resource-oper-status.last-action' value='`$tunnelxconn-topology-operation-input.request-information.request-action`' />
                <parameter name='tx-ar.allotted-resource-data.allotted-resource-oper-status.last-rpc-action' value='`$tunnelxconn-topology-operation-input.sdnc-request-header.svc-action`' />
                <parameter name='tx-ar.allotted-resource-data.allotted-resource-oper-status.last-svc-request-id' value='`$tunnelxconn-topology-operation-input.sdnc-request-header.svc-request-id`' />
                <parameter name='tx-ar.allotted-resource-data.allotted-resource-oper-status.create-timestamp' value='`$tmp.current-time`' />
            </set>
            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.tx.templatefile`" />
                <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='PUT' />
                <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 tunnelxconn-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 tunnelxconn-allotted-resource" />
                    </return>
                </outcome>
            </execute>
            <get-resource plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='IPADDR' key="SELECT min(ip_addr) ip from DHCP_MAP where mac_addr = $tx-ar.allotted-resource-data.allotted-resource-operation-information.tunnelxconn-request-input.brg-wan-mac-address" pfx="tmp.brg-wan-ip" ></get-resource>
            <set>
                <parameter name='tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vbrg-wan-ip' value='`$tmp.brg-wan-ip.ip`' />
            </set>
            <set>
                <parameter name='tmp.tunnel-vgMUX-vG-name' value="`'vxlanTun' + $tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vg-ip` " />
                <parameter name='tmp.tunnel-vgMUX-vBRG-name' value="`'vxlanTun' + $tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vbrg-wan-ip` " />
            </set>
            <set>
                <parameter name='tmp.search.parent-service-instance-id' value='`$tmp.ar.parent-service-instance-id`' />
            </set>
            <call module='GENERIC-RESOURCE-API' rpc='get-vnf-api-parent-instance' mode='sync' ></call>
            <for index='paramidx' start='0' end='`$parent-service-instance.service-data.vnf-topology-information.vnf-parameters_length`' >
                <!--
            <for index='paramidx' start='0' end='`$parent-service-instance.vnf-topology-information.vnf-parameters_length`' >
                -->
                <switch test='`$parent-service-instance.service-data.vnf-topology-information.vnf-parameters[$paramidx].vnf-parameter-name == vgmux_private_ip_1`'>
                    <!--
                <switch test='`$parent-service-instance.vnf-topology-information.vnf-parameters[$paramidx].vnf-parameter-name == vgmux_private_ip_1`'>
                    -->
                    <outcome value='true'>
                        <set>
                            <parameter name='tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vgmux-mgmt-ip' value='`$parent-service-instance.service-data.vnf-topology-information.vnf-parameters[$paramidx].vnf-parameter-value`' />
                            <!--
                             <parameter name='tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vgmux-mgmt-ip' value='`$parent-service-instance.vnf-topology-information.vnf-parameters[$paramidx].vnf-parameter-value`' />

                            -->
                        </set>
                    </outcome>
                </switch>
            </for>
            <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                <parameter name="source" value="`$prop.honeycomb.url`"/>
                <parameter name="outputPath" value="tmp.honeycomb.url"/>
                <parameter name="target" value="{honeycomb-instance-ip}"/>
                <parameter name="replacement" value="`$tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vgmux-mgmt-ip`"/>
            </execute>
            <set>
                <parameter name='tmp.tunnel-name' value="`$tmp.tunnel-vgMUX-vG-name` " />
                <parameter name='tmp.tunnel-dest-ip' value="`$tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vg-ip` " />
                <parameter name='tmp.tunnel-src-ip' value="`$tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vgmux-bearer-ip` " />
                <parameter name='tmp.tunnel-vni' value="`$tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vni` " />
            </set>
            <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                <parameter name="source" value="`$prop.restapi.vpp-honeycomb`"/>
                <parameter name="outputPath" value="tmp.vpp-honeycomb-url"/>
                <parameter name="target" value="{tunnel-name}"/>
                <parameter name="replacement" value="`$tmp.tunnel-name`"/>
            </execute>
            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.vpp.vxlan-tunnel.templatefile`" />
                <parameter name='restapiUrl' value='`$tmp.honeycomb.url + $tmp.vpp-honeycomb-url`' />
                <parameter name='restapiUser' value='`$prop.honeycomb.user`' />
                <parameter name='restapiPassword' value='`$prop.honeycomb.pwd`' />
                <parameter name='format' value='json' />
                <parameter name='httpMethod' value='PUT' />
                <parameter name="responsePrefix" value="honeycomb-vnf" />
                <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 tunnelxconn-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 tunnelxconn-allotted-resource" />
                    </return>
                </outcome>
            </execute>
            <set>
                <parameter name='tmp.tunnel-name' value="`$tmp.tunnel-vgMUX-vBRG-name` " />
                <parameter name='tmp.tunnel-dest-ip' value="`$tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vbrg-wan-ip` " />
                <parameter name='tmp.tunnel-src-ip' value="`$tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vgmux-lan-ip` " />
                <parameter name='tmp.tunnel-vni' value="`$tx-ar.allotted-resource-data.tunnelxconn-topology.tunnelxconn-assignments.vni` " />
            </set>
            <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                <parameter name="source" value="`$prop.restapi.vpp-honeycomb`"/>
                <parameter name="outputPath" value="tmp.vpp-honeycomb-url"/>
                <parameter name="target" value="{tunnel-name}"/>
                <parameter name="replacement" value="`$tmp.tunnel-name`"/>
            </execute>
            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.vpp.vxlan-tunnel.templatefile`" />
                <parameter name='restapiUrl' value='`$tmp.honeycomb.url + $tmp.vpp-honeycomb-url`' />
                <parameter name='restapiUser' value='`$prop.honeycomb.user`' />
                <parameter name='restapiPassword' value='`$prop.honeycomb.pwd`' />
                <parameter name='format' value='json' />
                <parameter name='httpMethod' value='PUT' />
                <parameter name="responsePrefix" value="honeycomb-vnf" />
                <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 tunnelxconn-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 tunnelxconn-allotted-resource" />
                    </return>
                </outcome>
            </execute>
            <set>
                <parameter name='tmp.tunnel-name' value="`$tmp.tunnel-vgMUX-vG-name` " />
            </set>
            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.vpp.xconnect.templatefile`" />
                <parameter name='restapiUrl' value="`$tmp.honeycomb.url + $tmp.vpp-honeycomb-url + '/v3po:l2' `" />
                <parameter name='restapiUser' value='`$prop.honeycomb.user`' />
                <parameter name='restapiPassword' value='`$prop.honeycomb.pwd`' />
                <parameter name='format' value='json' />
                <parameter name='httpMethod' value='PUT' />
                <parameter name="responsePrefix" value="honeycomb-vnf" />
                <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 tunnelxconn-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 tunnelxconn-allotted-resource" />
                    </return>
                </outcome>
            </execute>
            <set>
                <parameter name='tmp.tunnel-name' value="`$tmp.tunnel-vgMUX-vG-name` " />
            </set>
            <execute plugin='org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils' method='replace' >
                <parameter name="source" value="`$prop.restapi.vpp-honeycomb`"/>
                <parameter name="outputPath" value="tmp.vpp-honeycomb-url"/>
                <parameter name="target" value="{tunnel-name}"/>
                <parameter name="replacement" value="`$tmp.tunnel-name`"/>
            </execute>
            <set>
                <parameter name='tmp.tunnel-name' value="`$tmp.tunnel-vgMUX-vBRG-name` " />
            </set>
            <execute plugin='org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode' method='sendRequest' >
                <parameter name='templateFileName' value="`$prop.restapi.templateDir + '/' + $prop.restapi.vpp.xconnect.templatefile`" />
                <parameter name='restapiUrl' value="`$tmp.honeycomb.url + $tmp.vpp-honeycomb-url + '/v3po:l2' `" />
                <parameter name='restapiUser' value='`$prop.honeycomb.user`' />
                <parameter name='restapiPassword' value='`$prop.honeycomb.pwd`' />
                <parameter name='format' value='json' />
                <parameter name='httpMethod' value='PUT' />
                <parameter name="responsePrefix" value="honeycomb-vnf" />
                <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 tunnelxconn-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 tunnelxconn-allotted-resource" />
                    </return>
                </outcome>
            </execute>
            <set>
                <parameter name='allotted-resource-id' value='`$tmp.ar.allotted-resource-id`' />
                <parameter name='tunnelxconn-object-path' value="`$tmp.ar.self-link`"/>
                <parameter name='service-object-path' value="`'restconf/config/GENERIC-RESOURCE-API:services/service/' + $tunnelxconn-topology-operation-input.service-information.service-instance-id + '/service-data/service-topology/'`"/>
            </set>
            <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>