Initial Commit
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..6c68977
--- /dev/null
+++ b/main.go
@@ -0,0 +1,73 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+
+ "github.com/golang/glog"
+ "github.com/ybbus/jsonrpc"
+)
+
+var (
+ flagAristaAPI string
+ flagListenAddress string
+ flagDebugAddress string
+ flagCAPath string
+ flagCertificatePath string
+ flagKeyPath string
+ flagPKIRealm string
+)
+
+type aristaClient struct {
+ rpc jsonrpc.RPCClient
+}
+
+func (c *aristaClient) structuredCall(res interface{}, command ...string) error {
+ cmd := struct {
+ Version int `json:"version"`
+ Cmds []string `json:"cmds"`
+ Format string `json:"format"`
+ }{
+ Version: 1,
+ Cmds: command,
+ Format: "json",
+ }
+
+ err := c.rpc.CallFor(res, "runCmds", cmd)
+ if err != nil {
+ return fmt.Errorf("could not execute structured call: %v", err)
+ }
+ return nil
+}
+
+func main() {
+ flag.StringVar(&flagAristaAPI, "arista_api", "http://admin:password@1.2.3.4:80/command-api", "Arista remote endpoint")
+ flag.StringVar(&flagListenAddress, "listen_address", "127.0.0.1:8080", "gRPC listen address")
+ flag.StringVar(&flagDebugAddress, "debug_address", "127.0.0.1:8081", "Debug HTTP listen address, or empty to disable")
+ flag.StringVar(&flagCAPath, "tls_ca_path", "pki/ca.pem", "Path to PKI CA certificate")
+ flag.StringVar(&flagCertificatePath, "tls_certificate_path", "pki/service.pem", "Path to PKI service certificate")
+ flag.StringVar(&flagKeyPath, "tls_key_path", "pki/service-key.pem", "Path to PKI service private key")
+ flag.StringVar(&flagPKIRealm, "pki_realm", "svc.cluster.local", "PKI realm")
+ flag.Set("logtostderr", "true")
+ flag.Parse()
+
+ arista := &aristaClient{
+ rpc: jsonrpc.NewClient(flagAristaAPI),
+ }
+
+ opts := &serverOpts{
+ listenAddress: flagListenAddress,
+ debugAddress: flagDebugAddress,
+ tlsCAPath: flagCAPath,
+ tlsCertificatePath: flagCertificatePath,
+ tlsKeyPath: flagKeyPath,
+ pkiRealm: flagPKIRealm,
+ }
+ server, err := newServer(opts, arista)
+ if err != nil {
+ glog.Errorf("Could not create server: %v", err)
+ }
+
+ glog.Info("Starting up...")
+ server.serveForever()
+}