Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic /cmd entrypoint w/ cli support #5380

Closed
wants to merge 2 commits into from

Conversation

alexlarsson
Copy link
Contributor

If you do

   docker devmapper:resize -o Key=Value -o Foo=Bar plugin:op arg1 arg2

This will do a GET http request to /cmd/devmapper/resize with the arguments and options as keys. This will then try to spawn a job on the engine called "devmapper:resize" with the arg1, arg2, etc as arguments and the -o options as environment.

Also, any graph driver implementing the engine.Installer interface will get installed on the engine when the daemon is created.

This will be used by e.g. the devicemapper to allow driver-specific operations like pool resizing.

This PR is a break out from #4202, see comment there for the design input for this PR.

@alexlarsson
Copy link
Contributor Author

To test this i added:

diff --git a/daemon/graphdriver/devmapper/driver.go b/daemon/graphdriver/d
index e958ef3..430b07f 100644
--- a/daemon/graphdriver/devmapper/driver.go
+++ b/daemon/graphdriver/devmapper/driver.go
@@ -5,6 +5,7 @@ package devmapper
 import (
        "fmt"
        "github.com/dotcloud/docker/daemon/graphdriver"
+       "github.com/dotcloud/docker/engine"
        "github.com/dotcloud/docker/utils"
        "io/ioutil"
        "os"
@@ -140,3 +141,13 @@ func (d *Driver) mount(id, mountPoint string) error {
 func (d *Driver) Exists(id string) bool {
        return d.Devices[id] != nil
 }
+
+func (d *Driver) test(job *engine.Job) engine.Status {
+       fmt.Printf("****** TEST ******** %v\n", job.Env())
+       return engine.StatusOK
+}
+
+func (d *Driver) Install(eng *engine.Engine) error {
+       eng.Register("devmapper:test", d.test)
+       return nil
+}

And running docker devmapper:test -o foo=bar -o "key=value 2" test1 test2
Printed:

[d0d056e0] +job devmapper:test(test1, test2)
****** TEST ******** &[foo=bar key=value 2]
[d0d056e0] -job devmapper:test(test1, test2) = OK (0)

@shykes
Copy link
Contributor

shykes commented May 3, 2014

#assignee=shykes

@alexlarsson
Copy link
Contributor Author

@shykes ping?

@shykes
Copy link
Contributor

shykes commented May 6, 2014

@alexlarsson sorry I got overrun. I would like to get this in for 0.11.

@vieux would you mind taking over? (you can steal the PR to confirm).

Thanks

@vieux
Copy link
Contributor

vieux commented May 6, 2014

#assignee=vieux

@alexlarsson
Copy link
Contributor Author

rebased to latest master

This allows registering handlers after you've started using the engine,
as well as setting hack envs.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
If you do
  docker devmapper:resize -o Key=Value -o Foo=Bar plugin:op arg1 arg2

This will do a GET http request to /cmd/devmapper/resize with the
arguments and options as keys. This will then try to spawn a job on
the engine called "devmapper:resize" with the arg1, arg2, etc as
arguments and the -o options as environment.

Also, any graph driver implementing the engine.Installer interface
will get installed on the engine when the daemon is created.

This will be used by e.g. the devicemapper to allow driver-specific
operations like pool resizing.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
@alexlarsson
Copy link
Contributor Author

Updated to latest master. Any chance someone could take a look now?

@alexlarsson
Copy link
Contributor Author

I'm closing this in favour of #4202, which contains the same commits. Its just too painful to keep rebasing both, and the dm ops allow you to test the core code.

@alexlarsson alexlarsson closed this Jun 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants