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:
90
vendor/github.com/vmware/govmomi/govc/device/boot.go
generated
vendored
Normal file
90
vendor/github.com/vmware/govmomi/govc/device/boot.go
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 device
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"strings"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type boot struct {
|
||||
*flags.VirtualMachineFlag
|
||||
|
||||
order string
|
||||
types.VirtualMachineBootOptions
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.boot", &boot{})
|
||||
}
|
||||
|
||||
func (cmd *boot) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
f.Int64Var(&cmd.BootDelay, "delay", 0, "Delay in ms before starting the boot sequence")
|
||||
f.StringVar(&cmd.order, "order", "", "Boot device order")
|
||||
f.Int64Var(&cmd.BootRetryDelay, "retry-delay", 0, "Delay in ms before a boot retry")
|
||||
|
||||
cmd.BootRetryEnabled = types.NewBool(false)
|
||||
f.BoolVar(cmd.BootRetryEnabled, "retry", false, "If true, retry boot after retry-delay")
|
||||
|
||||
cmd.EnterBIOSSetup = types.NewBool(false)
|
||||
f.BoolVar(cmd.EnterBIOSSetup, "setup", false, "If true, enter BIOS setup on next boot")
|
||||
}
|
||||
|
||||
func (cmd *boot) Description() string {
|
||||
return `Configure VM boot settings.
|
||||
|
||||
Examples:
|
||||
govc device.boot -vm $vm -delay 1000 -order floppy,cdrom,ethernet,disk`
|
||||
}
|
||||
|
||||
func (cmd *boot) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *boot) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if cmd.order != "" {
|
||||
o := strings.Split(cmd.order, ",")
|
||||
cmd.BootOrder = devices.BootOrder(o)
|
||||
}
|
||||
|
||||
return vm.SetBootOptions(ctx, &cmd.VirtualMachineBootOptions)
|
||||
}
|
105
vendor/github.com/vmware/govmomi/govc/device/cdrom/add.go
generated
vendored
Normal file
105
vendor/github.com/vmware/govmomi/govc/device/cdrom/add.go
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 cdrom
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type add struct {
|
||||
*flags.VirtualMachineFlag
|
||||
|
||||
controller string
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.cdrom.add", &add{})
|
||||
}
|
||||
|
||||
func (cmd *add) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
f.StringVar(&cmd.controller, "controller", "", "IDE controller name")
|
||||
}
|
||||
|
||||
func (cmd *add) Description() string {
|
||||
return `Add CD-ROM device to VM.
|
||||
|
||||
Examples:
|
||||
govc device.cdrom.add -vm $vm
|
||||
govc device.ls -vm $vm | grep ide-
|
||||
govc device.cdrom.add -vm $vm -controller ide-200
|
||||
govc device.info cdrom-*`
|
||||
}
|
||||
|
||||
func (cmd *add) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *add) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := devices.FindIDEController(cmd.controller)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d, err := devices.CreateCdrom(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = vm.AddDevice(ctx, d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// output name of device we just created
|
||||
devices, err = vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
devices = devices.SelectByType(d)
|
||||
|
||||
name := devices.Name(devices[len(devices)-1])
|
||||
|
||||
fmt.Println(name)
|
||||
|
||||
return nil
|
||||
}
|
82
vendor/github.com/vmware/govmomi/govc/device/cdrom/eject.go
generated
vendored
Normal file
82
vendor/github.com/vmware/govmomi/govc/device/cdrom/eject.go
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 cdrom
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type eject struct {
|
||||
*flags.VirtualMachineFlag
|
||||
|
||||
device string
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.cdrom.eject", &eject{})
|
||||
}
|
||||
|
||||
func (cmd *eject) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
f.StringVar(&cmd.device, "device", "", "CD-ROM device name")
|
||||
}
|
||||
|
||||
func (cmd *eject) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *eject) Description() string {
|
||||
return `Eject media from CD-ROM device.
|
||||
|
||||
If device is not specified, the first CD-ROM device is used.
|
||||
|
||||
Examples:
|
||||
govc device.cdrom.eject -vm vm-1
|
||||
govc device.cdrom.eject -vm vm-1 -device floppy-1`
|
||||
}
|
||||
|
||||
func (cmd *eject) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := devices.FindCdrom(cmd.device)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return vm.EditDevice(ctx, devices.EjectIso(c))
|
||||
}
|
96
vendor/github.com/vmware/govmomi/govc/device/cdrom/insert.go
generated
vendored
Normal file
96
vendor/github.com/vmware/govmomi/govc/device/cdrom/insert.go
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 cdrom
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type insert struct {
|
||||
*flags.DatastoreFlag
|
||||
*flags.VirtualMachineFlag
|
||||
|
||||
device string
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.cdrom.insert", &insert{})
|
||||
}
|
||||
|
||||
func (cmd *insert) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.DatastoreFlag, ctx = flags.NewDatastoreFlag(ctx)
|
||||
cmd.DatastoreFlag.Register(ctx, f)
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
f.StringVar(&cmd.device, "device", "", "CD-ROM device name")
|
||||
}
|
||||
|
||||
func (cmd *insert) Process(ctx context.Context) error {
|
||||
if err := cmd.DatastoreFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *insert) Usage() string {
|
||||
return "ISO"
|
||||
}
|
||||
|
||||
func (cmd *insert) Description() string {
|
||||
return `Insert media on datastore into CD-ROM device.
|
||||
|
||||
If device is not specified, the first CD-ROM device is used.
|
||||
|
||||
Examples:
|
||||
govc device.cdrom.insert -vm vm-1 -device cdrom-3000 images/boot.iso`
|
||||
}
|
||||
|
||||
func (cmd *insert) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil || f.NArg() != 1 {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := devices.FindCdrom(cmd.device)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
iso, err := cmd.DatastorePath(f.Arg(0))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return vm.EditDevice(ctx, devices.InsertIso(c, iso))
|
||||
}
|
90
vendor/github.com/vmware/govmomi/govc/device/connect.go
generated
vendored
Normal file
90
vendor/github.com/vmware/govmomi/govc/device/connect.go
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 device
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type connect struct {
|
||||
*flags.VirtualMachineFlag
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.connect", &connect{})
|
||||
}
|
||||
|
||||
func (cmd *connect) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
}
|
||||
|
||||
func (cmd *connect) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *connect) Usage() string {
|
||||
return "DEVICE..."
|
||||
}
|
||||
|
||||
func (cmd *connect) Description() string {
|
||||
return `Connect DEVICE on VM.
|
||||
|
||||
Examples:
|
||||
govc device.connect -vm $name cdrom-3000`
|
||||
}
|
||||
|
||||
func (cmd *connect) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, name := range f.Args() {
|
||||
device := devices.Find(name)
|
||||
if device == nil {
|
||||
return fmt.Errorf("device '%s' not found", name)
|
||||
}
|
||||
|
||||
if err = devices.Connect(device); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = vm.EditDevice(ctx, device); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
90
vendor/github.com/vmware/govmomi/govc/device/disconnect.go
generated
vendored
Normal file
90
vendor/github.com/vmware/govmomi/govc/device/disconnect.go
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 device
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type disconnect struct {
|
||||
*flags.VirtualMachineFlag
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.disconnect", &disconnect{})
|
||||
}
|
||||
|
||||
func (cmd *disconnect) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
}
|
||||
|
||||
func (cmd *disconnect) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *disconnect) Usage() string {
|
||||
return "DEVICE..."
|
||||
}
|
||||
|
||||
func (cmd *disconnect) Description() string {
|
||||
return `Disconnect DEVICE on VM.
|
||||
|
||||
Examples:
|
||||
govc device.disconnect -vm $name cdrom-3000`
|
||||
}
|
||||
|
||||
func (cmd *disconnect) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, name := range f.Args() {
|
||||
device := devices.Find(name)
|
||||
if device == nil {
|
||||
return fmt.Errorf("device '%s' not found", name)
|
||||
}
|
||||
|
||||
if err = devices.Disconnect(device); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = vm.EditDevice(ctx, device); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
94
vendor/github.com/vmware/govmomi/govc/device/floppy/add.go
generated
vendored
Normal file
94
vendor/github.com/vmware/govmomi/govc/device/floppy/add.go
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 floppy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type add struct {
|
||||
*flags.VirtualMachineFlag
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.floppy.add", &add{})
|
||||
}
|
||||
|
||||
func (cmd *add) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
}
|
||||
|
||||
func (cmd *add) Description() string {
|
||||
return `Add floppy device to VM.
|
||||
|
||||
Examples:
|
||||
govc device.floppy.add -vm $vm
|
||||
govc device.info floppy-*`
|
||||
}
|
||||
|
||||
func (cmd *add) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *add) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d, err := devices.CreateFloppy()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = vm.AddDevice(ctx, d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// output name of device we just created
|
||||
devices, err = vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
devices = devices.SelectByType(d)
|
||||
|
||||
name := devices.Name(devices[len(devices)-1])
|
||||
|
||||
fmt.Println(name)
|
||||
|
||||
return nil
|
||||
}
|
81
vendor/github.com/vmware/govmomi/govc/device/floppy/eject.go
generated
vendored
Normal file
81
vendor/github.com/vmware/govmomi/govc/device/floppy/eject.go
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 floppy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type eject struct {
|
||||
*flags.VirtualMachineFlag
|
||||
|
||||
device string
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.floppy.eject", &eject{})
|
||||
}
|
||||
|
||||
func (cmd *eject) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
f.StringVar(&cmd.device, "device", "", "Floppy device name")
|
||||
}
|
||||
|
||||
func (cmd *eject) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *eject) Description() string {
|
||||
return `Eject image from floppy device.
|
||||
|
||||
If device is not specified, the first floppy device is used.
|
||||
|
||||
Examples:
|
||||
govc device.floppy.eject -vm vm-1`
|
||||
}
|
||||
|
||||
func (cmd *eject) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := devices.FindFloppy(cmd.device)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return vm.EditDevice(ctx, devices.EjectImg(c))
|
||||
}
|
96
vendor/github.com/vmware/govmomi/govc/device/floppy/insert.go
generated
vendored
Normal file
96
vendor/github.com/vmware/govmomi/govc/device/floppy/insert.go
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 floppy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type insert struct {
|
||||
*flags.DatastoreFlag
|
||||
*flags.VirtualMachineFlag
|
||||
|
||||
device string
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.floppy.insert", &insert{})
|
||||
}
|
||||
|
||||
func (cmd *insert) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.DatastoreFlag, ctx = flags.NewDatastoreFlag(ctx)
|
||||
cmd.DatastoreFlag.Register(ctx, f)
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
f.StringVar(&cmd.device, "device", "", "Floppy device name")
|
||||
}
|
||||
|
||||
func (cmd *insert) Process(ctx context.Context) error {
|
||||
if err := cmd.DatastoreFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *insert) Usage() string {
|
||||
return "IMG"
|
||||
}
|
||||
|
||||
func (cmd *insert) Description() string {
|
||||
return `Insert IMG on datastore into floppy device.
|
||||
|
||||
If device is not specified, the first floppy device is used.
|
||||
|
||||
Examples:
|
||||
govc device.floppy.insert -vm vm-1 vm-1/config.img`
|
||||
}
|
||||
|
||||
func (cmd *insert) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil || f.NArg() != 1 {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := devices.FindFloppy(cmd.device)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
img, err := cmd.DatastorePath(f.Arg(0))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return vm.EditDevice(ctx, devices.InsertImg(c, img))
|
||||
}
|
216
vendor/github.com/vmware/govmomi/govc/device/info.go
generated
vendored
Normal file
216
vendor/github.com/vmware/govmomi/govc/device/info.go
generated
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 device
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/object"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type info struct {
|
||||
*flags.VirtualMachineFlag
|
||||
*flags.OutputFlag
|
||||
*flags.NetworkFlag
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.info", &info{})
|
||||
}
|
||||
|
||||
func (cmd *info) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
cmd.OutputFlag, ctx = flags.NewOutputFlag(ctx)
|
||||
cmd.OutputFlag.Register(ctx, f)
|
||||
|
||||
cmd.NetworkFlag, ctx = flags.NewNetworkFlag(ctx)
|
||||
cmd.NetworkFlag.Register(ctx, f)
|
||||
}
|
||||
|
||||
func (cmd *info) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.OutputFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cmd.NetworkFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *info) Usage() string {
|
||||
return "[DEVICE]..."
|
||||
}
|
||||
|
||||
func (cmd *info) Description() string {
|
||||
return `Device info for VM.
|
||||
|
||||
Examples:
|
||||
govc device.info -vm $name
|
||||
govc device.info -vm $name disk-*
|
||||
govc device.info -vm $name -json ethernet-0 | jq -r .Devices[].MacAddress`
|
||||
}
|
||||
|
||||
func (cmd *info) match(p string, devices object.VirtualDeviceList) object.VirtualDeviceList {
|
||||
var matches object.VirtualDeviceList
|
||||
match := func(name string) bool {
|
||||
matched, _ := path.Match(p, name)
|
||||
return matched
|
||||
}
|
||||
|
||||
for _, device := range devices {
|
||||
name := devices.Name(device)
|
||||
eq := name == p
|
||||
if eq || match(name) {
|
||||
matches = append(matches, device)
|
||||
}
|
||||
if eq {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return matches
|
||||
}
|
||||
|
||||
func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
res := infoResult{
|
||||
list: devices,
|
||||
}
|
||||
|
||||
if cmd.NetworkFlag.IsSet() {
|
||||
net, err := cmd.Network()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
backing, err := net.EthernetCardBackingInfo(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
devices = devices.SelectByBackingInfo(backing)
|
||||
}
|
||||
|
||||
if f.NArg() == 0 {
|
||||
res.Devices = devices
|
||||
} else {
|
||||
for _, name := range f.Args() {
|
||||
matches := cmd.match(name, devices)
|
||||
if len(matches) == 0 {
|
||||
return fmt.Errorf("device '%s' not found", name)
|
||||
}
|
||||
|
||||
res.Devices = append(res.Devices, matches...)
|
||||
}
|
||||
}
|
||||
|
||||
return cmd.WriteResult(&res)
|
||||
}
|
||||
|
||||
type infoResult struct {
|
||||
Devices object.VirtualDeviceList
|
||||
// need the full list of devices to lookup attached devices and controllers
|
||||
list object.VirtualDeviceList
|
||||
}
|
||||
|
||||
func (r *infoResult) Write(w io.Writer) error {
|
||||
tw := tabwriter.NewWriter(os.Stdout, 2, 0, 2, ' ', 0)
|
||||
|
||||
for _, device := range r.Devices {
|
||||
d := device.GetVirtualDevice()
|
||||
info := d.DeviceInfo.GetDescription()
|
||||
|
||||
fmt.Fprintf(tw, "Name:\t%s\n", r.Devices.Name(device))
|
||||
fmt.Fprintf(tw, " Type:\t%s\n", r.Devices.TypeName(device))
|
||||
fmt.Fprintf(tw, " Label:\t%s\n", info.Label)
|
||||
fmt.Fprintf(tw, " Summary:\t%s\n", info.Summary)
|
||||
fmt.Fprintf(tw, " Key:\t%d\n", d.Key)
|
||||
|
||||
if c, ok := device.(types.BaseVirtualController); ok {
|
||||
var attached []string
|
||||
for _, key := range c.GetVirtualController().Device {
|
||||
attached = append(attached, r.Devices.Name(r.list.FindByKey(key)))
|
||||
}
|
||||
fmt.Fprintf(tw, " Devices:\t%s\n", strings.Join(attached, ", "))
|
||||
} else {
|
||||
if c := r.list.FindByKey(d.ControllerKey); c != nil {
|
||||
fmt.Fprintf(tw, " Controller:\t%s\n", r.Devices.Name(c))
|
||||
if d.UnitNumber != nil {
|
||||
fmt.Fprintf(tw, " Unit number:\t%d\n", *d.UnitNumber)
|
||||
} else {
|
||||
fmt.Fprintf(tw, " Unit number:\t<nil>\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ca := d.Connectable; ca != nil {
|
||||
fmt.Fprintf(tw, " Connected:\t%t\n", ca.Connected)
|
||||
fmt.Fprintf(tw, " Start connected:\t%t\n", ca.StartConnected)
|
||||
fmt.Fprintf(tw, " Guest control:\t%t\n", ca.AllowGuestControl)
|
||||
fmt.Fprintf(tw, " Status:\t%s\n", ca.Status)
|
||||
}
|
||||
|
||||
switch md := device.(type) {
|
||||
case types.BaseVirtualEthernetCard:
|
||||
fmt.Fprintf(tw, " MAC Address:\t%s\n", md.GetVirtualEthernetCard().MacAddress)
|
||||
fmt.Fprintf(tw, " Address type:\t%s\n", md.GetVirtualEthernetCard().AddressType)
|
||||
case *types.VirtualDisk:
|
||||
if b, ok := md.Backing.(types.BaseVirtualDeviceFileBackingInfo); ok {
|
||||
fmt.Fprintf(tw, " File:\t%s\n", b.GetVirtualDeviceFileBackingInfo().FileName)
|
||||
}
|
||||
if b, ok := md.Backing.(*types.VirtualDiskFlatVer2BackingInfo); ok && b.Parent != nil {
|
||||
fmt.Fprintf(tw, " Parent:\t%s\n", b.Parent.GetVirtualDeviceFileBackingInfo().FileName)
|
||||
}
|
||||
case *types.VirtualSerialPort:
|
||||
if b, ok := md.Backing.(*types.VirtualSerialPortURIBackingInfo); ok {
|
||||
fmt.Fprintf(tw, " Direction:\t%s\n", b.Direction)
|
||||
fmt.Fprintf(tw, " Service URI:\t%s\n", b.ServiceURI)
|
||||
fmt.Fprintf(tw, " Proxy URI:\t%s\n", b.ProxyURI)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tw.Flush()
|
||||
}
|
93
vendor/github.com/vmware/govmomi/govc/device/ls.go
generated
vendored
Normal file
93
vendor/github.com/vmware/govmomi/govc/device/ls.go
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 device
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type ls struct {
|
||||
*flags.VirtualMachineFlag
|
||||
|
||||
boot bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.ls", &ls{})
|
||||
}
|
||||
|
||||
func (cmd *ls) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
f.BoolVar(&cmd.boot, "boot", false, "List devices configured in the VM's boot options")
|
||||
}
|
||||
|
||||
func (cmd *ls) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *ls) Description() string {
|
||||
return `List devices for VM.
|
||||
|
||||
Examples:
|
||||
govc device.ls -vm $name`
|
||||
}
|
||||
|
||||
func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if cmd.boot {
|
||||
options, err := vm.BootOptions(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
devices = devices.SelectBootOrder(options.BootOrder)
|
||||
}
|
||||
|
||||
tw := tabwriter.NewWriter(os.Stdout, 3, 0, 2, ' ', 0)
|
||||
|
||||
for _, device := range devices {
|
||||
fmt.Fprintf(tw, "%s\t%s\t%s\n", devices.Name(device), devices.TypeName(device),
|
||||
device.GetVirtualDevice().DeviceInfo.GetDescription().Summary)
|
||||
}
|
||||
|
||||
return tw.Flush()
|
||||
}
|
89
vendor/github.com/vmware/govmomi/govc/device/remove.go
generated
vendored
Normal file
89
vendor/github.com/vmware/govmomi/govc/device/remove.go
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 device
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type remove struct {
|
||||
*flags.VirtualMachineFlag
|
||||
keepFiles bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.remove", &remove{})
|
||||
}
|
||||
|
||||
func (cmd *remove) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
f.BoolVar(&cmd.keepFiles, "keep", false, "Keep files in datastore")
|
||||
}
|
||||
|
||||
func (cmd *remove) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *remove) Usage() string {
|
||||
return "DEVICE..."
|
||||
}
|
||||
|
||||
func (cmd *remove) Description() string {
|
||||
return `Remove DEVICE from VM.
|
||||
|
||||
Examples:
|
||||
govc device.remove -vm $name cdrom-3000
|
||||
govc device.remove -vm $name -keep disk-1000`
|
||||
}
|
||||
|
||||
func (cmd *remove) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, name := range f.Args() {
|
||||
device := devices.Find(name)
|
||||
if device == nil {
|
||||
return fmt.Errorf("device '%s' not found", name)
|
||||
}
|
||||
|
||||
if err = vm.RemoveDevice(ctx, cmd.keepFiles, device); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
116
vendor/github.com/vmware/govmomi/govc/device/scsi/add.go
generated
vendored
Normal file
116
vendor/github.com/vmware/govmomi/govc/device/scsi/add.go
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 scsi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"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.VirtualMachineFlag
|
||||
|
||||
controller string
|
||||
sharedBus string
|
||||
hotAddRemove bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.scsi.add", &add{})
|
||||
}
|
||||
|
||||
func (cmd *add) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
var ctypes []string
|
||||
ct := object.SCSIControllerTypes()
|
||||
for _, t := range ct {
|
||||
ctypes = append(ctypes, ct.Type(t))
|
||||
}
|
||||
f.StringVar(&cmd.controller, "type", ct.Type(ct[0]),
|
||||
fmt.Sprintf("SCSI controller type (%s)", strings.Join(ctypes, "|")))
|
||||
f.StringVar(&cmd.sharedBus, "sharing", string(types.VirtualSCSISharingNoSharing), "SCSI sharing")
|
||||
f.BoolVar(&cmd.hotAddRemove, "hot", false, "Enable hot-add/remove")
|
||||
}
|
||||
|
||||
func (cmd *add) Description() string {
|
||||
return `Add SCSI controller to VM.
|
||||
|
||||
Examples:
|
||||
govc device.scsi.add -vm $vm
|
||||
govc device.scsi.add -vm $vm -type pvscsi
|
||||
govc device.info -vm $vm {lsi,pv}*`
|
||||
}
|
||||
|
||||
func (cmd *add) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *add) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d, err := devices.CreateSCSIController(cmd.controller)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := d.(types.BaseVirtualSCSIController).GetVirtualSCSIController()
|
||||
c.HotAddRemove = &cmd.hotAddRemove
|
||||
c.SharedBus = types.VirtualSCSISharing(cmd.sharedBus)
|
||||
|
||||
err = vm.AddDevice(ctx, d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// output name of device we just created
|
||||
devices, err = vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
devices = devices.SelectByType(d)
|
||||
|
||||
name := devices.Name(devices[len(devices)-1])
|
||||
|
||||
fmt.Println(name)
|
||||
|
||||
return nil
|
||||
}
|
94
vendor/github.com/vmware/govmomi/govc/device/serial/add.go
generated
vendored
Normal file
94
vendor/github.com/vmware/govmomi/govc/device/serial/add.go
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 serial
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type add struct {
|
||||
*flags.VirtualMachineFlag
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.serial.add", &add{})
|
||||
}
|
||||
|
||||
func (cmd *add) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
}
|
||||
|
||||
func (cmd *add) Description() string {
|
||||
return `Add serial port to VM.
|
||||
|
||||
Examples:
|
||||
govc device.serial.add -vm $vm
|
||||
govc device.info -vm $vm serialport-*`
|
||||
}
|
||||
|
||||
func (cmd *add) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *add) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d, err := devices.CreateSerialPort()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = vm.AddDevice(ctx, d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// output name of device we just created
|
||||
devices, err = vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
devices = devices.SelectByType(d)
|
||||
|
||||
name := devices.Name(devices[len(devices)-1])
|
||||
|
||||
fmt.Println(name)
|
||||
|
||||
return nil
|
||||
}
|
116
vendor/github.com/vmware/govmomi/govc/device/serial/connect.go
generated
vendored
Normal file
116
vendor/github.com/vmware/govmomi/govc/device/serial/connect.go
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 serial
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
)
|
||||
|
||||
type connect struct {
|
||||
*flags.VirtualMachineFlag
|
||||
|
||||
proxy string
|
||||
device string
|
||||
client bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.serial.connect", &connect{})
|
||||
}
|
||||
|
||||
func (cmd *connect) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
f.StringVar(&cmd.proxy, "vspc-proxy", "", "vSPC proxy URI")
|
||||
f.StringVar(&cmd.device, "device", "", "serial port device name")
|
||||
f.BoolVar(&cmd.client, "client", false, "Use client direction")
|
||||
}
|
||||
|
||||
func (cmd *connect) Usage() string {
|
||||
return "URI"
|
||||
}
|
||||
|
||||
func (cmd *connect) Description() string {
|
||||
return `Connect service URI to serial port.
|
||||
|
||||
If "-" is given as URI, connects file backed device with file name of
|
||||
device name + .log suffix in the VM Config.Files.LogDirectory.
|
||||
|
||||
Defaults to the first serial port if no DEVICE is given.
|
||||
|
||||
Examples:
|
||||
govc device.ls | grep serialport-
|
||||
govc device.serial.connect -vm $vm -device serialport-8000 telnet://:33233
|
||||
govc device.info -vm $vm serialport-*
|
||||
govc device.serial.connect -vm $vm "[datastore1] $vm/console.log"
|
||||
govc device.serial.connect -vm $vm -
|
||||
govc datastore.tail -f $vm/serialport-8000.log`
|
||||
}
|
||||
|
||||
func (cmd *connect) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *connect) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
if f.NArg() != 1 {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d, err := devices.FindSerialPort(cmd.device)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
uri := f.Arg(0)
|
||||
|
||||
if uri == "-" {
|
||||
var mvm mo.VirtualMachine
|
||||
err = vm.Properties(ctx, vm.Reference(), []string{"config.files.logDirectory"}, &mvm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
uri = path.Join(mvm.Config.Files.LogDirectory, fmt.Sprintf("%s.log", devices.Name(d)))
|
||||
}
|
||||
|
||||
return vm.EditDevice(ctx, devices.ConnectSerialPort(d, uri, cmd.client, cmd.proxy))
|
||||
}
|
81
vendor/github.com/vmware/govmomi/govc/device/serial/disconnect.go
generated
vendored
Normal file
81
vendor/github.com/vmware/govmomi/govc/device/serial/disconnect.go
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
Copyright (c) 2014-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 serial
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
)
|
||||
|
||||
type disconnect struct {
|
||||
*flags.VirtualMachineFlag
|
||||
|
||||
device string
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.serial.disconnect", &disconnect{})
|
||||
}
|
||||
|
||||
func (cmd *disconnect) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
f.StringVar(&cmd.device, "device", "", "serial port device name")
|
||||
}
|
||||
|
||||
func (cmd *disconnect) Description() string {
|
||||
return `Disconnect service URI from serial port.
|
||||
|
||||
Examples:
|
||||
govc device.ls | grep serialport-
|
||||
govc device.serial.disconnect -vm $vm -device serialport-8000
|
||||
govc device.info -vm $vm serialport-*`
|
||||
}
|
||||
|
||||
func (cmd *disconnect) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *disconnect) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d, err := devices.FindSerialPort(cmd.device)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return vm.EditDevice(ctx, devices.DisconnectSerialPort(d))
|
||||
}
|
114
vendor/github.com/vmware/govmomi/govc/device/usb/add.go
generated
vendored
Normal file
114
vendor/github.com/vmware/govmomi/govc/device/usb/add.go
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
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 usb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/vmware/govmomi/govc/cli"
|
||||
"github.com/vmware/govmomi/govc/flags"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type add struct {
|
||||
*flags.VirtualMachineFlag
|
||||
|
||||
controller string
|
||||
autoConnect bool
|
||||
ehciEnabled bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
cli.Register("device.usb.add", &add{})
|
||||
}
|
||||
|
||||
func (cmd *add) Register(ctx context.Context, f *flag.FlagSet) {
|
||||
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
|
||||
cmd.VirtualMachineFlag.Register(ctx, f)
|
||||
|
||||
ctypes := []string{"usb", "xhci"}
|
||||
f.StringVar(&cmd.controller, "type", ctypes[0],
|
||||
fmt.Sprintf("USB controller type (%s)", strings.Join(ctypes, "|")))
|
||||
|
||||
f.BoolVar(&cmd.autoConnect, "auto", true, "Enable ability to hot plug devices")
|
||||
f.BoolVar(&cmd.ehciEnabled, "ehci", true, "Enable enhanced host controller interface (USB 2.0)")
|
||||
}
|
||||
|
||||
func (cmd *add) Description() string {
|
||||
return `Add USB device to VM.
|
||||
|
||||
Examples:
|
||||
govc device.usb.add -vm $vm
|
||||
govc device.usb.add -type xhci -vm $vm
|
||||
govc device.info usb*`
|
||||
}
|
||||
|
||||
func (cmd *add) Process(ctx context.Context) error {
|
||||
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cmd *add) Run(ctx context.Context, f *flag.FlagSet) error {
|
||||
vm, err := cmd.VirtualMachine()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if vm == nil {
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
var d types.BaseVirtualDevice
|
||||
|
||||
switch cmd.controller {
|
||||
case "usb":
|
||||
c := new(types.VirtualUSBController)
|
||||
c.AutoConnectDevices = &cmd.autoConnect
|
||||
c.EhciEnabled = &cmd.ehciEnabled
|
||||
d = c
|
||||
case "xhci":
|
||||
c := new(types.VirtualUSBXHCIController)
|
||||
c.AutoConnectDevices = &cmd.autoConnect
|
||||
d = c
|
||||
default:
|
||||
return flag.ErrHelp
|
||||
}
|
||||
|
||||
err = vm.AddDevice(ctx, d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// output name of device we just created
|
||||
devices, err := vm.Device(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
devices = devices.SelectByType(d)
|
||||
|
||||
name := devices.Name(devices[len(devices)-1])
|
||||
|
||||
fmt.Println(name)
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user