2017-06-13 12:33:08 -07:00
|
|
|
/*
|
|
|
|
|
Copyright 2016 The Rook Authors. All rights reserved.
|
|
|
|
|
|
|
|
|
|
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 main
|
|
|
|
|
|
|
|
|
|
import (
|
2017-12-04 08:33:19 -08:00
|
|
|
"github.com/rook/rook/pkg/daemon/ceph/mgr"
|
|
|
|
|
"github.com/rook/rook/pkg/daemon/ceph/mon"
|
2017-06-13 12:33:08 -07:00
|
|
|
"github.com/rook/rook/pkg/util/flags"
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
mgrName string
|
|
|
|
|
mgrKeyring string
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var mgrCmd = &cobra.Command{
|
|
|
|
|
Use: "mgr",
|
|
|
|
|
Short: "Generates mgr config and runs the mgr daemon",
|
|
|
|
|
Hidden: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
mgrCmd.Flags().StringVar(&mgrName, "mgr-name", "", "the mgr name")
|
|
|
|
|
mgrCmd.Flags().StringVar(&mgrKeyring, "mgr-keyring", "", "the mgr keyring")
|
|
|
|
|
addCephFlags(mgrCmd)
|
|
|
|
|
|
2017-08-23 22:20:14 -07:00
|
|
|
flags.SetFlagsFromEnv(mgrCmd.Flags(), RookEnvVarPrefix)
|
2017-06-13 12:33:08 -07:00
|
|
|
|
|
|
|
|
mgrCmd.RunE = startMgr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func startMgr(cmd *cobra.Command, args []string) error {
|
2017-08-01 22:33:00 -07:00
|
|
|
required := []string{"mon-endpoints", "cluster-name", "mon-secret", "admin-secret", "public-ipv4", "private-ipv4"}
|
|
|
|
|
if err := flags.VerifyRequiredFlags(mgrCmd, required); err != nil {
|
2017-06-13 12:33:08 -07:00
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setLogLevel()
|
|
|
|
|
|
2017-08-23 22:20:14 -07:00
|
|
|
logStartupInfo(mgrCmd.Flags())
|
|
|
|
|
|
2017-06-13 12:33:08 -07:00
|
|
|
clusterInfo.Monitors = mon.ParseMonEndpoints(cfg.monEndpoints)
|
|
|
|
|
config := &mgr.Config{
|
|
|
|
|
Name: mgrName,
|
|
|
|
|
Keyring: mgrKeyring,
|
|
|
|
|
ClusterInfo: &clusterInfo,
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-14 14:24:31 -07:00
|
|
|
err := mgr.Run(createContext(), config)
|
2017-06-13 12:33:08 -07:00
|
|
|
if err != nil {
|
2017-10-31 17:00:04 -07:00
|
|
|
terminateFatal(err)
|
2017-06-13 12:33:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|