testhelpers.DeleteVirtualGuest(virtualGuest.Id)
			testhelpers.DeleteSshKey(createdSshKey.Id)
		})

		It("issues set_vm_metadata to cpi", func() {
			pwd, err := os.Getwd()
			Expect(err).ToNot(HaveOccurred())
			rootTemplatePath := filepath.Join(pwd, "..", "..")

			jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("set_vm_metadata", rootTemplatePath, replacementMap)
			Expect(err).ToNot(HaveOccurred())

			tmpConfigPath, err := testhelperscpi.CreateTmpConfigPath(rootTemplatePath, configPath, username, apiKey)
			Expect(err).ToNot(HaveOccurred())

			_, err = testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload)
			Expect(err).ToNot(HaveOccurred())

			err = os.RemoveAll(tmpConfigPath)
			Expect(err).ToNot(HaveOccurred())

			tagReferences, err := virtualGuestService.GetTagReferences(virtualGuest.Id)
			Expect(err).ToNot(HaveOccurred())

			tagReferencesJSON, err := json.Marshal(tagReferences)
			Expect(err).ToNot(HaveOccurred())

			Ω(tagReferencesJSON).Should(ContainSubstring("buildpack_python"))
			Ω(tagReferencesJSON).Should(ContainSubstring("metadata_deployment"))
		})
	})
		Expect(err).ToNot(HaveOccurred())
	})

	Context("attach_disk in SoftLayer with invalid virtual guest id and disk id", func() {
		BeforeEach(func() {
			replacementMap = map[string]string{
				"VMID":   "123456",
				"DiskID": "123",
			}
		})

		It("returns error", func() {
			jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("attach_disk", rootTemplatePath, replacementMap)
			Expect(err).ToNot(HaveOccurred())

			outputBytes, err := testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload)
			log.Println("outputBytes=" + string(outputBytes))
			Expect(err).ToNot(HaveOccurred())
			err = json.Unmarshal(outputBytes, &resultOutput)
			Expect(err).ToNot(HaveOccurred())
			Expect(resultOutput["error"]).ToNot(BeNil())
		})
	})

	Context("attach_disk in SoftLayer with valid virtual guest id(with multipath installed) and disk id", func() {
		BeforeEach(func() {
			err = testhelpers.FindAndDeleteTestSshKeys()
			Expect(err).ToNot(HaveOccurred())

			createdSshKey, _ = testhelpers.CreateTestSshKey()
			testhelpers.WaitForCreatedSshKeyToBePresent(createdSshKey.Id)
			payload := `{
							"method": "set_vm_metadata",
							"arguments": [
								"some ID",
								{
									"director": "BOSH Director",
									"deployment": "softlayer",
									"tags": "some, tags"
								}
							],
							"context": {
								"director_uuid": "some director UUID"
							}
						}`

			_, err := testhelpers.RunCpi(rootTemplatePath, configPath, payload)
			Expect(err).ToNot(HaveOccurred())
		})
	})

	Context("#CreateTmpConfigPath", func() {
		It("creates a config.json in temp dir with new config template values", func() {
			tmpConfigPath, err := testhelpers.CreateTmpConfigPath(rootTemplatePath, "test_fixtures/cpi_methods/config.json", "some username", "some ApiKey")
			Expect(err).ToNot(HaveOccurred())

			fileInfo, err := os.Stat(tmpConfigPath)
			Expect(err).ToNot(HaveOccurred())
			Expect(fileInfo.Mode().IsRegular()).To(BeTrue())

			err = os.RemoveAll(tmpConfigPath)
			Expect(err).ToNot(HaveOccurred())
		Expect(err).ToNot(HaveOccurred())
	})

	Context("detach_disk in SoftLayer with invalid virtual guest id and disk id", func() {
		BeforeEach(func() {
			replacementMap = map[string]string{
				"VMID":   "123456",
				"DiskID": "123",
			}
		})

		It("returns error", func() {
			jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("detach_disk", rootTemplatePath, replacementMap)
			Expect(err).ToNot(HaveOccurred())

			outputBytes, err := testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload)
			log.Println("outputBytes=" + string(outputBytes))
			Expect(err).ToNot(HaveOccurred())
			err = json.Unmarshal(outputBytes, &resultOutput)
			Expect(err).ToNot(HaveOccurred())
			Expect(resultOutput["error"]).ToNot(BeNil())
		})
	})

	Context("detach_disk in SoftLayer with valid virtual guest id(with multipath installed) and disk id", func() {
		BeforeEach(func() {
			err = testhelpers.FindAndDeleteTestSshKeys()
			Expect(err).ToNot(HaveOccurred())

			createdSshKey, _ = testhelpers.CreateTestSshKey()
			testhelpers.WaitForCreatedSshKeyToBePresent(createdSshKey.Id)