From: abhijit_onap Date: Wed, 13 May 2020 19:41:58 +0000 (+0530) Subject: Added files for CLI Commands X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;ds=sidebyside;h=440ecbc2b907e160a5eef66b04329a06e1aae2c6;p=ealt-edge.git Added files for CLI Commands Added CLI Commands for Application Deployment and Application Lifecycle Management Signed-off-by: abhijit_onap Change-Id: I5dab23773cb9def5358f92091e30bfdfbe93b503 --- diff --git a/ocd/cli/ealt/cmd/app.go b/ocd/cli/ealt/cmd/app.go new file mode 100644 index 0000000..49bec5d --- /dev/null +++ b/ocd/cli/ealt/cmd/app.go @@ -0,0 +1,42 @@ +/* +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 ( + "fmt" + + appCmds "ealt/cmd/appm" + + "github.com/spf13/cobra" +) + +// appCmd represents the app command +var appCmd = &cobra.Command{ + Use: "app", + Short: "The command is used for Application Management in the EALT Edge System.", + Long: `The command is used for Application Management in the EALT Edge System. + It has multiple options like create , delete`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("app called") + }, +} + +func init() { + appCmd.AddCommand(appCmds.NewAppCreateCommand()) + appCmd.AddCommand(appCmds.NewAppDeleteCommand()) + + rootCmd.AddCommand(appCmd) +} diff --git a/ocd/cli/ealt/cmd/applcm.go b/ocd/cli/ealt/cmd/applcm.go new file mode 100644 index 0000000..01057b5 --- /dev/null +++ b/ocd/cli/ealt/cmd/applcm.go @@ -0,0 +1,46 @@ +/* +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 ( + "fmt" + + applcmCmds "ealt/cmd/applcmpkg" + + "github.com/spf13/cobra" +) + +// applcmCmd represents the applcm command +var applcmCmd = &cobra.Command{ + Use: "applcm", + 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) { + fmt.Println("applcm called") + }, +} + +func init() { + + applcmCmd.AddCommand(applcmCmds.NewApplcmCreateCommand()) + rootCmd.AddCommand(applcmCmd) + +} diff --git a/ocd/cli/ealt/cmd/applcmpkg/delete.go b/ocd/cli/ealt/cmd/applcmpkg/delete.go new file mode 100644 index 0000000..9e53156 --- /dev/null +++ b/ocd/cli/ealt/cmd/applcmpkg/delete.go @@ -0,0 +1,44 @@ +/* +Copyright 2020 Huawei Technologies Co., Ltd. + +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 applcmpkg + +import ( + "ealt/cmd/adapter" + + "github.com/spf13/cobra" +) + +// allCmd represents the all command +func NewApplcmDeleteCommand() *cobra.Command { + var cmd = &cobra.Command{ + Use: "delete", + Short: "Install Complete EALT Deployment Environment", + Long: `Install Complete EALT Deployment Environment`, + RunE: func(cmd *cobra.Command, args []string) error { + applicationIdArg := cmd.Flag("appid") + applicationId := applicationIdArg.Value.String() + err := adapter.BuilderRequest(applicationId, "NewApplcmDeleteCommand") + if err != nil { + return err + } + return nil + }, + } + + cmd.Flags().StringP("appid", "i", "", "Application Package ID to be deleted from MEP") + + return cmd +} diff --git a/ocd/cli/ealt/cmd/applcmpkg/start.go b/ocd/cli/ealt/cmd/applcmpkg/start.go new file mode 100644 index 0000000..8c81bd1 --- /dev/null +++ b/ocd/cli/ealt/cmd/applcmpkg/start.go @@ -0,0 +1,42 @@ +/* +Copyright 2020 Huawei Technologies Co., Ltd. + +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 applcmpkg + +import ( + "ealt/cmd/adapter" + + "github.com/spf13/cobra" +) + +// deployCmd represents the deploy command +func NewApplcmStartCommand() *cobra.Command { + var cmd = &cobra.Command{ + Use: "start", + Short: "To start the application instance on MEP Node", + Long: `To start the application instance on MEP Node`, + RunE: func(cmd *cobra.Command, args []string) error { + appIdArg := cmd.Flag("appid") + applicationId := appIdArg.Value.String() + err := adapter.BuilderRequest(applicationId, "NewApplcmStartCommand") + if err != nil { + return err + } + return nil + }, + } + cmd.Flags().StringP("appid", "i", "", "Application Instance ID to be started") + return cmd +} diff --git a/ocd/cli/ealt/cmd/applcmpkg/terminate.go b/ocd/cli/ealt/cmd/applcmpkg/terminate.go new file mode 100644 index 0000000..bc1619f --- /dev/null +++ b/ocd/cli/ealt/cmd/applcmpkg/terminate.go @@ -0,0 +1,44 @@ +/* +Copyright 2020 Huawei Technologies Co., Ltd. + +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 applcmpkg + +import ( + "ealt/cmd/adapter" + + "github.com/spf13/cobra" +) + +// allCmd represents the all command +func NewApplcmTerminateCommand() *cobra.Command { + var cmd = &cobra.Command{ + Use: "kill", + Short: "To kill the application ", + Long: `Install Complete EALT Deployment Environment`, + RunE: func(cmd *cobra.Command, args []string) error { + appIdArg := cmd.Flag("appid") + applicationId := appIdArg.Value.String() + err := adapter.BuilderRequest(applicationId, "NewApplcmTerminateCommand") + if err != nil { + return err + } + return nil + }, + } + + cmd.Flags().StringP("appid", "i", "", "Application Instance ID to be terminated") + + return cmd +} diff --git a/ocd/cli/ealt/cmd/appm/delete.go b/ocd/cli/ealt/cmd/appm/delete.go new file mode 100644 index 0000000..8cca0da --- /dev/null +++ b/ocd/cli/ealt/cmd/appm/delete.go @@ -0,0 +1,44 @@ +/* +Copyright 2020 Huawei Technologies Co., Ltd. + +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 appm + +import ( + "ealt/cmd/adapter" + + "github.com/spf13/cobra" +) + +// allCmd represents the all command +func NewAppDeleteCommand() *cobra.Command { + var cmd = &cobra.Command{ + Use: "delete", + Short: "Install Complete EALT Deployment Environment", + Long: `Install Complete EALT Deployment Environment`, + RunE: func(cmd *cobra.Command, args []string) error { + pkgidArg := cmd.Flag("pkgid") + packageId := pkgidArg.Value.String() + err := adapter.BuilderRequest(packageId, "NewAppDeleteCommand") + if err != nil { + return err + } + return nil + }, + } + + cmd.Flags().StringP("pkgid", "i", "", "Application Package ID to be deleted from MEP") + + return cmd +} diff --git a/ocd/cli/ealt/main b/ocd/cli/ealt/main new file mode 100755 index 0000000..44d1dc6 Binary files /dev/null and b/ocd/cli/ealt/main differ