Files
my-rook-config/cmd/rook/discover.go
T

63 lines
1.8 KiB
Go
Raw Normal View History

2018-04-05 18:39:20 +00:00
/*
Copyright 2018 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 (
2018-10-17 09:56:47 -06:00
"time"
rook "github.com/rook/rook/cmd/rook/rook"
2018-04-05 18:39:20 +00:00
"github.com/rook/rook/pkg/daemon/discover"
2018-10-17 09:56:47 -06:00
"github.com/rook/rook/pkg/util/flags"
2018-04-05 18:39:20 +00:00
"github.com/spf13/cobra"
)
2018-10-17 09:56:47 -06:00
var (
discoverCmd = &cobra.Command{
Use: "discover",
Short: "Discover devices",
Hidden: true, // do not advertise to end users
2018-10-17 09:56:47 -06:00
}
// interval between discovering devices
discoverDevicesInterval time.Duration
// Uses ceph-volume inventory to extend devices information
usesCVInventory bool
2018-10-17 09:56:47 -06:00
)
2018-04-05 18:39:20 +00:00
func init() {
2018-10-17 09:56:47 -06:00
discoverCmd.Flags().DurationVar(&discoverDevicesInterval, "discover-interval", 60*time.Minute, "interval between discovering devices (default 60m)")
discoverCmd.Flags().BoolVar(&usesCVInventory, "use-ceph-volume", false, "Use ceph-volume inventory to extend storage devices information (default false)")
2018-10-17 09:56:47 -06:00
flags.SetFlagsFromEnv(discoverCmd.Flags(), rook.RookEnvVarPrefix)
2018-04-05 18:39:20 +00:00
discoverCmd.RunE = startDiscover
}
func startDiscover(cmd *cobra.Command, args []string) error {
rook.SetLogLevel()
2018-04-05 18:39:20 +00:00
rook.LogStartupInfo(discoverCmd.Flags())
2018-04-05 18:39:20 +00:00
context := rook.NewContext()
2022-02-21 13:03:51 +05:30
ctx := cmd.Context()
2018-04-05 18:39:20 +00:00
2022-02-21 13:03:51 +05:30
err := discover.Run(ctx, context, discoverDevicesInterval, usesCVInventory)
2018-04-05 18:39:20 +00:00
if err != nil {
rook.TerminateFatal(err)
2018-04-05 18:39:20 +00:00
}
return nil
}