forked from uyuni-project/uyuni-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mgradm start, stop and restart functions
- Loading branch information
Showing
14 changed files
with
347 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build !nok8s | ||
|
||
package restart | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func kubernetesRestart( | ||
globalFlags *types.GlobalFlags, | ||
flags *restartFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return fmt.Errorf("not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build nok8s | ||
|
||
package restart | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/podman" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func kubernetesRestart( | ||
globalFlags *types.GlobalFlags, | ||
flags *restartFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return fmt.Errorf("built without kubernetes support") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package restart | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/podman" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func podmanRestart( | ||
globalFlags *types.GlobalFlags, | ||
flags *restartFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return podman.RestartService(podman.ServerService) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package restart | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
"github.com/uyuni-project/uyuni-tools/shared/utils" | ||
) | ||
|
||
type restartFlags struct { | ||
Backend string | ||
} | ||
|
||
func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command { | ||
|
||
restartCmd := &cobra.Command{ | ||
Use: "restart", | ||
Short: "restart the server", | ||
Long: "Restart the server", | ||
Args: cobra.ExactArgs(0), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var flags restartFlags | ||
return utils.CommandHelper(globalFlags, cmd, args, &flags, restart) | ||
}, | ||
} | ||
restartCmd.SetUsageTemplate(restartCmd.UsageTemplate()) | ||
|
||
if utils.KubernetesBuilt { | ||
utils.AddBackendFlag(restartCmd) | ||
} | ||
|
||
return restartCmd | ||
} | ||
|
||
func restart(globalFlags *types.GlobalFlags, flags *restartFlags, cmd *cobra.Command, args []string) error { | ||
fn, err := shared.ChoosePodmanOrKubernetes(cmd.Flags(), podmanRestart, kubernetesRestart) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return fn(globalFlags, flags, cmd, args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build !nok8s | ||
|
||
package start | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func kubernetesStart( | ||
globalFlags *types.GlobalFlags, | ||
flags *startFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return fmt.Errorf("not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build nok8s | ||
|
||
package start | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/podman" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func kubernetesStart( | ||
globalFlags *types.GlobalFlags, | ||
flags *startFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return fmt.Errorf("built without kubernetes support") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package start | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/podman" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func podmanStart( | ||
globalFlags *types.GlobalFlags, | ||
flags *startFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return podman.StartService(podman.ServerService) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package start | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
"github.com/uyuni-project/uyuni-tools/shared/utils" | ||
) | ||
|
||
type startFlags struct { | ||
Backend string | ||
} | ||
|
||
func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command { | ||
|
||
startCmd := &cobra.Command{ | ||
Use: "start", | ||
Short: "start the server", | ||
Long: "Start the server", | ||
Args: cobra.ExactArgs(0), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var flags startFlags | ||
return utils.CommandHelper(globalFlags, cmd, args, &flags, start) | ||
}, | ||
} | ||
startCmd.SetUsageTemplate(startCmd.UsageTemplate()) | ||
|
||
if utils.KubernetesBuilt { | ||
utils.AddBackendFlag(startCmd) | ||
} | ||
|
||
return startCmd | ||
} | ||
|
||
func start(globalFlags *types.GlobalFlags, flags *startFlags, cmd *cobra.Command, args []string) error { | ||
fn, err := shared.ChoosePodmanOrKubernetes(cmd.Flags(), podmanStart, kubernetesStart) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return fn(globalFlags, flags, cmd, args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build !nok8s | ||
|
||
package stop | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func kubernetesStop( | ||
globalFlags *types.GlobalFlags, | ||
flags *stopFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return fmt.Errorf("not implemented") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build nok8s | ||
|
||
package stop | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/podman" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func kubernetesStop( | ||
globalFlags *types.GlobalFlags, | ||
flags *startFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return fmt.Errorf("built without kubernetes support") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package stop | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared/podman" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
) | ||
|
||
func podmanStop( | ||
globalFlags *types.GlobalFlags, | ||
flags *stopFlags, | ||
cmd *cobra.Command, | ||
args []string, | ||
) error { | ||
return podman.StopService(podman.ServerService) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package stop | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/uyuni-project/uyuni-tools/shared" | ||
"github.com/uyuni-project/uyuni-tools/shared/types" | ||
"github.com/uyuni-project/uyuni-tools/shared/utils" | ||
) | ||
|
||
type stopFlags struct { | ||
Backend string | ||
} | ||
|
||
func NewCommand(globalFlags *types.GlobalFlags) *cobra.Command { | ||
|
||
stopCmd := &cobra.Command{ | ||
Use: "stop", | ||
Short: "stop the server", | ||
Long: "Stop the server", | ||
Args: cobra.ExactArgs(0), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var flags stopFlags | ||
return utils.CommandHelper(globalFlags, cmd, args, &flags, stop) | ||
}, | ||
} | ||
|
||
stopCmd.SetUsageTemplate(stopCmd.UsageTemplate()) | ||
|
||
if utils.KubernetesBuilt { | ||
utils.AddBackendFlag(stopCmd) | ||
} | ||
|
||
return stopCmd | ||
} | ||
|
||
func stop(globalFlags *types.GlobalFlags, flags *stopFlags, cmd *cobra.Command, args []string) error { | ||
fn, err := shared.ChoosePodmanOrKubernetes(cmd.Flags(), podmanStop, kubernetesStop) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return fn(globalFlags, flags, cmd, args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Add mgradm start stop and restart commands |