예제 #1
0
func main() {
	utils.Logger = utils.NewLogger()

	configPath, err := local.DefaultBoshConfigPath()
	if err != nil {
		fmt.Println(err)
		return
	}
	config, err := local.LoadBoshConfig(configPath)
	if err != nil {
		fmt.Println(err)
		return
	}
	target, username, password, err := config.CurrentBoshTarget()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("Targeting %s with user %s...\n", target, username)

	director := gogobosh.NewDirector(target, username, password)
	repo := api.NewBoshDirectorRepository(&director, net.NewDirectorGateway())

	info, apiResponse := repo.GetInfo()
	if apiResponse.IsNotSuccessful() {
		fmt.Println("Could not fetch BOSH info")
		return
	}

	fmt.Println("Director")
	fmt.Printf("  Name       %s\n", info.Name)
	fmt.Printf("  URL        %s\n", info.URL)
	fmt.Printf("  Version    %s\n", info.Version)
	fmt.Printf("  User       %s\n", info.User)
	fmt.Printf("  UUID       %s\n", info.UUID)
	fmt.Printf("  CPI        %s\n", info.CPI)

}
예제 #2
0
package local_test

import (
	"path/filepath"

	"github.com/cloudfoundry-community/gogobosh/local"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Local config", func() {
	It("Loads BOSH config", func() {
		configPath, err := filepath.Abs("../testhelpers/fixtures/bosh_config.yml")
		Expect(err).ShouldNot(HaveOccurred())

		config, err := local.LoadBoshConfig(configPath)
		Expect(err).ShouldNot(HaveOccurred())
		Expect(config).ToNot(BeNil())
		Expect(config.Name).To(Equal("Bosh Lite Director"))
		Expect(config.Authentication["https://192.168.50.4:25555"].Username).To(Equal("admin"))
	})

	It("CurrentBoshTarget", func() {
		configPath, err := filepath.Abs("../testhelpers/fixtures/bosh_config.yml")
		Expect(err).ShouldNot(HaveOccurred())
		config, err := local.LoadBoshConfig(configPath)
		Expect(err).ShouldNot(HaveOccurred())
		Expect(config).ToNot(BeNil())

		target, username, password, err := config.CurrentBoshTarget()
		Expect(err).ShouldNot(HaveOccurred())