Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
  • Loading branch information
marceloneppel committed Jun 7, 2024
1 parent ac27b53 commit faa2370
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion microceph/ceph/configwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ auth allow insecure global id reclaim = false
[client.radosgw.gateway]
rgw init timeout = 1200
rgw frontends = beast port={{.rgwPort}}{{if and .sslCertificate .sslPrivateKey}} ssl_port={{.sslPort}}{{end}}{{if .sslCertificate}} ssl_certificate={{.sslCertificate}}{{end}}{{if .sslPrivateKey}} ssl_private_key={{.sslPrivateKey}}{{end}}
rgw frontends = beast {{if or (ne .rgwPort 0) (not .sslCertificate) (not .sslPrivateKey)}}port={{.rgwPort}}{{end}}{{if and .sslCertificate .sslPrivateKey}} ssl_port={{.sslPort}} ssl_certificate={{.sslCertificate}} ssl_private_key={{.sslPrivateKey}}{{end}}
`)),
configFile: "radosgw.conf",
configDir: configDir,
Expand Down
13 changes: 13 additions & 0 deletions microceph/ceph/rgw.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func EnableRGW(s interfaces.StateInterface, port int, sslPort int, sslCertificat

// Create RGW configuration.
conf := newRadosGWConfig(pathConsts.ConfPath)
if sslCertificate == "" || sslPrivateKey == "" {
port = 80
}
err := conf.WriteConfig(
map[string]any{
"runDir": pathConsts.RunPath,
Expand Down Expand Up @@ -126,6 +129,16 @@ func stopRGW() error {
return nil
}

// Store the SSL material in the ceph key value store.
func storeSSLMaterial(key string, material []byte) error {
// Run the ceph config-key set command
_, err := processExec.RunCommand("ceph", "config-key", "set", fmt.Sprintf("microceph:rgw/%s", key), string(material))
if err != nil {
return fmt.Errorf("failed to store key: %w", err)
}
return nil
}

// createRGWKeyring creates the RGW keyring.
func createRGWKeyring(path string) error {
if err := os.MkdirAll(path, 0770); err != nil {
Expand Down
5 changes: 3 additions & 2 deletions microceph/cmd/microceph/enable_rgw.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ type cmdEnableRGW struct {

func (c *cmdEnableRGW) Command() *cobra.Command {
cmd := &cobra.Command{
Use: "rgw [--port <port>] [--ssl-port <port>] [--ssl-certificate <certificate path>] [--ssl-private-key <private key path>] [--target <server>] [--wait <bool>]",
Use: "rgw [--port <port>] [--ssl-port <port>] [--ssl-certificate <certificate material>] [--ssl-private-key <private key material>] [--target <server>] [--wait <bool>]",
Short: "Enable the RGW service on the --target server (default: this server)",
RunE: c.Run,
}
cmd.PersistentFlags().IntVar(&c.flagPort, "port", 80, "Service non-SSL port (default: 80)")
// The flagPort has a default value of 0 for the case where both the SSL certificate and private key are provided.
cmd.PersistentFlags().IntVar(&c.flagPort, "port", 0, "Service non-SSL port (default: 80 if no SSL certificate and/or private key are provided)")
cmd.PersistentFlags().IntVar(&c.flagSSLPort, "ssl-port", 443, "Service SSL port (default: 443)")
cmd.PersistentFlags().StringVar(&c.flagSSLCertificate, "ssl-certificate", "", "Path to SSL certificate")
cmd.PersistentFlags().StringVar(&c.flagSSLPrivateKey, "ssl-private-key", "", "Path to SSL private key")
Expand Down

0 comments on commit faa2370

Please sign in to comment.