-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
playbook(memcache): support instances and instances_sequence
Signed-off-by: Ericwai <[email protected]>
- Loading branch information
Showing
10 changed files
with
407 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package hosts | ||
|
||
import ( | ||
"fmt" | ||
"github.com/opencurve/curveadm/internal/errno" | ||
"github.com/opencurve/curveadm/pkg/variable" | ||
) | ||
|
||
type Var struct { | ||
name string | ||
resolved bool | ||
} | ||
|
||
var ( | ||
hostVars = []Var{ | ||
{name: "instances_sequence"}, | ||
} | ||
) | ||
|
||
func addVariables(hcs []*HostConfig, idx int, vars []Var) error { | ||
hc := hcs[idx] | ||
for _, v := range vars { | ||
err := hc.GetVariables().Register(variable.Variable{ | ||
Name: v.name, | ||
Value: getValue(v.name, hcs, idx), | ||
}) | ||
if err != nil { | ||
return errno.ERR_REGISTER_VARIABLE_FAILED.E(err) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func AddHostVariables(hcs []*HostConfig, idx int) error { | ||
return addVariables(hcs, idx, hostVars) | ||
} | ||
|
||
func getValue(name string, hcs []*HostConfig, idx int) string { | ||
hc := hcs[idx] | ||
switch name { | ||
case "instances_sequence": | ||
return fmt.Sprintf("%02d", hc.GetInstancesSequence()) | ||
} | ||
return "" | ||
} |
Oops, something went wrong.