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:
73
vendor/github.com/vmware/govmomi/govc/host/portgroup/add.go
generated
vendored
Normal file
73
vendor/github.com/vmware/govmomi/govc/host/portgroup/add.go
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 portgroup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type add struct {
|
||||
*flags.HostSystemFlag
|
||||
|
||||
spec types.HostPortGroupSpec
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("host.portgroup.add", &add{})
|
||||
}
|
||||
|
||||
func (cmd *add) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
|
||||
cmd.HostSystemFlag.Register(ctx, f)
|
||||
|
||||
f.StringVar(&cmd.spec.VswitchName, "vswitch", "", "vSwitch Name")
|
||||
f.Var(flags.NewInt32(&cmd.spec.VlanId), "vlan", "VLAN ID")
|
||||
}
|
||||
|
||||
func (cmd *add) Description() string {
|
||||
return `Add portgroup to HOST.
|
||||
|
||||
Examples:
|
||||
govc host.portgroup.add -vswitch vSwitch0 -vlan 3201 bridge`
|
||||
}
|
||||
|
||||
func (cmd *add) Usage() string {
|
||||
return "NAME"
|
||||
}
|
||||
|
||||
func (cmd *add) Process(ctx context.Context) error {
|
||||
if err := cmd.HostSystemFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *add) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
ns, err := cmd.HostNetworkSystem()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.spec.Name = f.Arg(0)
|
||||
|
||||
return ns.AddPortGroup(ctx, cmd.spec)
|
||||
}
|
118
vendor/github.com/vmware/govmomi/govc/host/portgroup/change.go
generated
vendored
Normal file
118
vendor/github.com/vmware/govmomi/govc/host/portgroup/change.go
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
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 portgroup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type change struct {
|
||||
*flags.ClientFlag
|
||||
*flags.HostSystemFlag
|
||||
|
||||
types.HostPortGroupSpec
|
||||
types.HostNetworkSecurityPolicy
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("host.portgroup.change", &change{})
|
||||
}
|
||||
|
||||
func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.ClientFlag, ctx = flags.NewClientFlag(ctx)
|
||||
cmd.ClientFlag.Register(ctx, f)
|
||||
cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
|
||||
cmd.HostSystemFlag.Register(ctx, f)
|
||||
|
||||
cmd.VlanId = -1
|
||||
f.Var(flags.NewInt32(&cmd.VlanId), "vlan-id", "VLAN ID")
|
||||
f.StringVar(&cmd.Name, "name", "", "Portgroup name")
|
||||
f.StringVar(&cmd.VswitchName, "vswitch-name", "", "vSwitch name")
|
||||
|
||||
f.Var(flags.NewOptionalBool(&cmd.AllowPromiscuous), "allow-promiscuous", "Allow promiscuous mode")
|
||||
f.Var(flags.NewOptionalBool(&cmd.ForgedTransmits), "forged-transmits", "Allow forged transmits")
|
||||
f.Var(flags.NewOptionalBool(&cmd.MacChanges), "mac-changes", "Allow MAC changes")
|
||||
}
|
||||
|
||||
func (cmd *change) Description() string {
|
||||
return `Change configuration of HOST portgroup NAME.
|
||||
|
||||
Examples:
|
||||
govc host.portgroup.change -allow-promiscuous -forged-transmits -mac-changes "VM Network"
|
||||
govc host.portgroup.change -vswitch-name vSwitch1 "Management Network"`
|
||||
}
|
||||
|
||||
func (cmd *change) Usage() string {
|
||||
return "NAME"
|
||||
}
|
||||
|
||||
func (cmd *change) Process(ctx context.Context) error {
|
||||
if err := cmd.ClientFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.HostSystemFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *change) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
if f.NArg() != 1 {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
pg, err := networkInfoPortgroup(ctx, cmd.ClientFlag, cmd.HostSystemFlag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ns, err := cmd.HostNetworkSystem()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name := f.Arg(0)
|
||||
var current *types.HostPortGroupSpec
|
||||
|
||||
for _, g := range pg {
|
||||
if g.Spec.Name == name {
|
||||
current = &g.Spec
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if current != nil {
|
||||
if cmd.Name == "" {
|
||||
cmd.Name = current.Name
|
||||
}
|
||||
if cmd.VswitchName == "" {
|
||||
cmd.VswitchName = current.VswitchName
|
||||
}
|
||||
if cmd.VlanId < 0 {
|
||||
cmd.VlanId = current.VlanId
|
||||
}
|
||||
}
|
||||
|
||||
cmd.HostPortGroupSpec.Policy.Security = &cmd.HostNetworkSecurityPolicy
|
||||
|
||||
return ns.UpdatePortGroup(ctx, name, cmd.HostPortGroupSpec)
|
||||
}
|
118
vendor/github.com/vmware/govmomi/govc/host/portgroup/info.go
generated
vendored
Normal file
118
vendor/github.com/vmware/govmomi/govc/host/portgroup/info.go
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 portgroup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/govc/host/vswitch"
|
||||
"github.com/vmware/govmomi/property"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type info struct {
|
||||
*flags.ClientFlag
|
||||
*flags.OutputFlag
|
||||
*flags.HostSystemFlag
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("host.portgroup.info", &info{})
|
||||
}
|
||||
|
||||
func (cmd *info) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.ClientFlag, ctx = flags.NewClientFlag(ctx)
|
||||
cmd.ClientFlag.Register(ctx, f)
|
||||
cmd.OutputFlag, ctx = flags.NewOutputFlag(ctx)
|
||||
cmd.OutputFlag.Register(ctx, f)
|
||||
cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
|
||||
cmd.HostSystemFlag.Register(ctx, f)
|
||||
}
|
||||
|
||||
func (cmd *info) Process(ctx context.Context) error {
|
||||
if err := cmd.ClientFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.OutputFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.HostSystemFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func networkInfoPortgroup(ctx context.Context, c *flags.ClientFlag, h *flags.HostSystemFlag) ([]types.HostPortGroup, error) {
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ns, err := h.HostNetworkSystem()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var mns mo.HostNetworkSystem
|
||||
|
||||
pc := property.DefaultCollector(client)
|
||||
err = pc.RetrieveOne(ctx, ns.Reference(), []string{"networkInfo.portgroup"}, &mns)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return mns.NetworkInfo.Portgroup, nil
|
||||
}
|
||||
|
||||
func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
pg, err := networkInfoPortgroup(ctx, cmd.ClientFlag, cmd.HostSystemFlag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r := &infoResult{pg}
|
||||
|
||||
return cmd.WriteResult(r)
|
||||
}
|
||||
|
||||
type infoResult struct {
|
||||
Portgroup []types.HostPortGroup
|
||||
}
|
||||
|
||||
func (r *infoResult) Write(w io.Writer) error {
|
||||
tw := tabwriter.NewWriter(w, 2, 0, 2, ' ', 0)
|
||||
|
||||
for i, s := range r.Portgroup {
|
||||
if i > 0 {
|
||||
fmt.Fprintln(tw)
|
||||
}
|
||||
fmt.Fprintf(tw, "Name:\t%s\n", s.Spec.Name)
|
||||
fmt.Fprintf(tw, "Virtual switch:\t%s\n", s.Spec.VswitchName)
|
||||
fmt.Fprintf(tw, "VLAN ID:\t%d\n", s.Spec.VlanId)
|
||||
fmt.Fprintf(tw, "Active ports:\t%d\n", len(s.Port))
|
||||
vswitch.HostNetworkPolicy(tw, &s.ComputedPolicy)
|
||||
}
|
||||
|
||||
return tw.Flush()
|
||||
}
|
65
vendor/github.com/vmware/govmomi/govc/host/portgroup/remove.go
generated
vendored
Normal file
65
vendor/github.com/vmware/govmomi/govc/host/portgroup/remove.go
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 portgroup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type remove struct {
|
||||
*flags.HostSystemFlag
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("host.portgroup.remove", &remove{})
|
||||
}
|
||||
|
||||
func (cmd *remove) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.HostSystemFlag, ctx = flags.NewHostSystemFlag(ctx)
|
||||
cmd.HostSystemFlag.Register(ctx, f)
|
||||
}
|
||||
|
||||
func (cmd *remove) Description() string {
|
||||
return `Remove portgroup from HOST.
|
||||
|
||||
Examples:
|
||||
govc host.portgroup.remove bridge`
|
||||
}
|
||||
|
||||
func (cmd *remove) Usage() string {
|
||||
return "NAME"
|
||||
}
|
||||
|
||||
func (cmd *remove) Process(ctx context.Context) error {
|
||||
if err := cmd.HostSystemFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *remove) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
ns, err := cmd.HostNetworkSystem()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ns.RemovePortGroup(ctx, f.Arg(0))
|
||||
}
|
Reference in New Issue
Block a user