diff options
author | Itohan Ukponmwan <itohan.ukponmwan@intel.com> | 2019-08-05 16:30:20 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-08-05 16:30:20 +0000 |
commit | 55f55f93890a2c4745ee89505cc889f54ba3c3dd (patch) | |
tree | 5eb804de9b3907b38621a3f5d8169ae3f6a64c21 /grpc | |
parent | d53b78f51ed1a37f13163fe0ffd77ebd1c7f6f6f (diff) | |
parent | b9d85a33892c99949aff8e3471eb0fdc039d44aa (diff) |
Merge changes I816a1dbb,Ice38da57,I1217d391,I07d22e81,I0ddcdc1c, ...
* changes:
Add integration support
Update framework
Add vf model add artifact command
Add service model artifact add command
Add VF model checkout command
Add VF checkin command
Add sdc service resource property set
Add sdc consumer-show command
Add sdc consumer create command
Add ID output in service-model commands
Update open-cli.properties
Update the sample command OCS YAML
Add product into service and schema list
Update the version format
Update the README
Set SNAPSHOT versioning
clean-up stale onap profiles
Ignore python build artifacts from git
Diffstat (limited to 'grpc')
-rw-r--r-- | grpc/grpc-client/pom.xml | 2 | ||||
-rw-r--r-- | grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenInterfaceGrpcClient.java | 12 | ||||
-rw-r--r-- | grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenRemoteCli.java | 47 | ||||
-rw-r--r-- | grpc/grpc-server/pom.xml | 4 | ||||
-rw-r--r-- | grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java | 40 | ||||
-rw-r--r-- | grpc/grpc-stub/pom.xml | 2 | ||||
-rw-r--r-- | grpc/pom.xml | 4 |
7 files changed, 91 insertions, 20 deletions
diff --git a/grpc/grpc-client/pom.xml b/grpc/grpc-client/pom.xml index 813e8e72..3b7ad6d5 100644 --- a/grpc/grpc-client/pom.xml +++ b/grpc/grpc-client/pom.xml @@ -18,7 +18,7 @@ <parent> <groupId>org.onap.cli</groupId> <artifactId>oclip-grpc</artifactId> - <version>3.0.0</version> + <version>4.0.0-SNAPSHOT</version> </parent> <artifactId>oclip-grpc-client</artifactId> <name>oclip/grpc/client</name> diff --git a/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenInterfaceGrpcClient.java b/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenInterfaceGrpcClient.java index 9a818d7a..e32110de 100644 --- a/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenInterfaceGrpcClient.java +++ b/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenInterfaceGrpcClient.java @@ -37,6 +37,9 @@ public class OpenInterfaceGrpcClient { private final ManagedChannel channel; private final OpenInterfaceGrpc.OpenInterfaceBlockingStub blockingStub; + //10 seconds + private int timeout = 60000; + public static class OpenInterfaceGrpcExecption extends Exception { private static final long serialVersionUID = -8755636432217894246L; @@ -64,6 +67,11 @@ public class OpenInterfaceGrpcClient { .build()); } + public OpenInterfaceGrpcClient(String host, int port, int timeout) { + this(host, port); + this.timeout = timeout; + + } OpenInterfaceGrpcClient(ManagedChannel channel) { this.channel = channel; blockingStub = OpenInterfaceGrpc.newBlockingStub(channel); @@ -78,7 +86,7 @@ public class OpenInterfaceGrpcClient { Output result = Output.newBuilder().build(); try { - result = blockingStub.withDeadlineAfter(10, TimeUnit.SECONDS).invoke(input); + result = blockingStub.withDeadlineAfter(timeout, TimeUnit.MILLISECONDS).invoke(input); } catch (StatusRuntimeException e) { logger.warn("RPC failed: {0}", e.getStatus()); //Status{code=DEADLINE_EXCEEDED} @@ -93,7 +101,7 @@ public class OpenInterfaceGrpcClient { Result result = Result.newBuilder().setExitCode(1).build(); try { - result = blockingStub.withDeadlineAfter(10, TimeUnit.SECONDS).remoteCli(args); + result = blockingStub.withDeadlineAfter(timeout, TimeUnit.MILLISECONDS).remoteCli(args); } catch (StatusRuntimeException e) { logger.warn("RPC failed: {0}", e.getStatus()); //Status{code=DEADLINE_EXCEEDED} diff --git a/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenRemoteCli.java b/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenRemoteCli.java index fc0c2aac..724267e8 100644 --- a/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenRemoteCli.java +++ b/grpc/grpc-client/src/main/java/org/open/infc/grpc/client/OpenRemoteCli.java @@ -26,6 +26,51 @@ import org.open.infc.grpc.Output; import org.open.infc.grpc.Result; public class OpenRemoteCli { + + private String host; + private int port; + private int timeout; + private String requestId; + + public OpenRemoteCli(String host, int port, int timeout, String requestId) { + this.host = host; + this.port = port; + this.timeout = timeout; + this.requestId = requestId; + + } + + public Result run (List <String> args) throws Exception { + OpenInterfaceGrpcClient client = new OpenInterfaceGrpcClient( + host, port, timeout); + try { + Result result = client.remoteCli(Args.newBuilder().setRequestId(this.requestId).addAllArgs(args).build()); + return result; + } finally { + client.shutdown(); + } + } + + public Output invoke (String product, String profile, String action, Map <String, String> params) throws Exception { + OpenInterfaceGrpcClient client = new OpenInterfaceGrpcClient( + host, port, timeout); + try { + + Map <String, String> options = new HashMap<>(); + options.put("product", product); + if (profile != null && !profile.isEmpty()) + options.put("profile", profile); + params.put("format", "json"); + Input input = Input.newBuilder().setAction(action).setRequestId(requestId).putAllOptions(options).putAllParams(params).build(); + + Output output = client.invoke(input); + return output; + } finally { + client.shutdown(); + } + } + + //Absolute the static methods /** * Runs CLI remotely * @param host @@ -48,7 +93,7 @@ public class OpenRemoteCli { } } - /** + /** * Runs commands as remote procedure call :) * @param host * @param port diff --git a/grpc/grpc-server/pom.xml b/grpc/grpc-server/pom.xml index be038ad5..c894e67b 100644 --- a/grpc/grpc-server/pom.xml +++ b/grpc/grpc-server/pom.xml @@ -18,7 +18,7 @@ <parent> <groupId>org.onap.cli</groupId> <artifactId>oclip-grpc</artifactId> - <version>3.0.0</version> + <version>4.0.0-SNAPSHOT</version> </parent> <artifactId>oclip-grpc-server</artifactId> <name>oclip/grpc/server</name> @@ -32,7 +32,7 @@ <dependency> <groupId>org.onap.cli</groupId> <artifactId>cli-main</artifactId> - <version>3.0.0</version> + <version>4.0.0-SNAPSHOT</version> </dependency> </dependencies> <build> diff --git a/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java b/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java index 79d761d6..f34df89f 100644 --- a/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java +++ b/grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java @@ -29,11 +29,13 @@ import org.onap.cli.fw.conf.OnapCommandConfig; import org.onap.cli.fw.conf.OnapCommandConstants; import org.onap.cli.fw.error.OnapCommandException; import org.onap.cli.fw.input.OnapCommandParameter; +import org.onap.cli.fw.input.OnapCommandParameterType; import org.onap.cli.fw.output.OnapCommandResultType; import org.onap.cli.fw.registrar.OnapCommandRegistrar; import org.onap.cli.fw.store.OnapCommandExecutionStore; import org.onap.cli.fw.store.OnapCommandExecutionStore.ExecutionStoreContext; import org.onap.cli.main.OnapCli; +import org.onap.cli.main.utils.OnapCliArgsParser; import org.open.infc.grpc.Args; import org.open.infc.grpc.Input; import org.open.infc.grpc.OpenInterfaceGrpc; @@ -181,6 +183,24 @@ public class OpenInterfaceGrpcServer { if (params.contains(arg.getKey())) cmd.getParametersMap().get(arg.getKey()).setValue(arg.getValue()); } + + //fill values from the file, if needed + for (OnapCommandParameter param: cmd.getParameters()) { + if (param.getParameterType().equals(OnapCommandParameterType.JSON)) { + param.setValue(OnapCliArgsParser.readJsonStringFromUrl(param.getValue().toString(), param.getName())); + + } else if (param.getParameterType().equals(OnapCommandParameterType.TEXT)) { + param.setValue(OnapCliArgsParser.readTextStringFromUrl(param.getValue().toString(), param.getName())); + + } else if (param.getParameterType().equals(OnapCommandParameterType.BYTE)) { + param.setValue(OnapCliArgsParser.readBytesFromUrl(param.getValue().toString(), param.getName())); + + } else if (param.getParameterType().equals(OnapCommandParameterType.YAML)) { + param.setValue(OnapCliArgsParser.readYamlStringFromUrl(param.getValue().toString(), param.getName())); + + } + } + } else { cmd.getParametersMap().get(OnapCommandConstants.INFO_PRODUCT).setValue(product); @@ -194,7 +214,9 @@ public class OpenInterfaceGrpcServer { if (!cmd.isRpc()) { //Start the execution - if (req.getRequestId() != null) { + if (req.getRequestId() != null && !req.getRequestId().isEmpty()) { + if (!(cmd.getInfo().getProduct().equalsIgnoreCase("open-cli") && + cmd.getName().equalsIgnoreCase("execution-list"))) { String input = cmd.getArgsJson(true); executionStoreContext = OnapCommandExecutionStore.getStore().storeExectutionStart( req.getRequestId(), @@ -203,12 +225,16 @@ public class OpenInterfaceGrpcServer { cmd.getName(), profile, input); + } } } - + cmd.setExecutionContext(executionStoreContext); cmd.execute(); if (!cmd.isRpc()) { + //Track and/or persist the execution context + new OnapCli().handleTracking(cmd); + String printOut = cmd.getResult().print(); Builder reply = Output.newBuilder(); reply.putAttrs(OnapCommandConstants.ERROR, "{}"); @@ -226,15 +252,6 @@ public class OpenInterfaceGrpcServer { } output = reply.build(); - - if (req.getRequestId() != null) { - //complete the execution recording - OnapCommandExecutionStore.getStore().storeExectutionEnd( - executionStoreContext, - printOut, - null, - cmd.getResult().isPassed()); - } logger.info(output.toString()); } else { //Rpc command will set the output. @@ -254,6 +271,7 @@ public class OpenInterfaceGrpcServer { executionStoreContext, null, e.getMessage(), + cmd.getResult().getDebugInfo(), false); reply.putAddons("execution-id", executionStoreContext.getExecutionId()); } diff --git a/grpc/grpc-stub/pom.xml b/grpc/grpc-stub/pom.xml index 0b8007d8..28703a43 100644 --- a/grpc/grpc-stub/pom.xml +++ b/grpc/grpc-stub/pom.xml @@ -18,7 +18,7 @@ <parent> <groupId>org.onap.cli</groupId> <artifactId>oclip-grpc</artifactId> - <version>3.0.0</version> + <version>4.0.0-SNAPSHOT</version> </parent> <artifactId>oclip-grpc-stub</artifactId> <name>oclip/grpc/stub</name> diff --git a/grpc/pom.xml b/grpc/pom.xml index 1023e629..75721607 100644 --- a/grpc/pom.xml +++ b/grpc/pom.xml @@ -18,9 +18,9 @@ <parent> <groupId>org.onap.cli</groupId> <artifactId>cli</artifactId> - <version>3.0.0</version> + <version>4.0.0-SNAPSHOT</version> </parent> - <version>3.0.0</version> + <version>4.0.0-SNAPSHOT</version> <artifactId>oclip-grpc</artifactId> <packaging>pom</packaging> <name>oclip/grpc</name> |