OSAM infra seed code - merge with osam-core side-by-side - fixed warnings in onap-enabler POMs

Change-Id: I0cd9ea39d4b7c1dc088ab0ecd6fb787c7f490e5e
Signed-off-by: Aharoni, Pavel (pa0916) <pavel.aharoni@intl.att.com>
diff --git a/osam-core/external/pom.xml b/osam-core/external/pom.xml
new file mode 100644
index 0000000..dd70a2c
--- /dev/null
+++ b/osam-core/external/pom.xml
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--/*-

+        * ============LICENSE_START=======================================================

+        * OSAM Core

+        * ================================================================================

+        * Copyright (C) 2018 Netsia

+        * ================================================================================

+        * 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=========================================================

+        */-->

+

+<project xmlns="http://maven.apache.org/POM/4.0.0"

+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+    <parent>

+        <artifactId>osam-core</artifactId>

+        <groupId>org.onap.osam</groupId>

+        <version>0.0.1-SNAPSHOT</version>

+    </parent>

+    <modelVersion>4.0.0</modelVersion>

+

+    <artifactId>external</artifactId>

+

+    <repositories>

+        <repository>

+            <id>jcenter</id>

+            <url>https://jcenter.bintray.com/</url>

+        </repository>

+    </repositories>

+    <dependencies>

+        <dependency>

+            <groupId>org.springframework</groupId>

+            <artifactId>spring-webflux</artifactId>

+        </dependency>

+        <dependency>

+            <groupId>org.springframework.boot</groupId>

+            <artifactId>spring-boot-starter-reactor-netty</artifactId>

+        </dependency>

+        <dependency>

+            <groupId>org.lognet</groupId>

+            <artifactId>grpc-spring-boot-starter</artifactId>

+            <version>${grpc-spring-boot-starter.version}</version>

+        </dependency>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>api</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+        <dependency>

+            <groupId>com.google.guava</groupId>

+            <artifactId>guava</artifactId>

+            <version>${guava.version}</version>

+        </dependency>

+    </dependencies>

+    <pluginRepositories>

+        <pluginRepository>

+            <releases>

+                <updatePolicy>never</updatePolicy>

+            </releases>

+            <snapshots>

+                <enabled>false</enabled>

+            </snapshots>

+            <id>central</id>

+            <name>Central Repository</name>

+            <url>https://repo.maven.apache.org/maven2</url>

+        </pluginRepository>

+        <pluginRepository>

+            <id>protoc-plugin</id>

+            <url>https://dl.bintray.com/sergei-ivanov/maven/</url>

+        </pluginRepository>

+    </pluginRepositories>

+

+    <build>

+        <extensions>

+            <extension>

+                <groupId>kr.motd.maven</groupId>

+                <artifactId>os-maven-plugin</artifactId>

+                <version>${os-maven-plugin.version}</version>

+            </extension>

+        </extensions>

+        <plugins>

+            <!-- protobuf-maven-plugin -->

+            <plugin>

+                <groupId>org.xolstice.maven.plugins</groupId>

+                <artifactId>protobuf-maven-plugin</artifactId>

+                <version>${protobuf-maven-plugin.version}</version>

+                <configuration>

+                    <protocArtifact>com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}</protocArtifact>

+                    <pluginId>grpc-java</pluginId>

+                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.11.0:exe:${os.detected.classifier}</pluginArtifact>

+                </configuration>

+                <executions>

+                    <execution>

+                        <goals>

+                            <goal>compile</goal>

+                            <goal>compile-custom</goal>

+                        </goals>

+                    </execution>

+                </executions>

+            </plugin>

+        </plugins>

+    </build>

+</project>
\ No newline at end of file
diff --git a/osam-core/external/src/main/java/org/onap/osam/external/aai/AaiClient.java b/osam-core/external/src/main/java/org/onap/osam/external/aai/AaiClient.java
new file mode 100644
index 0000000..2f7c7fd
--- /dev/null
+++ b/osam-core/external/src/main/java/org/onap/osam/external/aai/AaiClient.java
@@ -0,0 +1,36 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.osam.external.aai;

+

+import org.onap.osam.external.aai.model.PNF;

+

+import javax.net.ssl.SSLException;

+import java.io.IOException;

+

+/**

+ * Created by cemturker on 26.09.2018.

+ */

+public interface AaiClient {

+    PNF queryPnf(String name);

+    void putPnf(PNF pnf);

+}

diff --git a/osam-core/external/src/main/java/org/onap/osam/external/aai/AaiClientImpl.java b/osam-core/external/src/main/java/org/onap/osam/external/aai/AaiClientImpl.java
new file mode 100644
index 0000000..066f109
--- /dev/null
+++ b/osam-core/external/src/main/java/org/onap/osam/external/aai/AaiClientImpl.java
@@ -0,0 +1,97 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.osam.external.aai;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.common.exception.BadFormatException;

+import org.onap.osam.common.exception.InvalidOperationException;

+import org.onap.osam.common.exception.NotFoundException;

+import org.onap.osam.external.aai.config.AaiConfig;

+import org.onap.osam.external.aai.exception.ExternalSystemException;

+import org.onap.osam.external.aai.model.PNF;

+import org.onap.osam.external.aai.util.AaiHeaderUtil;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.http.HttpStatus;

+import org.springframework.stereotype.Service;

+import org.springframework.web.reactive.function.client.ClientResponse;

+

+import javax.net.ssl.SSLException;

+

+

+/**

+ * Created by cemturker on 12.04.2018.

+ */

+

+@Service

+@Slf4j

+public class AaiClientImpl implements AaiClient {

+

+    private AaiConfig aaiConfig;

+

+    @Autowired

+    public AaiClientImpl(AaiConfig aaiConfig) {

+        this.aaiConfig = aaiConfig;

+    }

+

+    @Override

+    public PNF queryPnf(String name) {

+        try {

+            ClientResponse response = AaiWebClient.webClient(aaiConfig).build().queryPNF(name);

+            commonErrorCheck(name,response);

+            log.info("Pnf query response code {} for {} id",response.statusCode(),name);

+            if (response.statusCode().is2xxSuccessful()) {

+                return AaiHeaderUtil.convertToPnf(response.bodyToMono(String.class).block());

+            }

+        } catch (SSLException e) {

+            log.error("",e);

+        }

+        throw new InvalidOperationException("");

+    }

+

+    @Override

+    public void putPnf(PNF pnf) {

+        try {

+            ClientResponse response = AaiWebClient.webClient(aaiConfig).build().putPNF(pnf);

+            commonErrorCheck(pnf,response);

+            log.info("Pnf query response code {} for {} ",response.statusCode(),pnf);

+            if (response.statusCode().is2xxSuccessful()) {

+                return;

+            }

+        } catch (SSLException e) {

+            log.error("",e);

+        }

+        throw new InvalidOperationException("");

+    }

+

+    private <T> void commonErrorCheck(T t, ClientResponse response){

+        if (response.statusCode().is5xxServerError()) {

+            throw new ExternalSystemException("Aai error code:"+response.statusCode().value());

+        }

+        if (HttpStatus.BAD_REQUEST.equals(response.statusCode())) {

+            throw new BadFormatException("Bad format exception is received from AAI");

+        }

+        if (HttpStatus.NOT_FOUND.equals(response.statusCode())) {

+            throw new NotFoundException(t+" is not found in AAI");

+        }

+    }

+}

diff --git a/osam-core/external/src/main/java/org/onap/osam/external/aai/AaiWebClient.java b/osam-core/external/src/main/java/org/onap/osam/external/aai/AaiWebClient.java
new file mode 100644
index 0000000..d548715
--- /dev/null
+++ b/osam-core/external/src/main/java/org/onap/osam/external/aai/AaiWebClient.java
@@ -0,0 +1,97 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.osam.external.aai;

+

+import io.netty.handler.ssl.SslContext;

+import io.netty.handler.ssl.SslContextBuilder;

+import io.netty.handler.ssl.util.InsecureTrustManagerFactory;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.external.aai.config.AaiConfig;

+import org.onap.osam.external.aai.model.PNF;

+import org.onap.osam.external.aai.util.AaiHeaderUtil;

+import org.springframework.http.client.reactive.ReactorClientHttpConnector;

+import org.springframework.web.reactive.function.client.ClientResponse;

+import org.springframework.web.reactive.function.client.WebClient;

+import org.springframework.web.util.DefaultUriBuilderFactory;

+import reactor.core.publisher.Mono;

+

+import javax.net.ssl.SSLException;

+import java.net.URI;

+

+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;

+

+/**

+ * Created by cemturker on 01.10.2018.

+ */

+@Slf4j

+public class AaiWebClient {

+    private AaiConfig config;

+    private WebClient webClient;

+    private AaiWebClient(AaiConfig config) {

+        this.config = config;

+    }

+

+    public static AaiWebClient webClient(AaiConfig config) {

+        return new AaiWebClient(config);

+    }

+

+    public AaiWebClient build() throws SSLException {

+        SslContext sslContext;

+        sslContext = SslContextBuilder

+                .forClient()

+                .trustManager(InsecureTrustManagerFactory.INSTANCE)

+                .build();

+        log.debug("Setting ssl context");

+

+        this.webClient =  WebClient.builder()

+                .clientConnector(new ReactorClientHttpConnector(clientOptions -> {

+                    clientOptions.sslContext(sslContext);

+                    clientOptions.disablePool();

+                }))

+                .defaultHeaders(httpHeaders -> httpHeaders.setAll(AaiHeaderUtil.headers()))

+                .filter(basicAuthentication(config.getUsername(), config.getPassword()))

+                .build();

+        return this;

+    }

+

+    public ClientResponse queryPNF(String pnfId) {

+        return this.webClient.get().uri(getUri(pnfId)).exchange().block();

+    }

+

+    public ClientResponse putPNF(PNF pnf) {

+        String aai = AaiHeaderUtil.convertPnfToString(pnf);

+        log.debug(aai);

+        return this.webClient.put()

+                .uri(getUri(pnf.getPnfName()))

+                .body(Mono.just(aai),String.class)

+                .exchange().block();

+    }

+

+    private URI getUri(String pnfName) {

+        return new DefaultUriBuilderFactory().builder().scheme(config.getProtocol())

+                .host(config.getHost()).port(config.getPort())

+                .path(config.getBasePath() + config.getPnfPath() + "/" + pnfName).build();

+    }

+

+

+}

diff --git a/osam-core/external/src/main/java/org/onap/osam/external/aai/config/AaiConfig.java b/osam-core/external/src/main/java/org/onap/osam/external/aai/config/AaiConfig.java
new file mode 100644
index 0000000..08ee7e7
--- /dev/null
+++ b/osam-core/external/src/main/java/org/onap/osam/external/aai/config/AaiConfig.java
@@ -0,0 +1,66 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.osam.external.aai.config;

+

+import lombok.Getter;

+import lombok.Setter;

+import lombok.extern.slf4j.Slf4j;

+import org.springframework.beans.factory.annotation.Value;

+import org.springframework.context.annotation.Configuration;

+import org.springframework.context.annotation.PropertySource;

+

+/**

+ * Created by cemturker on 12.04.2018.

+ */

+@Configuration

+@PropertySource("classpath:aai.properties")

+@Slf4j

+@Getter

+@Setter

+public class AaiConfig {

+    private static final String AAI_HOST = "${aai.host}";

+    private static final String AAI_PORT = "${aai.port}";

+

+    private static final String AAI_PROTOCOL = "${aai.protocol}";

+

+    private static final String AAI_USERNAME = "${aai.username}";

+    private static final String AAI_PASSWORD = "${aai.password}";

+    private static final String AAI_BASE_PATH = "${aai.base.path}";

+    private static final String AAI_PNF_PATH = "${aai.pnf.path}";

+

+    @Value(AAI_HOST)

+    private String host;

+    @Value(AAI_PORT)

+    private int port;

+    @Value(AAI_PROTOCOL)

+    private String protocol;

+    @Value(AAI_USERNAME)

+    private String username;

+    @Value(AAI_PASSWORD)

+    private String password;

+    @Value(AAI_BASE_PATH)

+    private String basePath;

+    @Value(AAI_PNF_PATH)

+    private String pnfPath;

+

+}

diff --git a/osam-core/external/src/main/java/org/onap/osam/external/aai/exception/ExternalSystemException.java b/osam-core/external/src/main/java/org/onap/osam/external/aai/exception/ExternalSystemException.java
new file mode 100644
index 0000000..157539e
--- /dev/null
+++ b/osam-core/external/src/main/java/org/onap/osam/external/aai/exception/ExternalSystemException.java
@@ -0,0 +1,32 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.osam.external.aai.exception;

+

+/**

+ * Created by cemturker on 26.09.2018.

+ */

+public class ExternalSystemException extends RuntimeException {

+    public ExternalSystemException(String message) {

+        super(message);

+    }

+}

diff --git a/osam-core/external/src/main/java/org/onap/osam/external/aai/model/PNF.java b/osam-core/external/src/main/java/org/onap/osam/external/aai/model/PNF.java
new file mode 100644
index 0000000..63b9042
--- /dev/null
+++ b/osam-core/external/src/main/java/org/onap/osam/external/aai/model/PNF.java
@@ -0,0 +1,51 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.osam.external.aai.model;

+

+import com.google.gson.annotations.SerializedName;

+import lombok.Getter;

+import lombok.Setter;

+

+/**

+ * Created by cemturker on 26.09.2018.

+ */

+@Setter

+@Getter

+public class PNF {

+    @SerializedName("pnf-id")

+    private String pnfId;

+    @SerializedName("pnf-name")

+    private String pnfName;

+    @SerializedName("ipaddress-v4-oam")

+    private String ipaddressV4Oam;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("PNF{");

+        sb.append("pnfName='").append(pnfName).append('\'');

+        sb.append(", pnfId='").append(pnfId).append('\'');

+        sb.append(", ipaddressV4Oam='").append(ipaddressV4Oam).append('\'');

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core/external/src/main/java/org/onap/osam/external/aai/util/AaiHeaderUtil.java b/osam-core/external/src/main/java/org/onap/osam/external/aai/util/AaiHeaderUtil.java
new file mode 100644
index 0000000..526a59f
--- /dev/null
+++ b/osam-core/external/src/main/java/org/onap/osam/external/aai/util/AaiHeaderUtil.java
@@ -0,0 +1,64 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.osam.external.aai.util;

+

+import com.google.common.collect.ImmutableMap;

+import com.google.gson.Gson;

+import com.google.gson.GsonBuilder;

+import org.onap.osam.external.aai.model.PNF;

+import org.slf4j.Logger;

+import org.slf4j.LoggerFactory;

+import org.springframework.http.MediaType;

+

+

+import java.util.Map;

+

+/**

+ * Created by cemturker on 12.04.2018.

+ */

+public class AaiHeaderUtil {

+    private static final Logger logger = LoggerFactory.getLogger(AaiHeaderUtil.class);

+    private static final String X_FROM_APP_ID = "X-FromAppId";

+    private static final String X_TRANSACTION_ID = "X-TransactionId";

+    private static final String ACCEPT = "Accept";

+    private static final String CONTENT_TYPE = "Content-Type";

+    private AaiHeaderUtil(){}

+

+    public static Map<String, String> headers() {

+        return new ImmutableMap.Builder<String, String>()

+                .put(X_FROM_APP_ID,"OSAM")

+                .put(X_TRANSACTION_ID,"99")

+                .put(ACCEPT, MediaType.APPLICATION_JSON_VALUE)

+                .put(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)

+                .build();

+    }

+

+    public static PNF convertToPnf(String body) {

+        return new Gson().fromJson(body, PNF.class);

+    }

+

+    public static String convertPnfToString(PNF pnf) {

+        GsonBuilder gsonBuilder = new GsonBuilder();

+        return gsonBuilder.create().toJson(pnf, PNF.class);

+    }

+}

diff --git a/osam-core/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTClient.java b/osam-core/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTClient.java
new file mode 100644
index 0000000..688f00a
--- /dev/null
+++ b/osam-core/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTClient.java
@@ -0,0 +1,184 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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=========================================================

+ */

+

+

+

+/*

+ * Copyright 2015, Google Inc. All rights reserved.

+ *

+ * Redistribution and use in source and binary forms, with or without

+ * modification, are permitted provided that the following conditions are

+ * met:

+ *

+ *    * Redistributions of source code must retain the above copyright

+ * notice, this list of conditions and the following disclaimer.

+ *    * Redistributions in binary form must reproduce the above

+ * copyright notice, this list of conditions and the following disclaimer

+ * in the documentation and/or other materials provided with the

+ * distribution.

+ *

+ *    * Neither the name of Google Inc. nor the names of its

+ * contributors may be used to endorse or promote products derived from

+ * this software without specific prior written permission.

+ *

+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS

+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR

+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT

+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,

+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT

+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY

+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ */

+

+package org.onap.osam.external.grpc;

+

+import io.grpc.ManagedChannel;

+import io.grpc.ManagedChannelBuilder;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.common.exception.NotFoundException;

+import org.onap.osam.grpc.*;

+import org.onap.osam.model.dao.Chassis;

+import org.onap.osam.model.dao.OLTSlot;

+import org.springframework.beans.factory.annotation.Value;

+import org.springframework.context.annotation.PropertySource;

+import org.springframework.stereotype.Component;

+

+import javax.annotation.PostConstruct;

+

+@Component

+@PropertySource("classpath:abstractolt.properties")

+@Slf4j

+public class AbstractOLTClient {

+

+  private static final String ABSTRACTOLT_HOST = "${abstractolt.host}";

+  private static final String ABSTRACTOLT_PORT = "${abstractolt.port}";

+

+  public static int NUMBER_OF_OLT_PORTS = 16;

+

+  private AbstractOLTGrpc.AbstractOLTBlockingStub blockingStub;

+  @Value(ABSTRACTOLT_HOST)

+  private String host;

+  @Value(ABSTRACTOLT_PORT)

+  private int port;

+

+  @PostConstruct

+  private void init() {

+      ManagedChannel managedChannel = ManagedChannelBuilder

+                .forAddress(host, port).usePlaintext().build();

+

+      blockingStub = AbstractOLTGrpc.newBlockingStub(managedChannel);

+  }

+

+  /** create chassis */

+  public String createChassis(Chassis chassis) {

+

+      String deviceID = null;

+

+      log.info("createChassis begin, chassis: {}", chassis);

+

+      String clli = chassis.getClli();

+      int rack = chassis.getRack();

+      int shelf = chassis.getShelf();

+      if (chassis.getAccessPod() == null) {

+          throw new NotFoundException("Access pod not found");

+      }

+      String xosIP = chassis.getAccessPod().getCoreIp();

+      int port = Integer.parseInt(chassis.getAccessPod().getCorePort());

+      String user = chassis.getAccessPod().getUsername();

+      String pass = chassis.getAccessPod().getPassword();

+

+      AddChassisMessage request = AddChassisMessage.newBuilder()

+              .setCLLI(clli)

+              .setRack(rack)

+              .setShelf(shelf)

+              .setXOSIP(xosIP)

+              .setXOSPort(port)

+              .setXOSUser(user)

+              .setXOSPassword(pass)

+              .build();

+

+      AddChassisReturn response = blockingStub.createChassis(request);

+      deviceID = response.getDeviceID();

+      log.info("createChassis with device id : " + deviceID);

+      return deviceID;

+  }

+

+    public String createOLTChassis(OLTSlot olt) {

+

+        String deviceID = null, chassisDeviceId = null;

+

+        try {

+            log.info("createOLTChassis begin, olt:{}", olt);

+

+            String clli = olt.getChassis().getClli();

+            AddOLTChassisMessage.OltDriver oltDriver =  AddOLTChassisMessage.OltDriver.forNumber((olt.getOltDriver().ordinal()));

+            AddOLTChassisMessage.OltType oltType = AddOLTChassisMessage.OltType.forNumber((olt.getOltType().ordinal()));

+

+            AddOLTChassisMessage request = AddOLTChassisMessage.newBuilder()

+                    .setCLLI(clli)

+                    .setDriver(oltDriver)

+                    .setNumPorts(NUMBER_OF_OLT_PORTS)

+                    .setSlotPort(olt.getPort())

+                    .setSlotIP(olt.getIpAddress())

+                    .setType(oltType)

+                    .build();

+

+            AddOLTChassisReturn response = blockingStub.createOLTChassis(request);

+            deviceID = response.getDeviceID();

+            chassisDeviceId = response.getChassisDeviceID();

+            log.info("createOLTChassis with device id : {} chassisDeviceId : {}",chassisDeviceId,deviceID);

+

+        } catch (RuntimeException e) {

+            log.error("createOLTChassis RPC failed", e);

+        }

+

+        return deviceID;

+    }

+

+    public boolean provisionONT(String clli, int slotNumber, int portNumber, int ontNumber, String serialNumber) {

+

+        boolean result = false;

+

+        try {

+            log.info("provisionONT begin, clli: {}, slotNumber: {}, portNumber:{}, ontNumber:{}, serialNumber:{}", clli, slotNumber, portNumber, ontNumber, serialNumber);

+            AddOntMessage request = AddOntMessage.newBuilder()

+                    .setCLLI(clli)

+                    .setPortNumber(portNumber)

+                    .setSlotNumber(slotNumber)

+                    .setOntNumber(ontNumber)

+                    .setSerialNumber(serialNumber)

+                    .build();

+

+            AddOntReturn response = blockingStub.provisionOnt(request);

+            result = response.getSuccess();

+            log.info("provisionONT with device id : {} success : {}" + serialNumber, result);

+

+        } catch (RuntimeException e) {

+            log.error("provisionONT RPC failed", e);

+        }

+

+        return result;

+    }

+

+}

diff --git a/osam-core/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTServer.java b/osam-core/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTServer.java
new file mode 100644
index 0000000..39c21c7
--- /dev/null
+++ b/osam-core/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTServer.java
@@ -0,0 +1,108 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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=========================================================

+ */

+

+

+

+/*

+ * Copyright 2015, Google Inc. All rights reserved.

+ *

+ * Redistribution and use in source and binary forms, with or without

+ * modification, are permitted provided that the following conditions are

+ * met:

+ *

+ *    * Redistributions of source code must retain the above copyright

+ * notice, this list of conditions and the following disclaimer.

+ *    * Redistributions in binary form must reproduce the above

+ * copyright notice, this list of conditions and the following disclaimer

+ * in the documentation and/or other materials provided with the

+ * distribution.

+ *

+ *    * Neither the name of Google Inc. nor the names of its

+ * contributors may be used to endorse or promote products derived from

+ * this software without specific prior written permission.

+ *

+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS

+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR

+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT

+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,

+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT

+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY

+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ */

+

+package org.onap.osam.external.grpc;

+

+import io.grpc.stub.StreamObserver;

+import lombok.extern.slf4j.Slf4j;

+import org.lognet.springboot.grpc.GRpcService;

+import org.onap.osam.grpc.*;

+

+import java.util.UUID;

+

+/**

+ * Server that manages startup/shutdown of a {@code AbstractOLTServer} server.

+ */

+

+@GRpcService

+@Slf4j

+public class AbstractOLTServer extends AbstractOLTGrpc.AbstractOLTImplBase {

+

+    @Override

+    public void echo(EchoMessage request, StreamObserver<EchoReplyMessage> responseObserver) {

+

+    }

+

+    @Override

+    public void createChassis(AddChassisMessage request, StreamObserver<AddChassisReturn> responseObserver) {

+        AddChassisReturn response = AddChassisReturn.newBuilder()

+                .setDeviceID(request.getCLLI())

+                .build();

+        responseObserver.onNext(response);

+        responseObserver.onCompleted();

+        log.info("createChassis with clli : {}" , request.getCLLI());

+    }

+

+    @Override

+    public void createOLTChassis(AddOLTChassisMessage request, StreamObserver<AddOLTChassisReturn> responseObserver) {

+        AddOLTChassisReturn response = AddOLTChassisReturn.newBuilder()

+                .setDeviceID(UUID.randomUUID().toString())

+                .setChassisDeviceID(request.getCLLI()).build();

+        responseObserver.onNext(response);

+        responseObserver.onCompleted();

+        log.info("createOLTChassis with clli : {}" , request.getCLLI());

+    }

+

+    @Override

+    public void provisionOnt(AddOntMessage request, StreamObserver<AddOntReturn> responseObserver) {

+        AddOntReturn response = AddOntReturn.newBuilder().setSuccess(true).build();

+        responseObserver.onNext(response);

+        responseObserver.onCompleted();

+        log.info("provisionOnt success");

+    }

+

+    @Override

+    public void deleteOnt(DeleteOntMessage request, StreamObserver<DeleteOntReturn> responseObserver) {

+

+    }

+}

diff --git a/osam-core/external/src/main/proto/abstract_olt_api.proto b/osam-core/external/src/main/proto/abstract_olt_api.proto
new file mode 100644
index 0000000..ce9a322
--- /dev/null
+++ b/osam-core/external/src/main/proto/abstract_olt_api.proto
@@ -0,0 +1,149 @@
+//Copyright 2017 the original author or authors.

+//

+//  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.

+

+syntax = "proto3";

+package api;

+import "google/api/annotations.proto";

+

+option java_multiple_files = true;

+option java_package = "org.onap.osam.grpc";

+option java_outer_classname = "AbstractOLTProto";

+

+message EchoMessage{

+   string Ping =1;

+}

+message EchoReplyMessage{

+   string Pong =1;

+}

+

+message AddChassisMessage{

+   string CLLI =1;

+   string XOSIP =2;

+   int32 XOSPort=3;

+   string XOSUser=4;

+   string XOSPassword=5;

+   int32 Rack=6;

+   int32 Shelf=7;

+}

+message AddChassisReturn{

+   string DeviceID = 1;

+}

+message ChangeXOSUserPasswordMessage{

+   string CLLI =1;

+   string XOSUser=2;

+   string XOSPassword=3;

+}

+message ChangeXOSUserPasswordReturn{

+   bool Success=1;

+}

+

+message AddOLTChassisMessage{

+   string CLLI=1;

+   string SlotIP=2;

+   fixed32 SlotPort=3;

+   string Hostname=4;

+   fixed32 NumPorts = 5;

+   bool Activate = 6;

+   enum OltDriver {

+      openoltDriver= 0;

+      asfvolt16Driver=1;

+      adtranDriver=2;

+      tibitsDriver=3;

+   }

+   OltDriver Driver=7;

+   enum OltType{

+      edgecore=0;

+      adtran=1;

+      tibit=2;

+   }

+   OltType Type=8;

+

+}

+message AddOLTChassisReturn {

+   string DeviceID =1;

+   string ChassisDeviceID =2;

+}

+

+message AddOntMessage{

+   string CLLI=1;

+   int32 SlotNumber=2;

+   int32 PortNumber=3;

+   int32 OntNumber=4;

+   string SerialNumber=5;

+}

+message AddOntReturn{

+   bool Success=1;

+}

+

+message DeleteOntMessage{

+   string CLLI=1;

+   int32 SlotNumber=2;

+   int32 PortNumber=3;

+   int32 OntNumber=4;

+   string SerialNumber=5;

+}

+message DeleteOntReturn{

+   bool Success=1;

+}

+message OutputMessage{

+   string Something=1;

+}

+message OutputReturn{

+   bool Success=1;

+}

+service AbstractOLT{

+   rpc Echo(EchoMessage) returns (EchoReplyMessage){

+      option(google.api.http)={

+        post:"/v1/Echo"

+	body:"*"

+      };

+   }

+   rpc CreateChassis(AddChassisMessage) returns (AddChassisReturn) {

+      option(google.api.http) = {

+         post: "/v1/CreateAbstractChassis"

+	 body:"*"

+      };

+   }

+   rpc ChangeXOSUserPassword(ChangeXOSUserPasswordMessage) returns(ChangeXOSUserPasswordReturn){

+      option(google.api.http)={

+        post:"/v1/ChangeXOSUserPassword"

+	body:"*"

+      };

+   }

+   rpc CreateOLTChassis(AddOLTChassisMessage) returns (AddOLTChassisReturn) {

+      option(google.api.http) = {

+         post: "/v1/CreateOLTChassis"

+	 body:"*"

+      };

+   }

+   rpc ProvisionOnt(AddOntMessage) returns (AddOntReturn) {

+      option(google.api.http) = {

+         post:"/v1/ProvsionOnt"

+	 body:"*"

+      };

+   }

+   rpc DeleteOnt(DeleteOntMessage) returns (DeleteOntReturn){

+      option(google.api.http)={

+        post:"/v1/DeleteOnt"

+	body:"*"

+      };

+   }

+   rpc Output(OutputMessage)returns(OutputReturn){

+      option(google.api.http)={

+        post:"/v1/Output"

+	body:"*"

+      };

+   }

+}

+

diff --git a/osam-core/external/src/main/proto/google/api/annotations.proto b/osam-core/external/src/main/proto/google/api/annotations.proto
new file mode 100644
index 0000000..8430836
--- /dev/null
+++ b/osam-core/external/src/main/proto/google/api/annotations.proto
@@ -0,0 +1,31 @@
+// Copyright (c) 2015, Google Inc.

+//

+// 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.

+

+syntax = "proto3";

+

+package google.api;

+

+import "google/api/http.proto";

+import "google/protobuf/descriptor.proto";

+

+option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";

+option java_multiple_files = true;

+option java_outer_classname = "AnnotationsProto";

+option java_package = "com.google.api";

+option objc_class_prefix = "GAPI";

+

+extend google.protobuf.MethodOptions {

+  // See `HttpRule`.

+  HttpRule http = 72295728;

+}

diff --git a/osam-core/external/src/main/proto/google/api/http.proto b/osam-core/external/src/main/proto/google/api/http.proto
new file mode 100644
index 0000000..1c98236
--- /dev/null
+++ b/osam-core/external/src/main/proto/google/api/http.proto
@@ -0,0 +1,370 @@
+// Copyright 2018 Google LLC.

+//

+// 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.

+//

+

+syntax = "proto3";

+

+package google.api;

+

+option cc_enable_arenas = true;

+option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";

+option java_multiple_files = true;

+option java_outer_classname = "HttpProto";

+option java_package = "com.google.api";

+option objc_class_prefix = "GAPI";

+

+

+// Defines the HTTP configuration for an API service. It contains a list of

+// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method

+// to one or more HTTP REST API methods.

+message Http {

+  // A list of HTTP configuration rules that apply to individual API methods.

+  //

+  // **NOTE:** All service configuration rules follow "last one wins" order.

+  repeated HttpRule rules = 1;

+

+  // When set to true, URL path parmeters will be fully URI-decoded except in

+  // cases of single segment matches in reserved expansion, where "%2F" will be

+  // left encoded.

+  //

+  // The default behavior is to not decode RFC 6570 reserved characters in multi

+  // segment matches.

+  bool fully_decode_reserved_expansion = 2;

+}

+

+// # gRPC Transcoding

+//

+// gRPC Transcoding is a feature for mapping between a gRPC method and one or

+// more HTTP REST endpoints. It allows developers to build a single API service

+// that supports both gRPC APIs and REST APIs. Many systems, including [Google

+// APIs](https://github.com/googleapis/googleapis),

+// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC

+// Gateway](https://github.com/grpc-ecosystem/grpc-gateway),

+// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature

+// and use it for large scale production services.

+//

+// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies

+// how different portions of the gRPC request message are mapped to the URL

+// path, URL query parameters, and HTTP request body. It also controls how the

+// gRPC response message is mapped to the HTTP response body. `HttpRule` is

+// typically specified as an `google.api.http` annotation on the gRPC method.

+//

+// Each mapping specifies a URL path template and an HTTP method. The path

+// template may refer to one or more fields in the gRPC request message, as long

+// as each field is a non-repeated field with a primitive (non-message) type.

+// The path template controls how fields of the request message are mapped to

+// the URL path.

+//

+// Example:

+//

+//     service Messaging {

+//       rpc GetMessage(GetMessageRequest) returns (Message) {

+//         option (google.api.http) = {

+//             get: "/v1/{name=messages/*"}"

+//         };

+//       }

+//     }

+//     message GetMessageRequest {

+//       string name = 1; // Mapped to URL path.

+//     }

+//     message Message {

+//       string text = 1; // The resource content.

+//     }

+//

+// This enables an HTTP REST to gRPC mapping as below:

+//

+// HTTP | gRPC

+// -----|-----

+// `GET /v1/messages/123456`  | `GetMessage(name: "messages/123456")`

+//

+// Any fields in the request message which are not bound by the path template

+// automatically become HTTP query parameters if there is no HTTP request body.

+// For example:

+//

+//     service Messaging {

+//       rpc GetMessage(GetMessageRequest) returns (Message) {

+//         option (google.api.http) = {

+//             get:"/v1/messages/{message_id}"

+//         };

+//       }

+//     }

+//     message GetMessageRequest {

+//       message SubMessage {

+//         string subfield = 1;

+//       }

+//       string message_id = 1; // Mapped to URL path.

+//       int64 revision = 2;    // Mapped to URL query parameter `revision`.

+//       SubMessage sub = 3;    // Mapped to URL query parameter `sub.subfield`.

+//     }

+//

+// This enables a HTTP JSON to RPC mapping as below:

+//

+// HTTP | gRPC

+// -----|-----

+// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))`

+//

+// Note that fields which are mapped to URL query parameters must have a

+// primitive type or a repeated primitive type or a non-repeated message type.

+// In the case of a repeated type, the parameter can be repeated in the URL

+// as `...?param=A&param=B`. In the case of a message type, each field of the

+// message is mapped to a separate parameter, such as

+// `...?foo.a=A&foo.b=B&foo.c=C`.

+//

+// For HTTP methods that allow a request body, the `body` field

+// specifies the mapping. Consider a REST update method on the

+// message resource collection:

+//

+//     service Messaging {

+//       rpc UpdateMessage(UpdateMessageRequest) returns (Message) {

+//         option (google.api.http) = {

+//           patch: "/v1/messages/{message_id}"

+//           body: "message"

+//         };

+//       }

+//     }

+//     message UpdateMessageRequest {

+//       string message_id = 1; // mapped to the URL

+//       Message message = 2;   // mapped to the body

+//     }

+//

+// The following HTTP JSON to RPC mapping is enabled, where the

+// representation of the JSON in the request body is determined by

+// protos JSON encoding:

+//

+// HTTP | gRPC

+// -----|-----

+// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`

+//

+// The special name `*` can be used in the body mapping to define that

+// every field not bound by the path template should be mapped to the

+// request body.  This enables the following alternative definition of

+// the update method:

+//

+//     service Messaging {

+//       rpc UpdateMessage(Message) returns (Message) {

+//         option (google.api.http) = {

+//           patch: "/v1/messages/{message_id}"

+//           body: "*"

+//         };

+//       }

+//     }

+//     message Message {

+//       string message_id = 1;

+//       string text = 2;

+//     }

+//

+//

+// The following HTTP JSON to RPC mapping is enabled:

+//

+// HTTP | gRPC

+// -----|-----

+// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`

+//

+// Note that when using `*` in the body mapping, it is not possible to

+// have HTTP parameters, as all fields not bound by the path end in

+// the body. This makes this option more rarely used in practice when

+// defining REST APIs. The common usage of `*` is in custom methods

+// which don't use the URL at all for transferring data.

+//

+// It is possible to define multiple HTTP methods for one RPC by using

+// the `additional_bindings` option. Example:

+//

+//     service Messaging {

+//       rpc GetMessage(GetMessageRequest) returns (Message) {

+//         option (google.api.http) = {

+//           get: "/v1/messages/{message_id}"

+//           additional_bindings {

+//             get: "/v1/users/{user_id}/messages/{message_id}"

+//           }

+//         };

+//       }

+//     }

+//     message GetMessageRequest {

+//       string message_id = 1;

+//       string user_id = 2;

+//     }

+//

+// This enables the following two alternative HTTP JSON to RPC mappings:

+//

+// HTTP | gRPC

+// -----|-----

+// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`

+// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`

+//

+// ## Rules for HTTP mapping

+//

+// 1. Leaf request fields (recursive expansion nested messages in the request

+//    message) are classified into three categories:

+//    - Fields referred by the path template. They are passed via the URL path.

+//    - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP

+//      request body.

+//    - All other fields are passed via the URL query parameters, and the

+//      parameter name is the field path in the request message. A repeated

+//      field can be represented as multiple query parameters under the same

+//      name.

+//  2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields

+//     are passed via URL path and HTTP request body.

+//  3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all

+//     fields are passed via URL path and URL query parameters.

+//

+// ### Path template syntax

+//

+//     Template = "/" Segments [ Verb ] ;

+//     Segments = Segment { "/" Segment } ;

+//     Segment  = "*" | "**" | LITERAL | Variable ;

+//     Variable = "{" FieldPath [ "=" Segments ] "}" ;

+//     FieldPath = IDENT { "." IDENT } ;

+//     Verb     = ":" LITERAL ;

+//

+// The syntax `*` matches a single URL path segment. The syntax `**` matches

+// zero or more URL path segments, which must be the last part of the URL path

+// except the `Verb`.

+//

+// The syntax `Variable` matches part of the URL path as specified by its

+// template. A variable template must not contain other variables. If a variable

+// matches a single path segment, its template may be omitted, e.g. `{var}`

+// is equivalent to `{var=*}`.

+//

+// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL`

+// contains any reserved character, such characters should be percent-encoded

+// before the matching.

+//

+// If a variable contains exactly one path segment, such as `"{var}"` or

+// `"{var=*}"`, when such a variable is expanded into a URL path on the client

+// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The

+// server side does the reverse decoding. Such variables show up in the

+// [Discovery Document](https://developers.google.com/discovery/v1/reference/apis)

+// as `{var}`.

+//

+// If a variable contains multiple path segments, such as `"{var=foo/*}"`

+// or `"{var=**}"`, when such a variable is expanded into a URL path on the

+// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded.

+// The server side does the reverse decoding, except "%2F" and "%2f" are left

+// unchanged. Such variables show up in the

+// [Discovery Document](https://developers.google.com/discovery/v1/reference/apis)

+// as `{+var}`.

+//

+// ## Using gRPC API Service Configuration

+//

+// gRPC API Service Configuration (service config) is a configuration language

+// for configuring a gRPC service to become a user-facing product. The

+// service config is simply the YAML representation of the `google.api.Service`

+// proto message.

+//

+// As an alternative to annotating your proto file, you can configure gRPC

+// transcoding in your service config YAML files. You do this by specifying a

+// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same

+// effect as the proto annotation. This can be particularly useful if you

+// have a proto that is reused in multiple services. Note that any transcoding

+// specified in the service config will override any matching transcoding

+// configuration in the proto.

+//

+// Example:

+//

+//     http:

+//       rules:

+//         # Selects a gRPC method and applies HttpRule to it.

+//         - selector: example.v1.Messaging.GetMessage

+//           get: /v1/messages/{message_id}/{sub.subfield}

+//

+// ## Special notes

+//

+// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the

+// proto to JSON conversion must follow the [proto3

+// specification](https://developers.google.com/protocol-buffers/docs/proto3#json).

+//

+// While the single segment variable follows the semantics of

+// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String

+// Expansion, the multi segment variable **does not** follow RFC 6570 Section

+// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion

+// does not expand special characters like `?` and `#`, which would lead

+// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding

+// for multi segment variables.

+//

+// The path variables **must not** refer to any repeated or mapped field,

+// because client libraries are not capable of handling such variable expansion.

+//

+// The path variables **must not** capture the leading "/" character. The reason

+// is that the most common use case "{var}" does not capture the leading "/"

+// character. For consistency, all path variables must share the same behavior.

+//

+// Repeated message fields must not be mapped to URL query parameters, because

+// no client library can support such complicated mapping.

+//

+// If an API needs to use a JSON array for request or response body, it can map

+// the request or response body to a repeated field. However, some gRPC

+// Transcoding implementations may not support this feature.

+message HttpRule {

+  // Selects a method to which this rule applies.

+  //

+  // Refer to [selector][google.api.DocumentationRule.selector] for syntax details.

+  string selector = 1;

+

+  // Determines the URL pattern is matched by this rules. This pattern can be

+  // used with any of the {get|put|post|delete|patch} methods. A custom method

+  // can be defined using the 'custom' field.

+  oneof pattern {

+    // Maps to HTTP GET. Used for listing and getting information about

+    // resources.

+    string get = 2;

+

+    // Maps to HTTP PUT. Used for replacing a resource.

+    string put = 3;

+

+    // Maps to HTTP POST. Used for creating a resource or performing an action.

+    string post = 4;

+

+    // Maps to HTTP DELETE. Used for deleting a resource.

+    string delete = 5;

+

+    // Maps to HTTP PATCH. Used for updating a resource.

+    string patch = 6;

+

+    // The custom pattern is used for specifying an HTTP method that is not

+    // included in the `pattern` field, such as HEAD, or "*" to leave the

+    // HTTP method unspecified for this rule. The wild-card rule is useful

+    // for services that provide content to Web (HTML) clients.

+    CustomHttpPattern custom = 8;

+  }

+

+  // The name of the request field whose value is mapped to the HTTP request

+  // body, or `*` for mapping all request fields not captured by the path

+  // pattern to the HTTP body, or omitted for not having any HTTP request body.

+  //

+  // NOTE: the referred field must be present at the top-level of the request

+  // message type.

+  string body = 7;

+

+  // Optional. The name of the response field whose value is mapped to the HTTP

+  // response body. When omitted, the entire response message will be used

+  // as the HTTP response body.

+  //

+  // NOTE: The referred field must be present at the top-level of the response

+  // message type.

+  string response_body = 12;

+

+  // Additional HTTP bindings for the selector. Nested bindings must

+  // not contain an `additional_bindings` field themselves (that is,

+  // the nesting may only be one level deep).

+  repeated HttpRule additional_bindings = 11;

+}

+

+// A custom pattern is used for defining custom HTTP verb.

+message CustomHttpPattern {

+  // The name of this custom HTTP verb.

+  string kind = 1;

+

+  // The path matched by this custom verb.

+  string path = 2;

+}

diff --git a/osam-core/external/src/main/resources/aai.properties b/osam-core/external/src/main/resources/aai.properties
new file mode 100644
index 0000000..e8abfe0
--- /dev/null
+++ b/osam-core/external/src/main/resources/aai.properties
@@ -0,0 +1,7 @@
+aai.host=192.168.62.68

+aai.port=8443

+aai.protocol=https

+aai.username=AAI

+aai.password=AAI

+aai.base.path=/aai/v12

+aai.pnf.path=/network/pnfs/pnf

diff --git a/osam-core/external/src/main/resources/abstractolt.properties b/osam-core/external/src/main/resources/abstractolt.properties
new file mode 100644
index 0000000..07392d8
--- /dev/null
+++ b/osam-core/external/src/main/resources/abstractolt.properties
@@ -0,0 +1,2 @@
+abstractolt.host=135.25.86.132

+abstractolt.port=7777

diff --git a/osam-core/external/src/test/java/org/onap/osam/external/aai/AaiClientTestIT.java b/osam-core/external/src/test/java/org/onap/osam/external/aai/AaiClientTestIT.java
new file mode 100644
index 0000000..aadcd00
--- /dev/null
+++ b/osam-core/external/src/test/java/org/onap/osam/external/aai/AaiClientTestIT.java
@@ -0,0 +1,73 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.osam.external.aai;

+

+import org.junit.Before;

+import org.junit.Test;

+import org.junit.runner.RunWith;

+import org.onap.osam.external.aai.config.AaiConfig;

+import org.onap.osam.external.aai.model.PNF;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.boot.test.context.SpringBootTest;

+import org.springframework.test.context.ContextConfiguration;

+import org.springframework.test.context.junit4.SpringRunner;

+

+/**

+ * Created by cemturker on 01.10.2018.

+ */

+

+@RunWith(SpringRunner.class)

+@SpringBootTest

+@ContextConfiguration(classes = {AaiConfig.class, AaiClientImpl.class})

+public class AaiClientTestIT {

+

+    @Autowired

+    private AaiClient aaiClient;

+

+    @Before

+    public void preProcess(){

+    }

+

+    @Test

+    public void aaiQueryTest(){

+        try {

+            //PNF pnf = aaiClient.queryPnf("1111");

+        }catch (Exception e) {

+            e.printStackTrace();

+        }

+    }

+

+    @Test

+    public void aaiPutTest(){

+        try {

+            PNF pnf = new PNF();

+            pnf.setPnfId("111");

+            pnf.setPnfName("1111");

+            pnf.setIpaddressV4Oam("192.168.61.24");

+            //pnf = aaiClient.putPnf(pnf);

+        }catch (Exception e) {

+            e.printStackTrace();

+        }

+    }

+

+}