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

Improve the Xen orchestra go client's API design #189

Open
ddelnano opened this issue Feb 1, 2022 · 0 comments
Open

Improve the Xen orchestra go client's API design #189

ddelnano opened this issue Feb 1, 2022 · 0 comments

Comments

@ddelnano
Copy link
Collaborator

ddelnano commented Feb 1, 2022

While working on #179 and past tasks, it's become apparent that the XO client (github.com/terra-farm/terraform-provider-xenorchestra/client module) has an inconsistent API design.

API calls that operate on VMs typically require a deeply nested struct (as seen below and here)

	vm, err := c.CreateVm(client.Vm{
		AffinityHost:      d.Get("affinity_host").(string),
		BlockedOperations: blockedOperations,
		Boot: client.Boot{
			Firmware: d.Get("hvm_boot_firmware").(string),
		},
		ExpNestedHvm:    d.Get("exp_nested_hvm").(bool),
		NameLabel:       d.Get("name_label").(string),
		NameDescription: d.Get("name_description").(string),
		Template:        d.Get("template").(string),
		CloudConfig:     d.Get("cloud_config").(string),
		ResourceSet:     rs,
		CPUs: client.CPUs{
			Number: d.Get("cpus").(int),
		},
		CloudNetworkConfig: d.Get("cloud_network_config").(string),
		Memory: client.MemoryObject{
			Static: []int{
				0, d.Get("memory_max").(int),
			},
		},
		Tags:         vmTags,
		Disks:        ds,
		Installation: installation,
		// TODO: (#145) Uncomment this once issues with secure_boot have been figured out
		// SecureBoot:   d.Get("secure_boot").(bool),
		VIFsMap:    network_maps,
		StartDelay: d.Get("start_delay").(int),
		WaitForIps: d.Get("wait_for_ip").(bool),
		Videoram: client.Videoram{
			Value: d.Get("videoram").(int),
		},
		Vga: d.Get("vga").(string),
	},
		d.Timeout(schema.TimeoutCreate),
	)

This differs from the rest of the XO client API and it makes it awkward to use. This issue is to investigate ways to make the API design more consistent and implement the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant