Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding vm clone resource #452

Open
wants to merge 8 commits into
base: feat/1.6.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions client/v3/v3_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Service interface {
GetVM(uuid string) (*VMIntentResponse, error)
ListVM(getEntitiesRequest *DSMetadata) (*VMListIntentResponse, error)
UpdateVM(uuid string, body *VMIntentInput) (*VMIntentResponse, error)
CloneVM(uuid string, body *VMCloneInput) (*VMCloneResponse, error)
CreateSubnet(createRequest *SubnetIntentInput) (*SubnetIntentResponse, error)
DeleteSubnet(uuid string) (*DeleteResponse, error)
GetSubnet(uuid string) (*SubnetIntentResponse, error)
Expand Down Expand Up @@ -2428,3 +2429,17 @@ func (op Operations) UpdateAddressGroup(uuid string, body *AddressGroupInput) er

return op.client.Do(ctx, req, nil)
}

func (op Operations) CloneVM(uuid string, body *VMCloneInput) (*VMCloneResponse, error) {
ctx := context.TODO()

path := fmt.Sprintf("/vms/%s/clone", uuid)
req, err := op.client.NewRequest(ctx, http.MethodPost, path, body)
vmIntentResponse := new(VMCloneResponse)

if err != nil {
return nil, err
}

return vmIntentResponse, op.client.Do(ctx, req, vmIntentResponse)
}
25 changes: 24 additions & 1 deletion client/v3/v3_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1668,9 +1668,11 @@ type Metadata struct {
// Applied on Prism Central only. Indicate whether force to translate the spec of the fanout request to fit the target cluster API schema.
ShouldForceTranslate *bool `json:"should_force_translate,omitempty" mapstructure:"should_force_translate,omitempty"`

// Logical entity version of the VM from which to clone the new VM.
EntityVersion *string `json:"entity_version,omitempty" mapstructure:"entity_version,omitempty"`

//TODO: add if necessary
//CategoriesMapping map[string][]string `json:"categories_mapping,omitempty" mapstructure:"categories_mapping,omitempty"`
//EntityVersion *string `json:"entity_version,omitempty" mapstructure:"entity_version,omitempty"`
//UseCategoriesMapping *bool `json:"use_categories_mapping,omitempty" mapstructure:"use_categories_mapping,omitempty"`

}
Expand Down Expand Up @@ -2600,3 +2602,24 @@ type AddressGroupListResponse struct {
Metadata *ListMetadataOutput `json:"metadata,omitempty"`
Entities []*AddressGroupListEntry `json:"entities,omitempty"`
}

type OverrideSpec struct {
Name *string `json:"name,omitempty"`
NumSockets *int `json:"num_sockets,omitempty"`
NumVcpusPerSocket *int `json:"num_vcpus_per_socket,omitempty"`
NumThreadsPerCore *int `json:"num_threads_per_core,omitempty"`
MemorySizeMib *int `json:"memory_size_mib,omitempty"`
NicList []*VMNic `json:"nic_list,omitempty"`
BootConfig *VMBootConfig `json:"boot_config,omitempty"`
GuestCustomization *GuestCustomization `json:"guest_customization,omitempty"`
}

type VMCloneInput struct {
Metadata *Metadata `json:"metadata,omitempty"`
OverrideSpec *OverrideSpec `json:"override_spec,omitempty"`
}

type VMCloneResponse struct {
TaskUUID *string `json:"task_uuid,omitempty"`
CloneVMUUID *string `json:"clone_vm_uuid,omitempty"`
}
1 change: 1 addition & 0 deletions nutanix/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func Provider() *schema.Provider {
"nutanix_foundation_image": resourceNutanixFoundationImage(),
"nutanix_foundation_central_image_cluster": resourceNutanixFCImageCluster(),
"nutanix_foundation_central_api_keys": resourceNutanixFCAPIKeys(),
"nutanix_virtual_machine_clone": resourceNutanixVirtualMachineClone(),
},
ConfigureContextFunc: providerConfigure,
}
Expand Down
Loading