-
Notifications
You must be signed in to change notification settings - Fork 937
/
Copy pathcluster_group.go
786 lines (615 loc) · 19.1 KB
/
cluster_group.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
package main
import (
"errors"
"fmt"
"io"
"os"
"sort"
"strings"
"github.com/spf13/cobra"
yaml "gopkg.in/yaml.v2"
"github.com/canonical/lxd/shared"
"github.com/canonical/lxd/shared/api"
cli "github.com/canonical/lxd/shared/cmd"
"github.com/canonical/lxd/shared/i18n"
"github.com/canonical/lxd/shared/termios"
)
type cmdClusterGroup struct {
global *cmdGlobal
cluster *cmdCluster
}
// Cluster management including assignment, creation, deletion, editing, listing, removal, renaming, and showing details.
func (c *cmdClusterGroup) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("group")
cmd.Short = i18n.G("Manage cluster groups")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`Manage cluster groups`))
// Assign
clusterGroupAssignCmd := cmdClusterGroupAssign{global: c.global, cluster: c.cluster}
cmd.AddCommand(clusterGroupAssignCmd.command())
// Create
clusterGroupCreateCmd := cmdClusterGroupCreate{global: c.global, cluster: c.cluster}
cmd.AddCommand(clusterGroupCreateCmd.command())
// Delete
clusterGroupDeleteCmd := cmdClusterGroupDelete{global: c.global, cluster: c.cluster}
cmd.AddCommand(clusterGroupDeleteCmd.command())
// Edit
clusterGroupEditCmd := cmdClusterGroupEdit{global: c.global, cluster: c.cluster}
cmd.AddCommand(clusterGroupEditCmd.command())
// List
clusterGroupListCmd := cmdClusterGroupList{global: c.global, cluster: c.cluster}
cmd.AddCommand(clusterGroupListCmd.command())
// Remove
clusterGroupRemoveCmd := cmdClusterGroupRemove{global: c.global, cluster: c.cluster}
cmd.AddCommand(clusterGroupRemoveCmd.command())
// Rename
clusterGroupRenameCmd := cmdClusterGroupRename{global: c.global, cluster: c.cluster}
cmd.AddCommand(clusterGroupRenameCmd.command())
// Show
clusterGroupShowCmd := cmdClusterGroupShow{global: c.global, cluster: c.cluster}
cmd.AddCommand(clusterGroupShowCmd.command())
// Add
clusterGroupAddCmd := cmdClusterGroupAdd{global: c.global, cluster: c.cluster}
cmd.AddCommand(clusterGroupAddCmd.command())
return cmd
}
// Assign.
type cmdClusterGroupAssign struct {
global *cmdGlobal
cluster *cmdCluster
}
// Setting a groups to cluster members, setting usage, description, examples, and the RunE method.
func (c *cmdClusterGroupAssign) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("assign", i18n.G("[<remote>:]<member> <group>"))
cmd.Aliases = []string{"apply"}
cmd.Short = i18n.G("Assign sets of groups to cluster members")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`Assign sets of groups to cluster members`))
cmd.Example = cli.FormatSection("", i18n.G(
`lxc cluster group assign foo default,bar
Set the groups for "foo" to "default" and "bar".
lxc cluster group assign foo default
Reset "foo" to only using the "default" cluster group.`))
cmd.RunE = c.run
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return c.global.cmpClusterMembers(toComplete)
}
if len(args) == 1 {
return c.global.cmpClusterGroupNames(args[0])
}
return nil, cobra.ShellCompDirectiveNoFileComp
}
return cmd
}
// Groups assigning to a cluster member, performing checks, parsing arguments, and updating the member's group configuration.
func (c *cmdClusterGroupAssign) run(cmd *cobra.Command, args []string) error {
// Quick checks.
exit, err := c.global.CheckArgs(cmd, args, 2, 2)
if exit {
return err
}
// Parse remote
resources, err := c.global.ParseServers(args[0])
if err != nil {
return err
}
resource := resources[0]
// Assign the cluster group
if resource.name == "" {
return errors.New(i18n.G("Missing cluster member name"))
}
member, etag, err := resource.server.GetClusterMember(resource.name)
if err != nil {
return err
}
if args[1] != "" {
member.Groups = strings.Split(args[1], ",")
} else {
member.Groups = nil
}
err = resource.server.UpdateClusterMember(resource.name, member.Writable(), etag)
if err != nil {
return err
}
if args[1] == "" {
args[1] = i18n.G("(none)")
}
if !c.global.flagQuiet {
fmt.Printf(i18n.G("Cluster member %s added to cluster groups %s")+"\n", resource.name, args[1])
}
return nil
}
// Create.
type cmdClusterGroupCreate struct {
global *cmdGlobal
cluster *cmdCluster
}
// Creation of a new cluster group, defining its usage, short and long descriptions, and the RunE method.
func (c *cmdClusterGroupCreate) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("create", i18n.G("[<remote>:]<group>"))
cmd.Short = i18n.G("Create a cluster group")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`Create a cluster group`))
cmd.Example = cli.FormatSection("", i18n.G(`lxc cluster group create g1
lxc cluster group create g1 < config.yaml
Create a cluster group with configuration from config.yaml`))
cmd.RunE = c.run
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return c.global.cmpRemotes(toComplete, false)
}
return nil, cobra.ShellCompDirectiveNoFileComp
}
return cmd
}
// It creates new cluster group after performing checks, parsing arguments, and making the server call for creation.
func (c *cmdClusterGroupCreate) run(cmd *cobra.Command, args []string) error {
var stdinData api.ClusterGroupPut
// Quick checks.
exit, err := c.global.CheckArgs(cmd, args, 1, 1)
if exit {
return err
}
// If stdin isn't a terminal, read text from it
if !termios.IsTerminal(getStdinFd()) {
contents, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}
err = yaml.Unmarshal(contents, &stdinData)
if err != nil {
return err
}
}
// Parse remote
resources, err := c.global.ParseServers(args[0])
if err != nil {
return err
}
resource := resources[0]
if resource.name == "" {
return errors.New(i18n.G("Missing cluster group name"))
}
// Create the cluster group
group := api.ClusterGroupsPost{
Name: resource.name,
ClusterGroupPut: stdinData,
}
err = resource.server.CreateClusterGroup(group)
if err != nil {
return err
}
if !c.global.flagQuiet {
fmt.Printf(i18n.G("Cluster group %s created")+"\n", resource.name)
}
return nil
}
// Delete.
type cmdClusterGroupDelete struct {
global *cmdGlobal
cluster *cmdCluster
}
// It deletes a cluster group, setting up usage, descriptions, aliases, and the RunE method.
func (c *cmdClusterGroupDelete) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("delete", i18n.G("[<remote>:]<group>"))
cmd.Aliases = []string{"rm"}
cmd.Short = i18n.G("Delete a cluster group")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`Delete a cluster group`))
cmd.RunE = c.run
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return c.global.cmpClusterGroups(toComplete)
}
return nil, cobra.ShellCompDirectiveNoFileComp
}
return cmd
}
// It's the deletion of a cluster group after argument checks, parsing, and making the server call for deletion.
func (c *cmdClusterGroupDelete) run(cmd *cobra.Command, args []string) error {
// Quick checks.
exit, err := c.global.CheckArgs(cmd, args, 1, 1)
if exit {
return err
}
// Parse remote
resources, err := c.global.ParseServers(args[0])
if err != nil {
return err
}
resource := resources[0]
if resource.name == "" {
return errors.New(i18n.G("Missing cluster group name"))
}
// Delete the cluster group
err = resource.server.DeleteClusterGroup(resource.name)
if err != nil {
return err
}
if !c.global.flagQuiet {
fmt.Printf(i18n.G("Cluster group %s deleted")+"\n", resource.name)
}
return nil
}
// Edit.
type cmdClusterGroupEdit struct {
global *cmdGlobal
cluster *cmdCluster
}
// This Command generates the cobra command that enables the editing of a cluster group's attributes.
func (c *cmdClusterGroupEdit) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("edit", i18n.G("[<remote>:]<group>"))
cmd.Short = i18n.G("Edit a cluster group")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`Edit a cluster group`))
cmd.RunE = c.run
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return c.global.cmpClusterGroups(toComplete)
}
return nil, cobra.ShellCompDirectiveNoFileComp
}
return cmd
}
// The modification of a cluster group's configuration, either through an editor or via the terminal.
func (c *cmdClusterGroupEdit) run(cmd *cobra.Command, args []string) error {
// Quick checks.
exit, err := c.global.CheckArgs(cmd, args, 1, 1)
if exit {
return err
}
// Parse remote
resources, err := c.global.ParseServers(args[0])
if err != nil {
return err
}
resource := resources[0]
if resource.name == "" {
return errors.New(i18n.G("Missing cluster group name"))
}
// If stdin isn't a terminal, read text from it
if !termios.IsTerminal(getStdinFd()) {
contents, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}
newdata := api.ClusterGroupPut{}
err = yaml.Unmarshal(contents, &newdata)
if err != nil {
return err
}
return resource.server.UpdateClusterGroup(resource.name, newdata, "")
}
// Extract the current value
group, etag, err := resource.server.GetClusterGroup(resource.name)
if err != nil {
return err
}
data, err := yaml.Marshal(group)
if err != nil {
return err
}
// Spawn the editor
content, err := shared.TextEditor("", []byte(c.helpTemplate()+"\n\n"+string(data)))
if err != nil {
return err
}
for {
// Parse the text received from the editor
newdata := api.ClusterGroupPut{}
err = yaml.Unmarshal(content, &newdata)
if err == nil {
err = resource.server.UpdateClusterGroup(resource.name, newdata, etag)
}
// Respawn the editor
if err != nil {
fmt.Fprintf(os.Stderr, i18n.G("Config parsing error: %s")+"\n", err)
fmt.Println(i18n.G("Press enter to open the editor again or ctrl+c to abort change"))
_, err := os.Stdin.Read(make([]byte, 1))
if err != nil {
return err
}
content, err = shared.TextEditor("", content)
if err != nil {
return err
}
continue
}
break
}
return nil
}
// Returns a string explaining the expected YAML structure for a cluster group configuration.
func (c *cmdClusterGroupEdit) helpTemplate() string {
return i18n.G(
`### This is a YAML representation of the cluster group.
### Any line starting with a '# will be ignored.`)
}
// List.
type cmdClusterGroupList struct {
global *cmdGlobal
cluster *cmdCluster
flagFormat string
}
// Command returns a cobra command to list all the cluster groups in a specified format.
func (c *cmdClusterGroupList) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("list", i18n.G("[<remote>:]"))
cmd.Aliases = []string{"ls"}
cmd.Short = i18n.G("List all the cluster groups")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`List all the cluster groups`))
cmd.Flags().StringVarP(&c.flagFormat, "format", "f", "table", i18n.G("Format (csv|json|table|yaml|compact)")+"``")
cmd.RunE = c.run
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return c.global.cmpRemotes(toComplete, false)
}
return nil, cobra.ShellCompDirectiveNoFileComp
}
return cmd
}
// Run executes the command to list all the cluster groups, their descriptions, and number of members.
func (c *cmdClusterGroupList) run(cmd *cobra.Command, args []string) error {
// Quick checks.
exit, err := c.global.CheckArgs(cmd, args, 0, 1)
if exit {
return err
}
// Parse remote
remote := ""
if len(args) == 1 {
remote = args[0]
}
resources, err := c.global.ParseServers(remote)
if err != nil {
return err
}
resource := resources[0]
// Check if clustered
cluster, _, err := resource.server.GetCluster()
if err != nil {
return err
}
if !cluster.Enabled {
return errors.New(i18n.G("LXD server isn't part of a cluster"))
}
groups, err := resource.server.GetClusterGroups()
if err != nil {
return err
}
// Render the table
data := [][]string{}
for _, group := range groups {
line := []string{group.Name, group.Description, fmt.Sprint(len(group.Members))}
data = append(data, line)
}
sort.Sort(cli.SortColumnsNaturally(data))
header := []string{
i18n.G("NAME"),
i18n.G("DESCRIPTION"),
i18n.G("MEMBERS"),
}
return cli.RenderTable(c.flagFormat, header, data, groups)
}
// Remove.
type cmdClusterGroupRemove struct {
global *cmdGlobal
cluster *cmdCluster
}
// Removal of a specified member from a specific cluster group.
func (c *cmdClusterGroupRemove) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("remove", i18n.G("[<remote>:]<member> <group>"))
cmd.Short = i18n.G("Remove member from group")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`Remove a cluster member from a cluster group`))
cmd.RunE = c.run
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return c.global.cmpClusterMembers(toComplete)
}
if len(args) == 1 {
return c.global.cmpClusterGroupNames(args[0])
}
return nil, cobra.ShellCompDirectiveNoFileComp
}
return cmd
}
// The removal process of a cluster member from a specific cluster group, with verbose output unless the 'quiet' flag is set.
func (c *cmdClusterGroupRemove) run(cmd *cobra.Command, args []string) error {
// Quick checks.
exit, err := c.global.CheckArgs(cmd, args, 2, 2)
if exit {
return err
}
// Parse remote
resources, err := c.global.ParseServers(args[0])
if err != nil {
return err
}
resource := resources[0]
if resource.name == "" {
return errors.New(i18n.G("Missing cluster member name"))
}
// Remove the cluster group
member, etag, err := resource.server.GetClusterMember(resource.name)
if err != nil {
return err
}
if !shared.ValueInSlice(args[1], member.Groups) {
return fmt.Errorf(i18n.G("Cluster group %s isn't currently applied to %s"), args[1], resource.name)
}
groups := []string{}
for _, group := range member.Groups {
if group == args[1] {
continue
}
groups = append(groups, group)
}
member.Groups = groups
err = resource.server.UpdateClusterMember(resource.name, member.Writable(), etag)
if err != nil {
return err
}
if !c.global.flagQuiet {
fmt.Printf(i18n.G("Cluster member %s removed from group %s")+"\n", resource.name, args[1])
}
return nil
}
// Rename.
type cmdClusterGroupRename struct {
global *cmdGlobal
cluster *cmdCluster
}
// Renaming a cluster group, defining usage, aliases, and linking the associated runtime function.
func (c *cmdClusterGroupRename) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("rename", i18n.G("[<remote>:]<group> <new-name>"))
cmd.Aliases = []string{"mv"}
cmd.Short = i18n.G("Rename a cluster group")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`Rename a cluster group`))
cmd.RunE = c.run
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return c.global.cmpClusterGroups(toComplete)
}
return nil, cobra.ShellCompDirectiveNoFileComp
}
return cmd
}
// Renaming operation of a cluster group after checking arguments and parsing the remote server, and provides appropriate output.
func (c *cmdClusterGroupRename) run(cmd *cobra.Command, args []string) error {
// Quick checks.
exit, err := c.global.CheckArgs(cmd, args, 2, 2)
if exit {
return err
}
// Parse remote
resources, err := c.global.ParseServers(args[0])
if err != nil {
return err
}
resource := resources[0]
// Perform the rename
err = resource.server.RenameClusterGroup(resource.name, api.ClusterGroupPost{Name: args[1]})
if err != nil {
return err
}
if !c.global.flagQuiet {
fmt.Printf(i18n.G("Cluster group %s renamed to %s")+"\n", resource.name, args[1])
}
return nil
}
// Show.
type cmdClusterGroupShow struct {
global *cmdGlobal
cluster *cmdCluster
}
// Setting up the 'show' command to display the configurations of a specified cluster group in a remote server.
func (c *cmdClusterGroupShow) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("show", i18n.G("[<remote>:]<group>"))
cmd.Short = i18n.G("Show cluster group configurations")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`Show cluster group configurations`))
cmd.RunE = c.run
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return c.global.cmpClusterGroups(toComplete)
}
return nil, cobra.ShellCompDirectiveNoFileComp
}
return cmd
}
// This retrieves and prints the configuration details of a specified cluster group from a remote server in YAML format.
func (c *cmdClusterGroupShow) run(cmd *cobra.Command, args []string) error {
// Quick checks.
exit, err := c.global.CheckArgs(cmd, args, 1, 1)
if exit {
return err
}
// Parse remote
resources, err := c.global.ParseServers(args[0])
if err != nil {
return err
}
resource := resources[0]
if resource.name == "" {
return errors.New(i18n.G("Missing cluster group name"))
}
// Show the cluster group
group, _, err := resource.server.GetClusterGroup(resource.name)
if err != nil {
return err
}
data, err := yaml.Marshal(&group)
if err != nil {
return err
}
fmt.Printf("%s", data)
return nil
}
// Add.
type cmdClusterGroupAdd struct {
global *cmdGlobal
cluster *cmdCluster
}
func (c *cmdClusterGroupAdd) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("add", i18n.G("[<remote>:]<member> <group>"))
cmd.Short = i18n.G("Add member to group")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`Add a cluster member to a cluster group`))
cmd.RunE = c.run
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return c.global.cmpClusterMembers(toComplete)
}
if len(args) == 1 {
return c.global.cmpClusterGroupNames(args[0])
}
return nil, cobra.ShellCompDirectiveNoFileComp
}
return cmd
}
func (c *cmdClusterGroupAdd) run(cmd *cobra.Command, args []string) error {
// Quick checks.
exit, err := c.global.CheckArgs(cmd, args, 2, 2)
if exit {
return err
}
// Parse remote
resources, err := c.global.ParseServers(args[0])
if err != nil {
return err
}
resource := resources[0]
if resource.name == "" {
return errors.New(i18n.G("Missing cluster member name"))
}
// Retrieve cluster member information.
member, etag, err := resource.server.GetClusterMember(resource.name)
if err != nil {
return err
}
if shared.ValueInSlice(args[1], member.Groups) {
return fmt.Errorf(i18n.G("Cluster member %s is already in group %s"), resource.name, args[1])
}
member.Groups = append(member.Groups, args[1])
err = resource.server.UpdateClusterMember(resource.name, member.Writable(), etag)
if err != nil {
return err
}
if !c.global.flagQuiet {
fmt.Printf(i18n.G("Cluster member %s added to group %s")+"\n", resource.name, args[1])
}
return nil
}