pwd, err := os.Getwd() Expect(err).ToNot(HaveOccurred()) rootTemplatePath = filepath.Join(pwd, "..", "..") strVGID = strconv.Itoa(virtualGuest.Id) replacementMap = map[string]string{ "ID": strVGID, "DirectorUuid": "fake-director-uuid", "Tag_compiling": "buildpack_python", "Tag_deployment": "metadata_deployment", } }) AfterEach(func() { 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)
vm, err := virtualGuestService.GetObject(vmId) Expect(err).ToNot(HaveOccurred()) disk = testhelpers.CreateDisk(20, strconv.Itoa(vm.Datacenter.Id)) strVGID = strconv.Itoa(vmId) strDID = strconv.Itoa(disk.Id) replacementMap = map[string]string{ "VMID": strVGID, "DiskID": strDID, } }) AfterEach(func() { testhelpers.DeleteVirtualGuest(vmId) testhelpers.WaitForVirtualGuestToHaveNoActiveTransactionsOrToErr(vmId) testhelpers.DeleteDisk(disk.Id) testhelpers.DeleteSshKey(createdSshKey.Id) }) It("attach_disk successfully", func() { jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("attach_disk", rootTemplatePath, replacementMap) Expect(err).ToNot(HaveOccurred()) log.Println("jsonPayload --> ", jsonPayload) log.Println("---> starting attach disk") outputBytes, err := testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload) log.Println("outputBytes=" + string(outputBytes)) Expect(err).ToNot(HaveOccurred()) err = json.Unmarshal(outputBytes, &resultOutput)