Skip to content

Commit bcbc501

Browse files
committed
EH: Add qconf host group resolving call
1 parent 016e108 commit bcbc501

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

pkg/qconf/v9.0/qconf.go

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type QConf interface {
6868
ModifyHostGroup(hostGroupName string, hg HostGroupConfig) error
6969
DeleteHostGroup(groupName string) error
7070
ShowHostGroup(groupName string) (HostGroupConfig, error)
71+
ShowHostGroupResolved(groupName string) ([]string, error)
7172
ShowHostGroups() ([]string, error)
7273

7374
AddResourceQuotaSet(rqs ResourceQuotaSetConfig) error

pkg/qconf/v9.0/qconf_impl.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ type CommandLineQConfConfig struct {
4646

4747
// NewCommandLineQConf creates a new instance of CommandLineQConf.
4848
func NewCommandLineQConf(config CommandLineQConfConfig) (*CommandLineQConf, error) {
49+
if config.Executable == "" {
50+
config.Executable = "qconf"
51+
}
4952
return &CommandLineQConf{config: config}, nil
5053
}
5154

@@ -122,7 +125,6 @@ func (c *CommandLineQConf) GetClusterConfiguration() (ClusterConfig, error) {
122125
if err != nil {
123126
return cc, fmt.Errorf("failed to read host config: %v", err)
124127
}
125-
126128
cc.HostConfigurations[host] = hc
127129
}
128130

@@ -1115,7 +1117,9 @@ func (c *CommandLineQConf) DeleteHostGroup(groupName string) error {
11151117
return err
11161118
}
11171119

1118-
// ShowHostGroup shows the specified host group.
1120+
// ShowHostGroup shows the host list of a particular host group. The host
1121+
// list can contain other host groups. Use ShowHowGroupResolved() for
1122+
// getting a list of all hosts.
11191123
func (c *CommandLineQConf) ShowHostGroup(groupName string) (HostGroupConfig, error) {
11201124
out, err := c.RunCommand("-shgrp", groupName)
11211125
if err != nil {
@@ -1139,6 +1143,15 @@ func (c *CommandLineQConf) ShowHostGroup(groupName string) (HostGroupConfig, err
11391143
return cfg, nil
11401144
}
11411145

1146+
// ShowHostGroupResolved shows all hosts in a host group and all sub-groups.
1147+
func (c *CommandLineQConf) ShowHostGroupResolved(groupName string) ([]string, error) {
1148+
out, err := c.RunCommand("-shgrp_resolved", groupName)
1149+
if err != nil {
1150+
return nil, err
1151+
}
1152+
return splitWithoutEmptyLines(out, "\n"), nil
1153+
}
1154+
11421155
// ShowHostGroups shows all host groups.
11431156
func (c *CommandLineQConf) ShowHostGroups() ([]string, error) {
11441157
output, err := c.RunCommand("-shgrpl")

pkg/qconf/v9.0/qconf_impl_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,12 @@ gid_range 20000-20100`, "\n")
699699
Expect(groups).NotTo(BeNil())
700700
Expect(groups).To(ContainElement(groupName))
701701

702-
// Show the specific host group configuration and verify its details
702+
// Show a list of all hosts in the host group
703+
hosts, err := qc.ShowHostGroupResolved(groupName)
704+
Expect(err).To(BeNil())
705+
Expect(hosts).NotTo(BeNil())
706+
Expect(hosts).To(ContainElement("master"))
707+
703708
retrievedHostGroupConfig, err := qc.ShowHostGroup(groupName)
704709
Expect(err).To(BeNil())
705710
Expect(retrievedHostGroupConfig).To(Equal(hostGroupConfig))
@@ -1157,7 +1162,8 @@ gid_range 20000-20100`, "\n")
11571162
var err error
11581163

11591164
BeforeEach(func() {
1160-
qc, err = qconf.NewCommandLineQConf(qconf.CommandLineQConfConfig{Executable: "qconf"})
1165+
qc, err = qconf.NewCommandLineQConf(
1166+
qconf.CommandLineQConfConfig{Executable: "qconf"})
11611167
Expect(err).To(BeNil())
11621168
})
11631169

0 commit comments

Comments
 (0)