本文整理匯總了Golang中github.com/vmware/vic/pkg/vsphere/session.Session.Datacenter方法的典型用法代碼示例。如果您正苦於以下問題:Golang Session.Datacenter方法的具體用法?Golang Session.Datacenter怎麽用?Golang Session.Datacenter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/vmware/vic/pkg/vsphere/session.Session
的用法示例。
在下文中一共展示了Session.Datacenter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createTestData
func createTestData(ctx context.Context, sess *session.Session, prefix string) error {
dcs, err := sess.Finder.DatacenterList(ctx, "*")
if err != nil {
return err
}
for _, dc := range dcs {
sess.Finder.SetDatacenter(dc)
sess.Datacenter = dc
resources := &Node{
Kind: rpNode,
Name: prefix + "Root",
Children: []*Node{
{
Kind: rpNode,
Name: prefix + "pool1",
Children: []*Node{
{
Kind: vmNode,
Name: prefix + "pool1",
},
{
Kind: rpNode,
Name: prefix + "pool1-2",
Children: []*Node{
{
Kind: rpNode,
Name: prefix + "pool1-2-1",
Children: []*Node{
{
Kind: vmNode,
Name: prefix + "vch1-2-1",
},
},
},
},
},
},
},
{
Kind: vmNode,
Name: prefix + "vch2",
},
},
}
if err = createResources(ctx, sess, resources); err != nil {
return err
}
}
return nil
}