Esempio n. 1
0
func main() {
	flag.Parse()

	ctx := ipc.NewTrustedContext(seesaw.SCLocalCLI)

	var err error
	seesawConn, err = conn.NewSeesawIPC(ctx)
	if err != nil {
		fatalf("Failed to connect to engine: %v", err)
	}
	if err := seesawConn.Dial(*engineSocket); err != nil {
		fatalf("Failed to connect to engine: %v", err)
	}
	defer seesawConn.Close()
	seesawCLI = cli.NewSeesawCLI(seesawConn, exit)

	if *command == "" {
		interactive()
		exit()
	}

	if err := seesawCLI.Execute(*command); err != nil {
		fatalf("%v", err)
	}
}
Esempio n. 2
0
// authConnect attempts to authenticate the user using the given context. If
// authentication succeeds an authenticated IPC connection to the Seesaw
// Engine is returned.
func (e *ECU) authConnect(ctx *ipc.Context) (*conn.Seesaw, error) {
	if ctx == nil {
		return nil, errors.New("context is nil")
	}
	authCtx, err := e.authenticate(ctx)
	if err != nil {
		return nil, fmt.Errorf("authentication failed: %v", err)
	}

	seesawConn, err := conn.NewSeesawIPC(authCtx)
	if err != nil {
		return nil, fmt.Errorf("failed to connect to engine: %v", err)
	}
	if err := seesawConn.Dial(e.cfg.EngineSocket); err != nil {
		return nil, fmt.Errorf("failed to connect to engine: %v", err)
	}

	return seesawConn, nil
}
Esempio n. 3
0
// update attempts to update the cached statistics from the Seesaw Engine.
func (e *ecuStats) update() error {
	// TODO(jsing): Make this untrusted.
	ctx := ipc.NewTrustedContext(seesaw.SCECU)
	seesawConn, err := conn.NewSeesawIPC(ctx)
	if err != nil {
		return fmt.Errorf("Failed to connect to engine: %v", err)
	}
	if err := seesawConn.Dial(e.ecu.cfg.EngineSocket); err != nil {
		return fmt.Errorf("Failed to connect to engine: %v", err)
	}
	defer seesawConn.Close()

	clusterStatus, err := seesawConn.ClusterStatus()
	if err != nil {
		return fmt.Errorf("Failed to get cluster status: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.ClusterStatus = *clusterStatus
	e.stats.lock.Unlock()

	configStatus, err := seesawConn.ConfigStatus()
	if err != nil {
		return fmt.Errorf("Failed to get config status: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.ConfigStatus = *configStatus
	e.stats.lock.Unlock()

	ha, err := seesawConn.HAStatus()
	if err != nil {
		return fmt.Errorf("Failed to get HA status: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.HAStatus = *ha
	e.stats.lock.Unlock()

	neighbors, err := seesawConn.BGPNeighbors()
	if err != nil {
		return fmt.Errorf("Failed to get BGP neighbors: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.neighbors = neighbors
	e.stats.lock.Unlock()

	vlans, err := seesawConn.VLANs()
	if err != nil {
		return fmt.Errorf("Failed to get VLANs: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.vlans = vlans.VLANs
	e.stats.lock.Unlock()

	vservers, err := seesawConn.Vservers()
	if err != nil {
		return fmt.Errorf("Failed to get vservers: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.vservers = vservers
	e.stats.lock.Unlock()

	return nil
}