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

96
vendor/github.com/vmware/govmomi/govc/license/add.go generated vendored Normal file
View File

@@ -0,0 +1,96 @@
/*
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 license
import (
"context"
"flag"
"fmt"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/license"
"github.com/vmware/govmomi/vim25/types"
)
type add struct {
*flags.ClientFlag
*flags.OutputFlag
}
func init() {
cli.Register("license.add", &add{})
}
func (cmd *add) 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)
}
func (cmd *add) 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
}
return nil
}
func (cmd *add) Usage() string {
return "KEY..."
}
func (cmd *add) Run(ctx context.Context, f *flag.FlagSet) error {
client, err := cmd.Client()
if err != nil {
return err
}
m := license.NewManager(client)
// From the vSphere 5.5 documentation:
//
// To specify the edition type and any optional functions, use
// updateLicense for ESX Server and addLicense follow by
// LicenseAssingmentManager.updateAssignedLicense for VirtualCenter.
//
var addFunc func(ctx context.Context, key string, labels map[string]string) (types.LicenseManagerLicenseInfo, error)
switch t := client.ServiceContent.About.ApiType; t {
case "HostAgent":
addFunc = m.Update
case "VirtualCenter":
addFunc = m.Add
default:
return fmt.Errorf("unsupported ApiType: %s", t)
}
result := make(licenseOutput, 0)
for _, v := range f.Args() {
license, err := addFunc(ctx, v, nil)
if err != nil {
return err
}
result = append(result, license)
}
return cmd.WriteResult(licenseOutput(result))
}

114
vendor/github.com/vmware/govmomi/govc/license/assign.go generated vendored Normal file
View File

@@ -0,0 +1,114 @@
/*
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 license
import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/license"
"github.com/vmware/govmomi/vim25/types"
)
type assign struct {
*flags.ClientFlag
*flags.OutputFlag
*flags.HostSystemFlag
name string
remove bool
}
func init() {
cli.Register("license.assign", &assign{})
}
func (cmd *assign) 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)
f.StringVar(&cmd.name, "name", "", "Display name")
f.BoolVar(&cmd.remove, "remove", false, "Remove assignment")
}
func (cmd *assign) 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 (cmd *assign) Usage() string {
return "KEY"
}
func (cmd *assign) Run(ctx context.Context, f *flag.FlagSet) error {
if f.NArg() != 1 {
return flag.ErrHelp
}
key := f.Arg(0)
client, err := cmd.Client()
if err != nil {
return err
}
m, err := license.NewManager(client).AssignmentManager(ctx)
if err != nil {
return err
}
host, err := cmd.HostSystemIfSpecified()
if err != nil {
return err
}
var id string
if host == nil {
// Default to vCenter UUID
id = client.ServiceContent.About.InstanceUuid
} else {
id = host.Reference().Value
}
if cmd.remove {
return m.Remove(ctx, id)
}
info, err := m.Update(ctx, id, key, cmd.name)
if err != nil {
return err
}
return cmd.WriteResult(licenseOutput([]types.LicenseManagerLicenseInfo{*info}))
}

View File

@@ -0,0 +1,96 @@
/*
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 license
import (
"context"
"flag"
"fmt"
"io"
"os"
"text/tabwriter"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/license"
"github.com/vmware/govmomi/vim25/types"
)
type assigned struct {
*flags.ClientFlag
*flags.OutputFlag
id string
}
func init() {
cli.Register("license.assigned.ls", &assigned{})
}
func (cmd *assigned) 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)
f.StringVar(&cmd.id, "id", "", "Entity ID")
}
func (cmd *assigned) 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
}
return nil
}
func (cmd *assigned) Run(ctx context.Context, f *flag.FlagSet) error {
client, err := cmd.Client()
if err != nil {
return err
}
m, err := license.NewManager(client).AssignmentManager(ctx)
if err != nil {
return err
}
assigned, err := m.QueryAssigned(ctx, cmd.id)
if err != nil {
return err
}
return cmd.WriteResult(assignedOutput(assigned))
}
type assignedOutput []types.LicenseAssignmentManagerLicenseAssignment
func (res assignedOutput) Write(w io.Writer) error {
tw := tabwriter.NewWriter(os.Stdout, 4, 0, 2, ' ', 0)
fmt.Fprintf(tw, "Id:\tScope:\tName:\tLicense:\n")
for _, v := range res {
fmt.Fprintf(tw, "%s\t", v.EntityId)
fmt.Fprintf(tw, "%s\t", v.Scope)
fmt.Fprintf(tw, "%s\t", v.EntityDisplayName)
fmt.Fprintf(tw, "%s\t", v.AssignedLicense.LicenseKey)
fmt.Fprintf(tw, "\n")
}
return tw.Flush()
}

View File

@@ -0,0 +1,85 @@
/*
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 license
import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/license"
)
type decode struct {
*flags.ClientFlag
*flags.OutputFlag
feature string
}
func init() {
cli.Register("license.decode", &decode{})
}
func (cmd *decode) 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)
f.StringVar(&cmd.feature, "feature", "", featureUsage)
}
func (cmd *decode) 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
}
return nil
}
func (cmd *decode) Usage() string {
return "KEY..."
}
func (cmd *decode) Run(ctx context.Context, f *flag.FlagSet) error {
client, err := cmd.Client()
if err != nil {
return err
}
var result license.InfoList
m := license.NewManager(client)
for _, v := range f.Args() {
license, err := m.Decode(ctx, v)
if err != nil {
return err
}
result = append(result, license)
}
if cmd.feature != "" {
result = result.WithFeature(cmd.feature)
}
return cmd.WriteResult(licenseOutput(result))
}

78
vendor/github.com/vmware/govmomi/govc/license/ls.go generated vendored Normal file
View File

@@ -0,0 +1,78 @@
/*
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 license
import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/license"
)
var featureUsage = "List licenses with given feature"
type ls struct {
*flags.ClientFlag
*flags.OutputFlag
feature string
}
func init() {
cli.Register("license.ls", &ls{})
}
func (cmd *ls) 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)
f.StringVar(&cmd.feature, "feature", "", featureUsage)
}
func (cmd *ls) 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
}
return nil
}
func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error {
client, err := cmd.Client()
if err != nil {
return err
}
m := license.NewManager(client)
result, err := m.List(ctx)
if err != nil {
return err
}
if cmd.feature != "" {
result = result.WithFeature(cmd.feature)
}
return cmd.WriteResult(licenseOutput(result))
}

View File

@@ -0,0 +1,41 @@
/*
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 license
import (
"fmt"
"io"
"os"
"text/tabwriter"
"github.com/vmware/govmomi/vim25/types"
)
type licenseOutput []types.LicenseManagerLicenseInfo
func (res licenseOutput) Write(w io.Writer) error {
tw := tabwriter.NewWriter(os.Stdout, 4, 0, 2, ' ', 0)
fmt.Fprintf(tw, "Key:\tEdition:\tUsed:\tTotal:\n")
for _, v := range res {
fmt.Fprintf(tw, "%s\t", v.LicenseKey)
fmt.Fprintf(tw, "%s\t", v.EditionKey)
fmt.Fprintf(tw, "%d\t", v.Used)
fmt.Fprintf(tw, "%d\t", v.Total)
fmt.Fprintf(tw, "\n")
}
return tw.Flush()
}

View File

@@ -0,0 +1,74 @@
/*
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 license
import (
"context"
"flag"
"github.com/vmware/govmomi/govc/cli"
"github.com/vmware/govmomi/govc/flags"
"github.com/vmware/govmomi/license"
)
type remove struct {
*flags.ClientFlag
*flags.OutputFlag
}
func init() {
cli.Register("license.remove", &remove{})
}
func (cmd *remove) 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)
}
func (cmd *remove) 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
}
return nil
}
func (cmd *remove) Usage() string {
return "KEY..."
}
func (cmd *remove) Run(ctx context.Context, f *flag.FlagSet) error {
client, err := cmd.Client()
if err != nil {
return err
}
m := license.NewManager(client)
for _, v := range f.Args() {
err = m.Remove(ctx, v)
if err != nil {
return err
}
}
return nil
}