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:
107
vendor/github.com/vmware/govmomi/govc/dvs/portgroup/add.go
generated
vendored
Normal file
107
vendor/github.com/vmware/govmomi/govc/dvs/portgroup/add.go
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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 portgroup
|
||||
|
||||
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/types"
|
||||
)
|
||||
|
||||
type add struct {
|
||||
*flags.DatacenterFlag
|
||||
|
||||
DVPortgroupConfigSpec
|
||||
|
||||
path string
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("dvs.portgroup.add", &add{})
|
||||
}
|
||||
|
||||
func (cmd *add) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.DatacenterFlag, ctx = flags.NewDatacenterFlag(ctx)
|
||||
cmd.DatacenterFlag.Register(ctx, f)
|
||||
|
||||
f.StringVar(&cmd.path, "dvs", "", "DVS path")
|
||||
|
||||
cmd.DVPortgroupConfigSpec.NumPorts = 128 // default
|
||||
|
||||
cmd.DVPortgroupConfigSpec.Register(ctx, f)
|
||||
}
|
||||
|
||||
func (cmd *add) Description() string {
|
||||
return `Add portgroup to DVS.
|
||||
|
||||
Examples:
|
||||
govc dvs.create DSwitch
|
||||
govc dvs.portgroup.add -dvs DSwitch -type earlyBinding -nports 16 ExternalNetwork
|
||||
govc dvs.portgroup.add -dvs DSwitch -type ephemeral InternalNetwork`
|
||||
}
|
||||
|
||||
func (cmd *add) Process(ctx context.Context) error {
|
||||
if err := cmd.DatacenterFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *add) Usage() string {
|
||||
return "NAME"
|
||||
}
|
||||
|
||||
func (cmd *add) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
if f.NArg() == 0 {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
name := f.Arg(0)
|
||||
|
||||
finder, err := cmd.Finder()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
net, err := finder.Network(ctx, cmd.path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dvs, ok := net.(*object.DistributedVirtualSwitch)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s (%T) is not of type %T", cmd.path, net, dvs)
|
||||
}
|
||||
|
||||
cmd.DVPortgroupConfigSpec.Name = name
|
||||
|
||||
task, err := dvs.AddPortgroup(ctx, []types.DVPortgroupConfigSpec{cmd.Spec()})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger := cmd.ProgressLogger(fmt.Sprintf("adding %s portgroup to dvs %s... ", name, dvs.InventoryPath))
|
||||
defer logger.Wait()
|
||||
|
||||
_, err = task.WaitForResult(ctx, logger)
|
||||
return err
|
||||
}
|
107
vendor/github.com/vmware/govmomi/govc/dvs/portgroup/change.go
generated
vendored
Normal file
107
vendor/github.com/vmware/govmomi/govc/dvs/portgroup/change.go
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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 portgroup
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
type change struct {
|
||||
*flags.DatacenterFlag
|
||||
|
||||
DVPortgroupConfigSpec
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("dvs.portgroup.change", &change{})
|
||||
}
|
||||
|
||||
func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.DatacenterFlag, ctx = flags.NewDatacenterFlag(ctx)
|
||||
cmd.DatacenterFlag.Register(ctx, f)
|
||||
|
||||
cmd.DVPortgroupConfigSpec.Register(ctx, f)
|
||||
}
|
||||
|
||||
func (cmd *change) Description() string {
|
||||
return `Change DVS portgroup configuration.
|
||||
|
||||
Examples:
|
||||
govc dvs.portgroup.change -nports 26 ExternalNetwork
|
||||
govc dvs.portgroup.change -vlan 3214 ExternalNetwork`
|
||||
}
|
||||
|
||||
func (cmd *change) Process(ctx context.Context) error {
|
||||
if err := cmd.DatacenterFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *change) Usage() string {
|
||||
return "PATH"
|
||||
}
|
||||
|
||||
func (cmd *change) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
if f.NArg() != 1 {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
path := f.Arg(0)
|
||||
|
||||
finder, err := cmd.Finder()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
net, err := finder.Network(ctx, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pg, ok := net.(*object.DistributedVirtualPortgroup)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s (%T) is not of type %T", path, net, pg)
|
||||
}
|
||||
|
||||
var s mo.DistributedVirtualPortgroup
|
||||
err = pg.Properties(ctx, pg.Reference(), []string{"config.configVersion"}, &s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
spec := cmd.Spec()
|
||||
spec.ConfigVersion = s.Config.ConfigVersion
|
||||
|
||||
task, err := pg.Reconfigure(ctx, spec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger := cmd.ProgressLogger(fmt.Sprintf("changing %s portgroup configuration %s... ", pg.Name(), pg.InventoryPath))
|
||||
defer logger.Wait()
|
||||
|
||||
_, err = task.WaitForResult(ctx, logger)
|
||||
return err
|
||||
}
|
177
vendor/github.com/vmware/govmomi/govc/dvs/portgroup/info.go
generated
vendored
Normal file
177
vendor/github.com/vmware/govmomi/govc/dvs/portgroup/info.go
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
Copyright (c) 2015-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"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/object"
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type info struct {
|
||||
*flags.DatacenterFlag
|
||||
|
||||
pg string
|
||||
active bool
|
||||
connected bool
|
||||
inside bool
|
||||
uplinkPort bool
|
||||
vlanID int
|
||||
count uint
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("dvs.portgroup.info", &info{})
|
||||
}
|
||||
|
||||
func (cmd *info) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.DatacenterFlag, ctx = flags.NewDatacenterFlag(ctx)
|
||||
cmd.DatacenterFlag.Register(ctx, f)
|
||||
|
||||
f.StringVar(&cmd.pg, "pg", "", "Distributed Virtual Portgroup")
|
||||
f.BoolVar(&cmd.active, "active", false, "Filter by port active or inactive status")
|
||||
f.BoolVar(&cmd.connected, "connected", false, "Filter by port connected or disconnected status")
|
||||
f.BoolVar(&cmd.inside, "inside", true, "Filter by port inside or outside status")
|
||||
f.BoolVar(&cmd.uplinkPort, "uplinkPort", false, "Filter for uplink ports")
|
||||
f.IntVar(&cmd.vlanID, "vlan", 0, "Filter by VLAN ID (0 = unfiltered)")
|
||||
f.UintVar(&cmd.count, "count", 0, "Number of matches to return (0 = unlimited)")
|
||||
}
|
||||
|
||||
func (cmd *info) Process(ctx context.Context) error {
|
||||
if err := cmd.ClientFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *info) Usage() string {
|
||||
return "DVS"
|
||||
}
|
||||
|
||||
func (cmd *info) Description() string {
|
||||
return `Portgroup info for DVS.
|
||||
|
||||
Examples:
|
||||
govc dvs.portgroup.info DSwitch
|
||||
govc find / -type DistributedVirtualSwitch | xargs -n1 govc dvs.portgroup.info`
|
||||
}
|
||||
|
||||
func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
if f.NArg() != 1 {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
client, err := cmd.Client()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
finder, err := cmd.Finder()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Retrieve DVS reference
|
||||
net, err := finder.Network(ctx, f.Arg(0))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Convert to DVS object type
|
||||
dvs, ok := net.(*object.DistributedVirtualSwitch)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s (%s) is not a DVS", f.Arg(0), net.Reference().Type)
|
||||
}
|
||||
|
||||
// Set base search criteria
|
||||
criteria := types.DistributedVirtualSwitchPortCriteria{
|
||||
Connected: types.NewBool(cmd.connected),
|
||||
Active: types.NewBool(cmd.active),
|
||||
UplinkPort: types.NewBool(cmd.uplinkPort),
|
||||
Inside: types.NewBool(cmd.inside),
|
||||
}
|
||||
|
||||
// If a distributed virtual portgroup path is set, then add its portgroup key to the base criteria
|
||||
if len(cmd.pg) > 0 {
|
||||
// Retrieve distributed virtual portgroup reference
|
||||
net, err = finder.Network(ctx, cmd.pg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Convert distributed virtual portgroup object type
|
||||
dvpg, ok := net.(*object.DistributedVirtualPortgroup)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s (%s) is not a DVPG", cmd.pg, net.Reference().Type)
|
||||
}
|
||||
|
||||
// Obtain portgroup key property
|
||||
var dvp mo.DistributedVirtualPortgroup
|
||||
if err := dvpg.Properties(ctx, dvpg.Reference(), []string{"key"}, &dvp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Add portgroup key to port search criteria
|
||||
criteria.PortgroupKey = []string{dvp.Key}
|
||||
}
|
||||
|
||||
// Prepare request
|
||||
req := types.FetchDVPorts{
|
||||
This: dvs.Reference(),
|
||||
Criteria: &criteria,
|
||||
}
|
||||
|
||||
// Fetch ports
|
||||
res, err := methods.FetchDVPorts(ctx, client, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var returnedPorts uint
|
||||
|
||||
// Iterate over returned ports
|
||||
for _, port := range res.Returnval {
|
||||
portConfigSetting := port.Config.Setting.(*types.VMwareDVSPortSetting)
|
||||
portVlan := portConfigSetting.Vlan.(*types.VmwareDistributedVirtualSwitchVlanIdSpec)
|
||||
portVlanID := portVlan.VlanId
|
||||
|
||||
// Show port info if: VLAN ID is not defined, or VLAN ID matches requested VLAN
|
||||
if cmd.vlanID == 0 || portVlanID == int32(cmd.vlanID) {
|
||||
returnedPorts++
|
||||
|
||||
fmt.Printf("PortgroupKey: %s\n", port.PortgroupKey)
|
||||
fmt.Printf("DvsUuid: %s\n", port.DvsUuid)
|
||||
fmt.Printf("VlanId: %d\n", portVlanID)
|
||||
fmt.Printf("PortKey: %s\n\n", port.Key)
|
||||
|
||||
// If we are limiting the count and have reached the count, then stop returning output
|
||||
if cmd.count > 0 && returnedPorts == cmd.count {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
55
vendor/github.com/vmware/govmomi/govc/dvs/portgroup/spec.go
generated
vendored
Normal file
55
vendor/github.com/vmware/govmomi/govc/dvs/portgroup/spec.go
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
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"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type DVPortgroupConfigSpec struct {
|
||||
types.DVPortgroupConfigSpec
|
||||
}
|
||||
|
||||
func (spec *DVPortgroupConfigSpec) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
ptypes := []string{
|
||||
string(types.DistributedVirtualPortgroupPortgroupTypeEarlyBinding),
|
||||
string(types.DistributedVirtualPortgroupPortgroupTypeLateBinding),
|
||||
string(types.DistributedVirtualPortgroupPortgroupTypeEphemeral),
|
||||
}
|
||||
|
||||
f.StringVar(&spec.Type, "type", ptypes[0],
|
||||
fmt.Sprintf("Portgroup type (%s)", strings.Join(ptypes, "|")))
|
||||
|
||||
f.Var(flags.NewInt32(&spec.NumPorts), "nports", "Number of ports")
|
||||
|
||||
config := new(types.VMwareDVSPortSetting)
|
||||
vlan := new(types.VmwareDistributedVirtualSwitchVlanIdSpec)
|
||||
spec.DefaultPortConfig = config
|
||||
config.Vlan = vlan
|
||||
|
||||
f.Var(flags.NewInt32(&vlan.VlanId), "vlan", "VLAN ID")
|
||||
}
|
||||
|
||||
func (spec *DVPortgroupConfigSpec) Spec() types.DVPortgroupConfigSpec {
|
||||
return spec.DVPortgroupConfigSpec
|
||||
}
|
Reference in New Issue
Block a user