Skip to content

Commit eb6aed2

Browse files
committed
Cleanup
Clean up: Remove unused code Add state of implementation to proxmox.md
1 parent 51ce22b commit eb6aed2

File tree

3 files changed

+16
-71
lines changed

3 files changed

+16
-71
lines changed

docs/proxmox.md

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Proxmox Virtual Environment
22

3+
## State of the implementation
4+
5+
Support for Proxmox as a provider in the machine-controller is currently just a technical demo. It
6+
is possible to create MachineDeployments using manually created VM templates as demonstrated below.
7+
In this example the VM template is using local storage, which is why this template can only be
8+
cloned on the same node it is located at.
9+
310
## Prerequisites
411

512
### Authentication
@@ -38,12 +45,12 @@ For the provider to properly function the user needs an API token with the follo
3845
### Cloud-Init enabled VM Templates
3946

4047
Although it is possible to upload Cloud-Init images in Proxmox VE and create VM disks directly from
41-
these imgages via CLI tools on the nodes directly, there is no API endpoint yet to provide this
48+
these images via CLI tools on the nodes directly, there is no API endpoint yet to provide this
4249
functionality externally. That's why the `proxmox` provider assumes there are VM templates in place
4350
to clone new machines from.
4451

45-
Proxmox recommends to use either ready-to-use Cloud-Init images provided by many Linux distributions
46-
(mostly designed for OpenStack) or to prepare the images yourself as you have full controll over
52+
Proxmox recommends using either ready-to-use Cloud-Init images provided by many Linux distributions
53+
(mostly designed for OpenStack) or to prepare the images yourself as you have full control over
4754
what's in these images.
4855

4956
For VM templates to be available on all nodes, they need to be added to the `ha-manager`.
@@ -59,7 +66,7 @@ qm create $INSTANCE_ID -name ubuntu-18.04-LTS
5966
qm importdisk $INSTANCE_ID bionic-server-cloudimg-amd64.img local-lvm
6067
# Set the imported Disk as SCSI drive.
6168
qm set $INSTANCE_ID -scsihw virtio-scsi-pci -scsi0 local-lvm:vm-$INSTANCE_ID-disk-0
62-
# Create the cloud-init drive where the userdata is read from.
69+
# Create the cloud-init drive where the user-data is read from.
6370
qm set $INSTANCE_ID -ide2 local-lvm:cloudinit
6471
# Boot from the imported disk.
6572
qm set $INSTANCE_ID -boot c -bootdisk scsi0
@@ -75,13 +82,13 @@ qm template $INSTANCE_ID
7582
ha-manager add vm:$INSTANCE_ID -state stopped
7683
```
7784

78-
### Cloud-Init userdata
85+
### Cloud-Init user-data
7986

8087
Proxmox currently does not support the upload of "snippets" via API, but these snippets are used for
81-
cloud-init userdata which are required for the machine-controller to function. This provider
82-
implementation needs to copy the generated userdata yaml file to every proxmox node where a VM is
88+
cloud-init user-data which are required for the machine-controller to function. This provider
89+
implementation needs to copy the generated user-data yaml file to every proxmox node where a VM is
8390
created or migrated to.
8491

85-
* A storage needs to ne enabled for content `snippets` (e.g. `local`)
86-
* SSH private key of a user that exists on all nodes and has write permission to the path were
92+
* A storage needs to be enabled for content `snippets` (e.g. `local`)
93+
* SSH private key of a user that exists on all nodes and has write permission to the path where
8794
snippets are stored (e.g. `/var/lib/vz/snippets`)

pkg/cloudprovider/provider/proxmox/client.go

-35
Original file line numberDiff line numberDiff line change
@@ -105,41 +105,6 @@ func (c ClientSet) getNodeList() (*proxmoxtypes.NodeList, error) {
105105
return nl, nil
106106
}
107107

108-
func (c ClientSet) checkNodeExists(name string) (bool, error) {
109-
nodeList, err := c.getNodeList()
110-
if err != nil {
111-
return false, fmt.Errorf("failed to check node existence: %w", err)
112-
}
113-
114-
for _, node := range nodeList.Data {
115-
if node.Name == name {
116-
return true, nil
117-
}
118-
}
119-
120-
return false, nil
121-
}
122-
123-
func (c ClientSet) getVMList() (*proxmoxtypes.VMList, error) {
124-
vmList, err := c.GetVmList()
125-
if err != nil {
126-
return nil, fmt.Errorf("cannot fetch nodes from cluster: %w", err)
127-
}
128-
129-
var vms *proxmoxtypes.VMList
130-
131-
nodeListJSON, err := json.Marshal(vmList)
132-
if err != nil {
133-
return nil, fmt.Errorf("marshalling vmList to JSON: %w", err)
134-
}
135-
err = json.Unmarshal(nodeListJSON, &vms)
136-
if err != nil {
137-
return nil, fmt.Errorf("unmarshalling JSON to VMList: %w", err)
138-
}
139-
140-
return vms, nil
141-
}
142-
143108
func (c ClientSet) checkTemplateExists(vmID int) (bool, error) {
144109
vmInfo, err := c.GetVmInfo(proxmox.NewVmRef(vmID))
145110
if err != nil {

pkg/cloudprovider/provider/proxmox/types/types.go

-27
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,6 @@ type Node struct {
6464
Uptime int `json:"uptime"`
6565
}
6666

67-
// VMList represents the response body of GET /api2/json/resources?type=vm.
68-
type VMList struct {
69-
Data []VM `json:"data"`
70-
}
71-
72-
// VM is one single vm in the response of GET /api2/json/resources?type=vm.
73-
type VM struct {
74-
CPUCount int `json:"maxcpu"`
75-
CPUUtilization float64 `json:"cpu"`
76-
Diskread int `json:"diskread"`
77-
DiskspaceAvailable int `json:"maxdisk"`
78-
DiskspaceUsed int `json:"disk"`
79-
Diskwrite int `json:"diskwrite"`
80-
ID string `json:"id"`
81-
MemoryAvailable int64 `json:"maxmem"`
82-
MemoryUsed int `json:"mem"`
83-
Name string `json:"name"`
84-
Netin int `json:"netin"`
85-
Netout int `json:"netout"`
86-
Node string `json:"node"`
87-
Status string `json:"status"`
88-
Template int `json:"template"`
89-
Type string `json:"type"`
90-
Uptime int `json:"uptime"`
91-
VMid int `json:"vmid"`
92-
}
93-
9467
// NodeNetworkDeviceList represents the response body of GET /api2/json/nodes/<node>/network.
9568
type NodeNetworkDeviceList struct {
9669
Data []NodeNetworkDevice `json:"data"`

0 commit comments

Comments
 (0)