當前位置: 首頁>>代碼示例>>Golang>>正文


Golang types.Extension類代碼示例

本文整理匯總了Golang中github.com/vmware/govmomi/vim25/types.Extension的典型用法代碼示例。如果您正苦於以下問題:Golang Extension類的具體用法?Golang Extension怎麽用?Golang Extension使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Extension類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Run

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

	c, err := cmd.Client()
	if err != nil {
		return err
	}

	m, err := object.GetExtensionManager(c)
	if err != nil {
		return err
	}

	b, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		return err
	}

	var e types.Extension
	e.Description = new(types.Description)

	if err = json.Unmarshal(b, &e); err != nil {
		return err
	}

	e.LastHeartbeatTime = time.Now().UTC()

	if cmd.update {
		return m.Update(ctx, e)
	}

	return m.Register(ctx, e)
}
開發者ID:hickeng,項目名稱:govmomi,代碼行數:33,代碼來源:register.go

示例2: Run

func (cmd *register) Run(ctx context.Context, f *flag.FlagSet) error {
	c, err := cmd.Client()
	if err != nil {
		return err
	}

	m, err := object.GetExtensionManager(c)
	if err != nil {
		return err
	}

	var e types.Extension
	e.Description = new(types.Description)

	if err = json.NewDecoder(os.Stdin).Decode(&e); err != nil {
		return err
	}

	e.LastHeartbeatTime = time.Now().UTC()

	if cmd.update {
		return m.Update(ctx, e)
	}

	return m.Register(ctx, e)
}
開發者ID:jak-atx,項目名稱:vic,代碼行數:26,代碼來源:register.go

示例3: RegisterExtension

func (d *Dispatcher) RegisterExtension(conf *config.VirtualContainerHostConfigSpec, extension types.Extension) error {
	defer trace.End(trace.Begin(conf.ExtensionName))

	log.Infoln("Registering VCH as a vSphere extension")

	// vSphere confusingly calls the 'name' of the extension a 'key'
	// This variable is named IdKey as to not confuse it with its private key
	if conf.ExtensionCert == "" {
		return errors.Errorf("Extension certificate does not exist")
	}

	extensionManager := object.NewExtensionManager(d.session.Vim25())

	extension.LastHeartbeatTime = time.Now().UTC()
	if err := extensionManager.Register(d.ctx, extension); err != nil {
		log.Errorf("Could not register the vSphere extension due to err: %s", err)
		return err
	}

	if err := extensionManager.SetCertificate(d.ctx, conf.ExtensionName, conf.ExtensionCert); err != nil {
		log.Errorf("Could not set the certificate on the vSphere extension due to error: %s", err)
		return err
	}

	return nil
}
開發者ID:vmware,項目名稱:vic,代碼行數:26,代碼來源:create.go

示例4: Register

// Register installs an extension to the target
func (p *Pluginator) Register() error {
	defer trace.End(trace.Begin(""))
	var err error
	if !p.connected {
		return errors.New("not connected")
	}

	desc := types.Description{
		Label:   p.info.Name,
		Summary: p.info.Summary,
	}

	e := types.Extension{
		Key:         p.info.Key,
		Version:     p.info.Version,
		Company:     p.info.Company,
		Description: &desc,
	}

	eci := types.ExtensionClientInfo{
		Version:     p.info.Version,
		Company:     p.info.Company,
		Description: &desc,
		Type:        p.info.Type,
		Url:         p.info.URL,
	}
	e.Client = append(e.Client, eci)

	d := types.KeyValue{
		Key:   "name",
		Value: p.info.Name,
	}

	eri := types.ExtensionResourceInfo{
		Locale: "en_US",
		Module: "name",
	}

	eri.Data = append(eri.Data, d)

	e.ResourceList = append(e.ResourceList, eri)

	// HTTPS requires extension server info
	if strings.HasPrefix(strings.ToLower(p.info.URL), "https://") {
		esi := types.ExtensionServerInfo{
			Url:              p.info.URL,
			Description:      &desc,
			Company:          p.info.Company,
			Type:             "HTTPS",
			AdminEmail:       []string{"[email protected]"},
			ServerThumbprint: p.info.ServerThumbprint,
		}
		e.Server = append(e.Server, esi)
	}

	e.ShownInSolutionManager = &p.info.ShowInSolutionManager

	e.LastHeartbeatTime = time.Now().UTC()

	err = p.ExtensionManager.Register(p.Context, e)
	if err != nil {
		return err
	}

	return nil
}
開發者ID:vmware,項目名稱:vic,代碼行數:67,代碼來源:register.go


注:本文中的github.com/vmware/govmomi/vim25/types.Extension類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。