当前位置: 首页>>代码示例>>Golang>>正文


Golang Metadata.Series方法代码示例

本文整理汇总了Golang中github.com/juju/juju/state/cloudimagemetadata.Metadata.Series方法的典型用法代码示例。如果您正苦于以下问题:Golang Metadata.Series方法的具体用法?Golang Metadata.Series怎么用?Golang Metadata.Series使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/juju/juju/state/cloudimagemetadata.Metadata的用法示例。


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

示例1: storeImageMetadataInState

// storeImageMetadataInState writes image metadata into state store.
func storeImageMetadataInState(st *state.State, source string, priority int, existingMetadata []*imagemetadata.ImageMetadata) error {
	if len(existingMetadata) == 0 {
		return nil
	}
	metadataState := make([]cloudimagemetadata.Metadata, len(existingMetadata))
	for i, one := range existingMetadata {
		m := cloudimagemetadata.Metadata{
			cloudimagemetadata.MetadataAttributes{
				Stream:          one.Stream,
				Region:          one.RegionName,
				Arch:            one.Arch,
				VirtType:        one.VirtType,
				RootStorageType: one.Storage,
				Source:          source,
			},
			priority,
			one.Id,
		}
		s, err := seriesFromVersion(one.Version)
		if err != nil {
			return errors.Annotatef(err, "cannot determine series for version %v", one.Version)
		}
		m.Series = s
		metadataState[i] = m
	}
	if err := st.CloudImageMetadataStorage.SaveMetadata(metadataState); err != nil {
		return errors.Annotatef(err, "cannot cache image metadata")
	}
	return nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:31,代码来源:bootstrap.go

示例2: saveCustomImageMetadata

// saveCustomImageMetadata reads the custom image metadata from disk,
// and saves it in state server.
func (c *BootstrapCommand) saveCustomImageMetadata(st *state.State) error {
	logger.Debugf("saving custom image metadata from %q", c.ImageMetadataDir)

	baseURL := fmt.Sprintf("file://%s", filepath.ToSlash(c.ImageMetadataDir))
	datasource := simplestreams.NewURLDataSource("bootstrap metadata", baseURL, utils.NoVerifySSLHostnames)

	// Read the image metadata, as we'll want to upload it to the environment.
	imageConstraint := imagemetadata.NewImageConstraint(simplestreams.LookupParams{})
	existingMetadata, _, err := imagemetadata.Fetch(
		[]simplestreams.DataSource{datasource}, imageConstraint, false)
	if err != nil && !errors.IsNotFound(err) {
		return errors.Annotate(err, "cannot read image metadata")
	}

	if len(existingMetadata) == 0 {
		return nil
	}
	msg := ""
	for _, one := range existingMetadata {
		m := cloudimagemetadata.Metadata{
			cloudimagemetadata.MetadataAttributes{
				Stream:          one.Stream,
				Region:          one.RegionName,
				Arch:            one.Arch,
				VirtType:        one.VirtType,
				RootStorageType: one.Storage,
				Source:          "custom",
			},
			one.Id,
		}
		s, err := seriesFromVersion(one.Version)
		if err != nil {
			return errors.Annotatef(err, "cannot determine series for version %v", one.Version)
		}
		m.Series = s
		err = st.CloudImageMetadataStorage.SaveMetadata(m)
		if err != nil {
			return errors.Annotatef(err, "cannot cache image metadata %v", m)
		}
	}
	if len(msg) > 0 {
		return errors.New(msg)
	}
	return nil
}
开发者ID:andrewdmcleod,项目名称:juju,代码行数:47,代码来源:bootstrap.go

示例3: parseMetadataFromParams

func (api *API) parseMetadataFromParams(p params.CloudImageMetadata, env environs.Environ) (cloudimagemetadata.Metadata, error) {
	result := cloudimagemetadata.Metadata{
		cloudimagemetadata.MetadataAttributes{
			Stream:          p.Stream,
			Region:          p.Region,
			Version:         p.Version,
			Series:          p.Series,
			Arch:            p.Arch,
			VirtType:        p.VirtType,
			RootStorageType: p.RootStorageType,
			RootStorageSize: p.RootStorageSize,
			Source:          p.Source,
		},
		p.Priority,
		p.ImageId,
	}

	// Fill in any required default values.
	if p.Stream == "" {
		result.Stream = env.Config().ImageStream()
	}
	if p.Source == "" {
		result.Source = "custom"
	}
	if result.Arch == "" {
		result.Arch = "amd64"
	}
	if result.Series == "" {
		result.Series = config.PreferredSeries(env.Config())
	}
	if result.Region == "" {
		// If the env supports regions, use the env default.
		if r, ok := env.(simplestreams.HasRegion); ok {
			spec, err := r.Region()
			if err != nil {
				return cloudimagemetadata.Metadata{}, errors.Annotatef(err, "getting cloud region")
			}
			result.Region = spec.Region
		}
	}
	return result, nil
}
开发者ID:exekias,项目名称:juju,代码行数:42,代码来源:metadata.go

示例4: storeImageMetadataInState

// storeImageMetadataInState writes image metadata into state store.
func storeImageMetadataInState(st *state.State, env environs.Environ, source string, priority int, existingMetadata []*imagemetadata.ImageMetadata) error {
	if len(existingMetadata) == 0 {
		return nil
	}
	cfg := env.Config()
	metadataState := make([]cloudimagemetadata.Metadata, len(existingMetadata))
	for i, one := range existingMetadata {
		m := cloudimagemetadata.Metadata{
			MetadataAttributes: cloudimagemetadata.MetadataAttributes{
				Stream:          one.Stream,
				Region:          one.RegionName,
				Arch:            one.Arch,
				VirtType:        one.VirtType,
				RootStorageType: one.Storage,
				Source:          source,
				Version:         one.Version,
			},
			Priority: priority,
			ImageId:  one.Id,
		}
		s, err := seriesFromVersion(one.Version)
		if err != nil {
			return errors.Annotatef(err, "cannot determine series for version %v", one.Version)
		}
		m.Series = s
		if m.Stream == "" {
			m.Stream = cfg.ImageStream()
		}
		if m.Source == "" {
			m.Source = "custom"
		}
		metadataState[i] = m
	}
	if err := st.CloudImageMetadataStorage.SaveMetadata(metadataState); err != nil {
		return errors.Annotatef(err, "cannot cache image metadata")
	}
	return nil
}
开发者ID:bac,项目名称:juju,代码行数:39,代码来源:bootstrap.go


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