From ecea0ea639a9d4a44bc0e8cbe5bcd96eecf0358e Mon Sep 17 00:00:00 2001 From: adi6496 Date: Tue, 5 May 2020 22:26:55 -0400 Subject: [PATCH 01/10] added kafka-bridge with OC route and Gstreamer Local Setup --- README.md | 32 ++++++------ cmd/app/gst-launch.py | 9 ++++ cmd/dummy.sh | 23 +++++++++ cmd/gstreamer-setup.go | 22 ++++++++- cmd/kafka-bridge-destroy.go | 93 +++++++++++++++++++++++++++++++++++ cmd/kafka-bridge.go | 47 ++++++++++++++++-- yamls/kafka/bridge/route.yaml | 11 +++++ 7 files changed, 217 insertions(+), 20 deletions(-) create mode 100644 cmd/app/gst-launch.py create mode 100755 cmd/dummy.sh create mode 100644 cmd/kafka-bridge-destroy.go create mode 100644 yamls/kafka/bridge/route.yaml diff --git a/README.md b/README.md index d0b3a9f..e1ea2e5 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,28 @@ -# Setting up Clound Native Edge systems with the IoTCLI +# OpenShift Clients -The user can choose which tools they want to use in order to either digest, display or process the IoT data. Eventually the user will be allowed to create custom data pipelines to connect the tools. Currently the following tools/commands are supported +The OpenShift client `oc` simplifies working with Kubernetes and OpenShift +clusters, offering a number of advantages over `kubectl` such as easy login, +kube config file management, and access to developer tools. The `kubectl` +binary is included alongside for when strict Kubernetes compliance is necessary. -## Getting Started +To learn more about OpenShift, visit [docs.openshift.com](https://docs.openshift.com) +and select the version of OpenShift you are using. -Download the latest Release from the [release page](https://github.com/redhat-iot/iot-dev/releases) +## Installing the tools -Move the Binary `IoTCLI` into your `$PATH` +After extracting this archive, move the `oc` and `kubectl` binaries +to a location on your PATH such as `/usr/local/bin`. Then run: -Run `IoTCLI login` to authenticate with your Openshift cluster + oc login [API_URL] -# Main Components Overview +to start a session against an OpenShift cluster. After login, run `oc` and +`oc help` to learn more about how to get started with OpenShift. -## Messaging Core +## License -In any Edge system that incorporates IoT devices, having a scalable cloud native edge system is very important. With the `IoTCLI` you can easily deploy these messaging services to your Openshift 4.X cluster - -### Enmasse - -[Enmasse](enmasse.io) is an open source project for managed, self-service messaging on Kubernetes. - -The IoTCLI makes it easy to deploy the system along with its [IoT services](https://enmasse.io/documentation/0.31.0/openshift/#iot-guide-messaging-iot) onto an openshift Cluster +OpenShift is licensed under the Apache Public License 2.0. The source code for this +program is [located on github](https://github.com/openshift/origin). +he system along with its [IoT services](https://enmasse.io/documentation/0.31.0/openshift/#iot-guide-messaging-iot) onto an openshift Cluster ### Kafka diff --git a/cmd/app/gst-launch.py b/cmd/app/gst-launch.py new file mode 100644 index 0000000..0c11cf8 --- /dev/null +++ b/cmd/app/gst-launch.py @@ -0,0 +1,9 @@ + +def main(): + + a = 1 + b = 2 + + print(a+b) + +main() diff --git a/cmd/dummy.sh b/cmd/dummy.sh new file mode 100755 index 0000000..40d2775 --- /dev/null +++ b/cmd/dummy.sh @@ -0,0 +1,23 @@ +#!/bin/bash +#echo "hello world" + +xhost local:root + +docker run -it --privileged --net=host \ +\ +-v ~/.Xauthority:/root/.Xauthority \ +-v /tmp/.X11-unix:/tmp/.X11-unix \ +-e DISPLAY=$DISPLAY \ +-e HTTP_PROXY=$HTTP_PROXY \ +-e HTTPS_PROXY=$HTTPS_PROXY \ +-e http_proxy=$http_proxy \ +-e https_proxy=$https_proxy \ +\ +-v ~/gva/data/models/intel:/root/intel_models:ro \ +-v ~/gva/data/models/common:/root/common_models:ro \ +-e MODELS_PATH=/root/intel_models:/root/common_models \ +\ +-v ~/gva/data/video:/root/video-examples:ro \ +-e VIDEO_EXAMPLES_DIR=/root/video-examples \ +\ +adi6496/gst-video-analytics:latest \ No newline at end of file diff --git a/cmd/gstreamer-setup.go b/cmd/gstreamer-setup.go index 22cf78f..80858c0 100644 --- a/cmd/gstreamer-setup.go +++ b/cmd/gstreamer-setup.go @@ -18,6 +18,7 @@ package cmd import ( "fmt" "log" + "os/exec" "github.com/IoTCLI/cmd/utils" "github.com/spf13/cobra" @@ -37,10 +38,28 @@ This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { fmt.Println(" gstreamer setup called") - gstreamerSetup() + fstatus, _ := cmd.Flags().GetBool("float") + if fstatus { // if status is true, call addFloat + gstreamerSetup() + } else { + log.Println("a") + gstreamerLocalSetup() + } }, } +func gstreamerLocalSetup() { + + cmd := exec.Command("/home/adkadam/work/golang/iot-dev/cmd/dummy.sh") + out, error := cmd.Output() + if error != nil { + println(error.Error()) + return + } else { + log.Println(string(out)) + } +} + func gstreamerSetup() { //Make command options for Kafka Setup co := utils.NewCommandOptions() @@ -80,4 +99,5 @@ func init() { // Cobra supports local flags which will only run when this command // is called directly, e.g.: // setupCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + gstreamerSetupCmd.Flags().BoolP("local", "l", false, "Setup gstreamer locally") } diff --git a/cmd/kafka-bridge-destroy.go b/cmd/kafka-bridge-destroy.go new file mode 100644 index 0000000..02f049b --- /dev/null +++ b/cmd/kafka-bridge-destroy.go @@ -0,0 +1,93 @@ +/* +Copyright © 2020 NAME HERE + +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. +*/ +package cmd + +import ( + "log" + + "github.com/IoTCLI/cmd/utils" + "github.com/spf13/cobra" + "k8s.io/cli-runtime/pkg/genericclioptions" + "k8s.io/kubectl/pkg/cmd/delete" +) + +var ( + kafkaBridgeDestroyNamespaceFlag string +) + +func kafkaBridgeDestroy() { + + //Make command options for Kafka Setup + co := utils.NewCommandOptions() + + _ = utils.DownloadAndUncompress("oc.gz", "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz") + log.Println("oc Source folder: ", "oc") + + //Fill in the commands that must be applied to + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/kafka-bridge.yaml") + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml") + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/cloud-generic.yaml") + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/ingress.yaml") + + // + IOStreams, _, out, _ := genericclioptions.NewTestIOStreams() + + co.SwitchContext(kafkaBridgeDestroyNamespaceFlag) + + log.Println("Destroy Kafka Bridge from cluster") + for _, command := range co.Commands { + cmd := delete.NewCmdDelete(co.CurrentFactory, IOStreams) + err := cmd.Flags().Set("filename", command) + if err != nil { + log.Fatal(err) + } + cmd.Run(cmd, []string{}) + log.Print(out.String()) + out.Reset() + } + //Remove tempfile when done +} + +// destroyCmd represents the destroy command +var kafkaBridgedestroyCmd = &cobra.Command{ + Use: "destroy", + Short: "A brief description of your command", + Long: `A longer description that spans multiple lines and likely contains examples +and usage of using your command. For example: + +Cobra is a CLI library for Go that empowers applications. +This application is a tool to generate the needed files +to quickly create a Cobra application.`, + Run: func(cmd *cobra.Command, args []string) { + log.Println("Kafka bridge destroy called") + kafkaBridgeDestroy() + }, +} + +func init() { + kafkaBridgeCmd.AddCommand(kafkaBridgedestroyCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // destroyCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // destroyCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + kafkaBridgedestroyCmd.Flags().StringVarP(&kafkaBridgeDestroyNamespaceFlag, "namespace", "n", "kafka", "Option to specify namespace for kafka deletion, defaults to 'kafka'") +} diff --git a/cmd/kafka-bridge.go b/cmd/kafka-bridge.go index a8aa664..aea3403 100644 --- a/cmd/kafka-bridge.go +++ b/cmd/kafka-bridge.go @@ -16,11 +16,12 @@ limitations under the License. package cmd import ( + "log" + "github.com/IoTCLI/cmd/utils" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/apply" - "log" ) var ( @@ -37,7 +38,7 @@ func kafkaBridge() { //Get Nginix controller and apply to cluster co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml") co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/cloud-generic.yaml") - //Seutp the K8s ingress resource + //Setup the K8s ingress resource co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/ingress.yaml") @@ -61,6 +62,34 @@ func kafkaBridge() { log.Println("To check status of Kafka HTTP bridge run 'curl -v GET http://my-bridge.io/healthy'") } +func kafkaBridgeRoute() { + + co := utils.NewCommandOptions() + + //Setup kafka bridge + co.Commands = append(co.Commands, "/home/adkadam/work/golang/iot-dev/yamls/kafka/bridge/route.yaml") + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/kafka-bridge.yaml") + + IOStreams, _, out, _ := genericclioptions.NewTestIOStreams() + + co.SwitchContext(kafkaBridgeNamespaceFlag) + + //Reload config flags after switching context + + log.Println("Provision Kafka Http Bridge using route") + for _, command := range co.Commands { + cmd := apply.NewCmdApply("kubectl", co.CurrentFactory, IOStreams) + err := cmd.Flags().Set("filename", command) + if err != nil { + log.Fatal(err) + } + cmd.Run(cmd, []string{}) + log.Print(out.String()) + out.Reset() + } + log.Println("To check status of Kafka HTTP bridge run 'curl -v GET http://my-bridge.io/healthy'") +} + // bridgeCmd represents the bridge command var kafkaBridgeCmd = &cobra.Command{ Use: "bridge", @@ -72,8 +101,16 @@ Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { - log.Println("Kafka Http Bridge called") - kafkaBridge() + + fstatus, _ := cmd.Flags().GetBool("float") + if fstatus { // if status is true, call addFloat + log.Println("Kafka Http Bridge called using Ingress") + kafkaBridge() + } else { + log.Println("Kafka Http Bridge called using Route") + kafkaBridgeRoute() + } + }, } @@ -90,4 +127,6 @@ func init() { // is called directly, e.g.: // bridgeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") kafkaBridgeCmd.Flags().StringVarP(&kafkaBridgeNamespaceFlag, "namespace", "n", "kafka", "Option to specify namespace for kafka deletion, defaults to 'kafka'") + + kafkaBridgeCmd.Flags().BoolP("route", "r", false, "Setup kafka bridge using route, defaults to using ingress") } diff --git a/yamls/kafka/bridge/route.yaml b/yamls/kafka/bridge/route.yaml new file mode 100644 index 0000000..cb87b89 --- /dev/null +++ b/yamls/kafka/bridge/route.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Route +metadata: + name: my-bridge-route +spec: + host: my-bridge.io + to: + kind: Service + name: my-bridge-bridge-service + port: + targetPort: rest-api \ No newline at end of file From 420bd01d7e08618a63b3230cc79449f574b50db6 Mon Sep 17 00:00:00 2001 From: adi6496 Date: Wed, 6 May 2020 15:58:10 -0400 Subject: [PATCH 02/10] added bridge destroy , routes and local gstreamer --- cmd/kafka-bridge-destroy.go | 52 +++++++++++++++++++++++++++++++---- cmd/kafka-bridge.go | 2 ++ yamls/kafka/bridge/route.yaml | 2 +- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/cmd/kafka-bridge-destroy.go b/cmd/kafka-bridge-destroy.go index 02f049b..12c245a 100644 --- a/cmd/kafka-bridge-destroy.go +++ b/cmd/kafka-bridge-destroy.go @@ -28,6 +28,37 @@ var ( kafkaBridgeDestroyNamespaceFlag string ) +func kafkaBridgeRouteDestroy() { + + //Make command options for Kafka Setup + co := utils.NewCommandOptions() + + _ = utils.DownloadAndUncompress("oc.gz", "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz") + log.Println("oc Source folder: ", "oc") + + //Fill in the commands that must be applied to + co.Commands = append(co.Commands, "/home/adkadam/work/golang/iot-dev/yamls/kafka/bridge/route.yaml") + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/kafka-bridge.yaml") + + // + IOStreams, _, out, _ := genericclioptions.NewTestIOStreams() + + co.SwitchContext(kafkaBridgeDestroyNamespaceFlag) + + log.Println("Destroy Kafka Bridge with route from cluster") + for _, command := range co.Commands { + cmd := delete.NewCmdDelete(co.CurrentFactory, IOStreams) + err := cmd.Flags().Set("filename", command) + if err != nil { + log.Fatal(err) + } + cmd.Run(cmd, []string{}) + log.Print(out.String()) + out.Reset() + } + //Remove tempfile when done +} + func kafkaBridgeDestroy() { //Make command options for Kafka Setup @@ -47,7 +78,7 @@ func kafkaBridgeDestroy() { co.SwitchContext(kafkaBridgeDestroyNamespaceFlag) - log.Println("Destroy Kafka Bridge from cluster") + log.Println("Destroy Kafka Bridge with ingress from cluster") for _, command := range co.Commands { cmd := delete.NewCmdDelete(co.CurrentFactory, IOStreams) err := cmd.Flags().Set("filename", command) @@ -62,7 +93,7 @@ func kafkaBridgeDestroy() { } // destroyCmd represents the destroy command -var kafkaBridgedestroyCmd = &cobra.Command{ +var kafkaBridgeDestroyCmd = &cobra.Command{ Use: "destroy", Short: "A brief description of your command", Long: `A longer description that spans multiple lines and likely contains examples @@ -72,13 +103,19 @@ Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { - log.Println("Kafka bridge destroy called") - kafkaBridgeDestroy() + fstatus, _ := cmd.Flags().GetBool("float") + if fstatus { // if status is true, call addFloat + log.Println("Kafka Bridge Destroy called") + kafkaBridgeDestroy() + } else { + log.Println("Kafka Bridge Destroy called") + kafkaBridgeRouteDestroy() + } }, } func init() { - kafkaBridgeCmd.AddCommand(kafkaBridgedestroyCmd) + kafkaBridgeCmd.AddCommand(kafkaBridgeDestroyCmd) // Here you will define your flags and configuration settings. @@ -89,5 +126,8 @@ func init() { // Cobra supports local flags which will only run when this command // is called directly, e.g.: // destroyCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") - kafkaBridgedestroyCmd.Flags().StringVarP(&kafkaBridgeDestroyNamespaceFlag, "namespace", "n", "kafka", "Option to specify namespace for kafka deletion, defaults to 'kafka'") + + kafkaBridgeDestroyCmd.Flags().StringVarP(&kafkaBridgeDestroyNamespaceFlag, "namespace", "n", "kafka", "Option to specify namespace for kafka deletion, defaults to 'kafka'") + + kafkaBridgeDestroyCmd.Flags().BoolP("route", "r", false, "Destroy kafka bridge with route, defaults to destroying kafka bridge with ingress") } diff --git a/cmd/kafka-bridge.go b/cmd/kafka-bridge.go index aea3403..4b42b9d 100644 --- a/cmd/kafka-bridge.go +++ b/cmd/kafka-bridge.go @@ -79,6 +79,8 @@ func kafkaBridgeRoute() { log.Println("Provision Kafka Http Bridge using route") for _, command := range co.Commands { cmd := apply.NewCmdApply("kubectl", co.CurrentFactory, IOStreams) + //Kubectl signals missing field, set validate to false to ignore this + cmd.Flags().Set("validate", "false") err := cmd.Flags().Set("filename", command) if err != nil { log.Fatal(err) diff --git a/yamls/kafka/bridge/route.yaml b/yamls/kafka/bridge/route.yaml index cb87b89..6ce1073 100644 --- a/yamls/kafka/bridge/route.yaml +++ b/yamls/kafka/bridge/route.yaml @@ -1,4 +1,4 @@ -apiVersion: v1 +apiVersion: route.openshift.io/v1 kind: Route metadata: name: my-bridge-route From 08db4d7ffbbde59c3acbe1c5b3cbbdc66f4a2297 Mon Sep 17 00:00:00 2001 From: adi6496 <46605791+adi6496@users.noreply.github.com> Date: Wed, 6 May 2020 16:40:14 -0400 Subject: [PATCH 03/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1ea2e5..98aa397 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Persistent storage is implemented using [Ceph Object Storage](https://ceph.io/ce | ceph | destroy | None | None | None | Return user secrets for c | | ceph | secrets | None | None | None | Return user secrets for ceph deployment | | ceph | setup | None | None | None | Setup Ceph Object Storage via the Rook Operator | -| enmasse | destroy | None | None | None | Remove Enmasse from openshift cluster | +| enmasse | destroy | None | None | None | Remove Enmasse from openshift cluster | enmasse | IoT | addDevice | ``, `` | None | Add a Device with specified ID to the Enmasse device registry for a specified messaging TenantSetup default Credentials | | enmasse | IoT | project | None | --namespace | Make a new enmasse IoT project in the specified namespace, defaults to “myapp” | | enmasse | setup | None | None | None | Download Enmasse Source, store in current directory. Setup Enmasse Setup IoT services | From 72715355d8a4b904d3373de84f0567ee3931e877 Mon Sep 17 00:00:00 2001 From: adi6496 <46605791+adi6496@users.noreply.github.com> Date: Wed, 6 May 2020 16:52:44 -0400 Subject: [PATCH 04/10] Update README.md --- README.md | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 98aa397..9137f7c 100644 --- a/README.md +++ b/README.md @@ -82,24 +82,28 @@ Persistent storage is implemented using [Ceph Object Storage](https://ceph.io/ce ## Command Reference -| Command1 (Tool) | Command2(Module) | Command3(Module command) | Argument (module input) | Flags | Function | -|-------------------|------------------|--------------------------|------------------------------------|--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------| -| ceph | destroy | None | None | None | Return user secrets for c | -| ceph | secrets | None | None | None | Return user secrets for ceph deployment | -| ceph | setup | None | None | None | Setup Ceph Object Storage via the Rook Operator | -| enmasse | destroy | None | None | None | Remove Enmasse from openshift cluster -| enmasse | IoT | addDevice | ``, `` | None | Add a Device with specified ID to the Enmasse device registry for a specified messaging TenantSetup default Credentials | -| enmasse | IoT | project | None | --namespace | Make a new enmasse IoT project in the specified namespace, defaults to “myapp” | -| enmasse | setup | None | None | None | Download Enmasse Source, store in current directory. Setup Enmasse Setup IoT services | -| kafka | bridge | None | None | --namespace | Deploy kafka HTTP bridge Deploy nginx ingress to access bridge from outside the cluster (will be transitioned to a route) | -| kafka | destroy | None | None | --namespace | Destroy the kafka deployment located at the specified namespace | -| kafka | setup | None | None | --namespace | Setup a kafka cluster viat the strimzi operator at the specified namespace | -| knative | setup | None | None | --status=true/false | Setup Knative serverless on openshift clusterConfigures both Knative-Eventing and Knative-ServingSet --status=true to check on Knative deployment | -| knative | destroy | None | None | None | Remove Knative deployment from openshift cluster | -| knative | service | None | `` | --status=true/false--namespace | Deploy a knative service Set --status=true to check on Knative service deploymentDefault namespace is “knative-eventing” | -| knative | service | destroy | `` | --namespace | Remove a specified Knative service from the cluster at specified namespace Default namespace is “knative-eventing” | -| knative | source | None | `` `` | --namespace | Deploy a Knative Source at specified namespace Defaults to namespace “knative-eventing” | -| knative | source | destroy | `` | --namespace | Remove a specified knative source from the cluster from specified namespaceDefault namespace is “knative-eventing” | -| login | None | None | None | None | Login to your openshift cluster with the username and password | -| tensorflowServing | setup | None | None | --namespace | Deploy a tensorflow serving deployment and service Default namespace is “default” | -| tensorflowServing | destroy | None | None | --namesapce | Deploy a tensorflow serving deployment and serviceDefault namespace is “default” | +| Command1 (Tool) | Command2(Module) | Command3(Module command) | Argument (module input) | Flags | Function | +|-------------------|------------------|--------------------------|-------------------------------------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| | | | | | | +| ceph | destroy | None | None | None | Destroy the ceph object store instance on the cluster | +| ceph | user | None | `` | None | Create an Ceph Object Store User | +| ceph | secrets | None | `` | None | Return user secrets for ceph deployment | +| ceph | setup | None | None | None | Setup Ceph Object Storage via the Rook Operator | +| enmasse | destroy | None | None | None | Remove Enmasse from openshift cluster | +| enmasse | IoT | addDevice | ``, `` | None | Add a Device with specified ID to the Enmasse device registry for a specified messaging TenantSetup default Credentials | +| enmasse | IoT | project | None | --namespace | Make a new enmasse IoT project in the specified namespace, defaults to “myapp” | +| enmasse | setup | None | None | None | Download Enmasse Source, store in current directory. Setup Enmasse Setup IoT services | +| gstreamer | setup | None | None | --local=true/false | Deploy Gtsreamer with OpenVino Toolkit for video/audio streaming with analyticsSet local=True for deploying gstreamer locally | +| gstreamer | destroy | None | None | None | Destroy Gstreamer deployment | +| kafka | bridge | None | None | --namespace --route=true/false | Deploy kafka HTTP bridge Set route=True to deploy a route to access bridge from outside(only for Openshift Cluster)Default deploys nginx ingress to access bridge from outside the cluster | +| kafka | destroy | None | None | --namespace | Destroy the kafka deployment located at the specified namespace | +| kafka | setup | None | None | --namespace | Setup a kafka cluster viat the strimzi operator at the specified namespace | +| knative | setup | None | None | --status=true/false | Setup Knative serverless on openshift clusterConfigures both Knative-Eventing and Knative-ServingSet --status=true to check on Knative deployment | +| knative | destroy | None | None | None | Remove Knative deployment from openshift cluster | +| knative | service | None | `` | --status=true/false--namespace | Deploy a knative service Set --status=true to check on Knative service deploymentDefault namespace is “knative-eventing” | +| knative | service | destroy | `` | --namespace | Remove a specified Knative service from the cluster at specified namespace Default namespace is “knative-eventing” | +| knative | source | None | `` | --namespace | Deploy a Knative Source at specified namespace Defaults to namespace “knative-eventing” | +| knative | source | destroy | `` | --namespace | Remove a specified knative source from the cluster from specified namespaceDefault namespace is “knative-eventing” | +| login | None | None | None | None | Login to your openshift cluster with the username and password | +| tensorflowServing | setup | None | None | --namespace | Deploy a tensorflow serving deployment and service Default namespace is “default” | +| tensorflowServing | destroy | None | None | --namesapce | Deploy a tensorflow serving deployment and serviceDefault namespace is “default” | From 4d400b8e63b67d8aec51c6311f42eb6bd5bd5a5d Mon Sep 17 00:00:00 2001 From: adi6496 Date: Wed, 6 May 2020 19:06:16 -0400 Subject: [PATCH 05/10] Added help messages to all the commands --- cmd/ceph-destroy.go | 5 +++-- cmd/ceph-secrets.go | 5 +++-- cmd/ceph-setup.go | 7 ++++--- cmd/ceph.go | 9 ++------- cmd/enmasse-IoT-addDevice.go | 6 ++++-- cmd/enmasse-IoT-project.go | 6 ++---- cmd/enmasse-IoT.go | 2 +- cmd/enmasse-destroy.go | 2 +- cmd/enmasse-setup.go | 2 +- cmd/enmasse.go | 2 +- cmd/gstreamer-destroy.go | 2 +- cmd/gstreamer-setup.go | 13 ++++++------- cmd/gstreamer.go | 2 +- cmd/kafka-bridge-destroy.go | 10 +++++----- cmd/kafka-bridge.go | 10 +++++----- cmd/kafka-destroy.go | 11 +++++++---- cmd/kafka.go | 2 +- cmd/knative-destroy.go | 5 +++-- cmd/knative-service.go | 11 ++++++----- cmd/knative-setup.go | 8 +++++--- cmd/knative-source-destroy.go | 3 ++- cmd/knative.go | 2 +- cmd/login.go | 9 +++++---- cmd/root.go | 13 +++++-------- cmd/tensorflowServing-destroy.go | 5 +++-- cmd/tensorflowServing-setup.go | 5 +++-- cmd/tensorflowServing.go | 2 +- 27 files changed, 82 insertions(+), 77 deletions(-) diff --git a/cmd/ceph-destroy.go b/cmd/ceph-destroy.go index 985a671..aaccb8c 100644 --- a/cmd/ceph-destroy.go +++ b/cmd/ceph-destroy.go @@ -16,11 +16,12 @@ limitations under the License. package cmd import ( + "log" + "github.com/IoTCLI/cmd/utils" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/delete" - "log" //"time" ) @@ -63,7 +64,7 @@ func cephDestroy() { // destroyCmd represents the destroy command var cephDestroyCmd = &cobra.Command{ Use: "destroy", - Short: "A brief description of your command", + Short: "Destroy the Ceph cluster", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/ceph-secrets.go b/cmd/ceph-secrets.go index 03766b7..e0b96ee 100644 --- a/cmd/ceph-secrets.go +++ b/cmd/ceph-secrets.go @@ -16,11 +16,12 @@ limitations under the License. package cmd import ( + "log" + "github.com/IoTCLI/cmd/utils" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/get" - "log" ) func getCredentials() { @@ -44,7 +45,7 @@ func getCredentials() { // secretsCmd represents the secrets command var cephSecretsCmd = &cobra.Command{ Use: "secrets", - Short: "A brief description of your command", + Short: "Get S3 secrets from ceph object storage", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/ceph-setup.go b/cmd/ceph-setup.go index 6a64e05..dd723c0 100644 --- a/cmd/ceph-setup.go +++ b/cmd/ceph-setup.go @@ -16,13 +16,14 @@ limitations under the License. package cmd import ( + "log" + "time" + "github.com/IoTCLI/cmd/utils" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/apply" "k8s.io/kubectl/pkg/cmd/get" - "log" - "time" ) //Made from Instructions @https://opendatahub.io/docs/administration/advanced-installation/object-storage.html for installing @@ -96,7 +97,7 @@ func cephSetup() { // setupCmd represents the setup command var cephSetupCmd = &cobra.Command{ Use: "setup", - Short: "A brief description of your command", + Short: "Setup Ceph Object storage", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/ceph.go b/cmd/ceph.go index b190e6a..4a79005 100644 --- a/cmd/ceph.go +++ b/cmd/ceph.go @@ -24,13 +24,8 @@ import ( // cephCmd represents the ceph command var cephCmd = &cobra.Command{ Use: "ceph", - Short: "A brief description of your command", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, + Short: "Deploy Ceph object storage", + Long: `Deploy Ceph object storage`, Run: func(cmd *cobra.Command, args []string) { fmt.Println("ceph called") }, diff --git a/cmd/enmasse-IoT-addDevice.go b/cmd/enmasse-IoT-addDevice.go index 3fad0a4..16ff252 100644 --- a/cmd/enmasse-IoT-addDevice.go +++ b/cmd/enmasse-IoT-addDevice.go @@ -21,13 +21,15 @@ import ( //"os" "bytes" "crypto/tls" - "github.com/spf13/cobra" "net/http" "strings" + "github.com/spf13/cobra" + //in package import "github.com/IoTCLI/cmd/utils" "k8s.io/cli-runtime/pkg/genericclioptions" + //"k8s.io/kubectl/pkg/cmd/" "k8s.io/kubectl/pkg/cmd/get" ) @@ -113,7 +115,7 @@ func device(tenant string, deviceID string) { // addDeviceCmd represents the addDevice command var addDeviceCmd = &cobra.Command{ Use: "addDevice", - Short: "A brief description of your command", + Short: "Add an IoT device to enmasse", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/enmasse-IoT-project.go b/cmd/enmasse-IoT-project.go index 0ec53b6..fa94d1b 100644 --- a/cmd/enmasse-IoT-project.go +++ b/cmd/enmasse-IoT-project.go @@ -23,10 +23,8 @@ import ( "strings" "time" - "github.com/spf13/cobra" - - //in package import "github.com/IoTCLI/cmd/utils" + "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/apply" "k8s.io/kubectl/pkg/cmd/get" @@ -118,7 +116,7 @@ func createProject() { // projectCmd represents the project command var enmasseIoTProjectCmd = &cobra.Command{ Use: "project", - Short: "A brief description of your command", + Short: "Setup enmasse project", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/enmasse-IoT.go b/cmd/enmasse-IoT.go index 67aece6..e4c3fb8 100644 --- a/cmd/enmasse-IoT.go +++ b/cmd/enmasse-IoT.go @@ -24,7 +24,7 @@ import ( // IoTCmd represents the IoT command var enmasseIoTCmd = &cobra.Command{ Use: "IoT", - Short: "A brief description of your command", + Short: "Setup Enmasse IoT project", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/enmasse-destroy.go b/cmd/enmasse-destroy.go index 9232af0..b7d32f8 100644 --- a/cmd/enmasse-destroy.go +++ b/cmd/enmasse-destroy.go @@ -57,7 +57,7 @@ func enmasseDestroy() { // destroyCmd represents the destroy command var enmasseDestroyCmd = &cobra.Command{ Use: "destroy", - Short: "A brief description of your command", + Short: "Destroy enmasse project", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/enmasse-setup.go b/cmd/enmasse-setup.go index b87646f..04a768e 100644 --- a/cmd/enmasse-setup.go +++ b/cmd/enmasse-setup.go @@ -94,7 +94,7 @@ func enmasseSetup() { // setupCmd represents the setup command var enmasseSetupCmd = &cobra.Command{ Use: "setup", - Short: "A brief description of your command", + Short: "Setup Enmasse as a messaging backend", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/enmasse.go b/cmd/enmasse.go index 84dd526..8c40127 100644 --- a/cmd/enmasse.go +++ b/cmd/enmasse.go @@ -24,7 +24,7 @@ import ( // enmasseCmd represents the enmasse command var enmasseCmd = &cobra.Command{ Use: "enmasse", - Short: "A brief description of your command", + Short: "Setup Enmasse as a messaging backend", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/gstreamer-destroy.go b/cmd/gstreamer-destroy.go index 1ffbc0c..3617a97 100644 --- a/cmd/gstreamer-destroy.go +++ b/cmd/gstreamer-destroy.go @@ -57,7 +57,7 @@ func gstreamerDestroy() { // destroyCmd represents the destroy command var gstreamerDestroyCmd = &cobra.Command{ Use: "destroy", - Short: "A brief description of your command", + Short: "Destroy gstreamer deployment", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/gstreamer-setup.go b/cmd/gstreamer-setup.go index 80858c0..037a218 100644 --- a/cmd/gstreamer-setup.go +++ b/cmd/gstreamer-setup.go @@ -29,7 +29,7 @@ import ( // setupCmd represents the setup command var gstreamerSetupCmd = &cobra.Command{ Use: "setup", - Short: "A brief description of your command", + Short: "Setup Gstreamer with Openvino toolkit for video streaming and analytics", Long: `A longer descriptSion that spans multiple lines and likely contains examples and usage of using your command. For example: @@ -37,13 +37,12 @@ Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println(" gstreamer setup called") - fstatus, _ := cmd.Flags().GetBool("float") - if fstatus { // if status is true, call addFloat - gstreamerSetup() - } else { - log.Println("a") + fmt.Println("Gstreamer setup called") + fstatus, _ := cmd.Flags().GetBool("local") + if fstatus { // if status is true, gstreamerLocalSetup() + } else { + gstreamerSetup() } }, } diff --git a/cmd/gstreamer.go b/cmd/gstreamer.go index 4cec986..610ec37 100644 --- a/cmd/gstreamer.go +++ b/cmd/gstreamer.go @@ -25,7 +25,7 @@ import ( // gstreamerCmd represents the gstreamer command var gstreamerCmd = &cobra.Command{ Use: "gstreamer", - Short: "A brief description of your command", + Short: "Setup Gstreamer with OpenVino toolkit for video streaming with analytics ", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/kafka-bridge-destroy.go b/cmd/kafka-bridge-destroy.go index 12c245a..5ae4309 100644 --- a/cmd/kafka-bridge-destroy.go +++ b/cmd/kafka-bridge-destroy.go @@ -95,7 +95,7 @@ func kafkaBridgeDestroy() { // destroyCmd represents the destroy command var kafkaBridgeDestroyCmd = &cobra.Command{ Use: "destroy", - Short: "A brief description of your command", + Short: "Destory the Kafka Bridge", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: @@ -103,13 +103,13 @@ Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { - fstatus, _ := cmd.Flags().GetBool("float") - if fstatus { // if status is true, call addFloat + fstatus, _ := cmd.Flags().GetBool("route") + if fstatus { // if status is true, call Kafka bridge destroy with route log.Println("Kafka Bridge Destroy called") - kafkaBridgeDestroy() + kafkaBridgeRouteDestroy() } else { log.Println("Kafka Bridge Destroy called") - kafkaBridgeRouteDestroy() + kafkaBridgeDestroy() } }, } diff --git a/cmd/kafka-bridge.go b/cmd/kafka-bridge.go index 4b42b9d..ce0bf58 100644 --- a/cmd/kafka-bridge.go +++ b/cmd/kafka-bridge.go @@ -95,7 +95,7 @@ func kafkaBridgeRoute() { // bridgeCmd represents the bridge command var kafkaBridgeCmd = &cobra.Command{ Use: "bridge", - Short: "A brief description of your command", + Short: "Setup Kafka bridge to send data over to the Kafka cluster", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: @@ -104,13 +104,13 @@ This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { - fstatus, _ := cmd.Flags().GetBool("float") + fstatus, _ := cmd.Flags().GetBool("route") if fstatus { // if status is true, call addFloat - log.Println("Kafka Http Bridge called using Ingress") - kafkaBridge() - } else { log.Println("Kafka Http Bridge called using Route") kafkaBridgeRoute() + } else { + log.Println("Kafka Http Bridge called using Ingress") + kafkaBridge() } }, diff --git a/cmd/kafka-destroy.go b/cmd/kafka-destroy.go index 30dfc1f..9932f71 100644 --- a/cmd/kafka-destroy.go +++ b/cmd/kafka-destroy.go @@ -16,11 +16,12 @@ limitations under the License. package cmd import ( + "log" + "github.com/IoTCLI/cmd/utils" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/delete" - "log" ) var ( @@ -39,8 +40,10 @@ func kafkaDestroy() { co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/setup/kafka.yaml") co.Commands = append(co.Commands, "https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.17.0/strimzi-cluster-operator-0.17.0.yaml") co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/setup/kafka-namespace.yaml") - co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml") - co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/cloud-generic.yaml") + + //Destroying kafka + // co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml") + // co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/cloud-generic.yaml") // IOStreams, _, out, _ := genericclioptions.NewTestIOStreams() @@ -63,7 +66,7 @@ func kafkaDestroy() { // destroyCmd represents the destroy command var kafkaDestroyCmd = &cobra.Command{ Use: "destroy", - Short: "A brief description of your command", + Short: "Destroy the Kafka cluster along with Strimzi operator", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/kafka.go b/cmd/kafka.go index 7b64987..965e842 100644 --- a/cmd/kafka.go +++ b/cmd/kafka.go @@ -24,7 +24,7 @@ import ( // kafkaCmd represents the kafka command var kafkaCmd = &cobra.Command{ Use: "kafka", - Short: "A brief description of your command", + Short: "Setup kafka as the messaging backend", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/knative-destroy.go b/cmd/knative-destroy.go index fc287bc..78eebc0 100644 --- a/cmd/knative-destroy.go +++ b/cmd/knative-destroy.go @@ -24,6 +24,7 @@ import ( //in package import "github.com/IoTCLI/cmd/utils" "k8s.io/cli-runtime/pkg/genericclioptions" + //"k8s.io/kubectl/pkg/cmd/" "k8s.io/kubectl/pkg/cmd/delete" ) @@ -76,7 +77,7 @@ func destroyKnative() { // destroyCmd represents the destroy command var knativeDestroyCmd = &cobra.Command{ Use: "destroy", - Short: "A brief description of your command", + Short: "Destroy Knative serving and eventing", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: @@ -84,7 +85,7 @@ Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { - log.Println("destroy called") + log.Println("knative destroy called") destroyKnative() }, } diff --git a/cmd/knative-service.go b/cmd/knative-service.go index caf2136..6bc0591 100644 --- a/cmd/knative-service.go +++ b/cmd/knative-service.go @@ -17,15 +17,16 @@ package cmd import ( b64 "encoding/base64" + "io/ioutil" + "log" + "os" + "strings" + "github.com/IoTCLI/cmd/utils" "github.com/spf13/cobra" - "io/ioutil" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/apply" "k8s.io/kubectl/pkg/cmd/get" - "log" - "os" - "strings" ) var ( @@ -197,7 +198,7 @@ func logs(name string) { // serviceCmd represents the service command var knativeServiceCmd = &cobra.Command{ Use: "service", - Short: "A brief description of your command", + Short: "Setup Knative service for video analtytics", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/knative-setup.go b/cmd/knative-setup.go index 7a5d13c..9166664 100644 --- a/cmd/knative-setup.go +++ b/cmd/knative-setup.go @@ -24,11 +24,13 @@ import ( //in package import "github.com/IoTCLI/cmd/utils" "k8s.io/cli-runtime/pkg/genericclioptions" + //"k8s.io/kubectl/pkg/cmd/" - "k8s.io/kubectl/pkg/cmd/apply" - "k8s.io/kubectl/pkg/cmd/get" "strings" "time" + + "k8s.io/kubectl/pkg/cmd/apply" + "k8s.io/kubectl/pkg/cmd/get" ) //var setupStatus = false @@ -202,7 +204,7 @@ func knativeStatus() { // setupCmd represents the setup command var knativeSetupCmd = &cobra.Command{ Use: "setup", - Short: "A brief description of your command", + Short: "Setup Knative serving and eventing for serverless application", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/knative-source-destroy.go b/cmd/knative-source-destroy.go index c3e8e69..95d7146 100644 --- a/cmd/knative-source-destroy.go +++ b/cmd/knative-source-destroy.go @@ -25,6 +25,7 @@ import ( //in package import "github.com/IoTCLI/cmd/utils" "k8s.io/cli-runtime/pkg/genericclioptions" + //"k8s.io/kubectl/pkg/cmd/" "k8s.io/kubectl/pkg/cmd/delete" ) @@ -67,7 +68,7 @@ func desContainerSource(source string) { // destroyCmd represents the destroy command var knativeSourceDestroyCmd = &cobra.Command{ Use: "destroy", - Short: "A brief description of your command", + Short: "Destroy Knative Source eployment", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/knative.go b/cmd/knative.go index e74fc0a..9802418 100644 --- a/cmd/knative.go +++ b/cmd/knative.go @@ -24,7 +24,7 @@ import ( // knativeCmd represents the knative command var knativeCmd = &cobra.Command{ Use: "knative", - Short: "A brief description of your command", + Short: "Setup Knative serving and eventing for serverless application", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/login.go b/cmd/login.go index a15784e..a2a7167 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -17,12 +17,13 @@ package cmd import ( "fmt" - "github.com/IoTCLI/cmd/utils" - "github.com/spf13/cobra" - "golang.org/x/crypto/ssh/terminal" "log" "os" "os/exec" + + "github.com/IoTCLI/cmd/utils" + "github.com/spf13/cobra" + "golang.org/x/crypto/ssh/terminal" ) func login() { @@ -56,7 +57,7 @@ func login() { // loginCmd represents the login command var loginCmd = &cobra.Command{ Use: "login", - Short: "A brief description of your command", + Short: "Login to the Openshift Cluster", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/root.go b/cmd/root.go index ad836c6..a170f19 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,9 +17,10 @@ package cmd import ( "fmt" - "github.com/spf13/cobra" "os" + "github.com/spf13/cobra" + homedir "github.com/mitchellh/go-homedir" "github.com/spf13/viper" ) @@ -29,13 +30,9 @@ var cfgFile string // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "IoTCLI", - Short: "A brief description of your application", - Long: `A longer description that spans multiple lines and likely contains -examples and usage of using your application. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, + Short: "Setting up Cloud native Egde Applications with various messaging backends", + Long: `Setting up Cloud native Egde Applications with various messaging backends. +Allows user to track the IoTDevices, setup various messaging backends like Kafka or Enmasse, deploy gstreamer analytics as smart edge device etc`, // Uncomment the following line if your bare application // has an action associated with it: // Run: func(cmd *cobra.Command, args []string) { }, diff --git a/cmd/tensorflowServing-destroy.go b/cmd/tensorflowServing-destroy.go index 72655f6..acd3b52 100644 --- a/cmd/tensorflowServing-destroy.go +++ b/cmd/tensorflowServing-destroy.go @@ -16,11 +16,12 @@ limitations under the License. package cmd import ( + "log" + "github.com/IoTCLI/cmd/utils" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/delete" - "log" ) func tensorflowServingDestroy() { @@ -52,7 +53,7 @@ func tensorflowServingDestroy() { // tensorflowServingDestroyCmd represents the tensorflowServingDestroy command var tensorflowServingDestroyCmd = &cobra.Command{ Use: "destroy", - Short: "A brief description of your command", + Short: "Destroy the deployed tensorflow service", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/tensorflowServing-setup.go b/cmd/tensorflowServing-setup.go index f81fc8b..442545d 100644 --- a/cmd/tensorflowServing-setup.go +++ b/cmd/tensorflowServing-setup.go @@ -16,11 +16,12 @@ limitations under the License. package cmd import ( + "log" + "github.com/IoTCLI/cmd/utils" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/apply" - "log" ) func tensorflowServingSetup() { @@ -51,7 +52,7 @@ func tensorflowServingSetup() { // tensorflowServingSetupCmd represents the tensorflowServingSetup command var tensorflowServingSetupCmd = &cobra.Command{ Use: "setup", - Short: "A brief description of your command", + Short: "Setup tensorflow service for analtyics", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: diff --git a/cmd/tensorflowServing.go b/cmd/tensorflowServing.go index ae9a49e..e022a4c 100644 --- a/cmd/tensorflowServing.go +++ b/cmd/tensorflowServing.go @@ -28,7 +28,7 @@ var ( // tensorflowServingCmd represents the tensorflowServing command var tensorflowServingCmd = &cobra.Command{ Use: "tensorflowServing", - Short: "A brief description of your command", + Short: "Setup a tensorflow service for analytics", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: From 27f0b4ddb3ed89d82a3d2c333a355d6ee83f92a1 Mon Sep 17 00:00:00 2001 From: adi6496 <46605791+adi6496@users.noreply.github.com> Date: Wed, 6 May 2020 19:15:47 -0400 Subject: [PATCH 06/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9137f7c..2411ce9 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Persistent storage is implemented using [Ceph Object Storage](https://ceph.io/ce ### On Edge #### Gstreamer - Gstreamer AI plugin to run analytics on low resource devices @Aditya +Gstreamer is an open source multimedia framework for managing media files and real time streaming using camera. This project leverages gstreamer capabilities with CNN model based enchanced analytics from OpenVino toolkit by Intel. This can be used to perform HLS video streaming with various use cases such as object detection, classification, recognition and tracking. #### TensorFlow lite From 5068e8b082cbc1a648336bfa42f01aa3fdd5d155 Mon Sep 17 00:00:00 2001 From: adi6496 Date: Wed, 13 May 2020 13:57:09 -0400 Subject: [PATCH 07/10] Gstreamer Setup changed to MOV files --- cmd/gstreamer-setup.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/cmd/gstreamer-setup.go b/cmd/gstreamer-setup.go index eefcec1..3be29c1 100644 --- a/cmd/gstreamer-setup.go +++ b/cmd/gstreamer-setup.go @@ -58,14 +58,27 @@ func gstreamerLocalSetup() { log.Println(string(out)) } - cmd2 := exec.Command("docker exec python3 /root/gst-video-analytics/samples/python/playlist_sender.py") - out2, error2 := cmd2.Output() - if error2 != nil { - println(error2.Error()) - return - } else { - log.Println(string(out2)) + for { + fmt.Print("Press 'S' to stop the Gstreamer container: ") + var key string + fmt.Scanln(&key) + + if key == "s" { + cmd2 := exec.Command("/bin/sh", "-c", " docker kill gstreamer_launch_2") + out2, error2 := cmd2.Output() + if error2 != nil { + println(error2.Error()) + return + } else { + log.Println(string(out2)) + } + fmt.Print("Container stopped: ") + + break + + } } + } func gstreamerSetup() { From da1d1fc746810c647fc14ac6f4cb30a85fc9a545 Mon Sep 17 00:00:00 2001 From: adi6496 Date: Wed, 13 May 2020 19:42:49 -0400 Subject: [PATCH 08/10] Removed Gst-launch --- cmd/app/gst-launch.py | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 cmd/app/gst-launch.py diff --git a/cmd/app/gst-launch.py b/cmd/app/gst-launch.py deleted file mode 100644 index 0c11cf8..0000000 --- a/cmd/app/gst-launch.py +++ /dev/null @@ -1,9 +0,0 @@ - -def main(): - - a = 1 - b = 2 - - print(a+b) - -main() From 493675032daae1e23a8b9c2d1e99ea0f3b80ca00 Mon Sep 17 00:00:00 2001 From: adi6496 Date: Wed, 13 May 2020 20:02:26 -0400 Subject: [PATCH 09/10] Cleaned --- cmd/ceph-destroy.go | 6 ------ cmd/ceph-secrets.go | 2 -- cmd/ceph-setup.go | 5 ----- cmd/ceph-user.go | 7 ++++--- cmd/gstreamer-setup.go | 2 +- cmd/gstreamer.go | 1 + cmd/kafka-bridge-destroy.go | 5 +---- cmd/kafka-bridge.go | 32 -------------------------------- cmd/kafka-destroy.go | 5 ----- cmd/knative-service.go | 3 --- cmd/knative-setup.go | 3 ++- cmd/login.go | 4 ---- 12 files changed, 9 insertions(+), 66 deletions(-) diff --git a/cmd/ceph-destroy.go b/cmd/ceph-destroy.go index ed19cc5..7ce163c 100644 --- a/cmd/ceph-destroy.go +++ b/cmd/ceph-destroy.go @@ -16,17 +16,11 @@ limitations under the License. package cmd import ( - "log" - "github.com/IoTCLI/cmd/utils" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/delete" -<<<<<<< HEAD - //"time" -======= ->>>>>>> 9809cb2abeca22b5ed2c28099b35ee268a52029c ) //Made from Instructions @https://opendatahub.io/docs/administration/advanced-installation/object-storage.html for installing diff --git a/cmd/ceph-secrets.go b/cmd/ceph-secrets.go index 6912c05..c4cb3d6 100644 --- a/cmd/ceph-secrets.go +++ b/cmd/ceph-secrets.go @@ -16,8 +16,6 @@ limitations under the License. package cmd import ( - "log" - "github.com/IoTCLI/cmd/utils" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/cmd/ceph-setup.go b/cmd/ceph-setup.go index a3cc792..15075b7 100644 --- a/cmd/ceph-setup.go +++ b/cmd/ceph-setup.go @@ -16,7 +16,6 @@ limitations under the License. package cmd import ( - "log" "time" "github.com/IoTCLI/cmd/utils" @@ -25,10 +24,6 @@ import ( "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/apply" "k8s.io/kubectl/pkg/cmd/get" -<<<<<<< HEAD -======= - "time" ->>>>>>> 9809cb2abeca22b5ed2c28099b35ee268a52029c ) //Made from Instructions @https://opendatahub.io/docs/administration/advanced-installation/object-storage.html for installing diff --git a/cmd/ceph-user.go b/cmd/ceph-user.go index 82a0aba..803f1a3 100644 --- a/cmd/ceph-user.go +++ b/cmd/ceph-user.go @@ -16,13 +16,14 @@ limitations under the License. package cmd import ( + "io/ioutil" + "os" + "github.com/IoTCLI/cmd/utils" + log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "io/ioutil" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/apply" - "log" - "os" ) func cephUser(user string) { diff --git a/cmd/gstreamer-setup.go b/cmd/gstreamer-setup.go index 083734d..9100615 100644 --- a/cmd/gstreamer-setup.go +++ b/cmd/gstreamer-setup.go @@ -38,7 +38,7 @@ Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("Gstreamer setup called") + log.Println("Gstreamer setup called") fstatus, _ := cmd.Flags().GetBool("local") if fstatus { // if status is true, gstreamerLocalSetup() diff --git a/cmd/gstreamer.go b/cmd/gstreamer.go index 5d1d014..53368b3 100644 --- a/cmd/gstreamer.go +++ b/cmd/gstreamer.go @@ -17,6 +17,7 @@ package cmd import ( "fmt" + "github.com/spf13/cobra" ) diff --git a/cmd/kafka-bridge-destroy.go b/cmd/kafka-bridge-destroy.go index 5ae4309..9e13004 100644 --- a/cmd/kafka-bridge-destroy.go +++ b/cmd/kafka-bridge-destroy.go @@ -33,11 +33,8 @@ func kafkaBridgeRouteDestroy() { //Make command options for Kafka Setup co := utils.NewCommandOptions() - _ = utils.DownloadAndUncompress("oc.gz", "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz") - log.Println("oc Source folder: ", "oc") - //Fill in the commands that must be applied to - co.Commands = append(co.Commands, "/home/adkadam/work/golang/iot-dev/yamls/kafka/bridge/route.yaml") + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/route.yaml") co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/kafka-bridge.yaml") // diff --git a/cmd/kafka-bridge.go b/cmd/kafka-bridge.go index 4d0754d..bc10c31 100644 --- a/cmd/kafka-bridge.go +++ b/cmd/kafka-bridge.go @@ -16,8 +16,6 @@ limitations under the License. package cmd import ( - "log" - "github.com/IoTCLI/cmd/utils" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -92,36 +90,6 @@ func kafkaBridge() { log.Println("To check status of Kafka HTTP bridge run 'curl -v GET http://my-bridge.io/healthy'") } -func kafkaBridgeRoute() { - - co := utils.NewCommandOptions() - - //Setup kafka bridge - co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/route.yaml") - co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/kafka-bridge.yaml") - - IOStreams, _, out, _ := genericclioptions.NewTestIOStreams() - - co.SwitchContext(kafkaBridgeNamespaceFlag) - - //Reload config flags after switching context - - log.Println("Provision Kafka Http Bridge using route") - for _, command := range co.Commands { - cmd := apply.NewCmdApply("kubectl", co.CurrentFactory, IOStreams) - //Kubectl signals missing field, set validate to false to ignore this - cmd.Flags().Set("validate", "false") - err := cmd.Flags().Set("filename", command) - if err != nil { - log.Fatal(err) - } - cmd.Run(cmd, []string{}) - log.Print(out.String()) - out.Reset() - } - log.Println("To check status of Kafka HTTP bridge run 'curl -v GET http://my-bridge.io/healthy'") -} - // bridgeCmd represents the bridge command var kafkaBridgeCmd = &cobra.Command{ Use: "bridge", diff --git a/cmd/kafka-destroy.go b/cmd/kafka-destroy.go index 337a28d..3c116e5 100644 --- a/cmd/kafka-destroy.go +++ b/cmd/kafka-destroy.go @@ -16,8 +16,6 @@ limitations under the License. package cmd import ( - "log" - "github.com/IoTCLI/cmd/utils" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -34,9 +32,6 @@ func kafkaDestroy() { //Make command options for Kafka Setup co := utils.NewCommandOptions() - _ = utils.DownloadAndUncompress("oc.gz", "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz") - log.Println("oc Source folder: ", "oc") - //Fill in the commands that must be applied to co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/setup/kafka.yaml") co.Commands = append(co.Commands, "https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.17.0/strimzi-cluster-operator-0.17.0.yaml") diff --git a/cmd/knative-service.go b/cmd/knative-service.go index 09a5422..d7b4281 100644 --- a/cmd/knative-service.go +++ b/cmd/knative-service.go @@ -21,9 +21,6 @@ import ( "os" "strings" - "os" - "strings" - "github.com/IoTCLI/cmd/utils" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/cmd/knative-setup.go b/cmd/knative-setup.go index afac6cf..964fea4 100644 --- a/cmd/knative-setup.go +++ b/cmd/knative-setup.go @@ -16,9 +16,10 @@ limitations under the License. package cmd import ( - log "github.com/sirupsen/logrus" "strconv" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" //in package import diff --git a/cmd/login.go b/cmd/login.go index 2afdda8..4512182 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -24,10 +24,6 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "golang.org/x/crypto/ssh/terminal" - - "github.com/IoTCLI/cmd/utils" - "github.com/spf13/cobra" - "golang.org/x/crypto/ssh/terminal" ) func login() { From 6b629b6f26eb295e3459fa7cc2d9311ccafa8f39 Mon Sep 17 00:00:00 2001 From: adi6496 Date: Wed, 13 May 2020 20:06:38 -0400 Subject: [PATCH 10/10] Gstreamer Setup --- cmd/gstreamer-setup.go | 2 +- {yamls => scripts}/gstreamer/startup.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {yamls => scripts}/gstreamer/startup.sh (100%) diff --git a/cmd/gstreamer-setup.go b/cmd/gstreamer-setup.go index 9100615..61e7969 100644 --- a/cmd/gstreamer-setup.go +++ b/cmd/gstreamer-setup.go @@ -50,7 +50,7 @@ to quickly create a Cobra application.`, func gstreamerLocalSetup() { - cmd := exec.Command("https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/gstreamer/startup.sh") + cmd := exec.Command("https://raw.githubusercontent.com/redhat-iot/iot-dev/master/scripts/gstreamer/startup.sh") out, error := cmd.Output() if error != nil { println(error.Error()) diff --git a/yamls/gstreamer/startup.sh b/scripts/gstreamer/startup.sh similarity index 100% rename from yamls/gstreamer/startup.sh rename to scripts/gstreamer/startup.sh