@@ -21,6 +21,9 @@ type Entry struct {
21
21
// NamePrefix will be used to set prefix for xlator section
22
22
// name if Name is not set.
23
23
NamePrefix string
24
+ // NameSuffix will be used to set suffix for xlator section
25
+ // name if Name is not set.
26
+ NameSuffix string
24
27
// XlatorData represents the Xlator object with all the
25
28
// necessory information.
26
29
XlatorData Xlator
@@ -57,6 +60,12 @@ func (e *Entry) SetNamePrefix(name string) *Entry {
57
60
return e
58
61
}
59
62
63
+ // SetNameSuffix sets name prefix
64
+ func (e * Entry ) SetNameSuffix (name string ) * Entry {
65
+ e .NameSuffix = name
66
+ return e
67
+ }
68
+
60
69
// Generate generates Volfile content
61
70
func (v * Volfile ) Generate () (string , error ) {
62
71
return v .RootEntry .Generate ()
@@ -80,18 +89,18 @@ func setNameAndType(entry *Entry) error {
80
89
if entry .Name == "" {
81
90
// If Xlator name template is not specified, construct the xlator
82
91
// graph name as <volume-name>-<xlator-suffix>
83
- prefix := entry .NamePrefix
84
- if prefix != "" {
85
- prefix = prefix + "-"
86
- }
92
+ entry .Name = entry .NamePrefix
87
93
88
94
if entry .NamePrefix == "" {
89
95
volname , exists := entry .VarStrData ["volume.name" ]
90
96
if exists {
91
- prefix = volname + "-"
97
+ entry . Name = volname + "-" + entry . XlatorData . suffix ()
92
98
}
93
99
}
94
- entry .Name = prefix + entry .XlatorData .suffix ()
100
+
101
+ if entry .NameSuffix != "" {
102
+ entry .Name = entry .Name + "-" + entry .NameSuffix
103
+ }
95
104
}
96
105
return nil
97
106
}
@@ -279,14 +288,19 @@ func volumegraph(tmpl *Template, volinfo volume.Volinfo, entry *Entry, varStrDat
279
288
// cluster/distribute graph again. Directly assign
280
289
// brick entries to main cluster/distribute itself
281
290
sentry := entry
291
+ svname := ""
282
292
if sv .Type != volume .SubvolDistribute || (sv .Type == volume .SubvolDistribute && numSubvols > 1 ) {
283
293
for _ , sxl := range subvolXlators {
284
294
if ! sxl .OnlyLocalBricks || (sxl .OnlyLocalBricks && numberOfLocalBricks > 0 ) {
295
+ svname = sxl .suffix () + "-" + strconv .Itoa (sidx )
285
296
sentry = sentry .Add (sxl , utils .MergeStringMaps (
286
297
* varStrData ,
287
298
sv .StringMap (),
288
299
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
290
304
}
291
305
}
292
306
}
@@ -321,7 +335,8 @@ func volumegraph(tmpl *Template, volinfo volume.Volinfo, entry *Entry, varStrDat
321
335
map [string ]string {"remote-port" : remotePort },
322
336
)
323
337
}
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 ))
325
340
}
326
341
}
327
342
}
0 commit comments