2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.adaptors.util.vrf;
24 public class VrfUtil {
26 public static String createVrfInstanceName(
27 String serviceInstanceId,
31 if (vpnId == null || vpnId.trim().length() == 0)
34 String ss = "VPN-" + vpnId;
35 if (siteType != null && siteType.equalsIgnoreCase("hub"))
37 if (siteType != null && siteType.equalsIgnoreCase("spoke"))
38 ss += "-SP-" + serviceInstanceId;
39 if (routeGroup != null && routeGroup.trim().length() > 0)
40 ss += "-RG-" + routeGroup;
45 public static VpnParam parseVrfInstanceName(String vrfInstanceName) {
46 VpnParam vpnParam = new VpnParam();
48 int i1 = vrfInstanceName.indexOf("-HUB");
50 vpnParam.siteType = "HUB";
52 int i2 = vrfInstanceName.indexOf("-SP-");
54 vpnParam.siteType = "SPOKE";
56 int i3 = vrfInstanceName.indexOf("-RG-");
58 vpnParam.routeGroupName = vrfInstanceName.substring(i3 + 4);
60 int i4 = vrfInstanceName.length();
67 vpnParam.vpnId = vrfInstanceName.substring(4, i4);
70 vpnParam.spokeServiceInstanceId = vrfInstanceName.substring(i2 + 4);
72 vpnParam.spokeServiceInstanceId = vrfInstanceName.substring(i2 + 4, i3);