summaryrefslogtreecommitdiffstats
path: root/sample-apps/src/main/java/org/onap/integration/actninterfacetools/sampleapp/mpiconverter/OssExcuter.java
blob: 1d19526563026c826fbd133728194a3006ff0061 (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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/*
 *   ============LICENSE_START=======================================================
 *   Actn Interface Tools
 *   ================================================================================
 *   Copyright (C) 2023 Huawei Canada Limited.
 *   ================================================================================
 *   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.
 *   ============LICENSE_END=========================================================
 */
package org.onap.integration.actninterfacetools.sampleapp.mpiconverter;

import com.google.common.net.InetAddresses;
import org.onap.integration.actninterfacetools.globalapi.ActnDataConverter;
import org.onap.integration.actninterfacetools.globalapi.CustomerOtnTopology;
import org.onap.integration.actninterfacetools.globalapi.CustomerOtnTunnel;
import org.onap.integration.actninterfacetools.globalapi.PncClient;
import org.onap.integration.actninterfacetools.globalapi.GlobalService;
import org.onap.integration.actninterfacetools.globalapi.ActnClientService;
import org.onap.integration.actninterfacetools.globalapi.CustomerEthService;
import org.onap.integration.actninterfacetools.protocol.restconf.DefaultPncInstance;
import org.onap.integration.actninterfacetools.protocol.restconf.PncInstance;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.converter.PncConverter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.LTPoint;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.LtpId;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.TeNodeKey;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.TsLink;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.OduResource;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.TsTunnel;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.EthSrvInstance;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.EthSrvAccessPoint;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.EthSrvEndPoint;
import org.onap.integration.actninterfacetools.sampleapp.mpiconverter.model.TsEthSrv;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OssExcuter {
    private static final Logger log = LoggerFactory.getLogger(OssExcuter.class);
    public static void main(String[] args) throws Exception {
        PncInstance pncInstanceA = new DefaultPncInstance(InetAddresses.forString("192.168.198.10"), 18181, null, null, "http", null);
        PncInstance pncInstanceB = new DefaultPncInstance(InetAddresses.forString("192.168.198.10"), 28181, null, null, "http", null);
        ActnDataConverter actnDataConverter = new PncConverter();
        ActnClientService actnClientService = GlobalService.getActnClientSvc(actnDataConverter);
        PncClient pncClientA = actnClientService.getPncClient(pncInstanceA);
        PncClient pncClientB = actnClientService.getPncClient(pncInstanceB);
        testGetOtnTopology(pncClientA, pncClientB);
    }

    public static void testGetOtnTopology(PncClient pncClientA, PncClient pncClientB) throws Exception {
        CustomerOtnTopology customerOtnTopology = pncClientA.getNetworkTopology("providerId-10-clientId-0-topologyId-1");
        log.info("pncA: " + customerOtnTopology.toString());
        CustomerOtnTopology customerOtnTopologyB = pncClientB.getNetworkTopology("providerId-20-clientId-0-topologyId-1");
        log.info("pncB: " + customerOtnTopologyB.toString());
    }

    public static void testGetOtnTunnel(PncClient pncClientA, PncClient pncClientB) throws Exception {
        CustomerOtnTunnel otnTunnel = pncClientA.getOtnTunnel("otntunnel-1");
        log.info("pncA: " + otnTunnel.toString());
        CustomerOtnTunnel otnTunnelB = pncClientB.getOtnTunnel("otntunnel-1");
        log.info("pncB: " + otnTunnelB.toString());
    }

    public static void testCreateOtnTunnel(PncClient pncClientA, PncClient pncClientB) throws Exception {
        CustomerOtnTunnel customerOtnTunnel = buildTeOtnTunnel("otntunnel-1");
        pncClientA.createOtnTunnel(customerOtnTunnel);
        CustomerOtnTunnel customerOtnTunnelB = buildTeOtnTunnel2("otntunnel-1");
        pncClientB.createOtnTunnel(customerOtnTunnelB);
    }

    public static void testDeleteOtnTunnel(PncClient pncClientA, PncClient pncClientB) throws Exception {
        pncClientA.deleteOtnTunnel("otntunnel-1");
        pncClientB.deleteOtnTunnel("otntunnel-1");
    }

    public static void testUpdateOtnTunnel(PncClient pncClientA, PncClient pncClientB) throws Exception {
        CustomerOtnTunnel customerOtnTunnel = updateTeOtnTunnel("otntunnel-1");
        pncClientA.updateOtnTunnel(customerOtnTunnel, "otntunnel-1");
        CustomerOtnTunnel customerOtnTunnelB = updateTeOtnTunnel2("otntunnel-1");
        pncClientB.updateOtnTunnel(customerOtnTunnelB, "otntunnel-1");
    }

    public static void testGetEthSvc(PncClient pncClientA, PncClient pncClientB) throws Exception {
        CustomerEthService ethService = pncClientA.getEthService("cll-instance-01");
        log.info("pncA: " + ethService.toString());
        CustomerEthService ethServiceB = pncClientB.getEthService("cll-instance-01");
        log.info("pncB: " + ethServiceB.toString());
    }

    public static void testCreateEthSvc(PncClient pncClientA, PncClient pncClientB) throws Exception {
        CustomerEthService customerEthService = buildTeEthSrv("cll-instance-01");
        pncClientA.createEthService(customerEthService);
        CustomerEthService customerEthServiceB = buildTeEthSrv2("cll-instance-01");
        pncClientB.createEthService(customerEthServiceB);
    }

    public static void testDeleteEthSvc(PncClient pncClientA, PncClient pncClientB) throws Exception {
        pncClientA.deleteEthService("cll-instance-01");
        pncClientB.deleteEthService("cll-instance-01");
    }

    public static void testUpdateEthSvc(PncClient pncClientA, PncClient pncClientB) throws Exception {
        CustomerEthService customerEthService = updateTeEthSrv("cll-instance-01");
        pncClientA.updateEthService(customerEthService);
        CustomerEthService customerEthServiceB = updateTeEthSrv2("cll-instance-01");
        pncClientB.updateEthService(customerEthServiceB);
    }

    public static CustomerOtnTunnel buildTeOtnTunnel(String tunnelName) {
        TeNodeKey src = new TeNodeKey(10, 1, 1, 1);
        TeNodeKey dst = new TeNodeKey(10, 1, 1, 2);
        LtpId dstLtpId = LtpId.ltpId(0, "MTI=");
        LTPoint srcLTPoint = new LTPoint(src, null);
        LTPoint dstLTPoint = new LTPoint(dst, dstLtpId);
        List<TsLink> tsLinkList = new ArrayList<>();
        TsLink tsLink = new TsLink(srcLTPoint, dstLTPoint);
        tsLinkList.add(tsLink);
        OduResource oduResource = new OduResource((short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 3, null, null);
        CustomerOtnTunnel customerOtnTunnel = new TsTunnel(tsLinkList, tunnelName);
        ((TsTunnel) customerOtnTunnel).bw(oduResource);
        return customerOtnTunnel;
    }

    public static CustomerOtnTunnel buildTeOtnTunnel2(String tunnelName) {
        TeNodeKey src = new TeNodeKey(10, 2, 1, 1);
        TeNodeKey dst = new TeNodeKey(10, 2, 1, 2);
        LtpId dstLtpId = LtpId.ltpId(0, "MJI=");
        LTPoint srcLTPoint = new LTPoint(src, null);
        LTPoint dstLTPoint = new LTPoint(dst, dstLtpId);
        List<TsLink> tsLinkList = new ArrayList<>();
        TsLink tsLink = new TsLink(srcLTPoint, dstLTPoint);
        tsLinkList.add(tsLink);
        OduResource oduResource = new OduResource((short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 3, null, null);
        CustomerOtnTunnel customerOtnTunnel = new TsTunnel(tsLinkList, tunnelName);
        ((TsTunnel) customerOtnTunnel).bw(oduResource);
        return customerOtnTunnel;
    }

    public static CustomerEthService buildTeEthSrv(String serviceName) {
        List<EthSrvInstance> ethSrvInstances = new ArrayList<>();
        List<TsTunnel> tsTunnelList = new ArrayList<>();
        TeNodeKey src = new TeNodeKey(-1, -1, -1, -1);
        TeNodeKey dst = new TeNodeKey(-1, -1, -1, -1);
        LtpId dstLtpId = LtpId.ltpId(0, "");
        LTPoint srcLTPoint = new LTPoint(src, null);
        LTPoint dstLTPoint = new LTPoint(dst, dstLtpId);
        List<TsLink> tsLinkList = new ArrayList<>();
        TsLink tsLink = new TsLink(srcLTPoint, dstLTPoint);
        tsLinkList.add(tsLink);
        TsTunnel tsTunnela = new TsTunnel(tsLinkList, "otntunnel-2");
        TsTunnel tsTunnelb = new TsTunnel(tsLinkList, "otntunnel-1");
        tsTunnelList.add(tsTunnela);
        tsTunnelList.add(tsTunnelb);
        List<EthSrvEndPoint> ethSrvEndPoints = new ArrayList<>();
        List<EthSrvAccessPoint> ethSrvAccessPointsA = new ArrayList<>();
        ethSrvAccessPointsA.add(new EthSrvAccessPoint("0", "10.1.1.1", 1000001));
        EthSrvEndPoint ethSrvEndPointA = new EthSrvEndPoint("uni-01", ethSrvAccessPointsA, 47, BigInteger.valueOf(3000000), BigInteger.valueOf(3000000));
        List<EthSrvAccessPoint> ethSrvAccessPointsB = new ArrayList<>();
        ethSrvAccessPointsB.add(new EthSrvAccessPoint("0", "10.1.1.1", 2000001));
        EthSrvEndPoint ethSrvEndPointB = new EthSrvEndPoint("uni-02", ethSrvAccessPointsB, 48, BigInteger.valueOf(3000000), BigInteger.valueOf(3000000));
        List<EthSrvAccessPoint> ethSrvAccessPointsC = new ArrayList<>();
        ethSrvAccessPointsC.add(new EthSrvAccessPoint("0", "10.1.1.3", 1000001));
        EthSrvEndPoint ethSrvEndPointC = new EthSrvEndPoint("uni-03", ethSrvAccessPointsC, 49, BigInteger.valueOf(3000000), BigInteger.valueOf(3000000));
        ethSrvEndPoints.add(ethSrvEndPointA);
        ethSrvEndPoints.add(ethSrvEndPointB);
        ethSrvEndPoints.add(ethSrvEndPointC);
        EthSrvInstance ethSrvInstance = new EthSrvInstance(serviceName, "desc-Eth-service", 10, 0, "2", tsTunnelList, ethSrvEndPoints);
        ethSrvInstances.add(ethSrvInstance);
        CustomerEthService customerEthService = new TsEthSrv(ethSrvInstances);
        return customerEthService;
    }

    public static CustomerEthService buildTeEthSrv2(String serviceName) {
        List<EthSrvInstance> ethSrvInstances = new ArrayList<>();
        List<TsTunnel> tsTunnelList = new ArrayList<>();
        TeNodeKey src = new TeNodeKey(-1, -1, -1, -1);
        TeNodeKey dst = new TeNodeKey(-1, -1, -1, -1);
        LtpId dstLtpId = LtpId.ltpId(0, "");
        LTPoint srcLTPoint = new LTPoint(src, null);
        LTPoint dstLTPoint = new LTPoint(dst, dstLtpId);
        List<TsLink> tsLinkList = new ArrayList<>();
        TsLink tsLink = new TsLink(srcLTPoint, dstLTPoint);
        tsLinkList.add(tsLink);
        TsTunnel tsTunnela = new TsTunnel(tsLinkList, "otntunnel-2");
        TsTunnel tsTunnelb = new TsTunnel(tsLinkList, "otntunnel-1");
        tsTunnelList.add(tsTunnela);
        tsTunnelList.add(tsTunnelb);
        List<EthSrvEndPoint> ethSrvEndPoints = new ArrayList<>();
        List<EthSrvAccessPoint> ethSrvAccessPointsA = new ArrayList<>();
        ethSrvAccessPointsA.add(new EthSrvAccessPoint("0", "10.2.1.2", 512));
        EthSrvEndPoint ethSrvEndPointA = new EthSrvEndPoint("uni-04", ethSrvAccessPointsA, 47, BigInteger.valueOf(3000000), BigInteger.valueOf(3000000));
        ethSrvEndPoints.add(ethSrvEndPointA);
        EthSrvInstance ethSrvInstance = new EthSrvInstance(serviceName, "desc-Eth-service", 20, 0, "2", tsTunnelList, ethSrvEndPoints);
        ethSrvInstances.add(ethSrvInstance);
        CustomerEthService customerEthService = new TsEthSrv(ethSrvInstances);
        return customerEthService;
    }
    public static CustomerOtnTunnel updateTeOtnTunnel(String tunnelName) {
        TeNodeKey src = new TeNodeKey(10, 1, 1, 1);
        TeNodeKey dst = new TeNodeKey(10, 1, 1, 2);
        LtpId dstLtpId = LtpId.ltpId(0, "12");
        LTPoint srcLTPoint = new LTPoint(src, null);
        LTPoint dstLTPoint = new LTPoint(dst, dstLtpId);
        List<TsLink> tsLinkList = new ArrayList<>();
        TsLink tsLink = new TsLink(srcLTPoint, dstLTPoint);
        tsLinkList.add(tsLink);
        OduResource oduResource = new OduResource((short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 4, null, null);
        CustomerOtnTunnel customerOtnTunnel = new TsTunnel(tsLinkList, tunnelName);
        ((TsTunnel) customerOtnTunnel).bw(oduResource);
        return customerOtnTunnel;
    }

    public static CustomerOtnTunnel updateTeOtnTunnel2(String tunnelName) {
        TeNodeKey src = new TeNodeKey(10, 2, 1, 1);
        TeNodeKey dst = new TeNodeKey(10, 2, 1, 2);
        LtpId dstLtpId = LtpId.ltpId(0, "13");
        LTPoint srcLTPoint = new LTPoint(src, null);
        LTPoint dstLTPoint = new LTPoint(dst, dstLtpId);
        List<TsLink> tsLinkList = new ArrayList<>();
        TsLink tsLink = new TsLink(srcLTPoint, dstLTPoint);
        tsLinkList.add(tsLink);
        OduResource oduResource = new OduResource((short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 4, null, null);
        CustomerOtnTunnel customerOtnTunnel = new TsTunnel(tsLinkList, tunnelName);
        ((TsTunnel) customerOtnTunnel).bw(oduResource);
        return customerOtnTunnel;
    }

    public static CustomerEthService updateTeEthSrv(String serviceName) {
        List<EthSrvInstance> ethSrvInstances = new ArrayList<>();
        List<TsTunnel> tsTunnelList = new ArrayList<>();
        TeNodeKey src = new TeNodeKey(-1, -1, -1, -1);
        TeNodeKey dst = new TeNodeKey(-1, -1, -1, -1);
        LtpId dstLtpId = LtpId.ltpId(0, "");
        LTPoint srcLTPoint = new LTPoint(src, null);
        LTPoint dstLTPoint = new LTPoint(dst, dstLtpId);
        List<TsLink> tsLinkList = new ArrayList<>();
        TsLink tsLink = new TsLink(srcLTPoint, dstLTPoint);
        tsLinkList.add(tsLink);
        TsTunnel tsTunnela = new TsTunnel(tsLinkList, "otntunnel-2");
        TsTunnel tsTunnelb = new TsTunnel(tsLinkList, "otntunnel-1");
        tsTunnelList.add(tsTunnela);
        tsTunnelList.add(tsTunnelb);
        List<EthSrvEndPoint> ethSrvEndPoints = new ArrayList<>();
        List<EthSrvAccessPoint> ethSrvAccessPointsA = new ArrayList<>();
        ethSrvAccessPointsA.add(new EthSrvAccessPoint("0", "10.1.1.1", 1000001));
        EthSrvEndPoint ethSrvEndPointA = new EthSrvEndPoint("uni-01", ethSrvAccessPointsA, 47, BigInteger.valueOf(3000000), BigInteger.valueOf(3000000));
        List<EthSrvAccessPoint> ethSrvAccessPointsB = new ArrayList<>();
        ethSrvAccessPointsB.add(new EthSrvAccessPoint("0", "10.1.1.1", 2000001));
        EthSrvEndPoint ethSrvEndPointB = new EthSrvEndPoint("uni-02", ethSrvAccessPointsB, 48, BigInteger.valueOf(3000000), BigInteger.valueOf(3000000));
        List<EthSrvAccessPoint> ethSrvAccessPointsC = new ArrayList<>();
        ethSrvAccessPointsC.add(new EthSrvAccessPoint("0", "10.1.1.3", 1000001));
        EthSrvEndPoint ethSrvEndPointC = new EthSrvEndPoint("uni-03", ethSrvAccessPointsC, 49, BigInteger.valueOf(3000000), BigInteger.valueOf(3000000));
        List<EthSrvAccessPoint> ethSrvAccessPointsD = new ArrayList<>();
        ethSrvAccessPointsD.add(new EthSrvAccessPoint("0", "10.1.1.4", 1000001));
        EthSrvEndPoint ethSrvEndPointD = new EthSrvEndPoint("uni-04", ethSrvAccessPointsC, 50, BigInteger.valueOf(3000000), BigInteger.valueOf(3000000));
        ethSrvEndPoints.add(ethSrvEndPointA);
        ethSrvEndPoints.add(ethSrvEndPointB);
        ethSrvEndPoints.add(ethSrvEndPointC);
        ethSrvEndPoints.add(ethSrvEndPointD);
        EthSrvInstance ethSrvInstance = new EthSrvInstance(serviceName, "desc-Eth-service", 10, 0, "2", tsTunnelList, ethSrvEndPoints);
        ethSrvInstances.add(ethSrvInstance);
        CustomerEthService customerEthService = new TsEthSrv(ethSrvInstances);
        return customerEthService;
    }

    public static CustomerEthService updateTeEthSrv2(String serviceName) {
        List<EthSrvInstance> ethSrvInstances = new ArrayList<>();
        List<TsTunnel> tsTunnelList = new ArrayList<>();
        TeNodeKey src = new TeNodeKey(-1, -1, -1, -1);
        TeNodeKey dst = new TeNodeKey(-1, -1, -1, -1);
        LtpId dstLtpId = LtpId.ltpId(0, "");
        LTPoint srcLTPoint = new LTPoint(src, null);
        LTPoint dstLTPoint = new LTPoint(dst, dstLtpId);
        List<TsLink> tsLinkList = new ArrayList<>();
        TsLink tsLink = new TsLink(srcLTPoint, dstLTPoint);
        tsLinkList.add(tsLink);
        TsTunnel tsTunnela = new TsTunnel(tsLinkList, "otntunnel-2");
        TsTunnel tsTunnelb = new TsTunnel(tsLinkList, "otntunnel-1");
        tsTunnelList.add(tsTunnela);
        tsTunnelList.add(tsTunnelb);
        List<EthSrvEndPoint> ethSrvEndPoints = new ArrayList<>();
        List<EthSrvAccessPoint> ethSrvAccessPointsA = new ArrayList<>();
        List<EthSrvAccessPoint> ethSrvAccessPointsC = new ArrayList<>();
        ethSrvAccessPointsA.add(new EthSrvAccessPoint("0", "10.2.1.2", 512));
        EthSrvEndPoint ethSrvEndPointA = new EthSrvEndPoint("uni-04", ethSrvAccessPointsA, 47, BigInteger.valueOf(3000000), BigInteger.valueOf(3000000));
        ethSrvAccessPointsC.add(new EthSrvAccessPoint("0", "10.2.1.3", 1000001));
        EthSrvEndPoint ethSrvEndPointC = new EthSrvEndPoint("uni-03", ethSrvAccessPointsC, 49, BigInteger.valueOf(3000000), BigInteger.valueOf(3000000));
        ethSrvEndPoints.add(ethSrvEndPointA);
        ethSrvEndPoints.add(ethSrvEndPointC);
        EthSrvInstance ethSrvInstance = new EthSrvInstance(serviceName, "desc-Eth-service", 10, 0, "2", tsTunnelList, ethSrvEndPoints);
        ethSrvInstances.add(ethSrvInstance);
        CustomerEthService customerEthService = new TsEthSrv(ethSrvInstances);
        return customerEthService;
    }
}