Closed bsassmann closed 3 years ago
I tried 0.1.7 it showed the same issue to me.
Hello I am trying to use the vmworkstation plugin for some training, as I do not want to use cloud. I found out, that it is not working with windows, you need linux. That is not the problem. I can create VMs via rest-api, but when I try to use this provider, i get the following output:
merlin@CAMELOTH:~/terraform-vmware$ terraform apply var.vmws_reource_frontend_description (Required) The Description at later maybe to explain the instance Enter a value: neTestOs var.vmws_reource_frontend_sourceid (Required) The ID of the VM that to use for clone at the new Enter a value: O9JDEN8VTF8V09KGLDOGNL551UA2O369 An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # vmworkstation_vm.test_machine will be created + resource "vmworkstation_vm" "test_machine" { + denomination = "NewInstance" + description = "neTestOs" + id = (known after apply) + memory = 1024 + processors = 1 + sourceid = "O9JDEN8VTF8V09KGLDOGNL551UA2O369" } Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + vmws_frontend_id = (known after apply) Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes vmworkstation_vm.test_machine: Creating... Error: Provider produced inconsistent result after apply When applying changes to vmworkstation_vm.test_machine, provider "registry.terraform.io/elsudano/vmworkstation" produced an unexpected new value: Root resource was present, but now absent. This is a bug in the provider, which should be reported in the provider's own issue tracker.
Ok, please can you try to use a https://github.com/elsudano/vmware-workstation-api-client
To confirm me if you API rest working fine?
Sorry, it took some time to make it "GO" ;-) For me it seems to work after changing the ids in main.go. The Failure appears is only coused by wrong syntax, it has to be C:\VMs\testOS\testOS.vmx
merlin@CAMELOTH:~/vmware-api/vmware-workstation-api-client$ make test_api_client
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapiclient.go Fu: ConfigCli Obj:Variables "http://127.0.0.1:8697/api", "merlin", "myTest123#", true
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapiclient.go Fu: ConfigCli Obj:&url.URL{Scheme:"http", Opaque:"", User:(*url.Userinfo)(nil), Host:"127.0.0.1:8697", Path:"/api", RawPath:"", ForceQuery:false, RawQuery:"", Fragment:""}
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapiclient.go Fu: ConfigCli Obj:"merlin"
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapiclient.go Fu: ConfigCli Obj:"myTest123#"
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapiclient.go Fu: ConfigCli Obj:false
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapiclient.go Fu: ConfigCli Obj:true
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapivm.go Fu: CreateVM Obj:Request []byte{0x7b, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x22, 0x63, 0x6c, 0x6f, 0x6e, 0x65, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x63, 0x6f, 0x70, 0x79, 0x22, 0x2c, 0x22, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x3a, 0x22, 0x4f, 0x39, 0x4a, 0x44, 0x45, 0x4e, 0x38, 0x56, 0x54, 0x46, 0x38, 0x56, 0x30, 0x39, 0x4b, 0x47, 0x4c, 0x44, 0x4f, 0x47, 0x4e, 0x4c, 0x35, 0x35, 0x31, 0x55, 0x41, 0x32, 0x4f, 0x33, 0x36, 0x39, 0x22, 0x7d}
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapivm.go Fu: CreateVM Obj:Request Body "{\"name\":\"clone-test-copy\",\"parentId\":\"O9JDEN8VTF8V09KGLDOGNL551UA2O369\"}"
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapiclient.go Fu: requestPath Obj:"http://127.0.0.1:8697/api/vms"
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapiclient.go Fu: httpRequest Obj:buffer "{\"name\":\"clone-test-copy\",\"parentId\":\"O9JDEN8VTF8V09KGLDOGNL551UA2O369\"}"
2020/11/04 15:28:21 [WSAPICLI] Fi: wsapiclient.go Fu: httpRequest Obj:request &http.Request{Method:"POST", URL:(*url.URL)(0xc0000d6180), Proto:"HTTP/1.1", ProtoMajor:1, ProtoMinor:1, Header:http.Header{"Authorization":[]string{"Basic bWVybGluOm15VGVzdDEyMyM="}, "Content-Type":[]string{"application/vnd.vmware.vmw.rest-v1+json"}}, Body:ioutil.nopCloser{Reader:(*bytes.Buffer)(0xc000090d20)}, GetBody:(func() (io.ReadCloser, error))(0x63b910), ContentLength:72, TransferEncoding:[]string(nil), Close:false, Host:"127.0.0.1:8697", Form:url.Values(nil), PostForm:url.Values(nil), MultipartForm:(*multipart.Form)(nil), Trailer:http.Header(nil), RemoteAddr:"", RequestURI:"", TLS:(*tls.ConnectionState)(nil), Cancel:(<-chan struct {})(nil), Response:(*http.Response)(nil), ctx:(*context.emptyCtx)(0xc000016108)}
2020/11/04 15:29:25 [WSAPICLI] Fi: wsapiclient.go Fu: httpRequest Obj:response &http.Response{Status:"201 Created", StatusCode:201, Proto:"HTTP/1.1", ProtoMajor:1, ProtoMinor:1, Header:http.Header{"Cache-Control":[]string{"no-cache"}, "Content-Length":[]string{"100"}, "Content-Type":[]string{"application/vnd.vmware.vmw.rest-v1+json"}, "Date":[]string{"Wed, 04 Nov 2020 14:29:25 GMT"}}, Body:(*http.bodyEOFSignal)(0xc000024440), ContentLength:100, TransferEncoding:[]string(nil), Close:false, Uncompressed:false, Trailer:http.Header(nil), Request:(*http.Request)(0xc0000f4000), TLS:(*tls.ConnectionState)(nil)}
2020/11/04 15:29:25 [WSAPICLI] Fi: wsapivm.go Fu: CreateVM Obj:response raw &http.bodyEOFSignal{body:(*http.body)(0xc000024400), mu:sync.Mutex{state:0, sema:0x0}, closed:false, rerr:error(nil), fn:(func(error) error)(0x63c700), earlyCloseFn:(func() error)(0x63c690)}
2020/11/04 15:29:25 [WSAPICLI] Fi: wsapivm.go Fu: CreateVM Obj:Response Body "{\n \"id\": \"AP0PDSV8L14UJSP21LGUA6OGADA4FH18\",\n \"cpu\": {\n \"processors\": 1\n },\n \"memory\": 1024\n}"
ID: AP0PDSV8L14UJSP21LGUA6OGADA4FH18
Path:
Denomination:
Description:
Power Status:
Processor: 1
Memory: 1024
2020/11/04 15:29:25 [WSAPICLI] Fi: wsapiclient.go Fu: requestPath Obj:"http://127.0.0.1:8697/api/vms"
2020/11/04 15:29:25 [WSAPICLI] Fi: wsapiclient.go Fu: httpRequest Obj:buffer ""
2020/11/04 15:29:25 [WSAPICLI] Fi: wsapiclient.go Fu: httpRequest Obj:request &http.Request{Method:"GET", URL:(*url.URL)(0xc00013a000), Proto:"HTTP/1.1", ProtoMajor:1, ProtoMinor:1, Header:http.Header{"Authorization":[]string{"Basic bWVybGluOm15VGVzdDEyMyM="}, "Content-Type":[]string{"application/vnd.vmware.vmw.rest-v1+json"}}, Body:http.noBody{}, GetBody:(func() (io.ReadCloser, error))(0x63bbf0), ContentLength:0, TransferEncoding:[]string(nil), Close:false, Host:"127.0.0.1:8697", Form:url.Values(nil), PostForm:url.Values(nil), MultipartForm:(*multipart.Form)(nil), Trailer:http.Header(nil), RemoteAddr:"", RequestURI:"", TLS:(*tls.ConnectionState)(nil), Cancel:(<-chan struct {})(nil), Response:(*http.Response)(nil), ctx:(*context.emptyCtx)(0xc000016108)}
2020/11/04 15:29:27 [WSAPICLI] Fi: wsapiclient.go Fu: httpRequest Obj:response &http.Response{Status:"200 OK", StatusCode:200, Proto:"HTTP/1.1", ProtoMajor:1, ProtoMinor:1, Header:http.Header{"Cache-Control":[]string{"no-cache"}, "Content-Length":[]string{"1068"}, "Content-Type":[]string{"application/vnd.vmware.vmw.rest-v1+json"}, "Date":[]string{"Wed, 04 Nov 2020 14:29:27 GMT"}}, Body:(*http.bodyEOFSignal)(0xc000150080), ContentLength:1068, TransferEncoding:[]string(nil), Close:false, Uncompressed:false, Trailer:http.Header(nil), Request:(*http.Request)(0xc00013c000), TLS:(*tls.ConnectionState)(nil)}
2020/11/04 15:29:27 [WSAPICLI] Fi: wsapitools.go Fu: GetVM Obj: List of VMs []wsapiclient.MyVm{wsapiclient.MyVm{IdVM:"EFAG7OV3I4PUGBK9B86ES951L2J128L5", Path:"C:\\VMs\\CentOS 8 64-bit\\CentOS 8 64-bit.vmx", Denomination:"", Description:"", CPU:struct { Processors int "json:\"processors\"" }{Processors:0}, PowerStatus:"", Memory:0}, wsapiclient.MyVm{IdVM:"E7OLTT2B7TQ1VQ34HB1MF2P2UNVSN4Q4", Path:"C:\\VMs\\SUSE Linux 64-bit Github Terraform\\SUSE Linux 64-bit Github Terraform.vmx", Denomination:"", Description:"", CPU:struct { Processors int "json:\"processors\"" }{Processors:0}, PowerStatus:"", Memory:0}, wsapiclient.MyVm{IdVM:"LFVDMGQ63S74NTA5VP7NMVJRAHU1IC2G", Path:"C:\\VMs\\Ubuntu 64-bit MATE 2004 ONE\\Ubuntu 64-bit MATE 2004 ONE.vmx", Denomination:"", Description:"", CPU:struct { Processors int "json:\"processors\"" }{Processors:0}, PowerStatus:"", Memory:0}, wsapiclient.MyVm{IdVM:"8VRFHVFJEML73DFF0T2LCG7H7IIJAVNU", Path:"C:\\VMs\\VMware-vR-Appliance-7.6.0.317-13027280_OVF10\\VMware-vR-Appliance-7.6.0.317-13027280_OVF10.vmx", Denomination:"", Description:"", CPU:struct { Processors int "json:\"processors\"" }{Processors:0}, PowerStatus:"", Memory:0}, wsapiclient.MyVm{IdVM:"B2N5U3R4J0QQUS0UQN1E9UST1LE7ST26", Path:"C:\\VMs\\VMware-vRO-Appliance-7.6.0.317-13020602_OVF10\\VMware-vRO-Appliance-7.6.0.317-13020602_OVF10.vmx", Denomination:"", Description:"", CPU:struct { Processors int "json:\"processors\"" }{Processors:0}, PowerStatus:"", Memory:0}, wsapiclient.MyVm{IdVM:"AP0PDSV8L14UJSP21LGUA6OGADA4FH18", Path:"C:\\VMs\\clone-test-copy\\clone-test-copy.vmx", Denomination:"", Description:"", CPU:struct { Processors int "json:\"processors\"" }{Processors:0}, PowerStatus:"", Memory:0}, wsapiclient.MyVm{IdVM:"533QK6OC3M27ATOK5VJFI0KTMUF5K712", Path:"C:\\VMs\\testOS\\testOS.vmx", Denomination:"", Description:"", CPU:struct { Processors int "json:\"processors\"" }{Processors:0}, PowerStatus:"", Memory:0}, wsapiclient.MyVm{IdVM:"O9JDEN8VTF8V09KGLDOGNL551UA2O369", Path:"C:\\VMs\\testOs2\\testOs2.vmx", Denomination:"", Description:"", CPU:struct { Processors int "json:\"processors\"" }{Processors:0}, PowerStatus:"", Memory:0}}
2020/11/04 15:29:27 [WSAPICLI] Fi: wsapitools.go Fu: GetNameDescription Message: Failed opening file open **C:\VMs\testOS\testOS.vmx:** no such file or directory, please make sure the config file exists
exit status 1
make: *** [Makefile:50: test_api_client] Error 1
merlin@CAMELOTH:~/vmware-api/vmware-workstation-api-client$ ls
LICENSE Makefile README.md bin config.ini main.go src vmware-workstation-api-client_v0.0.1 workstationapi-cert.pem workstationapi-key.pem wsapiclient
merlin@CAMELOTH:~/vmware-api/vmware-workstation-api-client$
The solution is to install go. Perhaps you can work out hte requirements. Now I get a new error:
merlin@CAMELOTH:~/terraform-vmware$ terraform apply
var.vmws_reource_frontend_description
(Required) The Description at later maybe to explain the instance
Enter a value: new testOS
var.vmws_reource_frontend_sourceid
(Required) The ID of the VM that to use for clone at the new
Enter a value: 533QK6OC3M27ATOK5VJFI0KTMUF5K712
provider.vmworkstation.password
The user password for VMWare Workstation Pro API REST operations.
Enter a value: myTest123#
provider.vmworkstation.url
The URL for connect to the API REST
Enter a value: http://127.0.0.1:8697/api
provider.vmworkstation.user
The user name for VMWare Workstation Pro API REST operations.
Enter a value: merlin
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# vmworkstation_vm.test_machine will be created
+ resource "vmworkstation_vm" "test_machine" {
+ denomination = "NewInstance"
+ description = "new testOS"
+ id = (known after apply)
+ memory = 1024
+ processors = 1
+ sourceid = "533QK6OC3M27ATOK5VJFI0KTMUF5K712"
}
Plan: 1 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ vmws_frontend_id = (known after apply)
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
vmworkstation_vm.test_machine: Creating...
vmworkstation_vm.test_machine: Still creating... [10s elapsed]
vmworkstation_vm.test_machine: Still creating... [20s elapsed]
vmworkstation_vm.test_machine: Still creating... [30s elapsed]
vmworkstation_vm.test_machine: Still creating... [40s elapsed]
Error: rpc error: code = Unavailable desc = transport is closing
I think that you need read the documentation of provider
https://registry.terraform.io/providers/elsudano/vmworkstation/latest/docs#argument-reference
And this is the link to install the provider
https://registry.terraform.io/providers/elsudano/vmworkstation/latest
Firstly I would like to thank you for making this code available to the community. I too experienced the same issues as the original poster, "Root resource was present, but now absent." when running my Terraform script. I followed your recommendation and installed the vmware-workstation-api-client to test things out. When I went to run it though there was an issue with the test_api_client, in particular there are two hardcoded VMware VM IDs in main.go When these were replaced with IDs for my local VMs it allowed the code to work. Next, it was not clear to me but VMware Workstation needs to be running on the same host for the test_api_client to work. It seems to ignore the BaseURL value in the config.ini This last item, that VMware Workstation needs to be running locally, seems to have been the cause of my getting the "Root resource was present, but now absent." when running my Terraform script. The documentation did say that VMware Workstation 14+ was required, but because of the presence of the VMWS_URL it seemed to indicate to me that a remote VMware Workstation would be allowed. This does not appear to be the case, VMware Workstation needs to be running on the same host that the Terraform script is being run on. Again, thank you for taking the time to develop and maintain this code. I very much appreciate it.
Firstly I would like to thank you for making this code available to the community. I too experienced the same issues as the original poster, "Root resource was present, but now absent." when running my Terraform script. I followed your recommendation and installed the vmware-workstation-api-client to test things out. When I went to run it though there was an issue with the test_api_client, in particular there are two hardcoded VMware VM IDs in main.go When these were replaced with IDs for my local VMs it allowed the code to work. Next, it was not clear to me but VMware Workstation needs to be running on the same host for the test_api_client to work. It seems to ignore the BaseURL value in the config.ini This last item, that VMware Workstation needs to be running locally, seems to have been the cause of my getting the "Root resource was present, but now absent." when running my Terraform script. The documentation did say that VMware Workstation 14+ was required, but because of the presence of the VMWS_URL it seemed to indicate to me that a remote VMware Workstation would be allowed. This does not appear to be the case, VMware Workstation needs to be running on the same host that the Terraform script is being run on. Again, thank you for taking the time to develop and maintain this code. I very much appreciate it.
Milne, thanks for your comments are very interesting
Firstly I will review the code to see the possible problems with the IDs of VMS inside of code to the client.
About that you comment me to VmWare Workstation need to be installed in the same host to the client I don't sure really. All my tests I did in the same host, sorry I can't help you about this.
About of config.ini seems it that the version in the repo it's old I will review and update if need it
Finally about that workstation don't registered a VMS in the UI, maybe in the next version I will can implement it, the problem here is the API rest of VmWare, because don't permit manage the UI through the API. The trick here is create manually the vmx file in the same place of all VMS ... But of course this is not easy for the multiple options that have the file.
One more time thanks for your time to test the software and I appreciate your comments
hi Milne
It seems that in the VmWare Workstation 16 version the API REST allows registering the VMs within the GUI
I'm preparing a new version for this to be done.
Stay tuned for new releases
Cheers
Hi,
I'm go to close this issue because is repeated
Regards
Hello I am trying to use the vmworkstation plugin for some training, as I do not want to use cloud. I found out, that it is not working with windows, you need linux. That is not the problem. I can create VMs via rest-api, but when I try to use this provider, i get the following output: