summaryrefslogtreecommitdiffstats
path: root/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools
diff options
context:
space:
mode:
Diffstat (limited to 'actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools')
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/ActnDataConverter.java42
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerEthService.java23
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerOtnTopology.java23
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerOtnTunnel.java23
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerTopology.java23
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/OssMessage.java60
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/PncClient.java34
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/PncSession.java38
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/RequestId.java24
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/SessionId.java24
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/Transcoder.java27
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/YangValue.java32
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/impl/ActnClientServiceImpl.java60
-rw-r--r--actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/impl/PncClientInstance.java188
14 files changed, 248 insertions, 373 deletions
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/ActnDataConverter.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/ActnDataConverter.java
deleted file mode 100644
index e6eb42d..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/ActnDataConverter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ============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.actnclient.api;
-
-
-import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.DefaultEthtSvc;
-import org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.networks.Network;
-import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.tunnelsgrouping.tunnels.DefaultTunnel;
-public abstract class ActnDataConverter {
- CustomerOtnTopology convertActnOtnTopology(Network actnOtnTopology) throws Exception {
- throw new Exception("unsupported method");
- }
- CustomerOtnTunnel convertActnOtnTunnel(DefaultTunnel actnOtnTunnel) throws Exception {
- throw new Exception("unsupported method");
- }
- DefaultTunnel convertActnOtnTunnel(CustomerOtnTunnel customerOtnTunnel) throws Exception {
- throw new Exception("unsupported method");
- }
- CustomerEthService convertActnEthService(DefaultEthtSvc actnEthService) throws Exception {
- throw new Exception("unsupported method");
- }
- DefaultEthtSvc convertActnEthService(CustomerEthService customerEthService) throws Exception {
- throw new Exception("unsupported method");
- }
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerEthService.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerEthService.java
deleted file mode 100644
index 9c4aede..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerEthService.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * ============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.actnclient.api;
-
-public abstract class CustomerEthService {
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerOtnTopology.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerOtnTopology.java
deleted file mode 100644
index d57c0f7..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerOtnTopology.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * ============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.actnclient.api;
-
-public abstract class CustomerOtnTopology extends CustomerTopology{
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerOtnTunnel.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerOtnTunnel.java
deleted file mode 100644
index 4390c57..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerOtnTunnel.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * ============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.actnclient.api;
-
-public abstract class CustomerOtnTunnel {
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerTopology.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerTopology.java
deleted file mode 100644
index a9cd142..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/CustomerTopology.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * ============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.actnclient.api;
-
-public abstract class CustomerTopology {
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/OssMessage.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/OssMessage.java
deleted file mode 100644
index 84e13d0..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/OssMessage.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Actn Interface Tools
- * ================================================================================
- * Copyright (C) 2022 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.actnclient.api;
-
-/**
- * Base class for OSS internal message
- */
-public class OssMessage {
- protected int xid;
-
- public OssMessage() {
-
- }
-
- public int getXid() {
- return xid;
- }
-
- public OssMessage setXid(int xid) {
- this.xid = xid;
- return this;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof OssMessage)) {
- return false;
- }
- OssMessage other = (OssMessage) obj;
-
- if (xid != other.xid) {
- return false;
- }
- return true;
- }
-} \ No newline at end of file
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/PncClient.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/PncClient.java
deleted file mode 100644
index 3361ce4..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/PncClient.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Actn Interface Tools
- * ================================================================================
- * Copyright (C) 2022 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.actnclient.api;
-
-import java.util.concurrent.Future;
-
-public interface PncClient {
-
- <T> Future<YangValue<T>> asyncGets(String key, Transcoder<T> tc);
-
- Future<YangValue<Object>> asyncGets(String key);
-
- <T> Future<Boolean> put(String key, T o, Transcoder<T> tc);
-
- Future<Boolean> put(String key, Object o);
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/PncSession.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/PncSession.java
deleted file mode 100644
index fa72cc6..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/PncSession.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Actn Interface Tools
- * ================================================================================
- * Copyright (C) 2022 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.actnclient.api;
-
-import java.net.Inet4Address;
-import java.util.UUID;
-
-public interface PncSession {
- UUID pncId();
-
- Inet4Address ipAddress();
-
- int providerId();
-
- int clientId();
-
- int topologyId();
-
- MdscController getMdscController();
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/RequestId.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/RequestId.java
deleted file mode 100644
index d875880..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/RequestId.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Actn Interface Tools
- * ================================================================================
- * Copyright (C) 2022 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.actnclient.api;
-
-public class RequestId {
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/SessionId.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/SessionId.java
deleted file mode 100644
index 199a042..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/SessionId.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Actn Interface Tools
- * ================================================================================
- * Copyright (C) 2022 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.actnclient.api;
-
-public class SessionId {
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/Transcoder.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/Transcoder.java
deleted file mode 100644
index d110dde..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/Transcoder.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Actn Interface Tools
- * ================================================================================
- * Copyright (C) 2022 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.actnclient.api;
-
-public interface Transcoder<T> {
- T decode(byte[] d);
-
- byte[] encode(T o);
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/YangValue.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/YangValue.java
deleted file mode 100644
index 966eeb5..0000000
--- a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/api/YangValue.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Actn Interface Tools
- * ================================================================================
- * Copyright (C) 2022 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.actnclient.api;
-
-public class YangValue<T> {
- private final long version;
- private final T value;
-
- public YangValue(long v, T val) {
- super();
- version = v;
- value = val;
- }
-}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/impl/ActnClientServiceImpl.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/impl/ActnClientServiceImpl.java
new file mode 100644
index 0000000..647536b
--- /dev/null
+++ b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/impl/ActnClientServiceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * ============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.actnclient.impl;
+
+import com.google.auto.service.AutoService;
+import org.onap.integration.actninterfacetools.globalapi.ActnClientService;
+import org.onap.integration.actninterfacetools.globalapi.ActnDataConverter;
+import org.onap.integration.actninterfacetools.globalapi.PncClient;
+import org.onap.integration.actninterfacetools.protocol.restconf.PncInstance;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+@AutoService(ActnClientService.class)
+public class ActnClientServiceImpl implements ActnClientService {
+ private ActnDataConverter actnDataConverter;
+
+ private Map<PncInstance, PncClientInstance> pncClientMap = new ConcurrentHashMap();
+
+
+ public ActnClientServiceImpl() {
+ }
+ public ActnClientServiceImpl(ActnDataConverter actnDataConverter) {
+ this.actnDataConverter = actnDataConverter;
+ }
+
+
+ @Override
+ public void registerDataConverter(ActnDataConverter converter) {
+ this.actnDataConverter = converter;
+ }
+
+ @Override
+ public PncClient getPncClient(PncInstance pncInstance) {
+ if(pncClientMap.get(pncInstance)!=null){
+ return pncClientMap.get(pncInstance);
+ }else{
+ PncClientInstance pncClientInstance = new PncClientInstance(pncInstance, actnDataConverter);
+ this.pncClientMap.put(pncInstance, pncClientInstance);
+ return pncClientInstance;
+ }
+
+ }
+}
diff --git a/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/impl/PncClientInstance.java b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/impl/PncClientInstance.java
new file mode 100644
index 0000000..fccf1c8
--- /dev/null
+++ b/actn-interface-tools/actn-client/src/main/java/org/onap/integration/actninterfacetools/actnclient/impl/PncClientInstance.java
@@ -0,0 +1,188 @@
+/*
+ * ============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.actnclient.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.auto.service.AutoService;
+import org.onap.integration.actninterfacetools.globalapi.*;
+import org.onap.integration.actninterfacetools.protocol.restconf.PncInstance;
+import org.onap.integration.actninterfacetools.protocol.restconf.RestConfSBController;
+import org.onap.integration.actninterfacetools.protocol.restconf.ctl.RestConfSBControllerImpl;
+import org.onap.integration.actninterfacetools.yangutils.CodecConverter;
+import org.onap.integration.actninterfacetools.yangutils.YangToolsUtil;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.DefaultEthtSvc;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvc.DefaultEthtSvcInstances;
+import org.onosproject.yang.gen.v11.ietfethtranservice.rev20210111.ietfethtranservice.ethtsvc.EthtSvcInstances;
+import org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.DefaultNetworks;
+import org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.NetworkId;
+import org.onosproject.yang.gen.v11.ietfnetwork.rev20180226.ietfnetwork.networks.Network;
+import org.onosproject.yang.gen.v11.ietfte.rev20210220.ietfte.tunnelsgrouping.tunnels.DefaultTunnel;
+import org.onosproject.yang.model.DataNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+import static org.onap.integration.actninterfacetools.yangutils.YangToolsUtil.*;
+@AutoService(PncClient.class)
+public class PncClientInstance implements PncClient {
+ private static final Logger log = LoggerFactory.getLogger(PncClientInstance.class);
+
+ private PncInstance pncInstance;
+ private ActnDataConverter actnDataConverter;
+ private RestConfSBController restConfSBController;
+
+ public PncClientInstance(PncInstance pncInstance, ActnDataConverter actnDataConverter) {
+ this.pncInstance = pncInstance;
+ this.actnDataConverter = actnDataConverter;
+ this.restConfSBController = RestConfSBControllerImpl.getRestConfClient();
+ this.restConfSBController.addPncInstance(this.pncInstance);
+ }
+
+
+
+ public CustomerOtnTopology getNetworkTopology(String topologyId) throws Exception {
+
+ ObjectNode json = restConfSBController.get(pncInstance.pncId(), "ietf-network:networks", "json");
+ String s = json.toString();
+ String s1 = s.replaceAll("classify-c-vlan", "ietf-eth-tran-types:classify-c-vlan");
+ String s2 = s1.replaceAll("classify-s-vlan", "ietf-eth-tran-types:classify-s-vlan");
+ ObjectNode jsonNode = new ObjectMapper().readTree(s2).deepCopy();
+
+ DefaultNetworks yangNetworks = YangToolsUtil.convertJsonToYangObj("/", jsonNode, DefaultNetworks.class);
+
+ NetworkId networkId = NetworkId.fromString(topologyId);
+ List<Network> networkList = yangNetworks.network();
+
+ Network networkSelected = null;
+ if(networkList!=null && !networkList.isEmpty()){
+ for(Network network : networkList){
+ if(network.networkId().equals(networkId)){
+ networkSelected = network;
+ break;
+ }
+ }
+ }
+ CustomerOtnTopology ct = actnDataConverter.convertActnOtnTopology(networkSelected);
+ return ct;
+
+ }
+ public void createOtnTunnel(CustomerOtnTunnel customerOtnTunnel) throws Exception {
+ DefaultTunnel actnOtnTunnel = actnDataConverter.convertActnOtnTunnel(customerOtnTunnel);
+ ObjectNode jsonNodes = convertYangTeTunnel2Json(actnOtnTunnel);
+ String s = jsonNodes.toString();
+ String s1 = s.replaceAll("gfp-n", "ietf-otn-tunnel:gfp-n");
+ String s2 = s1.replaceAll("odu-type", "ietf-otn-tunnel:odu-type");
+ ObjectNode jsonNode = new ObjectMapper().readTree(s2).deepCopy();
+ boolean result = restConfSBController.post(pncInstance.pncId(), "ietf-te:te/tunnels", jsonNode, "json");
+ if(!result){
+ log.warn("Failed to create otn tunnel");
+ }else{
+ log.info("Create otn tunnel successfully");
+ }
+
+ }
+
+ public void updateOtnTunnel(CustomerOtnTunnel customerOtnTunnel, String otnName) throws Exception {
+ DefaultTunnel actnOtnTunnel = actnDataConverter.convertActnOtnTunnel(customerOtnTunnel);
+ ObjectNode jsonNodes = convertYangTeTunnel2Json(actnOtnTunnel);
+ boolean result = restConfSBController.patch(pncInstance.pncId(), "ietf-te:te/tunnels/tunnel="+otnName, jsonNodes, "json");
+ if(!result){
+ log.warn("Failed to update otn tunnel");
+ }else{
+ log.info("Update otn tunnel successfully");
+ }
+
+ }
+ public CustomerOtnTunnel getOtnTunnel(String actnOtnTunnelId) throws Exception {
+ ObjectNode jsonNode = restConfSBController.get(pncInstance.pncId(), "ietf-te:te/tunnels/tunnel="+actnOtnTunnelId, "json");
+ DefaultTunnel actnOtnTunnel = YangToolsUtil.convertJsonToYangObj("ietf-te:te/tunnels", jsonNode, DefaultTunnel.class);
+ CustomerOtnTunnel customerOtnTunnel = actnDataConverter.convertActnOtnTunnel(actnOtnTunnel);
+ return customerOtnTunnel;
+ }
+
+
+
+
+ public void createEthService(CustomerEthService customerEthService) throws Exception {
+ DefaultEthtSvc actnEthService = actnDataConverter.convertActnEthService(customerEthService);
+ ObjectNode jsonNodes = convertYangEthSvc2Json(actnEthService);
+ boolean result = restConfSBController.patch(pncInstance.pncId(), "ietf-eth-tran-service:etht-svc/etht-svc-instances", jsonNodes, "json");
+ if(!result){
+ log.warn("Failed to create ethernet service");
+ }else{
+ log.info("Create ethernet service successfully");
+ }
+
+ }
+ public void updateEthService(CustomerEthService customerEthService) throws Exception {
+ DefaultEthtSvc actnEthService = actnDataConverter.convertActnEthService(customerEthService);
+ ObjectNode jsonNodes = convertYangEthSvc2Json(actnEthService);
+ boolean result = restConfSBController.patch(pncInstance.pncId(), "ietf-eth-tran-service:etht-svc/etht-svc-instances", jsonNodes, "json");
+ if(!result){
+ log.warn("Failed to update ethernet service");
+ }else{
+ log.info("Update ethernet service successfully");
+ }
+
+ }
+
+
+ public CustomerEthService getEthService(String actnEthServiceId) throws Exception {
+ ObjectNode jsonNode = restConfSBController.get(pncInstance.pncId(), "ietf-eth-tran-service:etht-svc/etht-svc-instances="+actnEthServiceId, "json");
+ DefaultEthtSvcInstances actnEthSvcInstance = YangToolsUtil.convertJsonToYangObj("ietf-eth-tran-service:etht-svc", jsonNode, DefaultEthtSvcInstances.class);
+ DefaultEthtSvc actnEthSvc = new DefaultEthtSvc();
+ actnEthSvc.addToEthtSvcInstances(actnEthSvcInstance);
+
+ return actnDataConverter.convertActnEthService(actnEthSvc);
+ }
+ public void deleteOtnTunnel(String actnOtnTunnelId) throws Exception{
+ boolean result = restConfSBController.delete(pncInstance.pncId(), "ietf-te:te/tunnels/tunnel=" + actnOtnTunnelId, "json");
+ if(!result){
+ log.warn("Failed to delete otn tunnel");
+ }else{
+ log.info("Delete otn tunnel successfully");
+ }
+ }
+ public void deleteEthService(String actnEthServiceId) throws Exception{
+ boolean result = restConfSBController.delete(pncInstance.pncId(), "ietf-eth-tran-service:etht-svc/etht-svc-instances=" + actnEthServiceId, "json");
+ if(!result){
+ log.warn("Failed to delete ethernet service");
+ }else{
+ log.info("Delete ethernet service successfully");
+ }
+ }
+ public static ObjectNode convertYangTeTunnel2Json(DefaultTunnel yangTeTunnel){
+ String tunnelName = yangTeTunnel.name();
+
+ DataNode dataNode = yangPojo2DataNode(getModIdForTeTunnels(), yangTeTunnel);
+
+ return CodecConverter.dataNodeToObjectNode(getRidForTeTunnel(tunnelName), dataNode);
+ }
+ public static ObjectNode convertYangEthSvc2Json(DefaultEthtSvc yangEthSvc){
+ EthtSvcInstances ethtSvcInstances = yangEthSvc.ethtSvcInstances().get(0);
+ String ethSvcName = ethtSvcInstances.ethtSvcName();
+
+ DataNode dataNode = yangPojo2DataNode(getModIdForEthSvc(), (DefaultEthtSvcInstances)ethtSvcInstances);
+
+ return CodecConverter.dataNodeToObjectNode(getRIdForEthSvcInstances(ethSvcName), dataNode);
+ }
+}