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


Golang params.CloudImageMetadata類代碼示例

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


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

示例1: TestSaveAndFindAndDeleteMetadata

func (s *cloudImageMetadataSuite) TestSaveAndFindAndDeleteMetadata(c *gc.C) {
	metadata, err := s.client.List("", "", nil, nil, "", "")
	c.Assert(err, gc.ErrorMatches, "matching cloud image metadata not found")
	c.Assert(metadata, gc.HasLen, 0)

	//	check db too
	conn := s.State.MongoSession()
	coll, closer := mongo.CollectionFromName(conn.DB("juju"), "cloudimagemetadata")
	defer closer()

	before, err := coll.Count()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(before == 0, jc.IsTrue)

	imageId := "1"
	m := params.CloudImageMetadata{
		Source:          "custom",
		Stream:          "stream",
		Region:          "region",
		Series:          "trusty",
		Arch:            "arch",
		VirtType:        "virtType",
		RootStorageType: "rootStorageType",
		ImageId:         imageId,
	}

	err = s.client.Save([]params.CloudImageMetadata{m})
	c.Assert(err, jc.ErrorIsNil)

	added, err := s.client.List("", "", nil, nil, "", "")
	c.Assert(err, jc.ErrorIsNil)

	// m.Version would be deduced from m.Series
	m.Version = "14.04"
	c.Assert(added, jc.DeepEquals, []params.CloudImageMetadata{m})

	// make sure it's in db too
	after, err := coll.Count()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(after == 1, jc.IsTrue)

	err = s.client.Delete(imageId)
	c.Assert(err, jc.ErrorIsNil)
	// make sure it's no longer in db too
	afterDelete, err := coll.Count()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(afterDelete, gc.Equals, 0)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:48,代碼來源:cloudimagemetadata_test.go

示例2: constructMetadataParam

// constructMetadataParam returns cloud image metadata as a param.
func (c *addImageMetadataCommand) constructMetadataParam() params.CloudImageMetadata {
	info := params.CloudImageMetadata{
		ImageId:         c.ImageId,
		Region:          c.Region,
		Series:          c.Series,
		Arch:            c.Arch,
		VirtType:        c.VirtType,
		RootStorageType: c.RootStorageType,
		Stream:          c.Stream,
		Source:          "custom",
	}
	if c.RootStorageSize != 0 {
		info.RootStorageSize = &c.RootStorageSize
	}
	return info
}
開發者ID:snailwalker,項目名稱:juju,代碼行數:17,代碼來源:addimage.go

示例3: assertValidAddImageMetadata

func (s *addImageSuite) assertValidAddImageMetadata(c *gc.C, m params.CloudImageMetadata) {
	args := getAddImageMetadataCmdFlags(c, m)

	_, err := runAddImageMetadata(c, args...)
	c.Assert(err, jc.ErrorIsNil)

	// Need to make sure that defaults are populated
	if m.Arch == "" {
		m.Arch = "amd64"
	}
	if m.Stream == "" {
		m.Stream = "released"
	}

	c.Assert(s.data, gc.DeepEquals, []params.CloudImageMetadata{m})
}
開發者ID:howbazaar,項目名稱:juju,代碼行數:16,代碼來源:addimage_test.go


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