-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a3b0dc
commit 135cbe9
Showing
35 changed files
with
790 additions
and
1,390 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 was deleted.
Oops, something went wrong.
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,93 @@ | ||
package hosts | ||
|
||
import ( | ||
params "github.com/adrianriobo/qenvs/cmd/cmd/constants" | ||
qenvsContext "github.com/adrianriobo/qenvs/pkg/manager/context" | ||
"github.com/adrianriobo/qenvs/pkg/provider/aws/action/fedora" | ||
"github.com/adrianriobo/qenvs/pkg/util/logging" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
const ( | ||
cmdFedora = "fedora" | ||
cmdFedoraDesc = "create fedora dedicated host" | ||
|
||
fedoraVersion string = "version" | ||
fedoraVersionDesc string = "version for the Fedora Cloud OS" | ||
fedoraVersionDefault string = "39" | ||
) | ||
|
||
func GetFedoraCmd() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: cmdFedora, | ||
Short: cmdFedoraDesc, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := viper.BindPFlags(cmd.Flags()); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
c.AddCommand(getFedoraCreate(), getFedoraDestroy()) | ||
return c | ||
} | ||
|
||
func getFedoraCreate() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: params.CreateCmdName, | ||
Short: params.CreateCmdName, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := viper.BindPFlags(cmd.Flags()); err != nil { | ||
return err | ||
} | ||
|
||
// Initialize context | ||
qenvsContext.Init( | ||
viper.GetString(params.ProjectName), | ||
viper.GetString(params.BackedURL), | ||
viper.GetString(params.ConnectionDetailsOutput), | ||
viper.GetStringMapString(params.Tags)) | ||
|
||
// Run create | ||
if err := fedora.Create( | ||
&fedora.Request{ | ||
Prefix: "main", | ||
Version: viper.GetString(rhelVersion), | ||
Spot: viper.IsSet(spot), | ||
Airgap: viper.IsSet(airgap)}); err != nil { | ||
logging.Error(err) | ||
} | ||
return nil | ||
}, | ||
} | ||
flagSet := pflag.NewFlagSet(params.CreateCmdName, pflag.ExitOnError) | ||
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc) | ||
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc) | ||
flagSet.StringP(fedoraVersion, "", fedoraVersionDefault, fedoraVersionDesc) | ||
c.PersistentFlags().AddFlagSet(flagSet) | ||
return c | ||
} | ||
|
||
func getFedoraDestroy() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: params.DestroyCmdName, | ||
Short: params.DestroyCmdName, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := viper.BindPFlags(cmd.Flags()); err != nil { | ||
return err | ||
} | ||
|
||
qenvsContext.InitBase( | ||
viper.GetString(params.ProjectName), | ||
viper.GetString(params.BackedURL)) | ||
|
||
if err := fedora.Destroy(); err != nil { | ||
logging.Error(err) | ||
} | ||
return nil | ||
}, | ||
} | ||
return c | ||
} |
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,115 @@ | ||
package hosts | ||
|
||
import ( | ||
params "github.com/adrianriobo/qenvs/cmd/cmd/constants" | ||
qenvsContext "github.com/adrianriobo/qenvs/pkg/manager/context" | ||
"github.com/adrianriobo/qenvs/pkg/provider/aws/action/rhel" | ||
"github.com/adrianriobo/qenvs/pkg/util/logging" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
const ( | ||
cmdRHEL = "rhel" | ||
cmdRHELDesc = "create rhel dedicated host" | ||
|
||
rhelVersion string = "version" | ||
rhelVersionDesc string = "version for the RHEL OS" | ||
rhelVersionDefault string = "9.3" | ||
subsUsername string = "subs-username" | ||
subsUsernameDesc string = "username to register the subscription" | ||
subsUserpass string = "subs-userpass" | ||
subsUserpassDesc string = "password to register the subscription" | ||
profileSNC string = "snc" | ||
profileSNCDesc string = "if this flag is set the RHEL will be setup with SNC profile. Setting up all requirements to run https://github.com/crc-org/snc" | ||
) | ||
|
||
func GetRHELCmd() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: cmdRHEL, | ||
Short: cmdRHELDesc, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := viper.BindPFlags(cmd.Flags()); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
c.AddCommand(getRHELCreate(), getRHELDestroy()) | ||
return c | ||
} | ||
|
||
func getRHELCreate() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: params.CreateCmdName, | ||
Short: params.CreateCmdName, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := viper.BindPFlags(cmd.Flags()); err != nil { | ||
return err | ||
} | ||
|
||
// Initialize context | ||
qenvsContext.Init( | ||
viper.GetString(params.ProjectName), | ||
viper.GetString(params.BackedURL), | ||
viper.GetString(params.ConnectionDetailsOutput), | ||
viper.GetStringMapString(params.Tags)) | ||
|
||
// Run create | ||
if err := rhel.Create( | ||
&rhel.Request{ | ||
Prefix: "main", | ||
Version: viper.GetString(rhelVersion), | ||
SubsUsername: viper.GetString(subsUsername), | ||
SubsUserpass: viper.GetString(subsUserpass), | ||
ProfileSNC: viper.IsSet(profileSNC), | ||
Spot: viper.IsSet(spot), | ||
Airgap: viper.IsSet(airgap)}); err != nil { | ||
logging.Error(err) | ||
} | ||
return nil | ||
}, | ||
} | ||
flagSet := pflag.NewFlagSet(params.CreateCmdName, pflag.ExitOnError) | ||
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc) | ||
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc) | ||
flagSet.StringP(rhelVersion, "", rhelVersionDefault, rhelVersionDesc) | ||
flagSet.StringP(subsUsername, "", "", amiUsernameDesc) | ||
flagSet.StringP(subsUserpass, "", "", subsUserpassDesc) | ||
flagSet.Bool(airgap, false, airgapDesc) | ||
flagSet.Bool(spot, false, spotDesc) | ||
flagSet.Bool(profileSNC, false, profileSNCDesc) | ||
c.PersistentFlags().AddFlagSet(flagSet) | ||
if err := c.MarkFlagRequired(subsUsername); err != nil { | ||
logging.Error(err) | ||
return nil | ||
} | ||
if err := c.MarkFlagRequired(subsUserpass); err != nil { | ||
logging.Error(err) | ||
return nil | ||
} | ||
return c | ||
} | ||
|
||
func getRHELDestroy() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: params.DestroyCmdName, | ||
Short: params.DestroyCmdName, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := viper.BindPFlags(cmd.Flags()); err != nil { | ||
return err | ||
} | ||
|
||
qenvsContext.InitBase( | ||
viper.GetString(params.ProjectName), | ||
viper.GetString(params.BackedURL)) | ||
|
||
if err := rhel.Destroy(); err != nil { | ||
logging.Error(err) | ||
} | ||
return nil | ||
}, | ||
} | ||
return c | ||
} |
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,18 @@ | ||
package fedora | ||
|
||
var ( | ||
stackName = "stackFedoraBaremetal" | ||
awsFedoraDedicatedID = "afd" | ||
|
||
diskSize int = 200 | ||
|
||
amiRegex = "Fedora-Cloud-Base-%s*" | ||
amiOwner = "125523088429" | ||
amiUserDefault = "fedora" | ||
|
||
requiredInstanceTypes = []string{"c5.metal", "c5d.metal", "c5n.metal"} | ||
|
||
outputHost = "afdHost" | ||
outputUsername = "afdUsername" | ||
outputUserPrivateKey = "afdPrivatekey" | ||
) |
Oops, something went wrong.