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 }