Skip to content

Commit

Permalink
Merge pull request #310 from erikh/global-driver
Browse files Browse the repository at this point in the history
Global driver
  • Loading branch information
Erik Hollensbe authored Jun 15, 2016
2 parents 20a33b7 + 3943da4 commit 728f29f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,14 @@ build: golint govet
vagrant ssh mon0 -c 'sudo -i sh -c "cd $(GUESTGOPATH); make run-build"'
if [ ! -n "$$DEMO" ]; then for i in mon1 mon2; do vagrant ssh $$i -c 'sudo sh -c "pkill volplugin; pkill volmaster; pkill volsupervisor; mkdir -p /opt/golang/bin; cp /tmp/bin/* /opt/golang/bin"'; done; fi


docker: run-build
docker build -t contiv/volplugin .

docker-push: docker
docker push contiv/volplugin

run: build
set -e; for i in $$(seq 0 $$(($$(vagrant status | grep -v "not running" | grep -c running) - 2))); do vagrant ssh mon$$i -c 'cd $(GUESTGOPATH) && make run-volplugin run-volmaster'; done
set -e; for i in $$(seq 0 $$(($$(vagrant status | grep -cE 'mon.*running') - 1))); do vagrant ssh mon$$i -c 'cd $(GUESTGOPATH) && make run-volplugin run-volmaster'; done
vagrant ssh mon0 -c 'cd $(GUESTGOPATH) && make run-volsupervisor'
vagrant ssh mon0 -c 'volcli global upload < /testdata/globals/global1.json'

Expand Down
15 changes: 15 additions & 0 deletions volplugin/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,21 @@ func (dc *DaemonConfig) unmount(w http.ResponseWriter, r *http.Request) {
dc.returnMountPath(w, driver, driverOpts)
}

func (dc *DaemonConfig) capabilities(w http.ResponseWriter, r *http.Request) {
content, err := json.Marshal(map[string]map[string]string{
"Capabilities": map[string]string{
"Scope": "global",
},
})

if err != nil {
httpError(w, errors.UnmarshalRequest.Combine(err))
return
}

w.Write(content)
}

// Catchall for additional driver functions.
func (dc *DaemonConfig) action(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
Expand Down
19 changes: 10 additions & 9 deletions volplugin/volplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,16 @@ func (dc *DaemonConfig) Daemon() error {

func (dc *DaemonConfig) configureRouter() *mux.Router {
var routeMap = map[string]func(http.ResponseWriter, *http.Request){
"/Plugin.Activate": dc.activate,
"/Plugin.Deactivate": dc.nilAction,
"/VolumeDriver.Create": dc.create,
"/VolumeDriver.Remove": dc.getPath, // we never actually remove through docker's interface.
"/VolumeDriver.List": dc.list,
"/VolumeDriver.Get": dc.get,
"/VolumeDriver.Path": dc.getPath,
"/VolumeDriver.Mount": dc.mount,
"/VolumeDriver.Unmount": dc.unmount,
"/Plugin.Activate": dc.activate,
"/Plugin.Deactivate": dc.nilAction,
"/VolumeDriver.Create": dc.create,
"/VolumeDriver.Remove": dc.getPath, // we never actually remove through docker's interface.
"/VolumeDriver.List": dc.list,
"/VolumeDriver.Get": dc.get,
"/VolumeDriver.Path": dc.getPath,
"/VolumeDriver.Mount": dc.mount,
"/VolumeDriver.Unmount": dc.unmount,
"/VolumeDriver.Capabilities": dc.capabilities,
}

router := mux.NewRouter()
Expand Down

0 comments on commit 728f29f

Please sign in to comment.