(d map[string]interface{})
| 469 | } |
| 470 | |
| 471 | func (t *cmdDashboard) handleGroupCommand(d map[string]interface{}) { |
| 472 | c := t.newTopomClient() |
| 473 | |
| 474 | switch { |
| 475 | |
| 476 | case d["--create-group"].(bool): |
| 477 | |
| 478 | gid := utils.ArgumentIntegerMust(d, "--gid") |
| 479 | |
| 480 | log.Debugf("call rpc create-group to dashboard %s", t.addr) |
| 481 | if err := c.CreateGroup(gid); err != nil { |
| 482 | log.PanicErrorf(err, "call rpc create-group to dashboard %s failed", t.addr) |
| 483 | } |
| 484 | log.Debugf("call rpc create-group OK") |
| 485 | |
| 486 | case d["--remove-group"].(bool): |
| 487 | |
| 488 | gid := utils.ArgumentIntegerMust(d, "--gid") |
| 489 | |
| 490 | log.Debugf("call rpc remove-group to dashboard %s", t.addr) |
| 491 | if err := c.RemoveGroup(gid); err != nil { |
| 492 | log.PanicErrorf(err, "call rpc remove-group to dashboard %s failed", t.addr) |
| 493 | } |
| 494 | log.Debugf("call rpc remove-group OK") |
| 495 | |
| 496 | case d["--resync-group"].(bool): |
| 497 | |
| 498 | switch { |
| 499 | |
| 500 | case d["--all"].(bool): |
| 501 | |
| 502 | stats, err := c.Stats() |
| 503 | if err != nil { |
| 504 | log.PanicErrorf(err, "call rpc stats to dashboard %s failed", t.addr) |
| 505 | } |
| 506 | log.Debugf("call rpc stats OK") |
| 507 | |
| 508 | for _, g := range stats.Group.Models { |
| 509 | log.Debugf("call rpc resync-group [%d] to dashboard %s", g.Id, t.addr) |
| 510 | if err := c.ResyncGroup(g.Id); err != nil { |
| 511 | log.PanicErrorf(err, "call rpc resync-group to dashboard %s failed", t.addr) |
| 512 | } |
| 513 | } |
| 514 | log.Debugf("call rpc resync-group OK") |
| 515 | |
| 516 | default: |
| 517 | |
| 518 | gid := utils.ArgumentIntegerMust(d, "--gid") |
| 519 | |
| 520 | log.Debugf("call rpc resync-group to dashboard %s", t.addr) |
| 521 | if err := c.ResyncGroup(gid); err != nil { |
| 522 | log.PanicErrorf(err, "call rpc resync-group to dashboard %s failed", t.addr) |
| 523 | } |
| 524 | log.Debugf("call rpc resync-group OK") |
| 525 | |
| 526 | } |
| 527 | |
| 528 | case d["--group-add"].(bool): |
no test coverage detected