本文整理汇总了Golang中github.com/vmware/govmomi/object.NewDistributedVirtualPortgroup函数的典型用法代码示例。如果您正苦于以下问题:Golang NewDistributedVirtualPortgroup函数的具体用法?Golang NewDistributedVirtualPortgroup怎么用?Golang NewDistributedVirtualPortgroup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewDistributedVirtualPortgroup函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NetworkList
func (f *Finder) NetworkList(ctx context.Context, path string) ([]object.NetworkReference, error) {
es, err := f.find(ctx, f.networkFolder, false, path)
if err != nil {
return nil, err
}
var ns []object.NetworkReference
for _, e := range es {
ref := e.Object.Reference()
switch ref.Type {
case "Network":
r := object.NewNetwork(f.client, ref)
r.InventoryPath = e.Path
ns = append(ns, r)
case "DistributedVirtualPortgroup":
r := object.NewDistributedVirtualPortgroup(f.client, ref)
r.InventoryPath = e.Path
ns = append(ns, r)
case "DistributedVirtualSwitch", "VmwareDistributedVirtualSwitch":
r := object.NewDistributedVirtualSwitch(f.client, ref)
r.InventoryPath = e.Path
ns = append(ns, r)
}
}
if len(ns) == 0 {
return nil, &NotFoundError{"network", path}
}
return ns, nil
}
开发者ID:COLDTURNIP,项目名称:kubernetes,代码行数:31,代码来源:finder.go
示例2: isDVSUplink
// isDVSUplink determines if the DVP is an uplink
func (v *Validator) isDVSUplink(ref types.ManagedObjectReference) bool {
defer trace.End(trace.Begin(ref.Value))
var dvp mo.DistributedVirtualPortgroup
r := object.NewDistributedVirtualPortgroup(v.Session.Client.Client, ref)
if err := r.Properties(v.Context, r.Reference(), []string{"tag"}, &dvp); err != nil {
log.Errorf("Unable to check tags on %q: %s", ref, err)
return false
}
for _, t := range dvp.Tag {
if strings.Contains(t.Key, "UPLINKPG") {
return true
}
}
return false
}
开发者ID:kjplatz,项目名称:vic,代码行数:18,代码来源:network.go
示例3: getNetworkName
func (vm *VirtualMachine) getNetworkName(ctx context.Context, nic types.BaseVirtualEthernetCard) (string, error) {
if card, ok := nic.GetVirtualEthernetCard().Backing.(*types.VirtualEthernetCardDistributedVirtualPortBackingInfo); ok {
pg := card.Port.PortgroupKey
pgref := object.NewDistributedVirtualPortgroup(vm.Session.Client.Client, types.ManagedObjectReference{
Type: "DistributedVirtualPortgroup",
Value: pg,
})
var pgo mo.DistributedVirtualPortgroup
err := pgref.Properties(ctx, pgref.Reference(), []string{"config"}, &pgo)
if err != nil {
log.Errorf("Failed to query portgroup %s for %s", pg, err)
return "", err
}
return pgo.Config.Name, nil
}
return nic.GetVirtualEthernetCard().DeviceInfo.GetDescription().Summary, nil
}
开发者ID:kjplatz,项目名称:vic,代码行数:18,代码来源:vm.go
示例4: DVSWSList
func (f *Finder) DVSWSList(ctx context.Context, path string, recursive bool) ([]object.DistributedVirtualPortgroup, error) {
es, err := f.find(ctx, f.networkFolder, recursive, path)
if err != nil {
return nil, err
}
var ns []object.DistributedVirtualPortgroup
for _, e := range es {
ref := e.Object.Reference()
switch ref.Type {
case "DistributedVirtualPortgroup":
r := object.NewDistributedVirtualPortgroup(f.client, ref)
r.InventoryPath = e.Path
ns = append(ns, *r)
}
}
return ns, nil
}
开发者ID:zomboc0m,项目名称:govmomi,代码行数:18,代码来源:finder.go
示例5: checkVDSMembership
// checkVDSMembership verifes all hosts in the vCenter are connected to the vDS
func (v *Validator) checkVDSMembership(ctx context.Context, network types.ManagedObjectReference, netName string) error {
defer trace.End(trace.Begin(network.Value))
var dvp mo.DistributedVirtualPortgroup
var nonMembers []string
if !v.IsVC() {
return nil
}
if v.Session.Cluster == nil {
return errors.New("Invalid cluster. Check --compute-resource")
}
clusterHosts, err := v.Session.Cluster.Hosts(ctx)
if err != nil {
return err
}
r := object.NewDistributedVirtualPortgroup(v.Session.Client.Client, network)
if err := r.Properties(ctx, r.Reference(), []string{"name", "host"}, &dvp); err != nil {
return err
}
for _, h := range clusterHosts {
if !v.inDVP(h.Reference(), dvp.Host) {
nonMembers = append(nonMembers, h.InventoryPath)
}
}
if len(nonMembers) > 0 {
log.Errorf("vDS configuration incorrect on %q. All cluster hosts must be in the vDS.", netName)
log.Errorf(" %q is missing hosts:", netName)
for _, hs := range nonMembers {
log.Errorf(" %q", hs)
}
errMsg := fmt.Sprintf("All cluster hosts must be in the vDS. %q is missing hosts: %s", netName, nonMembers)
v.NoteIssue(errors.New(errMsg))
} else {
log.Infof("vDS configuration OK on %q", netName)
}
return nil
}
开发者ID:kjplatz,项目名称:vic,代码行数:45,代码来源:network.go
示例6: Run
func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
host, err := cmd.HostSystem()
if err != nil {
return err
}
ns, err := cmd.HostNetworkSystem()
if err != nil {
return err
}
var mns mo.HostNetworkSystem
m, err := host.ConfigManager().VirtualNicManager(ctx)
if err != nil {
return err
}
info, err := m.Info(ctx)
if err != nil {
return err
}
err = ns.Properties(ctx, ns.Reference(), []string{"networkInfo"}, &mns)
if err != nil {
return err
}
tw := tabwriter.NewWriter(os.Stdout, 2, 0, 2, ' ', 0)
type dnet struct {
dvp mo.DistributedVirtualPortgroup
dvs mo.VmwareDistributedVirtualSwitch
}
dnets := make(map[string]*dnet)
for _, nic := range mns.NetworkInfo.Vnic {
fmt.Fprintf(tw, "Device:\t%s\n", nic.Device)
if dvp := nic.Spec.DistributedVirtualPort; dvp != nil {
dn, ok := dnets[dvp.PortgroupKey]
if !ok {
dn = new(dnet)
o := object.NewDistributedVirtualPortgroup(host.Client(), types.ManagedObjectReference{
Type: "DistributedVirtualPortgroup",
Value: dvp.PortgroupKey,
})
err = o.Properties(ctx, o.Reference(), []string{"name", "config.distributedVirtualSwitch"}, &dn.dvp)
if err != nil {
return err
}
err = o.Properties(ctx, *dn.dvp.Config.DistributedVirtualSwitch, []string{"name"}, &dn.dvs)
if err != nil {
return err
}
dnets[dvp.PortgroupKey] = dn
}
fmt.Fprintf(tw, "Network label:\t%s\n", dn.dvp.Name)
fmt.Fprintf(tw, "Switch:\t%s\n", dn.dvs.Name)
} else {
fmt.Fprintf(tw, "Network label:\t%s\n", nic.Portgroup)
for _, pg := range mns.NetworkInfo.Portgroup {
if pg.Spec.Name == nic.Portgroup {
fmt.Fprintf(tw, "Switch:\t%s\n", pg.Spec.VswitchName)
break
}
}
}
fmt.Fprintf(tw, "IP address:\t%s\n", nic.Spec.Ip.IpAddress)
fmt.Fprintf(tw, "TCP/IP stack:\t%s\n", nic.Spec.NetStackInstanceKey)
var services []string
for _, nc := range info.NetConfig {
for _, dev := range nc.SelectedVnic {
key := nc.NicType + "." + nic.Key
if dev == key {
services = append(services, nc.NicType)
}
}
}
fmt.Fprintf(tw, "Enabled services:\t%s\n", strings.Join(services, ", "))
}
return tw.Flush()
}
开发者ID:jak-atx,项目名称:vic,代码行数:93,代码来源:info.go
注:本文中的github.com/vmware/govmomi/object.NewDistributedVirtualPortgroup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论