Skip to content

Commit

Permalink
Merge pull request nutanix#19 from nutanix/19-vm-data-source
Browse files Browse the repository at this point in the history
19 vm data source
  • Loading branch information
crizstian authored Apr 30, 2018
2 parents 60db7a1 + be2b7e5 commit 5e321d6
Show file tree
Hide file tree
Showing 13 changed files with 2,870 additions and 280 deletions.
11 changes: 8 additions & 3 deletions client/v3/v3_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ type Service interface {
GetSubnet(UUID string) (*SubnetIntentResponse, error)
ListSubnet(getEntitiesRequest *SubnetListMetadata) (*SubnetListIntentResponse, error)
UpdateSubnet(UUID string, body *SubnetIntentInput) (*SubnetIntentResponse, error)
CreateImage(createRequest *ImageIntentInput) (*ImageIntentResponse, error)
DeleteImage(UUID string) error
GetImage(UUID string) (*ImageIntentResponse, error)
ListImage(getEntitiesRequest *ImageListMetadata) (*ImageListIntentResponse, error)
UpdateImage(UUID string, body *ImageIntentInput) (*ImageIntentResponse, error)
}

/*CreateVM Creates a VM
Expand Down Expand Up @@ -276,7 +281,7 @@ func (op Operations) UpdateSubnet(UUID string, body *SubnetIntentInput) (*Subnet
* @param body
* @return *ImageIntentResponse
*/
func (op Operations) CreateImage(body ImageIntentInput) (*ImageIntentResponse, error) {
func (op Operations) CreateImage(body *ImageIntentInput) (*ImageIntentResponse, error) {
ctx := context.TODO()

req, err := op.client.NewRequest(ctx, http.MethodPost, "/images", body)
Expand Down Expand Up @@ -346,7 +351,7 @@ func (op Operations) GetImage(UUID string) (*ImageIntentResponse, error) {
* @param getEntitiesRequest
* @return *ImageListIntentResponse
*/
func (op Operations) ListImage(getEntitiesRequest ImageListMetadata) (*ImageListIntentResponse, error) {
func (op Operations) ListImage(getEntitiesRequest *ImageListMetadata) (*ImageListIntentResponse, error) {
ctx := context.TODO()
path := "/images/list"

Expand All @@ -373,7 +378,7 @@ func (op Operations) ListImage(getEntitiesRequest ImageListMetadata) (*ImageList
* @param body
* @return *ImageIntentResponse
*/
func (op Operations) UpdateImage(UUID string, body ImageIntentInput) (*ImageIntentResponse, error) {
func (op Operations) UpdateImage(UUID string, body *ImageIntentInput) (*ImageIntentResponse, error) {
ctx := context.TODO()

path := fmt.Sprintf("/images/%s", UUID)
Expand Down
22 changes: 21 additions & 1 deletion examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ resource "nutanix_virtual_machine" "vm1" {
data_source_reference = [{
kind = "image"
name = "Centos7"
uuid = "9eabbb39-1baf-4872-beaf-adedcb612a0b"
uuid = "${nutanix_image.test.id}"
}]

device_properties = [{
Expand Down Expand Up @@ -84,3 +84,23 @@ resource "nutanix_subnet" "test" {
dhcp_domain_name_server_list = ["8.8.8.8", "4.2.2.2"]
dhcp_domain_search_list = ["nutanix.com", "calm.io"]
}

resource "nutanix_image" "test" {
metadata = {
kind = "image"
}

name = "dou_image_%d"
description = "Dou Image Test"
name = "CentOS7-ISO"
source_uri = "http://10.7.1.7/data1/ISOs/CentOS-7-x86_64-Minimal-1503-01.iso"

checksum = {
checksum_algorithm = "SHA_256"
checksum_value = "a9e4e0018c98520002cd7cf506e980e66e31f7ada70b8fc9caa4f4290b019f4f"
}
}

data "nutanix_virtual_machine" "nutanix_virtual_machine" {
vm_id = "${nutanix_virtual_machine.vm1.id}"
}
Binary file modified examples/terraform-provider-nutanix
Binary file not shown.
Binary file modified examples/terraform-provider-nutanix.exe
Binary file not shown.
Loading

0 comments on commit 5e321d6

Please sign in to comment.