summaryrefslogtreecommitdiff
path: root/src/rhctl/switch_control.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/rhctl/switch_control.go')
-rw-r--r--src/rhctl/switch_control.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go
index df3dce9..ca27b86 100644
--- a/src/rhctl/switch_control.go
+++ b/src/rhctl/switch_control.go
@@ -22,6 +22,8 @@
package main
import (
+ "fmt"
+
"github.com/btittelbach/pubsub"
)
@@ -46,8 +48,9 @@ func (c CommandType) String() string {
}
type Command struct {
- Type CommandType
- args []string
+ Type CommandType
+ Args []string
+ Response chan<- interface{}
}
type SwitchControl struct {
@@ -58,9 +61,19 @@ type SwitchControl struct {
}
func (ctrl *SwitchControl) handleCommand(cmd *Command) {
- rhdl.Printf("Telnet: got command: %+v", cmd)
switch cmd.Type {
case CmdStatus:
+ if len(cmd.Args) == 0 {
+ rhl.Printf("SwitchCTRL: ignoring empty raw switch command")
+ return
+ }
+ c, err := NewSwitchCommandFromStrings(cmd.Args[0], cmd.Args[1:]...)
+ if err != nil {
+ cmd.Response <- fmt.Errorf("switch command syntax error: %s", err.Error())
+ return
+ }
+ c.Response = cmd.Response
+ ctrl.sw.Commands <- c
case CmdServer:
case CmdSwitch:
}