コード例 #1
0
	boshlog "github.com/cloudfoundry/bosh-utils/logger"

	fakesslclient "github.com/maximilien/softlayer-go/client/fakes"
)

var _ = Describe("SoftLayerFinder", func() {
	var (
		softLayerClient *fakesslclient.FakeSoftLayerClient
		logger          boshlog.Logger
		finder          SoftLayerFinder
	)

	BeforeEach(func() {
		softLayerClient = fakesslclient.NewFakeSoftLayerClient("fake-username", "fake-api-key")
		testhelpers.SetTestFixtureForFakeSoftLayerClient(softLayerClient, "SoftLayer_Account_Service_getVirtualDiskImages.json")

		logger = boshlog.NewLogger(boshlog.LevelNone)
		finder = NewSoftLayerFinder(softLayerClient, logger)
	})

	Describe("Find", func() {
		Context("valid stemcell ID pointing to a SL virtual disk image", func() {
			It("returns stemcell and found as true if stemcell ", func() {
				stemcell, found, err := finder.Find("8c7a8358-d9a9-4e4d-9345-6f637e10ccb7")
				Expect(err).ToNot(HaveOccurred())
				Expect(found).To(BeTrue())

				expectedStemcell := NewSoftLayerStemcell(4868344, "8c7a8358-d9a9-4e4d-9345-6f637e10ccb7", VirtualDiskImageKind, softLayerClient, logger)
				Expect(stemcell).To(Equal(expectedStemcell))
			})
コード例 #2
0
var _ = Describe("SoftLayerFinder", func() {
	var (
		fc     *fakeclient.FakeSoftLayerClient
		logger boshlog.Logger
		finder SoftLayerFinder
	)

	BeforeEach(func() {
		fc = fakeclient.NewFakeSoftLayerClient("fake-user", "fake-key")
		logger = boshlog.NewLogger(boshlog.LevelNone)
		finder = NewSoftLayerDiskFinder(fc, logger)
	})

	Describe("Find", func() {
		It("returns disk and found as true when found the disk successfully", func() {
			testhelpers.SetTestFixtureForFakeSoftLayerClient(fc, "SoftLayer_Network_Storage_Service_getIscsiVolume.json")

			disk, found, err := finder.Find(1234)
			Expect(err).ToNot(HaveOccurred())
			Expect(found).To(BeTrue())

			expectedDisk := NewSoftLayerDisk(1234, fc, logger)
			Expect(disk).To(Equal(expectedDisk))
		})

		It("returns found as false when failed to find the disk", func() {
			testhelpers.SetTestFixtureForFakeSoftLayerClient(fc, "SoftLayer_Network_Storage_Service_getEmptyIscsiVolume.json")
			disk, found, err := finder.Find(1234)

			Expect(err).ToNot(HaveOccurred())
			Expect(found).To(BeFalse())
コード例 #3
0
var _ = Describe("BaremetalCreator", func() {
	var (
		softLayerClient *fakeslclient.FakeSoftLayerClient
		logger          boshlog.Logger
		creator         bm.BaremetalCreator
	)

	BeforeEach(func() {
		softLayerClient = fakeslclient.NewFakeSoftLayerClient("fake-username", "fake-api-key")
		logger = boshlog.NewLogger(boshlog.LevelNone)

		creator = bm.NewBaremetalCreator(
			softLayerClient,
			logger,
		)
		testhelpers.SetTestFixtureForFakeSoftLayerClient(softLayerClient, "SoftLayer_Hardware_Service_createObject.json")
	})

	Describe("Create", func() {
		Context("succeeded", func() {
			It("returns a new Softlayer Hardware without an error", func() {
				baremetal, err := creator.Create(2, 1, 10, "fake-host", "fake-domain", "fake-os", "fake-data-center")
				Expect(err).ToNot(HaveOccurred())
				Expect(baremetal.GlobalIdentifier).To(Equal("fake-id"))
				Expect(baremetal.BareMetalInstanceFlag).To(Equal(0))
				Expect(baremetal.ProvisionDate).To(BeNil())
				Expect(baremetal.PrimaryIpAddress).To(Equal(""))
			})
		})

		Context("failed", func() {
コード例 #4
0
		logger                 boshlog.Logger
		finder                 SoftLayerFinder
	)

	BeforeEach(func() {
		softLayerClient = fakeslclient.NewFakeSoftLayerClient("fake-username", "fake-api-key")
		agentEnvServiceFactory = &fakevm.FakeAgentEnvServiceFactory{}
		logger = boshlog.NewLogger(boshlog.LevelNone)

		finder = NewSoftLayerFinder(
			softLayerClient,
			agentEnvServiceFactory,
			logger,
		)

		testhelpers.SetTestFixtureForFakeSoftLayerClient(softLayerClient, "SoftLayer_Virtual_Guest_Service_getObject.json")
	})

	Describe("Find", func() {
		var (
			vmID int
		)

		Context("when the VM ID is valid and existing", func() {
			BeforeEach(func() {
				vmID = 1234
			})

			It("finds and returns a new SoftLayerVM object with correct ID", func() {
				vm, found, err := finder.Find(vmID)
				Expect(err).ToNot(HaveOccurred())
コード例 #5
0
	)

	BeforeEach(func() {
		softLayerClient = fakeslclient.NewFakeSoftLayerClient("fake-username", "fake-api-key")
		logger = boshlog.NewLogger(boshlog.LevelNone)

		finder = bm.NewBaremetalFinder(
			softLayerClient,
			logger,
		)
	})

	Describe("Find", func() {
		Context("succeeded", func() {
			BeforeEach(func() {
				testhelpers.SetTestFixtureForFakeSoftLayerClient(softLayerClient, "SoftLayer_Hardware_Service_getObject.json")
			})

			It("returns a new Softlayer Hardware without an error", func() {
				baremetal, err := finder.Find("fake-id")
				Expect(err).ToNot(HaveOccurred())
				Expect(baremetal.GlobalIdentifier).To(Equal("fake-id"))
				Expect(baremetal.BareMetalInstanceFlag).To(Equal(1))
				Expect(baremetal.ProvisionDate).ToNot(BeNil())
				Expect(baremetal.PrimaryIpAddress).To(Equal("1.1.1.1"))
			})
		})

		Context("failed", func() {
			BeforeEach(func() {
				testhelpers.SetTestFixtureForFakeSoftLayerClient(softLayerClient, "SoftLayer_Hardware_Service_getObject_None_Exist.json")