@@ -21,6 +21,9 @@ type Entry struct {
2121 // NamePrefix will be used to set prefix for xlator section
2222 // name if Name is not set.
2323 NamePrefix string
24+ // NameSuffix will be used to set suffix for xlator section
25+ // name if Name is not set.
26+ NameSuffix string
2427 // XlatorData represents the Xlator object with all the
2528 // necessory information.
2629 XlatorData Xlator
@@ -57,6 +60,12 @@ func (e *Entry) SetNamePrefix(name string) *Entry {
5760 return e
5861}
5962
63+ // SetNameSuffix sets name prefix
64+ func (e * Entry ) SetNameSuffix (name string ) * Entry {
65+ e .NameSuffix = name
66+ return e
67+ }
68+
6069// Generate generates Volfile content
6170func (v * Volfile ) Generate () (string , error ) {
6271 return v .RootEntry .Generate ()
@@ -80,18 +89,18 @@ func setNameAndType(entry *Entry) error {
8089 if entry .Name == "" {
8190 // If Xlator name template is not specified, construct the xlator
8291 // graph name as <volume-name>-<xlator-suffix>
83- prefix := entry .NamePrefix
84- if prefix != "" {
85- prefix = prefix + "-"
86- }
92+ entry .Name = entry .NamePrefix
8793
8894 if entry .NamePrefix == "" {
8995 volname , exists := entry .VarStrData ["volume.name" ]
9096 if exists {
91- prefix = volname + "-"
97+ entry . Name = volname + "-" + entry . XlatorData . suffix ()
9298 }
9399 }
94- entry .Name = prefix + entry .XlatorData .suffix ()
100+
101+ if entry .NameSuffix != "" {
102+ entry .Name = entry .Name + "-" + entry .NameSuffix
103+ }
95104 }
96105 return nil
97106}
@@ -279,14 +288,19 @@ func volumegraph(tmpl *Template, volinfo volume.Volinfo, entry *Entry, varStrDat
279288 // cluster/distribute graph again. Directly assign
280289 // brick entries to main cluster/distribute itself
281290 sentry := entry
291+ svname := ""
282292 if sv .Type != volume .SubvolDistribute || (sv .Type == volume .SubvolDistribute && numSubvols > 1 ) {
283293 for _ , sxl := range subvolXlators {
284294 if ! sxl .OnlyLocalBricks || (sxl .OnlyLocalBricks && numberOfLocalBricks > 0 ) {
295+ svname = sxl .suffix () + "-" + strconv .Itoa (sidx )
285296 sentry = sentry .Add (sxl , utils .MergeStringMaps (
286297 * varStrData ,
287298 sv .StringMap (),
288299 extraStringMaps .Subvols [sidx ].StringMap ,
289- )).SetNamePrefix (sv .Name )
300+ )).SetNamePrefix (volinfo .Name ).SetNameSuffix (svname )
301+
302+ // Set name for future use while adding brick entries
303+ svname = volinfo .Name + "-" + svname
290304 }
291305 }
292306 }
@@ -321,7 +335,8 @@ func volumegraph(tmpl *Template, volinfo volume.Volinfo, entry *Entry, varStrDat
321335 map [string ]string {"remote-port" : remotePort },
322336 )
323337 }
324- bentry = bentry .Add (bxl , bopts ).SetNamePrefix (sv .Name + "-" + strconv .Itoa (bidx ))
338+ bentry = bentry .Add (bxl , bopts ).SetNamePrefix (svname ).
339+ SetNameSuffix (bxl .suffix () + "-" + strconv .Itoa (bidx ))
325340 }
326341 }
327342 }
0 commit comments