Skip to content

Commit 80a0440

Browse files
committed
add cluster join config
1 parent aef985f commit 80a0440

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

api/cluster_type.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package api
2+
3+
type ClusterJoinConfig struct {
4+
ConfigDigest string `json:"config_digest"`
5+
NodeList []ClusterNodeConfig `json:"nodelist"`
6+
PreferredNode string `json:"preferred_node"`
7+
Totem Totem `json:"totem"`
8+
}
9+
10+
type ClusterNodeConfig struct {
11+
Name string `json:"name"`
12+
NodeID string `json:"nodeid"`
13+
PVEAddr string `json:"pve_addr"`
14+
PVEFP string `json:"pve_fp"`
15+
QuorumVotes string `json:"quorum_votes"`
16+
Ring0Addr string `json:"ring0_addr"`
17+
}
18+
19+
type Totem struct {
20+
ClusterName string `json:"cluster_name"`
21+
ConfigVersion string `json:"config_version"`
22+
Interface interface{} `json:"interface"`
23+
IPVersion string `json:"ip_version"`
24+
LinkMode string `json:"link_mode"`
25+
SecAuth string `json:"secauth"`
26+
Version string `json:"version"`
27+
}
28+
29+
type CorosyncLink struct {
30+
Link0 string `json:"link0"`
31+
Link1 string `json:"link1"`
32+
Link2 string `json:"link2"`
33+
Link3 string `json:"link3"`
34+
Link4 string `json:"link4"`
35+
Link5 string `json:"link5"`
36+
Link6 string `json:"link6"`
37+
Link7 string `json:"link7"`
38+
Link8 string `json:"link8"`
39+
}

proxmox/cluster.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package proxmox
2+
3+
import (
4+
"context"
5+
6+
"github.com/sp-yduck/proxmox-go/api"
7+
)
8+
9+
func (s *Service) NextID(ctx context.Context) (int, error) {
10+
return s.restclient.GetNextID(ctx)
11+
}
12+
13+
func (s *Service) JoinConfig(ctx context.Context) (*api.ClusterJoinConfig, error) {
14+
return s.restclient.GetJoinConfig(ctx)
15+
}

rest/cluster.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package rest
33
import (
44
"context"
55
"encoding/json"
6+
7+
"github.com/sp-yduck/proxmox-go/api"
68
)
79

810
func (c *RESTClient) GetNextID(ctx context.Context) (int, error) {
@@ -16,3 +18,11 @@ func (c *RESTClient) GetNextID(ctx context.Context) (int, error) {
1618
}
1719
return int(nextid), nil
1820
}
21+
22+
func (c *RESTClient) GetJoinConfig(ctx context.Context) (*api.ClusterJoinConfig, error) {
23+
var config *api.ClusterJoinConfig
24+
if err := c.Get(ctx, "/cluster/config/join", &config); err != nil {
25+
return nil, err
26+
}
27+
return config, nil
28+
}

rest/cluster_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ func (s *TestSuite) TestGetNextID() {
99
}
1010
s.T().Logf("get nextID: %d", nextid)
1111
}
12+
13+
func (s *TestSuite) TestGetJoinConfig() {
14+
c, err := s.restclient.GetJoinConfig(context.Background())
15+
if err != nil {
16+
s.T().Errorf("failed to get join config: %v", err)
17+
}
18+
s.T().Logf("get join config: %v", c)
19+
}

0 commit comments

Comments
 (0)