mirror of
https://github.com/Oxalide/vsphere-influxdb-go.git
synced 2023-10-10 11:36:51 +00:00
add vendoring with go dep
This commit is contained in:
227
vendor/github.com/vmware/govmomi/govc/host/storage/info.go
generated
vendored
Normal file
227
vendor/github.com/vmware/govmomi/govc/host/storage/info.go
generated
vendored
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
Copyright (c) 2015 VMware, Inc. 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 storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/units"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
var infoTypes = []string{"hba", "lun"}
|
||||
|
||||
type infoType string
|
||||
|
||||
func (t *infoType) Set(s string) error {
|
||||
s = strings.ToLower(s)
|
||||
|
||||
for _, e := range infoTypes {
|
||||
if s == e {
|
||||
*t = infoType(s)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("invalid type")
|
||||
}
|
||||
|
||||
func (t *infoType) String() string {
|
||||
return string(*t)
|
||||
}
|
||||
|
||||
func (t *infoType) Result(hss mo.HostStorageSystem) flags.OutputWriter {
|
||||
switch string(*t) {
|
||||
case "hba":
|
||||
return hbaResult(hss)
|
||||
case "lun":
|
||||
return lunResult(hss)
|
||||
default:
|
||||
panic("unsupported")
|
||||
}
|
||||
}
|
||||
|
||||
type info struct {
|
||||
*flags.HostSystemFlag
|
||||
*flags.OutputFlag
|
||||
|
||||
typ infoType
|
||||
rescan bool
|
||||
unclaimed bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("host.storage.info", &info{})
|
||||
}
|
||||
|
||||
func (cmd *info) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
|
||||
cmd.HostSystemFlag.Register(ctx, f)
|
||||
cmd.OutputFlag, ctx = flags.NewOutputFlag(ctx)
|
||||
cmd.OutputFlag.Register(ctx, f)
|
||||
|
||||
err := cmd.typ.Set("lun")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
f.Var(&cmd.typ, "t", fmt.Sprintf("Type (%s)", strings.Join(infoTypes, ",")))
|
||||
|
||||
f.BoolVar(&cmd.rescan, "rescan", false, "Rescan for new storage devices")
|
||||
f.BoolVar(&cmd.unclaimed, "unclaimed", false, "Only show disks that can be used as new VMFS datastores")
|
||||
}
|
||||
|
||||
func (cmd *info) Description() string {
|
||||
return `Show HOST storage system information.
|
||||
|
||||
Examples:
|
||||
govc ls -t HostSystem host/* | xargs -n1 govc host.storage.info -unclaimed -host`
|
||||
}
|
||||
|
||||
func (cmd *info) Process(ctx context.Context) error {
|
||||
if err := cmd.HostSystemFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.OutputFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
host, err := cmd.HostSystem()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ss, err := host.ConfigManager().StorageSystem(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if cmd.rescan {
|
||||
err = ss.RescanAllHba(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var hss mo.HostStorageSystem
|
||||
err = ss.Properties(ctx, ss.Reference(), nil, &hss)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if cmd.unclaimed {
|
||||
ds, err := host.ConfigManager().DatastoreSystem(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
disks, err := ds.QueryAvailableDisksForVmfs(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var luns []types.BaseScsiLun
|
||||
for i := range disks {
|
||||
luns = append(luns, &disks[i])
|
||||
}
|
||||
hss.StorageDeviceInfo.ScsiLun = luns
|
||||
}
|
||||
|
||||
return cmd.WriteResult(cmd.typ.Result(hss))
|
||||
}
|
||||
|
||||
type hbaResult mo.HostStorageSystem
|
||||
|
||||
func (r hbaResult) Write(w io.Writer) error {
|
||||
tw := tabwriter.NewWriter(w, 2, 0, 2, ' ', 0)
|
||||
|
||||
fmt.Fprintf(tw, "Device\t")
|
||||
fmt.Fprintf(tw, "PCI\t")
|
||||
fmt.Fprintf(tw, "Driver\t")
|
||||
fmt.Fprintf(tw, "Status\t")
|
||||
fmt.Fprintf(tw, "Model\t")
|
||||
fmt.Fprintf(tw, "\n")
|
||||
|
||||
for _, e := range r.StorageDeviceInfo.HostBusAdapter {
|
||||
hba := e.GetHostHostBusAdapter()
|
||||
|
||||
fmt.Fprintf(tw, "%s\t", hba.Device)
|
||||
fmt.Fprintf(tw, "%s\t", hba.Pci)
|
||||
fmt.Fprintf(tw, "%s\t", hba.Driver)
|
||||
fmt.Fprintf(tw, "%s\t", hba.Status)
|
||||
fmt.Fprintf(tw, "%s\t", hba.Model)
|
||||
fmt.Fprintf(tw, "\n")
|
||||
}
|
||||
|
||||
return tw.Flush()
|
||||
}
|
||||
|
||||
type lunResult mo.HostStorageSystem
|
||||
|
||||
func (r lunResult) Write(w io.Writer) error {
|
||||
tw := tabwriter.NewWriter(w, 2, 0, 2, ' ', 0)
|
||||
|
||||
fmt.Fprintf(tw, "Name\t")
|
||||
fmt.Fprintf(tw, "Type\t")
|
||||
fmt.Fprintf(tw, "Capacity\t")
|
||||
fmt.Fprintf(tw, "Model\t")
|
||||
fmt.Fprintf(tw, "\n")
|
||||
|
||||
for _, e := range r.StorageDeviceInfo.ScsiLun {
|
||||
var tags []string
|
||||
var capacity int64
|
||||
|
||||
lun := e.GetScsiLun()
|
||||
if disk, ok := e.(*types.HostScsiDisk); ok {
|
||||
capacity = int64(disk.Capacity.Block) * int64(disk.Capacity.BlockSize)
|
||||
if disk.LocalDisk != nil && *disk.LocalDisk {
|
||||
tags = append(tags, "local")
|
||||
}
|
||||
if disk.Ssd != nil && *disk.Ssd {
|
||||
tags = append(tags, "ssd")
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(tw, "%s\t", lun.DeviceName)
|
||||
fmt.Fprintf(tw, "%s\t", lun.DeviceType)
|
||||
|
||||
if capacity == 0 {
|
||||
fmt.Fprintf(tw, "-\t")
|
||||
} else {
|
||||
fmt.Fprintf(tw, "%s\t", units.ByteSize(capacity))
|
||||
}
|
||||
|
||||
fmt.Fprintf(tw, "%s", lun.Model)
|
||||
if len(tags) > 0 {
|
||||
fmt.Fprintf(tw, " (%s)", strings.Join(tags, ","))
|
||||
}
|
||||
fmt.Fprintf(tw, "\n")
|
||||
}
|
||||
|
||||
return tw.Flush()
|
||||
}
|
141
vendor/github.com/vmware/govmomi/govc/host/storage/mark.go
generated
vendored
Normal file
141
vendor/github.com/vmware/govmomi/govc/host/storage/mark.go
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
Copyright (c) 2016 VMware, Inc. 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 storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/object"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type mark struct {
|
||||
*flags.HostSystemFlag
|
||||
|
||||
ssd *bool
|
||||
local *bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("host.storage.mark", &mark{})
|
||||
}
|
||||
|
||||
func (cmd *mark) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
|
||||
cmd.HostSystemFlag.Register(ctx, f)
|
||||
|
||||
f.Var(flags.NewOptionalBool(&cmd.ssd), "ssd", "Mark as SSD")
|
||||
f.Var(flags.NewOptionalBool(&cmd.local), "local", "Mark as local")
|
||||
}
|
||||
|
||||
func (cmd *mark) Process(ctx context.Context) error {
|
||||
if err := cmd.HostSystemFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *mark) Usage() string {
|
||||
return "DEVICE_PATH"
|
||||
}
|
||||
|
||||
func (cmd *mark) Description() string {
|
||||
return `Mark device at DEVICE_PATH.`
|
||||
}
|
||||
|
||||
func (cmd *mark) Mark(ctx context.Context, ss *object.HostStorageSystem, uuid string) error {
|
||||
var err error
|
||||
var task *object.Task
|
||||
|
||||
if cmd.ssd != nil {
|
||||
if *cmd.ssd {
|
||||
task, err = ss.MarkAsSsd(ctx, uuid)
|
||||
} else {
|
||||
task, err = ss.MarkAsNonSsd(ctx, uuid)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = task.Wait(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if cmd.local != nil {
|
||||
if *cmd.local {
|
||||
task, err = ss.MarkAsLocal(ctx, uuid)
|
||||
} else {
|
||||
task, err = ss.MarkAsNonLocal(ctx, uuid)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = task.Wait(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *mark) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
if f.NArg() != 1 {
|
||||
return fmt.Errorf("specify device path")
|
||||
}
|
||||
|
||||
path := f.Args()[0]
|
||||
|
||||
host, err := cmd.HostSystem()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ss, err := host.ConfigManager().StorageSystem(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var hss mo.HostStorageSystem
|
||||
err = ss.Properties(ctx, ss.Reference(), nil, &hss)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, e := range hss.StorageDeviceInfo.ScsiLun {
|
||||
disk, ok := e.(*types.HostScsiDisk)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if disk.DevicePath == path {
|
||||
return cmd.Mark(ctx, ss, disk.Uuid)
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("%s not found", path)
|
||||
}
|
126
vendor/github.com/vmware/govmomi/govc/host/storage/partition.go
generated
vendored
Normal file
126
vendor/github.com/vmware/govmomi/govc/host/storage/partition.go
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
Copyright (c) 2015 VMware, Inc. 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 storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/units"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type partition struct {
|
||||
*flags.HostSystemFlag
|
||||
*flags.OutputFlag
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("host.storage.partition", &partition{})
|
||||
}
|
||||
|
||||
func (cmd *partition) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
|
||||
cmd.HostSystemFlag.Register(ctx, f)
|
||||
cmd.OutputFlag, ctx = flags.NewOutputFlag(ctx)
|
||||
cmd.OutputFlag.Register(ctx, f)
|
||||
}
|
||||
|
||||
func (cmd *partition) Process(ctx context.Context) error {
|
||||
if err := cmd.HostSystemFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.OutputFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *partition) Usage() string {
|
||||
return "DEVICE_PATH"
|
||||
}
|
||||
|
||||
func (cmd *partition) Description() string {
|
||||
return `Show partition table for device at DEVICE_PATH.`
|
||||
}
|
||||
|
||||
func (cmd *partition) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
if f.NArg() != 1 {
|
||||
return fmt.Errorf("specify device path")
|
||||
}
|
||||
|
||||
path := f.Args()[0]
|
||||
|
||||
host, err := cmd.HostSystem()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ss, err := host.ConfigManager().StorageSystem(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var hss mo.HostStorageSystem
|
||||
err = ss.Properties(ctx, ss.Reference(), nil, &hss)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
info, err := ss.RetrieveDiskPartitionInfo(ctx, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return cmd.WriteResult(partitionInfo(*info))
|
||||
}
|
||||
|
||||
type partitionInfo types.HostDiskPartitionInfo
|
||||
|
||||
func (p partitionInfo) Write(w io.Writer) error {
|
||||
tw := tabwriter.NewWriter(w, 2, 0, 2, ' ', 0)
|
||||
|
||||
fmt.Fprintf(tw, "Table format: %s\n", p.Spec.PartitionFormat)
|
||||
fmt.Fprintf(tw, "Number of sectors: %d\n", p.Spec.TotalSectors)
|
||||
fmt.Fprintf(tw, "\n")
|
||||
|
||||
fmt.Fprintf(tw, "Number\t")
|
||||
fmt.Fprintf(tw, "Start\t")
|
||||
fmt.Fprintf(tw, "End\t")
|
||||
fmt.Fprintf(tw, "Size\t")
|
||||
fmt.Fprintf(tw, "Type\t")
|
||||
fmt.Fprintf(tw, "\n")
|
||||
|
||||
for _, e := range p.Spec.Partition {
|
||||
sectors := e.EndSector - e.StartSector
|
||||
|
||||
fmt.Fprintf(tw, "%d\t", e.Partition)
|
||||
fmt.Fprintf(tw, "%d\t", e.StartSector)
|
||||
fmt.Fprintf(tw, "%d\t", e.EndSector)
|
||||
fmt.Fprintf(tw, "%s\t", units.ByteSize(sectors*512))
|
||||
fmt.Fprintf(tw, "%s\t", e.Type)
|
||||
fmt.Fprintf(tw, "\n")
|
||||
}
|
||||
|
||||
return tw.Flush()
|
||||
}
|
Reference in New Issue
Block a user