예제 #1
0
func newUnmountHandler(logger lager.Logger, client volman.Manager) http.HandlerFunc {
	return func(w http.ResponseWriter, req *http.Request) {
		logger := logger.Session("unmount")
		logger.Info("start")
		defer logger.Info("end")

		body, err := ioutil.ReadAll(req.Body)
		if err != nil {
			respondWithError(logger, "Error reading unmount request body", err, w)
			return
		}

		var unmountRequest volman.UnmountRequest
		if err = json.Unmarshal(body, &unmountRequest); err != nil {
			respondWithError(logger, fmt.Sprintf("Error reading unmount request body: %#v", body), err, w)
			return
		}

		err = client.Unmount(logger, unmountRequest.DriverId, unmountRequest.VolumeId)
		if err != nil {
			respondWithError(logger, fmt.Sprintf("Error unmounting volume %s with driver %s", unmountRequest.VolumeId, unmountRequest.DriverId), err, w)
			return
		}

		cf_http_handlers.WriteJSONResponse(w, http.StatusOK, struct{}{})
	}
}
예제 #2
0
func newListDriversHandler(logger lager.Logger, client volman.Manager) http.HandlerFunc {
	return func(w http.ResponseWriter, req *http.Request) {
		logger := logger.Session("drivers")
		logger.Info("start")
		defer logger.Info("end")

		drivers, _ := client.ListDrivers(logger) // <- fix this!
		cf_http_handlers.WriteJSONResponse(w, http.StatusOK, drivers)
	}
}
예제 #3
0
	"code.cloudfoundry.org/volman/volhttp"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/ginkgomon"

	"encoding/json"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Volman main", func() {
	var (
		args                   []string
		listenAddr, driverAddr string
		driversPath            string
		process                ifrit.Process
		client                 volman.Manager
		testLogger             lager.Logger
	)

	BeforeEach(func() {
		driversPath = fmt.Sprintf("/tmp/testdrivers/%d/", GinkgoParallelNode())
		err := os.MkdirAll(driversPath, os.ModePerm)
		Expect(err).NotTo(HaveOccurred())

		listenAddr = fmt.Sprintf("0.0.0.0:%d", 8889+GinkgoParallelNode())
		driverAddr = fakeDriver.URL()
		client = volhttp.NewRemoteClient("http://" + listenAddr)
		Expect(err).NotTo(HaveOccurred())

		testLogger = lagertest.NewTestLogger("test")