forked from daos-stack/daos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage_query.go
131 lines (110 loc) · 4.62 KB
/
storage_query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//
// (C) Copyright 2019 Intel Corporation.
//
// 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.
//
// GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE
// The Government's rights to use, modify, reproduce, release, perform, display,
// or disclose this software are subject to the terms of the Apache License as
// provided in Contract No. 8F-30005.
// Any reproduction of computer software, computer software documentation, or
// portions thereof marked with this legend must also reproduce the markings.
//
package main
import (
"github.com/pkg/errors"
mgmtpb "github.com/daos-stack/daos/src/control/common/proto/mgmt"
)
// storageQueryCmd is the struct representing the query storage subcommand
type storageQueryCmd struct {
NVMe nvmeHealthQueryCmd `command:"nvme-health" alias:"n" description:"Query raw NVMe SPDK device statistics."`
BS bsHealthQueryCmd `command:"blobstore-health" alias:"b" description:"Query internal blobstore health data."`
Smd smdQueryCmd `command:"smd" alias:"s" description:"Query per-server metadata."`
DevState devStateQueryCmd `command:"device-state" alias:"d" description:"Query the device state (ie NORMAL or FAULTY)."`
}
// nvmeHealthQueryCmd is the struct representing the "storage query health" subcommand
//
// Command is issued across all connected hosts (calls client.StorageScan and is
// an alias for "storage scan").
type nvmeHealthQueryCmd struct {
logCmd
connectedCmd
}
// Execute is run when nvmeHealthQueryCmd activates. Runs NVMe
// storage scan including health query on all connected servers.
func (cmd *nvmeHealthQueryCmd) Execute(args []string) error {
cmd.log.Info(cmd.conns.StorageScan(nil).StringHealthStats())
return nil
}
// bsHealthQueryCmd is the struct representing the "storage query bio" subcommand
//
// Command is issued to the management service access point.
type bsHealthQueryCmd struct {
logCmd
connectedCmd
Devuuid string `short:"u" long:"devuuid" description:"Device/Blobstore UUID to query"`
Tgtid string `short:"t" long:"tgtid" description:"VOS target ID to query"`
}
// Execute is run when bsHealthQueryCmd activates.
// Query the BIO health and error stats of the given device.
func (b *bsHealthQueryCmd) Execute(args []string) error {
if b.Devuuid != "" && b.Tgtid != "" {
return errors.New("either device UUID OR target ID need to be specified not both")
} else if b.Devuuid == "" && b.Tgtid == "" {
return errors.New("device UUID or target ID is required")
}
req := &mgmtpb.BioHealthReq{DevUuid: b.Devuuid, TgtId: b.Tgtid}
b.log.Infof("Blobstore Health Data:\n%s\n", b.conns.BioHealthQuery(req))
return nil
}
// smdQueryCmd is the struct representing the "storage query smd" subcommand
//
// Command is issued to the management service access point.
type smdQueryCmd struct {
logCmd
connectedCmd
Devices bool `short:"d" long:"devices" description:"List all devices/blobstores stored in per-server metadata table."`
Pools bool `short:"p" long:"pools" description:"List all VOS pool targets stored in per-server metadata table."`
}
// Execute is run when ListSmdDevCmd activates
// Query per-server metadata device table for all connected servers
func (s *smdQueryCmd) Execute(args []string) error {
// default is to print both pools and devices if not specified
if !s.Pools && !s.Devices {
s.Pools = true
s.Devices = true
}
if s.Devices {
req_dev := &mgmtpb.SmdDevReq{}
s.log.Infof("SMD Device List:\n%s\n", s.conns.SmdListDevs(req_dev))
}
if s.Pools {
req_pool := &mgmtpb.SmdPoolReq{}
s.log.Infof("SMD Pool List:\n%s\n", s.conns.SmdListPools(req_pool))
}
return nil
}
// devStateQueryCmd is the struct representing the "storage query device-state" subcommand
type devStateQueryCmd struct {
logCmd
connectedCmd
Devuuid string `short:"u" long:"devuuid" description:"Device/Blobstore UUID to query" required:"1"`
}
// Execute is run when devStateQueryCmd activates
// Query the SMD device state of the given device
func (d *devStateQueryCmd) Execute(args []string) error {
// Devuuid is a required command parameter
req := &mgmtpb.DevStateReq{DevUuid: d.Devuuid}
d.log.Infof("Device State Info:\n%s\n", d.conns.DevStateQuery(req))
return nil
}