forked from canonical/lxd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_1.0.go
62 lines (52 loc) · 1.26 KB
/
api_1.0.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
package main
import (
"net/http"
"os"
"github.com/lxc/lxd/lxd/response"
lxdshared "github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/api"
"github.com/lxc/lxd/shared/version"
)
var api10Cmd = APIEndpoint{
Get: APIEndpointAction{Handler: api10Get},
}
var api10 = []APIEndpoint{
api10Cmd,
execCmd,
eventsCmd,
fileCmd,
operationsCmd,
operationCmd,
operationWebsocket,
stateCmd,
}
func api10Get(d *Daemon, r *http.Request) response.Response {
srv := api.ServerUntrusted{
APIExtensions: version.APIExtensions,
APIStatus: "stable",
APIVersion: version.APIVersion,
Public: false,
Auth: "trusted",
AuthMethods: []string{"tls"},
}
uname, err := lxdshared.Uname()
if err != nil {
return response.InternalError(err)
}
serverName, err := os.Hostname()
if err != nil {
return response.SmartError(err)
}
env := api.ServerEnvironment{
Kernel: uname.Sysname,
KernelArchitecture: uname.Machine,
KernelVersion: uname.Release,
Server: "lxd-agent",
ServerPid: os.Getpid(),
ServerVersion: version.Version,
ServerName: serverName,
}
fullSrv := api.Server{ServerUntrusted: srv}
fullSrv.Environment = env
return response.SyncResponseETag(true, fullSrv, fullSrv)
}