update provisioner to support consul based storage
Change-Id: Iaa649396d23bbf28a4d99a188c9846aea1310cd0
diff --git a/provisioner/provisioner.go b/provisioner/provisioner.go
index 362c06d..559e23c 100644
--- a/provisioner/provisioner.go
+++ b/provisioner/provisioner.go
@@ -14,6 +14,7 @@
RoleSelectorURL string `default:"" envconfig:"role_selector_url"`
DefaultRole string `default:"compute-node" envconfig:"default_role"`
Script string `default:"do-ansible"`
+ StorageURL string `default:"memory:" envconfig:"storage_url"`
}
type Context struct {
@@ -36,11 +37,16 @@
Port: %d
RoleSelectorURL: %s
DefaultRole: %s
- Script: %s`,
+ Script: %s
+ StorageURL: %s`,
context.config.Listen, context.config.Port, context.config.RoleSelectorURL,
- context.config.DefaultRole, context.config.Script)
+ context.config.DefaultRole, context.config.Script, context.config.StorageURL)
- context.storage = NewMemoryStorage()
+ context.storage, err = NewStorage(context.config.StorageURL)
+ if err != nil {
+ log.Fatalf("[error] Unable to connect to specified storage '%s' : %s",
+ context.config.StorageURL, err)
+ }
router := mux.NewRouter()
router.HandleFunc("/provision/", context.ProvisionRequestHandler).Methods("POST")