1
0
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:
Adrian Todorov
2017-10-25 20:52:40 +00:00
parent 704f4d20d1
commit a59409f16b
1627 changed files with 489673 additions and 0 deletions

View File

@@ -0,0 +1,111 @@
/*
Copyright (c) 2017 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 interval
import (
"context"
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/govc/metric"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/types"
)
type change struct {
*metric.PerformanceFlag
enabled *bool
level int
}
func init() {
cli.Register("metric.interval.change", &change{})
}
func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) {
cmd.PerformanceFlag, ctx = metric.NewPerformanceFlag(ctx)
cmd.PerformanceFlag.Register(ctx, f)
f.Var(flags.NewOptionalBool(&cmd.enabled), "enabled", "Enable or disable")
f.IntVar(&cmd.level, "level", 0, "Level")
}
func (cmd *change) Description() string {
return `Change historical metric intervals.
Examples:
govc metric.interval.change -i 300 -level 2
govc metric.interval.change -i 86400 -enabled=false`
}
func (cmd *change) Process(ctx context.Context) error {
if err := cmd.PerformanceFlag.Process(ctx); err != nil {
return err
}
return nil
}
func (cmd *change) Run(ctx context.Context, f *flag.FlagSet) error {
m, err := cmd.Manager(ctx)
if err != nil {
return err
}
intervals, err := m.HistoricalInterval(ctx)
if err != nil {
return err
}
interval := cmd.Interval(0)
if interval == 0 {
return flag.ErrHelp
}
var current *types.PerfInterval
for _, i := range intervals {
if i.SamplingPeriod == interval {
current = &i
break
}
}
if current == nil {
return fmt.Errorf("%d interval ID not found", interval)
}
if cmd.level != 0 {
if cmd.level > 4 {
return flag.ErrHelp
}
current.Level = int32(cmd.level)
}
if cmd.enabled != nil {
current.Enabled = *cmd.enabled
}
_, err = methods.UpdatePerfInterval(ctx, m.Client(), &types.UpdatePerfInterval{
This: m.Reference(),
Interval: *current,
})
return err
}

View File

@@ -0,0 +1,87 @@
/*
Copyright (c) 2017 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 interval
import (
"context"
"flag"
"fmt"
"text/tabwriter"
"time"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/metric"
)
type info struct {
*metric.PerformanceFlag
}
func init() {
cli.Register("metric.interval.info", &info{})
}
func (cmd *info) Register(ctx context.Context, f *flag.FlagSet) {
cmd.PerformanceFlag, ctx = metric.NewPerformanceFlag(ctx)
cmd.PerformanceFlag.Register(ctx, f)
}
func (cmd *info) Description() string {
return `List historical metric intervals.
Examples:
govc metric.interval.info
govc metric.interval.info -i 300`
}
func (cmd *info) Process(ctx context.Context) error {
if err := cmd.PerformanceFlag.Process(ctx); err != nil {
return err
}
return nil
}
func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
m, err := cmd.Manager(ctx)
if err != nil {
return err
}
intervals, err := m.HistoricalInterval(ctx)
if err != nil {
return err
}
tw := tabwriter.NewWriter(cmd.Out, 2, 0, 2, ' ', 0)
cmd.Out = tw
interval := cmd.Interval(0)
for _, i := range intervals {
if interval != 0 && i.SamplingPeriod != interval {
continue
}
fmt.Fprintf(cmd.Out, "ID:\t%d\n", i.SamplingPeriod)
fmt.Fprintf(cmd.Out, " Enabled:\t%t\n", i.Enabled)
fmt.Fprintf(cmd.Out, " Interval:\t%s\n", time.Duration(i.SamplingPeriod)*time.Second)
fmt.Fprintf(cmd.Out, " Name:\t%s\n", i.Name)
fmt.Fprintf(cmd.Out, " Level:\t%d\n", i.Level)
}
return tw.Flush()
}