Skip to content

Commit

Permalink
Update Readme for Ceph user command
Browse files Browse the repository at this point in the history
  • Loading branch information
astoycos committed May 5, 2020
1 parent 5f4175c commit 619982c
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 21 deletions.
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,25 @@ 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 | `<Messaging Tenant>`, `<DeviceID>` | 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 | `<Knative service to be deployed>` | --status=true/false--namespace | Deploy a knative service Set --status=true to check on Knative service deploymentDefault namespace is “knative-eventing” |
| knative | service | destroy | `<Knative service to be destroyed>` | --namespace | Remove a specified Knative service from the cluster at specified namespace Default namespace is “knative-eventing” |
| knative | source | None | `<containersource to be deployed>` `<sink for the source>` | --namespace | Deploy a Knative Source at specified namespace Defaults to namespace “knative-eventing” |
| knative | source | destroy | `<containersource to be destroyed>` | --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 | `<User Name>` | None | Create an Ceph Object Store User |
| ceph | secrets | None | `<User Name>` | 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 | `<Messaging Tenant>`, `<DeviceID>` | 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 | `<Knative service to be deployed>` | --status=true/false--namespace | Deploy a knative service Set --status=true to check on Knative service deploymentDefault namespace is “knative-eventing” |
| knative | service | destroy | `<Knative service to be destroyed>` | --namespace | Remove a specified Knative service from the cluster at specified namespace Default namespace is “knative-eventing” |
| knative | source | None | `<containersource to be deployed>` | --namespace | Deploy a Knative Source at specified namespace Defaults to namespace “knative-eventing” |
| knative | source | destroy | `<containersource to be destroyed>` | --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” |
101 changes: 101 additions & 0 deletions cmd/ceph-user.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
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 (
"github.com/IoTCLI/cmd/utils"
"github.com/spf13/cobra"
"io/ioutil"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/kubectl/pkg/cmd/apply"
"log"
"os"
)

func cephUser(user string) {
co := utils.NewCommandOptions()

co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/object-user.yaml")

IOStreams, _, out, _ := genericclioptions.NewTestIOStreams()

//Switch Context and Reload Config Flags
co.SwitchContext("rook-ceph")

tmpFile, err := ioutil.TempFile(os.TempDir(), "service-")
if err != nil {
log.Fatal("Cannot create temporary file", err)
}
defer os.Remove(tmpFile.Name())

sedCommands := []string{`s/name: .*/name: ` + user + `/`, `s/displayName: .*/displayName: "` + user + `"/`}

myOutput := utils.RemoteSed(sedCommands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/object-user.yaml")

//Write updated yaml to tempfile
tmpFile.Write(myOutput.Bytes())
log.Println("the Source file: ", myOutput.String())
//Close Tempfile after writing
if err := tmpFile.Close(); err != nil {
log.Fatal(err)
}
co.Commands = append(co.Commands, tmpFile.Name())

log.Println("Provision Ceph User")
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()
}

}

// userCmd represents the user command
var userCmd = &cobra.Command{
Use: "user",
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("user called")
cephUser(args[0])
},
}

func init() {
cephCmd.AddCommand(userCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// userCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// userCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

0 comments on commit 619982c

Please sign in to comment.