forked from canonical/lxd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.go
171 lines (139 loc) · 5.11 KB
/
server.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package api
// ServerEnvironment represents the read-only environment fields of a LXD server
type ServerEnvironment struct {
// List of addresses the server is listening on
// Example: [":8443"]
Addresses []string `json:"addresses" yaml:"addresses"`
// List of architectures supported by the server
// Example: ["x86_64", "i686"]
Architectures []string `json:"architectures" yaml:"architectures"`
// Server certificate as PEM encoded X509
// Example: X509 PEM certificate
Certificate string `json:"certificate" yaml:"certificate"`
// Server certificate fingerprint as SHA256
// Example: fd200419b271f1dc2a5591b693cc5774b7f234e1ff8c6b78ad703b6888fe2b69
CertificateFingerprint string `json:"certificate_fingerprint" yaml:"certificate_fingerprint"`
// List of supported instance drivers (separate by " | ")
// Example: lxc | qemu
Driver string `json:"driver" yaml:"driver"`
// List of supported instance driver versions (separate by " | ")
// Example: 4.0.7 | 5.2.0
DriverVersion string `json:"driver_version" yaml:"driver_version"`
// Current firewall driver
// Example: nftables
//
// API extension: firewall_driver
Firewall string `json:"firewall" yaml:"firewall"`
// OS kernel name
// Example: Linux
Kernel string `json:"kernel" yaml:"kernel"`
// OS kernel architecture
// Example: x86_64
KernelArchitecture string `json:"kernel_architecture" yaml:"kernel_architecture"`
// Map of kernel features that were tested on startup
// Example: {"netnsid_getifaddrs": "true", "seccomp_listener": "true"}
//
// API extension: kernel_features
KernelFeatures map[string]string `json:"kernel_features" yaml:"kernel_features"`
// Kernel version
// Example: 5.4.0-36-generic
KernelVersion string `json:"kernel_version" yaml:"kernel_version"`
// Map of LXC features that were tested on startup
// Example: {"cgroup2": "true", "devpts_fd": "true", "pidfd": "true"}
//
// API extension: lxc_features
LXCFeatures map[string]string `json:"lxc_features" yaml:"lxc_features"`
// Name of the operating system (Linux distribution)
// Example: Ubuntu
//
// API extension: api_os
OSName string `json:"os_name" yaml:"os_name"`
// Version of the operating system (Linux distribution)
// Example: 20.04
//
// API extension: api_os
OSVersion string `json:"os_version" yaml:"os_version"`
// Current project name
// Example: default
//
// API extension: projects
Project string `json:"project" yaml:"project"`
// Server implementation name
// Example: lxd
Server string `json:"server" yaml:"server"`
// Whether the server is part of a cluster
// Example: false
//
// API extension: clustering
ServerClustered bool `json:"server_clustered" yaml:"server_clustered"`
// Server hostname
// Example: castiana
//
// API extension: clustering
ServerName string `json:"server_name" yaml:"server_name"`
// PID of the LXD process
// Example: 1453969
ServerPid int `json:"server_pid" yaml:"server_pid"`
// Server version
// Example: 4.11
ServerVersion string `json:"server_version" yaml:"server_version"`
// List of active storage drivers (separate by " | ")
// Example: dir | zfs
Storage string `json:"storage" yaml:"storage"`
// List of active storage driver versions (separate by " | ")
// Example: 1 | 0.8.4-1ubuntu11
StorageVersion string `json:"storage_version" yaml:"storage_version"`
}
// ServerPut represents the modifiable fields of a LXD server configuration
//
// swagger:model
type ServerPut struct {
// Server configuration map (refer to doc/server.md)
// Example: {"core.https_address": ":8443", "core.trust_password": true}
Config map[string]interface{} `json:"config" yaml:"config"`
}
// ServerUntrusted represents a LXD server for an untrusted client
//
// swagger:model
type ServerUntrusted struct {
// List of supported API extensions
// Read only: true
// Example: ["etag", "patch", "network", "storage"]
APIExtensions []string `json:"api_extensions" yaml:"api_extensions"`
// Support status of the current API (one of "devel", "stable" or "deprecated")
// Read only: true
// Example: stable
APIStatus string `json:"api_status" yaml:"api_status"`
// API version number
// Read only: true
// Example: 1.0
APIVersion string `json:"api_version" yaml:"api_version"`
// Whether the client is trusted (one of "trusted" or "untrusted")
// Read only: true
// Example: untrusted
Auth string `json:"auth" yaml:"auth"`
// Whether the server is public-only (only public endpoints are implemented)
// Read only: true
// Example: false
Public bool `json:"public" yaml:"public"`
// List of supported authentication methods
// Read only: true
// Example: ["tls", "candid"]
//
// API extension: macaroon_authentication
AuthMethods []string `json:"auth_methods" yaml:"auth_methods"`
}
// Server represents a LXD server
//
// swagger:model
type Server struct {
ServerPut `yaml:",inline"`
ServerUntrusted `yaml:",inline"`
// Read-only status/configuration information
// Read only: true
Environment ServerEnvironment `json:"environment" yaml:"environment"`
}
// Writable converts a full Server struct into a ServerPut struct (filters read-only fields)
func (srv *Server) Writable() ServerPut {
return srv.ServerPut
}