aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_process_placement_opt.py
blob: 01be17dabce7b492735f24d0be52ad0285d6753b (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
# -------------------------------------------------------------------------
#   Copyright (c) 2017-2018 AT&T Intellectual Property
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
# -------------------------------------------------------------------------
#
import mock
import unittest

from flask import Response
from mock import patch
from osdf.adapters.local_data import local_policies
from osdf.optimizers.placementopt.conductor.remote_opt_processor import process_placement_opt
from osdf.utils.interfaces import json_from_file, yaml_from_file


class TestProcessPlacementOpt(unittest.TestCase):

    def setUp(self):
        mock_req_accept_message = Response("Accepted Request", content_type='application/json; charset=utf-8')
        self.patcher_req = patch('osdf.optimizers.placementopt.conductor.conductor.request',
                                 return_value={"solutionInfo": {"placementInfo": "dummy"}})
        self.patcher_req_accept = patch('osdf.operation.responses.osdf_response_for_request_accept',
                                        return_value=mock_req_accept_message)
        self.patcher_callback = patch(
            'osdf.optimizers.placementopt.conductor.remote_opt_processor.process_placement_opt',
            return_value=mock_req_accept_message)
        self.patcher_RestClient = patch(
            'osdf.utils.interfaces.RestClient', return_value=mock.MagicMock())
        self.Mock_req = self.patcher_req.start()
        self.Mock_req_accept = self.patcher_req_accept.start()
        self.Mock_callback = self.patcher_callback.start()
        self.Mock_RestClient = self.patcher_RestClient.start()

    def tearDown(self):
        patch.stopall()

    def test_process_placement_opt(self):
        main_dir = ""
        conductor_api_template = main_dir + "osdf/templates/conductor_interface.json"
        parameter_data_file = main_dir + "test/placement-tests/request.json"
        policy_data_path = main_dir + "test/policy-local-files/"
        local_config_file = main_dir + "config/common_config.yaml"

        valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt'
        valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file)

        request_json = json_from_file(parameter_data_file)
        policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files]
        local_config = yaml_from_file(local_config_file)
        templ_string = process_placement_opt(request_json, policies, local_config, [])


if __name__ == "__main__":
    unittest.main()
c.Strong */ .highlight .gu { color: #75715e } /* Generic.Subheading */ .highlight .kc { color: #66d9ef } /* Keyword.Constant */ .highlight .kd { color: #66d9ef } /* Keyword.Declaration */ .highlight .kn { color: #f92672 } /* Keyword.Namespace */ .highlight .kp { color: #66d9ef } /* Keyword.Pseudo */ .highlight .kr { color: #66d9ef } /* Keyword.Reserved */ .highlight .kt { color: #66d9ef } /* Keyword.Type */ .highlight .ld { color: #e6db74 } /* Literal.Date */ .highlight .m { color: #ae81ff } /* Literal.Number */ .highlight .s { color: #e6db74 } /* Literal.String */ .highlight .na { color: #a6e22e } /* Name.Attribute */ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */ .highlight .nc { color: #a6e22e } /* Name.Class */ .highlight .no { color: #66d9ef } /* Name.Constant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
<?xml version="1.0" encoding="UTF-8"?>
<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="network-topology-operation-create" mode="sync">
        <block atomic="true">
            <call module="GENERIC-RESOURCE-API" rpc="validate-network-input-parameters" mode="sync" />
            <for index="idx" start="0" end="`$network-topology-operation-input.network-request-input.network-input-parameters.param_length`">
                <block>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'name'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.name" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'serviceType'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.service-type" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'topology'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.topology" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'technology'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.technology" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'site1_name'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.site1_name" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'site2_name'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.site2_name" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'sna1_name'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.sna1_name" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'sna2_name'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.sna2_name" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'pe1_id'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.pe1_id" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'pe2_id'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.pe2_id" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac1_id'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac1_id" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac2_id'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac2_id" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac1_ip'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac1_ip" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac2_ip'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac2_ip" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac1_peer_ip'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac1_peer_ip" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac2_peer_ip'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac2_peer_ip" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac1_svlan'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac1_svlan" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac2_svlan'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac2_svlan" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac1_protocol'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac1_protocol" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac2_protocol'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac2_protocol" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac1_route'`">
                        <outcome value="true">
                            <block atomic="true">
                                <set>
                                    <parameter name="prop.l3vpn.ac1_route" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                                </set>
                                <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils" method="split">
                                    <parameter name="original_string" value="`$prop.l3vpn.ac1_route`" />
                                    <parameter name="regex" value=" ## " />
                                    <parameter name="ctx_memory_result_key" value="route1" />
                                    <outcome value="success">
                                        <set>
                                            <parameter name="prop.l3vpn.sna1-route.ip-prefix" value="`$route1[0]`" />
                                            <parameter name="prop.l3vpn.sna1-route.next-hop" value="`$route1[1]`" />
                                        </set>
                                    </outcome>
                                    <outcome value="failure">
                                        <return status="failure">
                                            <parameter name="error-code" value="" />
                                            <parameter name="error-message" value="An error occured while splitting sna1_route" />
                                        </return>
                                    </outcome>
                                </execute>
                            </block>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac2_route'`">
                        <outcome value="true">
                            <block atomic="true">
                                <set>
                                    <parameter name="prop.l3vpn.ac2_route" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                                </set>
                                <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils" method="split">
                                    <parameter name="original_string" value="`$prop.l3vpn.ac2_route`" />
                                    <parameter name="regex" value=" ## " />
                                    <parameter name="ctx_memory_result_key" value="route2" />
                                    <outcome value="success">
                                        <set>
                                            <parameter name="prop.l3vpn.sna2-route.ip-prefix" value="`$route2[0]`" />
                                            <parameter name="prop.l3vpn.sna2-route.next-hop" value="`$route2[1]`" />
                                        </set>
                                    </outcome>
                                    <outcome value="failure">
                                        <return status="failure">
                                            <parameter name="error-code" value="" />
                                            <parameter name="error-message" value="An error occured while splitting sna1_route" />
                                        </return>
                                    </outcome>
                                </execute>
                            </block>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac1_protocol_bgp_as'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac1_protocol_bgp_as" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                                <parameter name="prop.l3vpn.peer1-ip" value="`$prop.l3vpn.ac1_ip`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'ac2_protocol_bgp_as'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.ac2_protocol_bgp_as" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                                <parameter name="prop.l3vpn.peer2-ip" value="`$prop.l3vpn.ac2_ip`" />
                            </set>
                        </outcome>
                    </switch>
                    <switch test="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].name == 'af_type'`">
                        <outcome value="true">
                            <set>
                                <parameter name="prop.l3vpn.af_type" value="`$network-topology-operation-input.network-request-input.network-input-parameters.param[$idx].value`" />
                            </set>
                        </outcome>
                    </switch>
                </block>
            </for>
            <get-resource plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" resource="pnf" key="pnf.pnf-name = $prop.l3vpn.pe1_id AND         depth = '0'" pfx="tmp.aai.pnf" local-only="false">
                <outcome value="success">
                    <set>
                        <parameter name="tmp.thirdparty-sdnc-id" value="`$tmp.aai.pnf.relationship-list.relationship[0].relationship-data[0].relationship-value`" />
                    </set>
                </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="`'An error occurred while querying pnf from AnAI with pnf-name = ' + $prop.l3vpn.pe1_id`" />
                    </return>
                </outcome>
                <outcome value="Other">
                    <return status="failure">
                        <parameter name="ack-final" value="Y" />
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="`'Unexpected error occurred while querying pnf from AnAI with pnf-name = ' + $prop.l3vpn.pe1_id`" />
                    </return>
                </outcome>
            </get-resource>
            <get-resource plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" resource="esr-thirdparty-sdnc" key="esr-thirdparty-sdnc.thirdparty-sdnc-id = $tmp.thirdparty-sdnc-id AND         depth = '1'" pfx="tmp.aai.esr-thirdparty-sdnc" local-only="false">
                <outcome value="success">
                    <set>
                        <parameter name="prop.sdncRestApi.thirdpartySdnc.url" value="`$tmp.aai.esr-thirdparty-sdnc.esr-system-info-list.esr-system-info[0].service-url`" />
                        <parameter name="prop.sdncRestApi.thirdpartySdnc.user" value="`$tmp.aai.esr-thirdparty-sdnc.esr-system-info-list.esr-system-info[0].user-name`" />
                        <parameter name="prop.sdncRestApi.thirdpartySdnc.password" value="`$tmp.aai.esr-thirdparty-sdnc.esr-system-info-list.esr-system-info[0].password`" />
                    </set>
                </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="`'An error occurred while querying esr-thirdparty-sdnc from AnAI with thirdparty-sdnc-id = ' + $tmp.thirdparty-sdnc-id`" />
                    </return>
                </outcome>
                <outcome value="Other">
                    <return status="failure">
                        <parameter name="ack-final" value="Y" />
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="`'Unexpected error occurred while querying esr-thirdparty-sdnc from AnAI with thirdparty-sdnc-id = ' + $tmp.thirdparty-sdnc-id`" />
                    </return>
                </outcome>
            </get-resource>
            <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils" method="generateUUID">
                <parameter name="ctx-destination" value="prop.l3vpn.vpn-policy1-id" />
                <outcome value="failure">
                    <return status="failure">
                        <parameter name="error-code" value="" />
                        <parameter name="error-message" value="An error occured while generation vpn policy ID" />
                    </return>
                </outcome>
            </execute>
            <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils" method="generateUUID">
                <parameter name="ctx-destination" value="prop.l3vpn.entry1-id" />
                <outcome value="failure">
                    <return status="failure">
                        <parameter name="error-code" value="" />
                        <parameter name="error-message" value="An error occured while generation vpn policy ID" />
                    </return>
                </outcome>
            </execute>
            <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils" method="generateUUID">
                <parameter name="ctx-destination" value="prop.l3vpn.vrf1-id" />
                <outcome value="failure">
                    <return status="failure">
                        <parameter name="error-code" value="" />
                        <parameter name="error-message" value="An error occured while generation vpn policy ID" />
                    </return>
                </outcome>
            </execute>
            <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils" method="generateUUID">
                <parameter name="ctx-destination" value="prop.l3vpn.vrf2-id" />
                <outcome value="failure">
                    <return status="failure">
                        <parameter name="error-code" value="" />
                        <parameter name="error-message" value="An error occured while generation vpn policy ID" />
                    </return>
                </outcome>
            </execute>
            <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils" method="generateUUID">
                <parameter name="ctx-destination" value="prop.l3vpn.network-id" />
            </execute>
            <switch test="`$service-data.networks.network_length`">
                <outcome value="">
                    <set>
                        <parameter name="nidx" value="0" />
                    </set>
                </outcome>
                <outcome value="Other">
                    <set>
                        <parameter name="nidx" value="`$service-data.networks.network_length`" />
                    </set>
                </outcome>
            </switch>
            <record plugin="org.onap.ccsdk.sli.core.sli.recording.FileRecorder">
                <parameter name="file" value="/opt/opendaylight/current/data/log/svclogic.log" />
                <parameter name="field1" value="__TIMESTAMP__" />
                <parameter name="field2" value="network-topology-operation-create" />
                <parameter name="field3" value="L3VPN-Config" />
                <parameter name="field4" value="`l3vpn.name`" />
                <parameter name="field5" value="`$prop.l3vpn.name`" />
                <parameter name="field6" value="`l3vpn.topology`" />
                <parameter name="field7" value="`$prop.l3vpn.topology`" />
                <parameter name="field8" value="`l3vpn.site1_name`" />
                <parameter name="field9" value="`$prop.l3vpn.site1_name`" />
                <parameter name="field10" value="`l3vpn.vpn-policy1-id`" />
                <parameter name="field11" value="`$prop.l3vpn.vpn-policy1-id`" />
                <parameter name="field12" value="`l3vpn.entry1-id`" />
                <parameter name="field13" value="`$prop.l3vpn.entry1-id`" />
                <parameter name="field14" value="`l3vpn.sna1_name`" />
                <parameter name="field15" value="`$prop.l3vpn.sna1_name`" />
                <parameter name="field16" value="`l3vpn.pe1_id`" />
                <parameter name="field17" value="`$prop.l3vpn.pe1_id`" />
                <parameter name="field18" value="`l3vpn.ac1_id`" />
                <parameter name="field19" value="`$prop.l3vpn.ac1_id`" />
                <parameter name="field20" value="`l3vpn.ac1_svlan`" />
                <parameter name="field21" value="`$prop.l3vpn.ac1_svlan`" />
                <parameter name="field22" value="`l3vpn.ac1_peer_ip`" />
                <parameter name="field23" value="`$prop.l3vpn.ac1_peer_ip`" />
                <parameter name="field24" value="`l3vpn.ac1_ip`" />
                <parameter name="field25" value="`$prop.l3vpn.ac1_ip`" />
                <parameter name="field26" value="`l3vpn.ac1_protocol`" />
                <parameter name="field27" value="`$prop.l3vpn.ac1_protocol`" />
                <parameter name="field28" value="`l3vpn.sna1-route-ip-prefix`" />
                <parameter name="field29" value="`$prop.l3vpn.sna1-route-ip-prefix`" />
                <parameter name="field30" value="`l3vpn.sna1-route-next-hop`" />
                <parameter name="field31" value="`$prop.l3vpn.sna1-route-next-hop`" />
                <parameter name="field32" value="`l3vpn.peer1_ip`" />
                <parameter name="field33" value="`$prop.l3vpn.peer1_ip`" />
                <parameter name="field34" value="`l3vpn.ac1_protocol_bgp_as`" />
                <parameter name="field35" value="`$prop.l3vpn.ac1_protocol_bgp_as`" />
                <parameter name="field36" value="`l3vpn.vrf1-id`" />
                <parameter name="field37" value="`$prop.l3vpn.vrf1-id`" />
                <parameter name="field38" value="`l3vpn.site2_name`" />
                <parameter name="field39" value="`$prop.l3vpn.site2_name`" />
                <parameter name="field40" value="`l3vpn.vpn-policy2-id`" />
                <parameter name="field41" value="`$prop.l3vpn.vpn-policy2-id`" />
                <parameter name="field42" value="`l3vpn.entry2-id`" />
                <parameter name="field43" value="`$prop.l3vpn.entry2-id`" />
                <parameter name="field44" value="`l3vpn.sna2_name`" />
                <parameter name="field45" value="`$prop.l3vpn.sna2_name`" />
                <parameter name="field46" value="`l3vpn.pe2_id`" />
                <parameter name="field47" value="`$prop.l3vpn.pe2_id`" />
                <parameter name="field48" value="`l3vpn.ac2_id`" />
                <parameter name="field49" value="`$prop.l3vpn.ac2_id`" />
                <parameter name="field50" value="`l3vpn.ac2_svlan`" />
                <parameter name="field51" value="`$prop.l3vpn.ac2_svlan`" />
                <parameter name="field52" value="`l3vpn.ac2_peer_ip`" />
                <parameter name="field53" value="`$prop.l3vpn.ac2_peer_ip`" />
                <parameter name="field54" value="`l3vpn.ac2_ip`" />
                <parameter name="field55" value="`$prop.l3vpn.ac2_ip`" />
                <parameter name="field56" value="`l3vpn.ac2_protocol`" />
                <parameter name="field57" value="`$prop.l3vpn.ac2_protocol`" />
                <parameter name="field58" value="`l3vpn.sna2-route-ip-prefix`" />
                <parameter name="field59" value="`$prop.l3vpn.sna2-route-ip-prefix`" />
                <parameter name="field60" value="`l3vpn.sna2-route-next-hop`" />
                <parameter name="field61" value="`$prop.l3vpn.sna2-route-next-hop`" />
                <parameter name="field62" value="`l3vpn.peer2_ip`" />
                <parameter name="field63" value="`$prop.l3vpn.peer2_ip`" />
                <parameter name="field64" value="`l3vpn.ac2_protocol_bgp_as`" />
                <parameter name="field65" value="`$prop.l3vpn.ac2_protocol_bgp_as`" />
                <parameter name="field66" value="`l3vpn.vrf2-id`" />
                <parameter name="field67" value="`$prop.l3vpn.vrf2-id`" />
                <parameter name="field68" value="`l3vpn.af_type`" />
                <parameter name="field69" value="`$prop.l3vpn.af_type`" />
            </record>
            <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>
            <switch test="`$prop.l3vpn.service-type`">
                <outcome value="l3vpn-ipwan">
                    <block atomic="true">
                        <execute plugin="org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode" method="sendRequest">
                            <parameter name="templateFileName" value="`$prop.restapi.templateDir + '/actokentemplate.json'`" />
                            <parameter name="restapiUrl" value="`$prop.sdncRestApi.thirdpartySdnc.url + '/controller/v2/tokens'`" />
                            <parameter name="format" value="json" />
                            <parameter name="httpMethod" value="post" />
                            <parameter name="responsePrefix" value="token-result" />
                            <parameter name="trustStoreFileName" value="/opt/onap/sdnc/data/stores/truststore.openecomp.client.jks" />
                            <parameter name="trustStorePassword" value="adminadmin" />
                            <parameter name="keyStoreFileName" value="/opt/onap/sdnc/data/stores/sdnc.p12" />
                            <parameter name="keyStorePassword" value="adminadmin" />
                            <outcome value="success">
                                <set>
                                    <parameter name="prop.sdncRestApi.token_id" value="`$token-result.data.token_id`" />
                                </set>
                            </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 executing get token rest api" />
                                </return>
                            </outcome>
                        </execute>
                        <execute plugin="org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode" method="sendRequest">
                            <parameter name="templateFileName" value="`$prop.restapi.templateDir + '/l3smvpntemplate.json'`" />
                            <parameter name="restapiUrl" value="`$prop.sdncRestApi.thirdpartySdnc.url + '/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/vpn-services'`" />
                            <parameter name="restapiUser" value="`$prop.sdncRestApi.thirdpartySdnc.user`" />
                            <parameter name="restapiPassword" value="`$prop.sdncRestApi.thirdpartySdnc.password`" />
                            <parameter name="format" value="json" />
                            <parameter name="httpMethod" value="post" />
                            <parameter name="responsePrefix" value="vpn-result" />
                            <parameter name="trustStoreFileName" value="/opt/onap/sdnc/data/stores/truststore.openecomp.client.jks" />
                            <parameter name="trustStorePassword" value="adminadmin" />
                            <parameter name="keyStoreFileName" value="/opt/onap/sdnc/data/stores/sdnc.p12" />
                            <parameter name="keyStorePassword" value="adminadmin" />
                            <parameter name="customHttpHeaders" value="`'X-ACCESS-TOKEN=' + $prop.sdncRestApi.token_id`" />
                            <outcome value="failure">
                                <return status="failure">
                                    <parameter name="ack-final" value="Y" />
                                    <parameter name="error-code" value="500" />
                                    <parameter name="error-message" value="Error executing Create vpn rest api" />
                                </return>
                            </outcome>
                            <outcome value="success">
                                <block atomic="true" />
                            </outcome>
                        </execute>
                        <execute plugin="org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode" method="sendRequest">
                            <parameter name="templateFileName" value="`$prop.restapi.templateDir +'/l3smvrftemplate.json'`" />
                            <parameter name="restapiUrl" value="`$prop.sdncRestApi.thirdpartySdnc.url +'/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/huawei-ac-net-l3vpn-svc-vfi:vrf-attributes'`" />
                            <parameter name="restapiUser" value="`$prop.sdncRestApi.thirdpartySdnc.user`" />
                            <parameter name="restapiPassword" value="`$prop.sdncRestApi.thirdpartySdnc.password`" />
                            <parameter name="format" value="json" />
                            <parameter name="httpMethod" value="put" />
                            <parameter name="responsePrefix" value="vrf-result" />
                            <parameter name="trustStoreFileName" value="/opt/onap/sdnc/data/stores/truststore.openecomp.client.jks" />
                            <parameter name="trustStorePassword" value="adminadmin" />
                            <parameter name="keyStoreFileName" value="/opt/onap/sdnc/data/stores/sdnc.p12" />
                            <parameter name="keyStorePassword" value="adminadmin" />
                            <parameter name="customHttpHeaders" value="`'X-ACCESS-TOKEN=' + $prop.sdncRestApi.token_id`" />
                            <outcome value="success">
                                <block atomic="true" />
                            </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 executing Create vrf rest api" />
                                </return>
                            </outcome>
                        </execute>
                        <execute plugin="org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode" method="sendRequest">
                            <parameter name="templateFileName" value="`$prop.restapi.templateDir +'/l3smsitetemplate.json'`" />
                            <parameter name="restapiUrl" value="`$prop.sdncRestApi.thirdpartySdnc.url +'/restconf/data/huawei-ac-net-l3vpn-svc:l3vpn-svc-cfg/sites'`" />
                            <parameter name="restapiUser" value="`$prop.sdncRestApi.thirdpartySdnc.user`" />
                            <parameter name="restapiPassword" value="`$prop.sdncRestApi.thirdpartySdnc.password`" />
                            <parameter name="format" value="json" />
                            <parameter name="httpMethod" value="post" />
                            <parameter name="responsePrefix" value="site-result" />
                            <parameter name="trustStoreFileName" value="/opt/onap/sdnc/data/stores/truststore.openecomp.client.jks" />
                            <parameter name="trustStorePassword" value="adminadmin" />
                            <parameter name="keyStoreFileName" value="/opt/onap/sdnc/data/stores/sdnc.p12" />
                            <parameter name="keyStorePassword" value="adminadmin" />
                            <parameter name="customHttpHeaders" value="`'X-ACCESS-TOKEN=' + $prop.sdncRestApi.token_id`" />
                            <outcome value="success">
                                <block atomic="true" />
                            </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 executing Create site rest api" />
                                </return>
                            </outcome>
                        </execute>
                    </block>
                </outcome>
                <outcome value="l3vpn-sptn">
                    <execute plugin="org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode" method="sendRequest">
                        <parameter name="templateFileName" value="`$prop.restapi.templateDir +'/sptn-l3vpn-template.xml'`" />
                        <parameter name="restapiUrl" value="`$prop.sdncRestApi.thirdpartySdnc.url + '/restconf/data/sptn-service-l3vpn:service/snc-l3vpns'`" />
                        <parameter name="restapiUser" value="`$prop.sdncRestApi.thirdpartySdnc.user`" />
                        <parameter name="restapiPassword" value="`$prop.sdncRestApi.thirdpartySdnc.password`" />
                        <parameter name="format" value="xml" />
                        <parameter name="httpMethod" value="post" />
                        <parameter name="responsePrefix" value="restapi-result" />
                    </execute>
                </outcome>
                <outcome value="Other">
                    <return status="failure">
                        <parameter name="ack-final" value="Y" />
                        <parameter name="error-code" value="500" />
                        <parameter name="error-message" value="Unexpected error retrieving vpn binding" />
                    </return>
                </outcome>
            </switch>
            <set>
                <parameter name="service-data.networks.network[$nidx].network-id" value="`$prop.l3vpn.network-id`" />
                <parameter name="service-data.networks.network[$nidx].network-data.sdnc-request-header." value="`$network-topology-operation-input.sdnc-request-header.`" />
                <parameter name="service-data.networks.network[$nidx].network-data.request-information." value="`$network-topology-operation-input.request-information.`" />
                <parameter name="service-data.networks.network[$nidx].network-data.service-information." value="`$network-topology-operation-input.service-information.`" />
                <parameter name="service-data.networks.network[$nidx].network-data.network-information." value="`$network-topology-operation-input.network-information.`" />
                <parameter name="service-data.networks.network[$nidx].network-data.network-request-input." value="`$network-topology-operation-input.network-request-input.`" />
                <parameter name="service-data.networks.network_length" value="`$nidx+1`" />
            </set>
            <set>
                <parameter name="networkId" value="`$prop.l3vpn.network-id`" />
                <parameter name="network-object-path" value="`'restconf/config/GENERIC-RESOURCE-API:services/service/'  + $network-topology-operation-input.service-information.service-instance-id  + '/service-data/networks/network/'  + $prop.l3vpn.network-id  + '/network-data/'` " />
            </set>
            <set>
                <parameter name="service-data.networks.network[$nidx].network-data.network-level-oper-status.order-status" value="Created" />
                <parameter name="service-data.networks.network[$nidx].network-data.network-level-oper-status.last-rpc-action" value="`$network-topology-operation-input.sdnc-request-header.svc-action`" />
                <parameter name="service-data.networks.network[$nidx].network-data.network-level-oper-status.last-action" value="`$network-topology-operation-input.request-information.request-action`" />
            </set>
            <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" resource="configuration" key="configuration.configuration-id = $prop.l3vpn.network-id">
                <parameter name="configuration-id" value="`$prop.l3vpn.network-id`" />
                <parameter name="configuration-type" value="underlay" />
                <parameter name="configuration-sub-type" value="l3vpn" />
                <parameter name="orchestration-status" value="Created" />
                <parameter name="operational-status" value="Created" />
                <parameter name="model-customization-id" value="`$prop.l3vpn.network-id`" />
                <parameter name="configuration-selflink" value="`'restconf/config/GENERIC-RESOURCE-API:services/service/'  + $network-topology-operation-input.service-information.service-instance-id  + '/service-data/networks/network/'  + $prop.l3vpn.network-id  + '/network-data/'` " />
            </save>
            <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" resource="service-instance:relationship-list" key="service-instance.service-instance-id = $service-data.service-information.service-instance-id           AND customer.global-customer-id = $service-data.networks.network[$nidx].network-data.service-information.global-customer-id           AND service-subscription.service-type = $service-data.networks.network[$nidx].network-data.service-information.subscription-service-type" force="true" pfx="tmp.AnAI-data">
                <parameter name="relationship-list.relationship[0].related-to" value="configuration" />
                <parameter name="relationship-list.relationship[0].related-link" value="`'/network/configurations/configuration/' + $prop.l3vpn.network-id`" />
                <parameter name="relationship-list.relationship[0].relationship-data[0].relationship-key" value="configuration.configuration-id" />
                <parameter name="relationship-list.relationship[0].relationship-data[0].relationship-value" value="`$prop.l3vpn.network-id`" />
            </save>
            <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>