func getDefaultStore(rootPath, caCertPath, privateKeyPath string) (libmachine.Store, error) { return libmachine.NewFilestore( rootPath, caCertPath, privateKeyPath, ), nil }
func main() { flag.Parse() log.Printf("using store: %s\n", storePath) store := libmachine.NewFilestore(storePath, "", "") m, err := libmachine.New(store) if err != nil { log.Fatal(err) } mcn = m wsContainer := restful.NewContainer() h := HostResource{} h.Register(wsContainer) config := swagger.Config{ WebServices: wsContainer.RegisteredWebServices(), WebServicesUrl: "http://localhost:8080", ApiPath: "/apidocs.json", SwaggerPath: "/apidocs/", SwaggerFilePath: "swagger"} swagger.RegisterSwaggerService(config, wsContainer) log.Printf("start listening on localhost:8080") server := &http.Server{Addr: ":8080", Handler: wsContainer} log.Fatal(server.ListenAndServe()) }
func NewCluster(gopt *options.Options) (*Cluster, error) { rootPath := gopt.String("storage-path") os.Setenv("MACHINE_STORAGE_PATH", rootPath) if gopt.Bool("native-ssh") { ssh.SetDefaultClient(ssh.Native) } auth := getTLSAuthOptions(gopt) store := libmachine.NewFilestore(rootPath, auth.CaCertPath, auth.CaKeyPath) provider, _ := libmachine.New(store) hosts, err := provider.List() if err != nil { return nil, err } machines := make(map[string]*Machine, len(hosts)) for _, h := range hosts { machines[h.Name] = &Machine{ Host: h, } } c := &Cluster{ provider: provider, machines: machines, authOptions: auth, } c.LoadStates() return c, nil }
func getTestStore() (libmachine.Store, error) { tmpDir, err := ioutil.TempDir("", "machine-test-") if err != nil { fmt.Println(err) os.Exit(1) } hostTestStorePath = tmpDir os.Setenv("MACHINE_STORAGE_PATH", tmpDir) return libmachine.NewFilestore(tmpDir, hostTestCaCert, hostTestPrivateKey), nil }