• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang license.NewManager函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/vmware/govmomi/license.NewManager函数的典型用法代码示例。如果您正苦于以下问题:Golang NewManager函数的具体用法?Golang NewManager怎么用?Golang NewManager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewManager函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: checkLicense

func (v *Validator) checkLicense(ctx context.Context) error {
	var invalidLic []string
	client := v.Session.Client.Client

	lm := license.NewManager(client)
	licenses, err := lm.List(ctx)
	if err != nil {
		return err
	}
	v.checkEvalLicense(licenses)

	features := []string{"serialuri"}

	for _, feature := range features {
		if len(licenses.WithFeature(feature)) == 0 {
			msg := fmt.Sprintf("Host license missing feature %q", feature)
			invalidLic = append(invalidLic, msg)
		}
	}

	if len(invalidLic) > 0 {
		log.Errorf("License check FAILED:")
		for _, h := range invalidLic {
			log.Errorf("  %q", h)
		}
		msg := "License does not meet minimum requirements to use VIC"
		return errors.New(msg)
	}
	log.Infof("License check OK")
	return nil
}
开发者ID:vmware,项目名称:vic,代码行数:31,代码来源:config.go


示例2: checkAssignedLicenses

func (v *Validator) checkAssignedLicenses(ctx context.Context) error {
	var hosts []*object.HostSystem
	var invalidLic []string
	var validLic []string
	var err error
	client := v.Session.Client.Client

	if hosts, err = v.Session.Datastore.AttachedClusterHosts(ctx, v.Session.Cluster); err != nil {
		log.Errorf("Unable to get the list of hosts attached to given storage: %s", err)
		return err
	}

	lm := license.NewManager(client)

	am, err := lm.AssignmentManager(ctx)
	if err != nil {
		return err
	}

	features := []string{"serialuri", "dvs"}

	for _, host := range hosts {
		valid := true
		la, err := am.QueryAssigned(ctx, host.Reference().Value)
		if err != nil {
			return err
		}

		for _, feature := range features {
			if !v.assignedLicenseHasFeature(la, feature) {
				valid = false
				msg := fmt.Sprintf("%q - license missing feature %q", host.InventoryPath, feature)
				invalidLic = append(invalidLic, msg)
			}
		}

		if valid == true {
			validLic = append(validLic, host.InventoryPath)
		}
	}

	if len(validLic) > 0 {
		log.Infof("License check OK on hosts:")
		for _, h := range validLic {
			log.Infof("  %q", h)
		}
	}
	if len(invalidLic) > 0 {
		log.Errorf("License check FAILED on hosts:")
		for _, h := range invalidLic {
			log.Errorf("  %q", h)
		}
		msg := "License does not meet minimum requirements to use VIC"
		return errors.New(msg)
	}
	return nil
}
开发者ID:vmware,项目名称:vic,代码行数:57,代码来源:config.go


示例3: Run

func (cmd *list) Run(f *flag.FlagSet) error {
	client, err := cmd.Client()
	if err != nil {
		return err
	}

	m := license.NewManager(client)
	result, err := m.List(context.TODO())
	if err != nil {
		return err
	}

	return cmd.WriteResult(licenseOutput(result))
}
开发者ID:MerlinDMC,项目名称:machine,代码行数:14,代码来源:list.go


示例4: Run

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(context.TODO(), v)
		if err != nil {
			return err
		}
	}

	return nil
}
开发者ID:robvanmieghem,项目名称:machine,代码行数:16,代码来源:remove.go


示例5: Run

func (cmd *list) 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))
}
开发者ID:frapposelli,项目名称:govmomi,代码行数:18,代码来源:list.go


示例6: Run

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))
}
开发者ID:frapposelli,项目名称:govmomi,代码行数:18,代码来源:assigned.go


示例7: Run

func (cmd *assign) Run(f *flag.FlagSet) error {
	ctx := context.TODO()

	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}))
}
开发者ID:xchapter7x,项目名称:govmomi,代码行数:44,代码来源:assign.go


示例8: Run

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))
}
开发者ID:vmware,项目名称:vic,代码行数:23,代码来源:decode.go


示例9: Run

func (cmd *add) Run(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(context.TODO(), v, nil)
		if err != nil {
			return err
		}

		result = append(result, license)
	}

	return cmd.WriteResult(licenseOutput(result))
}
开发者ID:MerlinDMC,项目名称:machine,代码行数:36,代码来源:add.go



注:本文中的github.com/vmware/govmomi/license.NewManager函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang object.NewComputeResource函数代码示例发布时间:2022-05-28
下一篇:
Golang flags.NewVirtualMachineFlag函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap