Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #712 from fabriziosestito/skip_non_dc_cluster_proj…
Browse files Browse the repository at this point in the history
…ection

Skip non dc cluster projection
  • Loading branch information
fabriziosestito committed Jan 18, 2022
2 parents d40663f + c82243a commit c411c33
Show file tree
Hide file tree
Showing 5 changed files with 1,025 additions and 1,015 deletions.
5 changes: 4 additions & 1 deletion internal/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Cluster struct {
SBD SBD `mapstructure:"sbd,omitempty"`
Id string `mapstructure:"id"`
Name string `mapstructure:"name"`
DC bool `mapstructure:"dc"`
}

func NewCluster() (Cluster, error) {
Expand Down Expand Up @@ -89,6 +90,8 @@ func NewClusterWithDiscoveryTools(discoveryTools *DiscoveryTools) (Cluster, erro
cluster.SBD = sbdData
}

cluster.DC = isDC(&cluster)

return cluster, nil
}

Expand All @@ -108,7 +111,7 @@ func getName(c Cluster) string {
return ""
}

func (c *Cluster) IsDc() bool {
func isDC(c *Cluster) bool {
host, _ := os.Hostname()

for _, nodes := range c.Crmmon.Nodes {
Expand Down
16 changes: 8 additions & 8 deletions internal/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,43 +78,43 @@ func TestIsDC(t *testing.T) {

root.Configuration.CrmConfig = crmConfig

c := Cluster{
c := &Cluster{
Cib: *root,
Crmmon: crmmon.Root{
Version: "1.2.3",
Nodes: []crmmon.Node{
crmmon.Node{
{
Name: "othernode",
DC: false,
},
crmmon.Node{
{
Name: host,
DC: true,
},
},
},
}

assert.Equal(t, true, c.IsDc())
assert.Equal(t, true, isDC(c))

c = Cluster{
c = &Cluster{
Cib: *root,
Crmmon: crmmon.Root{
Version: "1.2.3",
Nodes: []crmmon.Node{
crmmon.Node{
{
Name: "othernode",
DC: true,
},
crmmon.Node{
{
Name: host,
DC: false,
},
},
},
}

assert.Equal(t, false, c.IsDc())
assert.Equal(t, false, isDC(c))
}

func TestIsFencingEnabled(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -856,5 +856,6 @@
}
]
}
}
},
"DC": true
}

0 comments on commit c411c33

Please sign in to comment.