forked from openshift/cluster-api-provider-libvirt
/
libvirtmachineproviderconfig_types.go
128 lines (109 loc) · 4.97 KB
/
libvirtmachineproviderconfig_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package v1alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Annotation constants
const (
// ClusterIDLabel is the label that a machineset must have to identify the
// cluster to which it belongs.
ClusterIDLabel = "sigs.k8s.io/cluster-api-cluster"
MachineRoleLabel = "sigs.k8s.io/cluster-api-machine-role"
MachineTypeLabel = "sigs.k8s.io/cluster-api-machine-type"
)
// LibvirtMachineProviderConfig is the type that will be embedded in a Machine.Spec.ProviderSpec field
// for an Libvirt instance.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type LibvirtMachineProviderConfig struct {
metav1.TypeMeta `json:",inline"`
DomainMemory int `json:"domainMemory"`
DomainVcpu int `json:"domainVcpu"`
IgnKey string `json:"ignKey"`
Ignition *Ignition `json:"ignition"`
CloudInit *CloudInit `json:"cloudInit"`
Volume *Volume `json:"volume"`
NetworkInterfaceName string `json:"networkInterfaceName"`
NetworkInterfaceHostname string `json:"networkInterfaceHostname"`
NetworkInterfaceAddress string `json:"networkInterfaceAddress"`
NetworkUUID string `json:"networkUUID"`
Autostart bool `json:"autostart"`
URI string `json:"uri"`
}
// Ignition contains location of ignition to be run during bootstrapping
type Ignition struct {
// Ignition config to be run during bootstrapping
UserDataSecret string `json:"userDataSecret"`
}
// CloudInit contains location of user data to be run during bootstrapping
type CloudInit struct {
// Bash script to be run during bootstrapping
UserDataSecret string `json:"userDataSecret"`
// Allow to ssh into instance
SSHAccess bool `json:"sshAccess"`
}
// Volume contains the info for the actuator to create a volume
type Volume struct {
PoolName string `json:"poolName"`
BaseVolumeID string `json:"baseVolumeID"`
VolumeName string `json:"volumeName"`
}
// LibvirtClusterProviderConfig is the type that will be embedded in a Cluster.Spec.ProviderSpec field.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type LibvirtClusterProviderConfig struct {
metav1.TypeMeta `json:",inline"`
}
// LibvirtMachineProviderStatus is the type that will be embedded in a Machine.Status.ProviderStatus field.
// It contains Libvirt-specific status information.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type LibvirtMachineProviderStatus struct {
metav1.TypeMeta `json:",inline"`
// InstanceID is the instance ID of the machine created in Libvirt
InstanceID *string `json:"instanceID"`
// InstanceState is the state of the Libvirt instance for this machine
InstanceState *string `json:"instanceState"`
// Conditions is a set of conditions associated with the Machine to indicate
// errors or other status
Conditions []LibvirtMachineProviderCondition `json:"conditions"`
}
// LibvirtMachineProviderConditionType is a valid value for LibvirtMachineProviderCondition.Type
type LibvirtMachineProviderConditionType string
// Valid conditions for an Libvirt machine instance
const (
// MachineCreated indicates whether the machine has been created or not. If not,
// it should include a reason and message for the failure.
MachineCreated LibvirtMachineProviderConditionType = "MachineCreated"
)
// LibvirtMachineProviderCondition is a condition in a LibvirtMachineProviderStatus
type LibvirtMachineProviderCondition struct {
// Type is the type of the condition.
Type LibvirtMachineProviderConditionType `json:"type"`
// Status is the status of the condition.
Status corev1.ConditionStatus `json:"status"`
// LastProbeTime is the last time we probed the condition.
// +optional
LastProbeTime metav1.Time `json:"lastProbeTime"`
// LastTransitionTime is the last time the condition transitioned from one status to another.
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
// Reason is a unique, one-word, CamelCase reason for the condition's last transition.
// +optional
Reason string `json:"reason"`
// Message is a human-readable message indicating details about last transition.
// +optional
Message string `json:"message"`
}
// LibvirtClusterProviderStatus is the type that will be embedded in a Cluster.Status.ProviderStatus field.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type LibvirtClusterProviderStatus struct {
metav1.TypeMeta `json:",inline"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// LibvirtMachineProviderConfigList contains a list of LibvirtMachineProviderConfig
type LibvirtMachineProviderConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []LibvirtMachineProviderConfig `json:"items"`
}
func init() {
SchemeBuilder.Register(&LibvirtMachineProviderConfig{}, &LibvirtMachineProviderConfigList{}, &LibvirtMachineProviderStatus{})
}