diff --git a/cmd/docker/main.go b/cmd/docker/main.go index 98ee32b81c..a03e3a8f13 100644 --- a/cmd/docker/main.go +++ b/cmd/docker/main.go @@ -24,16 +24,23 @@ import ( log "github.com/Sirupsen/logrus" apiserver "github.com/docker/docker/api/server" + "github.com/docker/docker/api/server/router" "github.com/docker/docker/api/server/router/container" "github.com/docker/docker/api/server/router/image" "github.com/docker/docker/api/server/router/network" + "github.com/docker/docker/api/server/router/swarm" "github.com/docker/docker/api/server/router/system" "github.com/docker/docker/api/server/router/volume" - "github.com/docker/docker/docker/listeners" + "github.com/docker/docker/api/server/router/checkpoint" + "github.com/docker/docker/api/server/router/plugin" + "github.com/docker/docker/daemon/cluster" + "github.com/docker/docker/pkg/listeners" "github.com/docker/docker/pkg/signal" + "github.com/docker/docker/runconfig" "github.com/docker/go-connections/tlsconfig" vicbackends "github.com/vmware/vic/lib/apiservers/engine/backends" + "github.com/vmware/vic/lib/apiservers/engine/backends/executor" "github.com/vmware/vic/lib/config" "github.com/vmware/vic/lib/pprof" viclog "github.com/vmware/vic/pkg/log" @@ -169,7 +176,7 @@ func startServerWithOptions(cli *CliOptions) *apiserver.Server { MaxVersion: c.MaxVersion, CurvePreferences: c.CurvePreferences, } - }(&tlsconfig.ServerDefault) + }(tlsconfig.ServerDefault()) if !vchConfig.HostCertificate.IsNil() { log.Info("TLS enabled") @@ -230,16 +237,40 @@ func startServerWithOptions(cli *CliOptions) *apiserver.Server { } func setAPIRoutes(api *apiserver.Server) { - imageHandler := &vicbackends.Image{} - containerHandler := vicbackends.NewContainerBackend() - volumeHandler := &vicbackends.Volume{} - networkHandler := &vicbackends.Network{} - systemHandler := vicbackends.NewSystemBackend() - - api.InitRouter(false, - image.NewRouter(imageHandler), - container.NewRouter(containerHandler), - volume.NewRouter(volumeHandler), - network.NewRouter(networkHandler), - system.NewRouter(systemHandler)) + decoder := runconfig.ContainerDecoder{} + + swarmBackend := executor.SwarmBackend{} + + c, err := cluster.New(cluster.Config{ + Root: "", + Name: "", + Backend: swarmBackend, + NetworkSubnetsProvider: nil, + DefaultAdvertiseAddr: "", + RuntimeRoot: "", + }) + if err != nil { + log.Fatalf("Error creating cluster component: %v", err) + } + + routers := []router.Router{ + image.NewRouter(vicbackends.NewImageBackend(), decoder), + container.NewRouter(vicbackends.NewContainerBackend(), decoder), + volume.NewRouter(vicbackends.NewVolumeBackend()), + network.NewRouter(vicbackends.NewNetworkBackend(), c), + system.NewRouter(vicbackends.NewSystemBackend(), c), + swarm.NewRouter(vicbackends.NewSwarmBackend()), + checkpoint.NewRouter(vicbackends.NewCheckpointBackend(), decoder), + plugin.NewRouter(vicbackends.NewPluginBackend()), + } + + for _, r := range routers { + for _, route := range r.Routes() { + if experimental, ok := route.(router.ExperimentalRoute); ok { + experimental.Enable() + } + } + } + + api.InitRouter(false, routers...) } diff --git a/cmd/vicadmin/server.go b/cmd/vicadmin/server.go index 5130624d25..e4df465a25 100644 --- a/cmd/vicadmin/server.go +++ b/cmd/vicadmin/server.go @@ -31,7 +31,7 @@ import ( "context" log "github.com/Sirupsen/logrus" - "github.com/docker/docker/pkg/tlsconfig" + "github.com/docker/go-connections/tlsconfig" "github.com/google/uuid" gorillacontext "github.com/gorilla/context" @@ -133,7 +133,7 @@ func (s *server) listen() error { MaxVersion: c.MaxVersion, CurvePreferences: c.CurvePreferences, } - }(&tlsconfig.ServerDefault) + }(tlsconfig.ServerDefault()) tlsconfig.Certificates = []tls.Certificate{*certificate} diff --git a/demos/compose/voting-app/votingapp.dab b/demos/compose/voting-app/votingapp.dab new file mode 100644 index 0000000000..57065325dd --- /dev/null +++ b/demos/compose/voting-app/votingapp.dab @@ -0,0 +1,69 @@ +{ + "Services": { + "db": { + "Env": [ + "PGDATA=/var/lib/postgresql/data/data" + ], + "Image": "postgres@sha256:9db811348585075eddb7b6938fa65c0236fe8e4f7feaf3c2890a3c4b7f4c9bfc", + "Networks": [ + "default" + ] + }, + "redis": { + "Image": "redis@sha256:f1ed3708f538b537eb9c2a7dd50dc90a706f7debd7e1196c9264edeea521a86d", + "Networks": [ + "default" + ], + "Ports": [ + { + "Port": 6379, + "Protocol": "tcp" + } + ] + }, + "result": { + "Args": [ + "nodemon", + "--debug", + "server.js" + ], + "Image": "victest/vote-result@sha256:413fcc5d11e4426d9e5ec512056aeeb7fa83acc61eec2ed6346e8d30d56b7ae7", + "Networks": [ + "default" + ], + "Ports": [ + { + "Port": 80, + "Protocol": "tcp" + }, + { + "Port": 5858, + "Protocol": "tcp" + } + ] + }, + "vote": { + "Args": [ + "python", + "app.py" + ], + "Image": "victest/vote@sha256:13037f3373a3b10dfeac4f323b38a215d9665d88d72b1bb5fe7baef83c3b34ad", + "Networks": [ + "default" + ], + "Ports": [ + { + "Port": 80, + "Protocol": "tcp" + } + ] + }, + "worker": { + "Image": "victest/vote-worker@sha256:70cc69d1e91b8c23bbfd7515572c804c8b954c227da0e55e1131c367929f79dd", + "Networks": [ + "default" + ] + } + }, + "Version": "0.1" +} \ No newline at end of file diff --git a/lib/apiservers/engine/backends/build.go b/lib/apiservers/engine/backends/build.go new file mode 100644 index 0000000000..816a117fdf --- /dev/null +++ b/lib/apiservers/engine/backends/build.go @@ -0,0 +1,32 @@ +// Copyright 2017 VMware, Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package backends + +import ( + "fmt" + "io" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/backend" + "golang.org/x/net/context" +) + +type Builder struct { + +} + +func (b *Builder) BuildFromContext(ctx context.Context, src io.ReadCloser, remote string, buildOptions *types.ImageBuildOptions, pg backend.ProgressWriter) (string, error) { + return "", fmt.Errorf("%s does not yet implement BuildFromContext", ProductName()) +} \ No newline at end of file diff --git a/lib/apiservers/engine/backends/cache/image_cache.go b/lib/apiservers/engine/backends/cache/image_cache.go index 213998b12e..b86cc50c0c 100644 --- a/lib/apiservers/engine/backends/cache/image_cache.go +++ b/lib/apiservers/engine/backends/cache/image_cache.go @@ -26,7 +26,7 @@ import ( log "github.com/Sirupsen/logrus" "github.com/docker/distribution/digest" - derr "github.com/docker/docker/errors" + derr "github.com/docker/docker/api/errors" "github.com/docker/docker/pkg/truncindex" "github.com/docker/docker/reference" @@ -166,6 +166,7 @@ func (ic *ICache) Get(idOrRef string) (*metadata.ImageConfig, error) { var config *metadata.ImageConfig if imgDigest != "" { config = ic.getImageByDigest(imgDigest) + // config = ic.getImageByDigest(string(imgDigest)) } else { config = ic.getImageByNamed(named) } diff --git a/lib/apiservers/engine/backends/checkpoint.go b/lib/apiservers/engine/backends/checkpoint.go new file mode 100644 index 0000000000..be38702e66 --- /dev/null +++ b/lib/apiservers/engine/backends/checkpoint.go @@ -0,0 +1,40 @@ +// Copyright 2017 VMware, Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package backends + +import ( + "fmt" + + "github.com/docker/docker/api/types" +) + +type Checkpoint struct { +} + +func NewCheckpointBackend() *Checkpoint { + return &Checkpoint{} +} + +func (c *Checkpoint) CheckpointCreate(container string, config types.CheckpointCreateOptions) error { + return fmt.Errorf("%s does not yet implement checkpointing", ProductName()) +} + +func (c *Checkpoint) CheckpointDelete(container string, config types.CheckpointDeleteOptions) error { + return fmt.Errorf("%s does not yet implement checkpointing", ProductName()) +} + +func (c *Checkpoint) CheckpointList(container string, config types.CheckpointListOptions) ([]types.Checkpoint, error) { + return nil, fmt.Errorf("%s does not yet implement checkpointing", ProductName()) +} diff --git a/lib/apiservers/engine/backends/container.go b/lib/apiservers/engine/backends/container.go index 17d22d7f8c..fc24602655 100644 --- a/lib/apiservers/engine/backends/container.go +++ b/lib/apiservers/engine/backends/container.go @@ -1,4 +1,4 @@ -// Copyright 2016-2017 VMware, Inc. All Rights Reserved. +// Copyright 2016 VMware, Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ package backends import ( - "context" "fmt" "io" "math/rand" @@ -26,20 +25,22 @@ import ( "sync" "time" + "golang.org/x/net/context" + log "github.com/Sirupsen/logrus" "github.com/docker/docker/api/types/backend" - derr "github.com/docker/docker/errors" + derr "github.com/docker/docker/api/errors" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/namesgenerator" "github.com/docker/docker/pkg/stdcopy" - "github.com/docker/docker/pkg/version" "github.com/docker/docker/reference" - "github.com/docker/engine-api/types" - containertypes "github.com/docker/engine-api/types/container" - dnetwork "github.com/docker/engine-api/types/network" - timetypes "github.com/docker/engine-api/types/time" - "github.com/docker/go-connections/nat" + "github.com/docker/docker/api/types" + containertypes "github.com/docker/docker/api/types/container" + dnetwork "github.com/docker/docker/api/types/network" + timetypes "github.com/docker/docker/api/types/time" + gonat "github.com/docker/go-connections/nat" + "github.com/docker/docker/api/types/filters" "github.com/docker/go-units" "github.com/docker/libnetwork/iptables" "github.com/docker/libnetwork/portallocator" @@ -184,33 +185,33 @@ func NewContainerBackend() *Container { // docker's container.execBackend // ContainerExecCreate sets up an exec in a running container. -func (c *Container) ContainerExecCreate(config *types.ExecConfig) (string, error) { - return "", fmt.Errorf("%s does not implement container.ContainerExecCreate", ProductName()) +func (c *Container) ContainerExecCreate(name string, config *types.ExecConfig) (string, error) { + return "", fmt.Errorf("%s does not yet implement ContainerExecCreate", ProductName()) } // ContainerExecInspect returns low-level information about the exec // command. An error is returned if the exec cannot be found. func (c *Container) ContainerExecInspect(id string) (*backend.ExecInspect, error) { - return nil, fmt.Errorf("%s does not implement container.ContainerExecInspect", ProductName()) + return nil, fmt.Errorf("%s does not yet implement ContainerExecInspect", ProductName()) } // ContainerExecResize changes the size of the TTY of the process // running in the exec with the given name to the given height and // width. func (c *Container) ContainerExecResize(name string, height, width int) error { - return fmt.Errorf("%s does not implement container.ContainerExecResize", ProductName()) + return fmt.Errorf("%s does not yet implement ContainerExecResize", ProductName()) } // ContainerExecStart starts a previously set up exec instance. The // std streams are set up. -func (c *Container) ContainerExecStart(name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error { - return fmt.Errorf("%s does not implement container.ContainerExecStart", ProductName()) +func (c *Container) ContainerExecStart(ctx context.Context, name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error { + return fmt.Errorf("%s does not yet implement ContainerExecStart", ProductName()) } // ExecExists looks up the exec instance and returns a bool if it exists or not. // It will also return the error produced by `getConfig` func (c *Container) ExecExists(name string) (bool, error) { - return false, fmt.Errorf("%s does not implement container.ExecExists", ProductName()) + return false, fmt.Errorf("%s does not yet implement ExecExists", ProductName()) } // docker's container.copyBackend @@ -219,19 +220,19 @@ func (c *Container) ExecExists(name string) (bool, error) { // specified path in the container identified by the given name. Returns a // tar archive of the resource and whether it was a directory or a single file. func (c *Container) ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error) { - return nil, nil, fmt.Errorf("%s does not implement container.ContainerArchivePath", ProductName()) + return nil, nil, fmt.Errorf("%s does not yet implement ContainerArchivePath", ProductName()) } // ContainerCopy performs a deprecated operation of archiving the resource at // the specified path in the container identified by the given name. func (c *Container) ContainerCopy(name string, res string) (io.ReadCloser, error) { - return nil, fmt.Errorf("%s does not implement container.ContainerCopy", ProductName()) + return nil, fmt.Errorf("%s does not yet implement ContainerCopy", ProductName()) } // ContainerExport writes the contents of the container to the given // writer. An error is returned if the container cannot be found. func (c *Container) ContainerExport(name string, out io.Writer) error { - return fmt.Errorf("%s does not implement container.ContainerExport", ProductName()) + return fmt.Errorf("%s does not yet implement ContainerExport", ProductName()) } // ContainerExtractToDir extracts the given archive to the specified location @@ -241,19 +242,19 @@ func (c *Container) ContainerExport(name string, out io.Writer) error { // be an error if unpacking the given content would cause an existing directory // to be replaced with a non-directory and vice versa. func (c *Container) ContainerExtractToDir(name, path string, noOverwriteDirNonDir bool, content io.Reader) error { - return fmt.Errorf("%s does not implement container.ContainerExtractToDir", ProductName()) + return fmt.Errorf("%s does not yet implement ContainerExtractToDir", ProductName()) } // ContainerStatPath stats the filesystem resource at the specified path in the // container identified by the given name. func (c *Container) ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error) { - return nil, fmt.Errorf("%s does not implement container.ContainerStatPath", ProductName()) + return nil, fmt.Errorf("%s does not yet implement ContainerStatPath", ProductName()) } // docker's container.stateBackend // ContainerCreate creates a container. -func (c *Container) ContainerCreate(config types.ContainerCreateConfig) (types.ContainerCreateResponse, error) { +func (c *Container) ContainerCreate(config types.ContainerCreateConfig) (containertypes.ContainerCreateCreatedBody, error) { defer trace.End(trace.Begin("")) var err error @@ -262,7 +263,7 @@ func (c *Container) ContainerCreate(config types.ContainerCreateConfig) (types.C if exists := cache.ContainerCache().GetContainer(config.Name); exists != nil { err := fmt.Errorf("Conflict. The name %q is already in use by container %s. You have to remove (or rename) that container to be able to re use that name.", config.Name, exists.ContainerID) log.Errorf("%s", err.Error()) - return types.ContainerCreateResponse{}, derr.NewRequestConflictError(err) + return containertypes.ContainerCreateCreatedBody{}, derr.NewRequestConflictError(err) } // get the image from the cache @@ -271,27 +272,27 @@ func (c *Container) ContainerCreate(config types.ContainerCreateConfig) (types.C // if no image found then error thrown and a pull // will be initiated by the docker client log.Errorf("ContainerCreate: image %s error: %s", config.Config.Image, err.Error()) - return types.ContainerCreateResponse{}, derr.NewRequestNotFoundError(err) + return containertypes.ContainerCreateCreatedBody{}, derr.NewRequestNotFoundError(err) } setCreateConfigOptions(config.Config, image.Config) log.Debugf("config.Config = %+v", config.Config) if err = validateCreateConfig(&config); err != nil { - return types.ContainerCreateResponse{}, err + return containertypes.ContainerCreateCreatedBody{}, err } // Create a container representation in the personality server. This representation // will be stored in the cache if create succeeds in the port layer. container, err := createInternalVicContainer(image, &config) if err != nil { - return types.ContainerCreateResponse{}, err + return containertypes.ContainerCreateCreatedBody{}, err } // Create an actualized container in the VIC port layer id, err := c.containerCreate(container, config) if err != nil { - return types.ContainerCreateResponse{}, err + return containertypes.ContainerCreateCreatedBody{}, err } // Container created ok, save the container id and save the config override from the API @@ -303,7 +304,7 @@ func (c *Container) ContainerCreate(config types.ContainerCreateConfig) (types.C log.Debugf("Container create - name(%s), containerID(%s), config(%#v), host(%#v)", container.Name, container.ContainerID, container.Config, container.HostConfig) - return types.ContainerCreateResponse{ID: id}, nil + return containertypes.ContainerCreateCreatedBody{ID: id}, nil } // createContainer() makes calls to the container proxy to actually create the backing @@ -373,14 +374,14 @@ func (c *Container) ContainerKill(name string, sig uint64) error { // ContainerPause pauses a container func (c *Container) ContainerPause(name string) error { - return fmt.Errorf("%s does not implement container.ContainerPause", ProductName()) + return fmt.Errorf("%s does not yet implement ContainerPause", ProductName()) } // ContainerRename changes the name of a container, using the oldName // to find the container. An error is returned if newName is already // reserved. func (c *Container) ContainerRename(oldName, newName string) error { - return fmt.Errorf("%s does not implement container.ContainerRename", ProductName()) + return fmt.Errorf("%s does not yet implement ContainerRename", ProductName()) } // ContainerResize changes the size of the TTY of the process running @@ -407,7 +408,7 @@ func (c *Container) ContainerResize(name string, height, width int) error { // timeout, ContainerRestart will wait forever until a graceful // stop. Returns an error if the container cannot be found, or if // there is an underlying error at any stage of the restart. -func (c *Container) ContainerRestart(name string, seconds int) error { +func (c *Container) ContainerRestart(name string, seconds *int) error { defer trace.End(trace.Begin(name)) // Look up the container name in the metadata cache ot get long ID @@ -454,8 +455,9 @@ func (c *Container) ContainerRm(name string, config *types.ContainerRmConfig) er _ = &config.RemoveVolume // Use the force and stop the container first + secs := 0 if config.ForceRemove { - c.containerProxy.Stop(vc, name, 0, true) + c.containerProxy.Stop(vc, name, &secs, true) } //call the remove directly on the name. No need for using a handle. @@ -531,7 +533,7 @@ func (c *Container) cleanupPortBindings(vc *viccontainer.VicContainer) error { } // ContainerStart starts a container. -func (c *Container) ContainerStart(name string, hostConfig *containertypes.HostConfig) error { +func (c *Container) ContainerStart(name string, hostConfig *containertypes.HostConfig, checkpoint string, checkpointDir string) error { defer trace.End(trace.Begin(name)) operation := func() error { @@ -668,16 +670,16 @@ func requestHostPort(proto string) (int, error) { type portMapping struct { intHostPort int strHostPort string - portProto nat.Port + portProto gonat.Port } // unrollPortMap processes config for mapping/unmapping ports e.g. from hostconfig.PortBindings -func unrollPortMap(portMap nat.PortMap) ([]*portMapping, error) { +func unrollPortMap(portMap gonat.PortMap) ([]*portMapping, error) { var portMaps []*portMapping for i, pb := range portMap { - proto, port := nat.SplitProtoPort(string(i)) - nport, err := nat.NewPort(proto, port) + proto, port := gonat.SplitProtoPort(string(i)) + nport, err := gonat.NewPort(proto, port) if err != nil { return nil, err } @@ -895,7 +897,7 @@ func (c *Container) findPortBoundNetworkEndpoint(hostconfig *containertypes.Host // will wait for a graceful termination. An error is returned if the // container is not found, is already stopped, or if there is a // problem stopping the container. -func (c *Container) ContainerStop(name string, seconds int) error { +func (c *Container) ContainerStop(name string, seconds *int) error { defer trace.End(trace.Begin(name)) // Look up the container name in the metadata cache to get long ID @@ -915,12 +917,12 @@ func (c *Container) ContainerStop(name string, seconds int) error { // ContainerUnpause unpauses a container func (c *Container) ContainerUnpause(name string) error { - return fmt.Errorf("%s does not implement container.ContainerUnpause", ProductName()) + return fmt.Errorf("%s does not yet implement ContainerUnpause", ProductName()) } // ContainerUpdate updates configuration of the container -func (c *Container) ContainerUpdate(name string, hostConfig *containertypes.HostConfig) ([]string, error) { - return make([]string, 0, 0), fmt.Errorf("%s does not implement container.ContainerUpdate", ProductName()) +func (c *Container) ContainerUpdate(name string, hostConfig *containertypes.HostConfig) (containertypes.ContainerUpdateOKBody, error) { + return containertypes.ContainerUpdateOKBody{}, fmt.Errorf("%s does not yet implement ontainerUpdate", ProductName()) } // ContainerWait stops processing until the given container is @@ -997,13 +999,13 @@ func dockerStatus(exitCode int, status string, state string, started time.Time, // ContainerChanges returns a list of container fs changes func (c *Container) ContainerChanges(name string) ([]archive.Change, error) { - return make([]archive.Change, 0, 0), fmt.Errorf("%s does not implement container.ContainerChanges", ProductName()) + return make([]archive.Change, 0, 0), fmt.Errorf("%s does not yet implement ontainerChanges", ProductName()) } // ContainerInspect returns low-level information about a // container. Returns an error if the container cannot be found, or if // there is an error getting the data. -func (c *Container) ContainerInspect(name string, size bool, version version.Version) (interface{}, error) { +func (c *Container) ContainerInspect(name string, size bool, version string) (interface{}, error) { // Ignore version. We're supporting post-1.20 version. defer trace.End(trace.Begin(name)) @@ -1064,7 +1066,7 @@ func (c *Container) ContainerInspect(name string, size bool, version version.Ver // ContainerLogs hooks up a container's stdout and stderr streams // configured with the given struct. -func (c *Container) ContainerLogs(name string, config *backend.ContainerLogsConfig, started chan struct{}) error { +func (c *Container) ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error { defer trace.End(trace.Begin("")) // Look up the container name in the metadata cache to get long ID @@ -1105,8 +1107,8 @@ func (c *Container) ContainerLogs(name string, config *backend.ContainerLogsConf // ContainerStats writes information about the container to the stream // given in the config object. -func (c *Container) ContainerStats(name string, config *backend.ContainerStatsConfig) error { - return fmt.Errorf("%s does not implement container.ContainerStats", ProductName()) +func (c *Container) ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error { + return fmt.Errorf("%s does not yet implement ContainerStats", ProductName()) } // ContainerTop lists the processes running inside of the given @@ -1115,7 +1117,7 @@ func (c *Container) ContainerStats(name string, config *backend.ContainerStatsCo // is not found, or is not running, or if there are any problems // running ps, or parsing the output. func (c *Container) ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error) { - return nil, fmt.Errorf("%s does not implement container.ContainerTop", ProductName()) + return nil, fmt.Errorf("%s does not yet implement ContainerTop", ProductName()) } // Containers returns the list of containers to show given the user's filtering. @@ -1170,7 +1172,7 @@ payloadLoop: // TODO: refactor labelsFromAnnotations func for broader use tempConfig := &containertypes.Config{} err = labelsFromAnnotations(tempConfig, t.ContainerConfig.Annotations) - if err != nil && config.Filter.Include("label") { + if err != nil && config.Filters.Include("label") { return nil, fmt.Errorf("unable to convert vic annotations to docker labels (%s)", t.ContainerConfig.ContainerID) } @@ -1260,6 +1262,11 @@ func (c *Container) ContainerAttach(name string, ca *backend.ContainerAttachConf return nil } +func (c *Container) ContainersPrune(pruneFilters filters.Args) (*types.ContainersPruneReport, error) { + return nil, fmt.Errorf("%s does not yet implement ContainersPrune", ProductName()) +} + + func (c *Container) containerAttach(name string, ca *backend.ContainerAttachConfig) error { // Look up the container name in the metadata cache to get long ID vc := cache.ContainerCache().GetContainer(name) @@ -1562,7 +1569,7 @@ func validateCreateConfig(config *types.ContainerCreateConfig) error { } } - start, end, _ := nat.ParsePortRangeToInt(pb.HostPort) + start, end, _ := gonat.ParsePortRangeToInt(pb.HostPort) if start != end { return InternalServerError("host port ranges are not supported for port bindings") } @@ -1642,25 +1649,26 @@ func portInformation(t *models.ContainerInfo, ips []netlink.Addr) []types.Port { portBindings := c.HostConfig.PortBindings var resultPorts []types.Port - var err error for _, port := range ports { for portBindingPrivatePort, hostPortBindings := range portBindings { portAndType := strings.SplitN(string(portBindingPrivatePort), "/", 2) - port.PrivatePort, err = strconv.Atoi(portAndType[0]) + portNum, err := strconv.Atoi(portAndType[0]) if err != nil { log.Infof("Got an error trying to convert private port number to an int") continue } + port.PrivatePort = uint16(portNum) port.Type = portAndType[1] for i := 0; i < len(hostPortBindings); i++ { newport := port - newport.PublicPort, err = strconv.Atoi(hostPortBindings[i].HostPort) + publicPort, err := strconv.Atoi(hostPortBindings[i].HostPort) if err != nil { log.Infof("Got an error trying to convert public port number to an int") continue } + newport.PublicPort = uint16(publicPort) // sanity check -- sometimes these come back as 0 when no binding actually exists // that doesn't make sense, so in that case we don't want to report these bindings if newport.PublicPort != 0 && newport.PrivatePort != 0 { diff --git a/lib/apiservers/engine/backends/container/viccontainer.go b/lib/apiservers/engine/backends/container/viccontainer.go index 33fa1e7361..dfbe07e8bd 100644 --- a/lib/apiservers/engine/backends/container/viccontainer.go +++ b/lib/apiservers/engine/backends/container/viccontainer.go @@ -15,7 +15,7 @@ package container import ( - containertypes "github.com/docker/engine-api/types/container" + containertypes "github.com/docker/docker/api/types/container" ) // VicContainer is VIC's abridged version of Docker's container object. diff --git a/lib/apiservers/engine/backends/container_proxy.go b/lib/apiservers/engine/backends/container_proxy.go index e199e9c67e..81ff609b37 100644 --- a/lib/apiservers/engine/backends/container_proxy.go +++ b/lib/apiservers/engine/backends/container_proxy.go @@ -51,13 +51,14 @@ import ( httpclient "github.com/mreiferson/go-httpclient" "github.com/docker/docker/api/types/backend" - derr "github.com/docker/docker/errors" + derr "github.com/docker/docker/api/errors" "github.com/docker/docker/pkg/stringid" - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/container" - dnetwork "github.com/docker/engine-api/types/network" - "github.com/docker/engine-api/types/strslice" + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" + dnetwork "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/strslice" "github.com/docker/go-connections/nat" + "github.com/docker/docker/pkg/term" "github.com/vmware/vic/lib/apiservers/engine/backends/cache" viccontainer "github.com/vmware/vic/lib/apiservers/engine/backends/container" @@ -84,7 +85,7 @@ type VicContainerProxy interface { CommitContainerHandle(handle, containerID string, waitTime int32) error StreamContainerLogs(name string, out io.Writer, started chan struct{}, showTimestamps bool, followLogs bool, since int64, tailLines int64) error - Stop(vc *viccontainer.VicContainer, name string, seconds int, unbound bool) error + Stop(vc *viccontainer.VicContainer, name string, seconds *int, unbound bool) error IsRunning(vc *viccontainer.VicContainer) (bool, error) Wait(vc *viccontainer.VicContainer, timeout time.Duration) (exitCode int32, processStatus string, containerState string, reterr error) Signal(vc *viccontainer.VicContainer, sig uint64) error @@ -459,7 +460,7 @@ func (c *ContainerProxy) StreamContainerLogs(name string, out io.Writer, started // // returns // error -func (c *ContainerProxy) Stop(vc *viccontainer.VicContainer, name string, seconds int, unbound bool) error { +func (c *ContainerProxy) Stop(vc *viccontainer.VicContainer, name string, seconds *int, unbound bool) error { defer trace.End(trace.Begin(vc.ContainerID)) if c.client == nil { @@ -523,7 +524,7 @@ func (c *ContainerProxy) Stop(vc *viccontainer.VicContainer, name string, second } handle = stateChangeResponse.Payload - wait := int32(seconds) + wait := int32(*seconds) err = c.CommitContainerHandle(handle, vc.ContainerID, wait) if err != nil { if IsNotFoundError(err) { @@ -711,11 +712,20 @@ func (c *ContainerProxy) AttachStreams(ctx context.Context, vc *viccontainer.Vic plClient, transport := c.createNewAttachClientWithTimeouts(attachConnectTimeout, 0, attachAttemptTimeout) defer transport.Close() + var keys []byte + var err error + if ca.DetachKeys != "" { + keys, err = term.ToBytes(ca.DetachKeys) + if err != nil { + return fmt.Errorf("Invalid escape keys (%s) provided", ca.DetachKeys) + } + } + if ca.UseStdin { wg.Add(1) go func() { defer wg.Done() - err := copyStdIn(ctx, plClient, vc, clStdin, ca.DetachKeys) + err := copyStdIn(ctx, plClient, vc, clStdin, keys) if err != nil { log.Errorf("container attach: stdin (%s): %s", vc.ContainerID, err.Error()) } else { @@ -1242,7 +1252,6 @@ func containerConfigFromContainerInfo(vc *viccontainer.VicContainer, info *model container.NetworkDisabled = false container.MacAddress = "" container.ExposedPorts = vc.Config.ExposedPorts - container.PublishService = "" // Name of the network service exposed by the container } // Get the original container config from the image's metadata in our image cache. diff --git a/lib/apiservers/engine/backends/container_test.go b/lib/apiservers/engine/backends/container_test.go index 7138b3333b..39507d09a9 100644 --- a/lib/apiservers/engine/backends/container_test.go +++ b/lib/apiservers/engine/backends/container_test.go @@ -25,11 +25,11 @@ import ( "context" "github.com/docker/docker/api/types/backend" - derr "github.com/docker/docker/errors" + derr "github.com/docker/docker/api/errors" "github.com/docker/docker/reference" - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/container" - dnetwork "github.com/docker/engine-api/types/network" + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" + dnetwork "github.com/docker/docker/api/types/network" "github.com/docker/go-connections/nat" "github.com/stretchr/testify/assert" "github.com/vishvananda/netlink" @@ -290,7 +290,7 @@ func (m *MockContainerProxy) StreamContainerLogs(name string, out io.Writer, sta return nil } -func (m *MockContainerProxy) Stop(vc *viccontainer.VicContainer, name string, seconds int, unbound bool) error { +func (m *MockContainerProxy) Stop(vc *viccontainer.VicContainer, name string, seconds *int, unbound bool) error { return nil } @@ -593,7 +593,7 @@ func TestContainerLogs(t *testing.T) { started := make(chan struct{}) start := time.Now() - err := cb.ContainerLogs(containerID, &data.Config, started) + err := cb.ContainerLogs(context.TODO(), containerID, &data.Config, started) end := time.Now() select { @@ -625,7 +625,7 @@ func TestContainerLogs(t *testing.T) { // cache, so the only error will come from StreamContainerLogs. Since the // containerID = "", StreamContainerLogs will return an error. started := make(chan struct{}) - err := cb.ContainerLogs(fakeContainerID, &mockData[0].Config, started) + err := cb.ContainerLogs(context.TODO(), fakeContainerID, &mockData[0].Config, started) assert.NoError(t, err) } diff --git a/lib/apiservers/engine/backends/endpoint.go b/lib/apiservers/engine/backends/endpoint.go index a5f5633785..d1f0bff038 100644 --- a/lib/apiservers/engine/backends/endpoint.go +++ b/lib/apiservers/engine/backends/endpoint.go @@ -19,7 +19,7 @@ import ( "net" "net/http" - derr "github.com/docker/docker/errors" + derr "github.com/docker/docker/api/errors" "github.com/docker/libnetwork" "github.com/docker/libnetwork/types" @@ -129,3 +129,7 @@ func (e *endpoint) Address() *net.IPNet { func (e *endpoint) AddressIPv6() *net.IPNet { return nil } + +func (e *endpoint) LinkLocalAddresses() []*net.IPNet { + return nil +} diff --git a/lib/apiservers/engine/backends/endpoint/endpoint.go b/lib/apiservers/engine/backends/endpoint/endpoint.go index 9c7be63e04..f0f20316f8 100644 --- a/lib/apiservers/engine/backends/endpoint/endpoint.go +++ b/lib/apiservers/engine/backends/endpoint/endpoint.go @@ -18,7 +18,7 @@ import ( "fmt" log "github.com/Sirupsen/logrus" - apinet "github.com/docker/engine-api/types/network" + apinet "github.com/docker/docker/api/types/network" ) func Alias(endpointConfig *apinet.EndpointSettings) []string { diff --git a/lib/apiservers/engine/backends/errors.go b/lib/apiservers/engine/backends/errors.go index 10daddf886..1df2511c38 100644 --- a/lib/apiservers/engine/backends/errors.go +++ b/lib/apiservers/engine/backends/errors.go @@ -18,7 +18,7 @@ import ( "fmt" "net/http" - derr "github.com/docker/docker/errors" + derr "github.com/docker/docker/api/errors" ) // Used to check status code of derr, which is not a public type diff --git a/lib/apiservers/engine/backends/executor/SwarmBackend.go b/lib/apiservers/engine/backends/executor/SwarmBackend.go new file mode 100644 index 0000000000..736b831efc --- /dev/null +++ b/lib/apiservers/engine/backends/executor/SwarmBackend.go @@ -0,0 +1,169 @@ +// Copyright 2017 VMware, Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package executor + +import ( + "io" + "time" + "fmt" + + "github.com/docker/distribution" + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/backend" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/events" + "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/network" + swarmtypes "github.com/docker/docker/api/types/swarm" + clustertypes "github.com/docker/docker/daemon/cluster/provider" + "github.com/docker/docker/plugin" + "github.com/docker/docker/reference" + "github.com/docker/libnetwork" + "github.com/docker/libnetwork/cluster" + networktypes "github.com/docker/libnetwork/types" + "github.com/docker/swarmkit/agent/exec" + "golang.org/x/net/context" +) + +type SwarmBackend struct { +} + +func (b SwarmBackend) CreateManagedNetwork(clustertypes.NetworkCreateRequest) error { + return nil +} + +func (b SwarmBackend) DeleteManagedNetwork(name string) error { + return nil +} + +func (b SwarmBackend) FindNetwork(idName string) (libnetwork.Network, error) { + return nil, nil +} + +func (b SwarmBackend) SetupIngress(req clustertypes.NetworkCreateRequest, nodeIP string) error { + return nil +} + +func (b SwarmBackend) PullImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error { + return nil +} + +func (b SwarmBackend) CreateManagedContainer(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) { + return container.ContainerCreateCreatedBody{}, nil +} + +func (b SwarmBackend) ContainerStart(name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error { + return nil +} + +func (b SwarmBackend) ContainerStop(name string, seconds *int) error { + return nil +} + +// ContainerLogs hooks up a container's stdout and stderr streams +// configured with the given struct. +func (b SwarmBackend) ContainerLogs(ctx context.Context, containerName string, config *backend.ContainerLogsConfig, started chan struct{}) error { + return nil +} + +func (b SwarmBackend) ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error { + return nil +} + +func (b SwarmBackend) ActivateContainerServiceBinding(containerName string) error { + return nil +} + +func (b SwarmBackend) DeactivateContainerServiceBinding(containerName string) error { + return nil +} + +func (b SwarmBackend) UpdateContainerServiceConfig(containerName string, serviceConfig *clustertypes.ServiceConfig) error { + return nil +} + +func (b SwarmBackend) ContainerInspectCurrent(name string, size bool) (*types.ContainerJSON, error) { + return nil, nil +} + +func (b SwarmBackend) ContainerWaitWithContext(ctx context.Context, name string) error { + return nil +} + +func (b SwarmBackend) ContainerRm(name string, config *types.ContainerRmConfig) error { + return nil +} + +func (b SwarmBackend) ContainerKill(name string, sig uint64) error { + return nil +} + +func (b SwarmBackend) SetContainerSecretStore(name string, store exec.SecretGetter) error { + return nil +} + +func (b SwarmBackend) SetContainerSecretReferences(name string, refs []*swarmtypes.SecretReference) error { + return nil +} + +func (b SwarmBackend) SystemInfo() (*types.Info, error) { + return nil, nil +} + +func (b SwarmBackend) VolumeCreate(name, driverName string, opts, labels map[string]string) (*types.Volume, error) { + return nil, nil +} + +func (b SwarmBackend) Containers(config *types.ContainerListOptions) ([]*types.Container, error) { + return nil, nil +} + +func (b SwarmBackend) SetNetworkBootstrapKeys([]*networktypes.EncryptionKey) error { + return nil +} + +func (b SwarmBackend) SetClusterProvider(provider cluster.Provider) { +} + +func (b SwarmBackend) IsSwarmCompatible() error { + return fmt.Errorf("vSphere Integrated Containers Engine does not yet support Docker Swarm.") +} + +func (b SwarmBackend) SubscribeToEvents(since, until time.Time, filter filters.Args) ([]events.Message, chan interface{}) { + return nil, nil +} + +func (b SwarmBackend) UnsubscribeFromEvents(listener chan interface{}) { +} + +func (b SwarmBackend) UpdateAttachment(string, string, string, *network.NetworkingConfig) error { + return nil +} + +func (b SwarmBackend) WaitForDetachment(context.Context, string, string, string, string) error { + return nil +} + +func (b SwarmBackend) GetRepository(context.Context, reference.NamedTagged, *types.AuthConfig) (distribution.Repository, bool, error) { + return nil, false, nil +} + +func (b SwarmBackend) LookupImage(name string) (*types.ImageInspect, error) { + return nil, nil +} + +func (b SwarmBackend) PluginManager() *plugin.Manager { + return nil +} diff --git a/lib/apiservers/engine/backends/filter/container.go b/lib/apiservers/engine/backends/filter/container.go index 3545e1506b..2cad947461 100644 --- a/lib/apiservers/engine/backends/filter/container.go +++ b/lib/apiservers/engine/backends/filter/container.go @@ -18,7 +18,7 @@ import ( "fmt" "strconv" - "github.com/docker/engine-api/types" + "github.com/docker/docker/api/types" "github.com/vmware/vic/lib/apiservers/engine/backends/cache" "github.com/vmware/vic/lib/apiservers/portlayer/models" @@ -49,14 +49,14 @@ type ContainerListContext struct { func IncludeContainer(listContext *ContainerListContext, container *models.ContainerInfo) FilterAction { // if we need to filter on name add to the listContext - if listContext.Filter.Include("name") { + if listContext.Filters.Include("name") { // containerConfig allows for multiple names, but only 1 ever // assigned listContext.Name = container.ContainerConfig.Names[0] } // filter common requirements - act := filterCommon(&listContext.FilterContext, listContext.Filter) + act := filterCommon(&listContext.FilterContext, listContext.Filters) if act != IncludeAction { return act } @@ -82,15 +82,15 @@ func IncludeContainer(listContext *ContainerListContext, container *models.Conta state := DockerState(container.ContainerConfig.State) // Do not include container if its status doesn't match the filter - if !listContext.Filter.Match("status", state) { + if !listContext.Filters.Match("status", state) { return ExcludeAction } // filter on network name for n := range container.Endpoints { name := container.Endpoints[n].Scope - if listContext.Filter.Include("network") { - err := listContext.Filter.WalkValues("network", func(value string) error { + if listContext.Filters.Include("network") { + err := listContext.Filters.WalkValues("network", func(value string) error { if name == value { return nil } @@ -113,7 +113,7 @@ func IncludeContainer(listContext *ContainerListContext, container *models.Conta * */ func ValidateContainerFilters(options *types.ContainerListOptions, acceptedFilters map[string]bool, unSupportedFilters map[string]bool) (*ContainerListContext, error) { - containerFilters := options.Filter + containerFilters := options.Filters // ensure filter options are valid and supported by vic if err := ValidateFilters(containerFilters, acceptedFilters, unSupportedFilters); err != nil { diff --git a/lib/apiservers/engine/backends/filter/container_test.go b/lib/apiservers/engine/backends/filter/container_test.go index 0a3dab32fc..7210af0bc6 100644 --- a/lib/apiservers/engine/backends/filter/container_test.go +++ b/lib/apiservers/engine/backends/filter/container_test.go @@ -17,8 +17,8 @@ package filter import ( "testing" - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/filters" + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/filters" "github.com/stretchr/testify/assert" "github.com/vmware/vic/lib/apiservers/engine/backends/cache" @@ -29,12 +29,12 @@ import ( func TestValidateContainerFilters(t *testing.T) { options := &types.ContainerListOptions{ - Filter: filters.NewArgs(), + Filters: filters.NewArgs(), } - options.Filter.Add("id", "12345") - options.Filter.Add("status", "running") - options.Filter.Add("exited", "143") - options.Filter.Add("exited", "127") + options.Filters.Add("id", "12345") + options.Filters.Add("status", "running") + options.Filters.Add("exited", "143") + options.Filters.Add("exited", "127") // valid status & exit listContext, err := ValidateContainerFilters(options, acceptedPsFilterTags, unSupportedPsFilters) assert.NoError(t, err) @@ -42,36 +42,36 @@ func TestValidateContainerFilters(t *testing.T) { // we should have two exit codes added to the list // context assert.Equal(t, 2, len(listContext.exitAllowed)) - assert.Equal(t, options.Filter, listContext.Filter) + assert.Equal(t, options.Filters, listContext.Filters) // remove valid status and replace w/invalid - options.Filter.Del("status", "running") - options.Filter.Add("status", "jackedup") + options.Filters.Del("status", "running") + options.Filters.Add("status", "jackedup") // invalid status _, err = ValidateContainerFilters(options, acceptedPsFilterTags, unSupportedPsFilters) assert.Error(t, err) // remove valid exit code and replace w/invalid - options.Filter.Del("exited", "143") - options.Filter.Add("exited", "abc") + options.Filters.Del("exited", "143") + options.Filters.Add("exited", "abc") // invalid exit code _, err = ValidateContainerFilters(options, acceptedPsFilterTags, unSupportedPsFilters) assert.Error(t, err) // add an invalid container option - options.Filter.Add("jojo", "jojo") + options.Filters.Add("jojo", "jojo") // invalid container filter option _, err = ValidateContainerFilters(options, acceptedPsFilterTags, unSupportedPsFilters) assert.Error(t, err) - options.Filter.Del("jojo", "jojo") + options.Filters.Del("jojo", "jojo") // add before filter - options.Filter = filters.NewArgs() - options.Filter.Add("before", "1234") + options.Filters = filters.NewArgs() + options.Filters.Add("before", "1234") // fail because the before container isn't present _, err = ValidateContainerFilters(options, acceptedPsFilterTags, unSupportedPsFilters) assert.Error(t, err) @@ -88,7 +88,7 @@ func TestValidateContainerFilters(t *testing.T) { _, err = ValidateContainerFilters(options, acceptedPsFilterTags, unSupportedPsFilters) assert.NoError(t, err) - options.Filter.Add("since", "8888") + options.Filters.Add("since", "8888") // fail because the since container isn't present _, err = ValidateContainerFilters(options, acceptedPsFilterTags, unSupportedPsFilters) @@ -138,10 +138,10 @@ func TestIncludeContainer(t *testing.T) { listCtx := &ContainerListContext{ ContainerListOptions: &types.ContainerListOptions{ - Filter: filters.NewArgs()}, + Filters: filters.NewArgs()}, } - listCtx.Filter.Add("name", "jojo") + listCtx.Filters.Add("name", "jojo") assert.Equal(t, IncludeAction, IncludeContainer(listCtx, contain)) listCtx.Limit = 1 @@ -165,16 +165,16 @@ func TestIncludeContainer(t *testing.T) { assert.Equal(t, IncludeAction, IncludeContainer(listCtx, contain)) // test network name - listCtx.Filter = filters.NewArgs() - listCtx.Filter.Add("network", "bridge") + listCtx.Filters = filters.NewArgs() + listCtx.Filters.Add("network", "bridge") assert.Equal(t, IncludeAction, IncludeContainer(listCtx, contain)) - listCtx.Filter = filters.NewArgs() - listCtx.Filter.Add("network", "missed") + listCtx.Filters = filters.NewArgs() + listCtx.Filters.Add("network", "missed") assert.Equal(t, ExcludeAction, IncludeContainer(listCtx, contain)) - listCtx.Filter = filters.NewArgs() - listCtx.Filter.Add("status", "stopped") + listCtx.Filters = filters.NewArgs() + listCtx.Filters.Add("status", "stopped") assert.Equal(t, ExcludeAction, IncludeContainer(listCtx, contain)) } diff --git a/lib/apiservers/engine/backends/filter/filter.go b/lib/apiservers/engine/backends/filter/filter.go index 0dc08f41c2..0fc2374866 100644 --- a/lib/apiservers/engine/backends/filter/filter.go +++ b/lib/apiservers/engine/backends/filter/filter.go @@ -15,7 +15,7 @@ package filter import ( - "github.com/docker/engine-api/types/filters" + "github.com/docker/docker/api/types/filters" ) // FilterAction represents possible results during filtering diff --git a/lib/apiservers/engine/backends/filter/filter_test.go b/lib/apiservers/engine/backends/filter/filter_test.go index c0481b4646..38307460b8 100644 --- a/lib/apiservers/engine/backends/filter/filter_test.go +++ b/lib/apiservers/engine/backends/filter/filter_test.go @@ -17,7 +17,7 @@ package filter import ( "testing" - "github.com/docker/engine-api/types/filters" + "github.com/docker/docker/api/types/filters" "github.com/stretchr/testify/assert" ) diff --git a/lib/apiservers/engine/backends/filter/image.go b/lib/apiservers/engine/backends/filter/image.go index 9cf3866fdd..46da50f3d7 100644 --- a/lib/apiservers/engine/backends/filter/image.go +++ b/lib/apiservers/engine/backends/filter/image.go @@ -18,7 +18,7 @@ import ( "fmt" "path" - "github.com/docker/engine-api/types/filters" + "github.com/docker/docker/api/types/filters" "github.com/vmware/vic/lib/apiservers/engine/backends/cache" ) diff --git a/lib/apiservers/engine/backends/filter/image_test.go b/lib/apiservers/engine/backends/filter/image_test.go index ed2ed03d47..52bcfe07aa 100644 --- a/lib/apiservers/engine/backends/filter/image_test.go +++ b/lib/apiservers/engine/backends/filter/image_test.go @@ -20,8 +20,8 @@ import ( "time" "github.com/docker/docker/reference" - "github.com/docker/engine-api/types/container" - "github.com/docker/engine-api/types/filters" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/filters" "github.com/stretchr/testify/assert" "github.com/vmware/vic/lib/apiservers/engine/backends/cache" diff --git a/lib/apiservers/engine/backends/filter/validation.go b/lib/apiservers/engine/backends/filter/validation.go index 7ee5d15887..16a0c03238 100644 --- a/lib/apiservers/engine/backends/filter/validation.go +++ b/lib/apiservers/engine/backends/filter/validation.go @@ -17,7 +17,7 @@ package filter import ( "fmt" - "github.com/docker/engine-api/types/filters" + "github.com/docker/docker/api/types/filters" ) /* diff --git a/lib/apiservers/engine/backends/filter/validation_test.go b/lib/apiservers/engine/backends/filter/validation_test.go index 2857e56ffa..b1a18aeff5 100644 --- a/lib/apiservers/engine/backends/filter/validation_test.go +++ b/lib/apiservers/engine/backends/filter/validation_test.go @@ -17,7 +17,7 @@ package filter import ( "testing" - "github.com/docker/engine-api/types/filters" + "github.com/docker/docker/api/types/filters" "github.com/stretchr/testify/assert" ) diff --git a/lib/apiservers/engine/backends/filter/volume.go b/lib/apiservers/engine/backends/filter/volume.go index ca1745aaf7..d4c62c57fe 100644 --- a/lib/apiservers/engine/backends/filter/volume.go +++ b/lib/apiservers/engine/backends/filter/volume.go @@ -17,7 +17,7 @@ package filter import ( "fmt" - "github.com/docker/engine-api/types/filters" + "github.com/docker/docker/api/types/filters" ) // VolumeFilterContext stores volume information used while filtering diff --git a/lib/apiservers/engine/backends/filter/volume_test.go b/lib/apiservers/engine/backends/filter/volume_test.go index 5bb29fcef9..b30a0b1d4f 100644 --- a/lib/apiservers/engine/backends/filter/volume_test.go +++ b/lib/apiservers/engine/backends/filter/volume_test.go @@ -17,7 +17,7 @@ package filter import ( "testing" - "github.com/docker/engine-api/types/filters" + "github.com/docker/docker/api/types/filters" "github.com/stretchr/testify/assert" ) diff --git a/lib/apiservers/engine/backends/image.go b/lib/apiservers/engine/backends/image.go index 38463ef487..57b74a592c 100644 --- a/lib/apiservers/engine/backends/image.go +++ b/lib/apiservers/engine/backends/image.go @@ -27,10 +27,11 @@ import ( "github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/reference" - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/container" - "github.com/docker/engine-api/types/filters" - "github.com/docker/engine-api/types/registry" + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/backend" + "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/registry" + "github.com/docker/distribution/digest" "github.com/vmware/vic/lib/apiservers/engine/backends/cache" vicfilter "github.com/vmware/vic/lib/apiservers/engine/backends/filter" @@ -60,8 +61,12 @@ var unSupportedImageFilters = map[string]bool{ type Image struct { } -func (i *Image) Commit(name string, config *types.ContainerCommitConfig) (imageID string, err error) { - return "", fmt.Errorf("%s does not implement image.Commit", ProductName()) +func NewImageBackend() *Image { + return &Image{} +} + +func (i *Image) Commit(name string, config *backend.ContainerCommitConfig) (imageID string, err error) { + return "", fmt.Errorf("%s does not yet implement image.Commit", ProductName()) } func (i *Image) Exists(containerName string) bool { @@ -189,24 +194,11 @@ func (i *Image) ImageDelete(imageRef string, force, prune bool) ([]types.ImageDe } func (i *Image) ImageHistory(imageName string) ([]*types.ImageHistory, error) { - return nil, fmt.Errorf("%s does not implement image.History", ProductName()) + return nil, fmt.Errorf("%s does not yet implement image.History", ProductName()) } -func (i *Image) Images(filterArgs string, filter string, all bool) ([]*types.Image, error) { - defer trace.End(trace.Begin(fmt.Sprintf("filterArgs: %s", filterArgs))) - - // This type conversion can be removed once we move to 1.13 - // At 1.13 the Images func will change signatures and filterArgs will be properly - // typed - imageFilters, err := filters.FromParam(filterArgs) - if err != nil { - return nil, err - } - - // utilize the filterArgs to incorporate the argument option - if filter != "" { - imageFilters.Add("reference", filter) - } +func (i *Image) Images(imageFilters filters.Args, all bool, withExtraAttrs bool) ([]*types.ImageSummary, error) { + defer trace.End(trace.Begin(fmt.Sprintf("imageFilters: %#v", imageFilters))) // validate filters for accuracy and support filterContext, err := vicfilter.ValidateImageFilters(imageFilters, acceptedImageFilterTags, unSupportedImageFilters) @@ -217,7 +209,7 @@ func (i *Image) Images(filterArgs string, filter string, all bool) ([]*types.Ima // get all images images := cache.ImageCache().GetImages() - result := make([]*types.Image, 0, len(images)) + result := make([]*types.ImageSummary, 0, len(images)) imageLoop: for i := range images { @@ -259,13 +251,22 @@ func (i *Image) LookupImage(name string) (*types.ImageInspect, error) { return imageConfigToDockerImageInspect(imageConfig, ProductName()), nil } -// TagImage will tag the specified image with the provided reference -func (i *Image) TagImage(newTag reference.Named, imageName string) error { +func (i *Image) TagImage(imageName, repository, tag string) error { img, err := cache.ImageCache().Get(imageName) if err != nil { return err } + newTag, err := reference.WithName(repository) + if err != nil { + return err + } + if tag != "" { + if newTag, err = reference.WithTag(newTag, tag); err != nil { + return err + } + } + // place tag in repo and save to portLayer k/v store err = cache.RepositoryCache().AddReference(newTag, img.ImageID, true, "", true) if err != nil { @@ -275,22 +276,49 @@ func (i *Image) TagImage(newTag reference.Named, imageName string) error { return nil } +func (i *Image) ImagesPrune(pruneFilters filters.Args) (*types.ImagesPruneReport, error) { + return nil, fmt.Errorf("%s does not yet implement image.ImagesPrune", ProductName()) +} + func (i *Image) LoadImage(inTar io.ReadCloser, outStream io.Writer, quiet bool) error { - return fmt.Errorf("%s does not implement image.LoadImage", ProductName()) + return fmt.Errorf("%s does not yet implement image.LoadImage", ProductName()) } -func (i *Image) ImportImage(src string, newRef reference.Named, msg string, inConfig io.ReadCloser, outStream io.Writer, config *container.Config) error { - return fmt.Errorf("%s does not implement image.ImportImage", ProductName()) +func (i *Image) ImportImage(src string, repository, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error { + return fmt.Errorf("%s does not yet implement image.ImportImage", ProductName()) } func (i *Image) ExportImage(names []string, outStream io.Writer) error { - return fmt.Errorf("%s does not implement image.ExportImage", ProductName()) + return fmt.Errorf("%s does not yet implement image.ExportImage", ProductName()) } -func (i *Image) PullImage(ctx context.Context, ref reference.Named, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error { - defer trace.End(trace.Begin(ref.String())) +func (i *Image) PullImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error { + defer trace.End(trace.Begin("")) + + log.Debugf("PullImage: image = %s, tag = %s, metaheaders = %+v\n", image, tag, metaHeaders) - log.Debugf("PullImage: ref = %+v, metaheaders = %+v\n", ref, metaHeaders) + //***** Code from Docker 1.13 PullImage to convert image and tag to a ref + image = strings.TrimSuffix(image, ":") + + ref, err := reference.ParseNamed(image) + if err != nil { + return err + } + + if tag != "" { + // The "tag" could actually be a digest. + var dgst digest.Digest + dgst, err = digest.ParseDigest(tag) + if err == nil { + ref, err = reference.WithDigest(reference.TrimNamed(ref), dgst) + } else { + ref, err = reference.WithTag(ref, tag) + } + if err != nil { + return err + } + } + //***** options := imagec.Options{ Destination: os.TempDir(), @@ -329,7 +357,7 @@ func (i *Image) PullImage(ctx context.Context, ref reference.Named, metaHeaders portLayerServer) ic := imagec.NewImageC(options, streamformatter.NewJSONStreamFormatter()) - err := ic.PullImage() + err = ic.PullImage() if err != nil { return err } @@ -337,23 +365,23 @@ func (i *Image) PullImage(ctx context.Context, ref reference.Named, metaHeaders return nil } -func (i *Image) PushImage(ctx context.Context, ref reference.Named, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error { - return fmt.Errorf("%s does not implement image.PushImage", ProductName()) +func (i *Image) PushImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error { + return fmt.Errorf("%s does not yet implement image.PushImage", ProductName()) } -func (i *Image) SearchRegistryForImages(ctx context.Context, term string, authConfig *types.AuthConfig, metaHeaders map[string][]string) (*registry.SearchResults, error) { - return nil, fmt.Errorf("%s does not implement image.SearchRegistryForImages", ProductName()) +func (i *Image) SearchRegistryForImages(ctx context.Context, filtersArgs string, term string, limit int, authConfig *types.AuthConfig, metaHeaders map[string][]string) (*registry.SearchResults, error) { + return nil, fmt.Errorf("%s does not yet implement image.SearchRegistryForImages", ProductName()) } // Utility functions -func convertV1ImageToDockerImage(image *metadata.ImageConfig) *types.Image { +func convertV1ImageToDockerImage(image *metadata.ImageConfig) *types.ImageSummary { var labels map[string]string if image.Config != nil { labels = image.Config.Labels } - return &types.Image{ + return &types.ImageSummary{ ID: image.ImageID, ParentID: image.Parent, RepoTags: image.Tags, diff --git a/lib/apiservers/engine/backends/image_test.go b/lib/apiservers/engine/backends/image_test.go index da78ba790d..e8995edc9b 100644 --- a/lib/apiservers/engine/backends/image_test.go +++ b/lib/apiservers/engine/backends/image_test.go @@ -20,7 +20,7 @@ import ( "time" v1 "github.com/docker/docker/image" - "github.com/docker/engine-api/types/container" + "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/assert" diff --git a/lib/apiservers/engine/backends/network.go b/lib/apiservers/engine/backends/network.go index 57d046e469..7d39179081 100644 --- a/lib/apiservers/engine/backends/network.go +++ b/lib/apiservers/engine/backends/network.go @@ -18,13 +18,17 @@ import ( "fmt" "net" "sync" + "time" "net/http" log "github.com/Sirupsen/logrus" - derr "github.com/docker/docker/errors" - apinet "github.com/docker/engine-api/types/network" + derr "github.com/docker/docker/api/errors" + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/filters" + apinet "github.com/docker/docker/api/types/network" "github.com/docker/libnetwork" + "github.com/docker/libnetwork/networkdb" "github.com/vmware/vic/lib/apiservers/engine/backends/cache" vicendpoint "github.com/vmware/vic/lib/apiservers/engine/backends/endpoint" @@ -36,6 +40,10 @@ import ( type Network struct { } +func NewNetworkBackend() *Network { + return &Network{} +} + func (n *Network) NetworkControllerEnabled() bool { return false } @@ -90,7 +98,7 @@ func (n *Network) GetNetworksByID(partialID string) []libnetwork.Network { return nets } -func (n *Network) GetAllNetworks() []libnetwork.Network { +func (n *Network) GetNetworks() []libnetwork.Network { ok, err := PortLayerClient().Scopes.ListAll(scopes.NewListAllParamsWithContext(ctx)) if err != nil { return nil @@ -105,35 +113,35 @@ func (n *Network) GetAllNetworks() []libnetwork.Network { return nets } -func (n *Network) CreateNetwork(name, driver string, ipam apinet.IPAM, options map[string]string, labels map[string]string, internal bool, enableIPv6 bool) (libnetwork.Network, error) { - if len(ipam.Config) > 1 { +func (n *Network) CreateNetwork(nc types.NetworkCreateRequest) (*types.NetworkCreateResponse, error) { + if nc.IPAM != nil && len(nc.IPAM.Config) > 1 { return nil, fmt.Errorf("at most one ipam config supported") } var gateway, subnet string var pools []string - if len(ipam.Config) > 0 { - if ipam.Config[0].Gateway != "" { - gateway = ipam.Config[0].Gateway + if nc.IPAM != nil && len(nc.IPAM.Config) > 0 { + if nc.IPAM.Config[0].Gateway != "" { + gateway = nc.IPAM.Config[0].Gateway } - if ipam.Config[0].Subnet != "" { - subnet = ipam.Config[0].Subnet + if nc.IPAM.Config[0].Subnet != "" { + subnet = nc.IPAM.Config[0].Subnet } - if ipam.Config[0].IPRange != "" { - pools = append(pools, ipam.Config[0].IPRange) + if nc.IPAM.Config[0].IPRange != "" { + pools = append(pools, nc.IPAM.Config[0].IPRange) } } - if driver == "" { - driver = "bridge" + if nc.Driver == "" { + nc.Driver = "bridge" } cfg := &models.ScopeConfig{ Gateway: gateway, - Name: name, - ScopeType: driver, + Name: nc.Name, + ScopeType: nc.Driver, Subnet: subnet, IPAM: pools, } @@ -142,7 +150,7 @@ func (n *Network) CreateNetwork(name, driver string, ipam apinet.IPAM, options m if err != nil { switch err := err.(type) { case *scopes.CreateScopeConflict: - return nil, derr.NewErrorWithStatusCode(fmt.Errorf("network %s already exists", name), http.StatusConflict) + return nil, derr.NewErrorWithStatusCode(fmt.Errorf("network %s already exists", nc.Name), http.StatusConflict) case *scopes.CreateScopeDefault: return nil, derr.NewErrorWithStatusCode(fmt.Errorf(err.Payload.Message), http.StatusInternalServerError) @@ -151,8 +159,13 @@ func (n *Network) CreateNetwork(name, driver string, ipam apinet.IPAM, options m return nil, derr.NewErrorWithStatusCode(err, http.StatusInternalServerError) } } + + ncResponse := &types.NetworkCreateResponse{ + ID: created.Payload.ID, + Warning: "", + } - return &network{cfg: created.Payload}, nil + return ncResponse, nil } func (n *Network) ConnectContainerToNetwork(containerName, networkName string, endpointConfig *apinet.EndpointSettings) error { @@ -271,12 +284,12 @@ func (n *Network) ConnectContainerToNetwork(containerName, networkName string, e return nil } -func (n *Network) DisconnectContainerFromNetwork(containerName string, network libnetwork.Network, force bool) error { +func (n *Network) DisconnectContainerFromNetwork(containerName string, networkName string, force bool) error { vc := cache.ContainerCache().GetContainer(containerName) if vc != nil { containerName = vc.ContainerID } - return fmt.Errorf("%s does not implement network.DisconnectContainerFromNetwork", ProductName()) + return fmt.Errorf("%s does not yet implement network.DisconnectContainerFromNetwork", ProductName()) } func (n *Network) DeleteNetwork(name string) error { @@ -298,6 +311,10 @@ func (n *Network) DeleteNetwork(name string) error { return nil } +func (n *Network) NetworksPrune(pruneFilters filters.Args) (*types.NetworksPruneReport, error) { + return nil, fmt.Errorf("%s does not yet implement NetworksPrune", ProductName()) +} + // network implements the libnetwork.Network and libnetwork.NetworkInfo interfaces type network struct { sync.Mutex @@ -451,3 +468,23 @@ func (n *network) Internal() bool { func (n *network) Labels() map[string]string { return make(map[string]string) } + +func (n *network) Attachable() bool { + return false //? +} + +func (n *network) Dynamic() bool { + return false //? +} + +func (n *network) Created() time.Time { + return time.Now() +} + +// Peers returns a slice of PeerInfo structures which has the information about the peer +// nodes participating in the same overlay network. This is currently the per-network +// gossip cluster. For non-dynamic overlay networks and bridge networks it returns an +// empty slice +func (n *network) Peers() []networkdb.PeerInfo { + return nil +} diff --git a/lib/apiservers/engine/backends/plugins.go b/lib/apiservers/engine/backends/plugins.go new file mode 100644 index 0000000000..1e4a17a46d --- /dev/null +++ b/lib/apiservers/engine/backends/plugins.go @@ -0,0 +1,73 @@ +// Copyright 2017 VMware, Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package backends + +import ( + "fmt" + "io" + "net/http" + + enginetypes "github.com/docker/docker/api/types" + "github.com/docker/docker/reference" + "golang.org/x/net/context" +) + +type Plugin struct { +} + +func NewPluginBackend() *Plugin { + return &Plugin{} +} + +func (p *Plugin) Disable(name string, config *enginetypes.PluginDisableConfig) error { + return fmt.Errorf("%s does not yet support plugins", ProductName()) +} + +func (p *Plugin) Enable(name string, config *enginetypes.PluginEnableConfig) error { + return fmt.Errorf("%s does not yet support plugins", ProductName()) +} + +func (p *Plugin) List() ([]enginetypes.Plugin, error) { + return nil, fmt.Errorf("%s does not yet support plugins", ProductName()) +} + +func (p *Plugin) Inspect(name string) (*enginetypes.Plugin, error) { + return nil, fmt.Errorf("%s does not yet support plugins", ProductName()) +} + +func (p *Plugin) Remove(name string, config *enginetypes.PluginRmConfig) error { + return fmt.Errorf("%s does not yet support plugins", ProductName()) +} + +func (p *Plugin) Set(name string, args []string) error { + return fmt.Errorf("%s does not yet support plugins", ProductName()) +} + +func (p *Plugin) Privileges(ctx context.Context, ref reference.Named, metaHeaders http.Header, authConfig *enginetypes.AuthConfig) (enginetypes.PluginPrivileges, error) { + return nil, fmt.Errorf("%s does not yet support plugins", ProductName()) +} + +func (p *Plugin) Pull(ctx context.Context, ref reference.Named, name string, metaHeaders http.Header, authConfig *enginetypes.AuthConfig, privileges enginetypes.PluginPrivileges, outStream io.Writer) error { + return fmt.Errorf("%s does not yet support plugins", ProductName()) +} + +func (p *Plugin) Push(ctx context.Context, name string, metaHeaders http.Header, authConfig *enginetypes.AuthConfig, outStream io.Writer) error { + return fmt.Errorf("%s does not yet support plugins", ProductName()) +} + +func (p *Plugin) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *enginetypes.PluginCreateOptions) error { + return fmt.Errorf("%s does not yet support plugins", ProductName()) +} + diff --git a/lib/apiservers/engine/backends/sandbox.go b/lib/apiservers/engine/backends/sandbox.go index 2a8624fc27..80c02641d7 100644 --- a/lib/apiservers/engine/backends/sandbox.go +++ b/lib/apiservers/engine/backends/sandbox.go @@ -102,3 +102,21 @@ func (s *sandbox) ResolveIP(name string) string { func (s *sandbox) Endpoints() []libnetwork.Endpoint { return nil } + +// ResolveService returns all the backend details about the containers or hosts +// backing a service. Its purpose is to satisfy an SRV query +func (s *sandbox) ResolveService(name string) ([]*net.SRV, []net.IP) { + return nil, nil +} + +// EnableService makes a managed container's service available by adding the +// endpoint to the service load balancer and service discovery +func (s *sandbox) EnableService() error { + return notImplementedError +} + +// DisableService removes a managed contianer's endpoints from the load balancer +// and service discovery +func (s *sandbox) DisableService() error { + return notImplementedError +} diff --git a/lib/apiservers/engine/backends/swarm.go b/lib/apiservers/engine/backends/swarm.go new file mode 100644 index 0000000000..2c9ec8a9a4 --- /dev/null +++ b/lib/apiservers/engine/backends/swarm.go @@ -0,0 +1,128 @@ +// Copyright 2017 VMware, Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package backends + +import ( + "fmt" + + "golang.org/x/net/context" + + basictypes "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/backend" + types "github.com/docker/docker/api/types/swarm" +) + +type Swarm struct { +} + +func NewSwarmBackend() *Swarm { + return &Swarm{} +} + +func (s *Swarm) Init(req types.InitRequest) (string, error) { + return "", fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) Join(req types.JoinRequest) error { + return fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) Leave(force bool) error { + return fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) Inspect() (types.Swarm, error) { + return types.Swarm{}, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) Update(uint64, types.Spec, types.UpdateFlags) error { + return fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) GetUnlockKey() (string, error) { + return "", fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) UnlockSwarm(req types.UnlockRequest) error { + return fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) GetServices(basictypes.ServiceListOptions) ([]types.Service, error) { + return nil, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) GetService(string) (types.Service, error) { + return types.Service{}, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) CreateService(types.ServiceSpec, string) (*basictypes.ServiceCreateResponse, error) { + return nil, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) UpdateService(string, uint64, types.ServiceSpec, string, string) (*basictypes.ServiceUpdateResponse, error) { + return nil, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) RemoveService(string) error { + return fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) ServiceLogs(context.Context, string, *backend.ContainerLogsConfig, chan struct{}) error { + return fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) GetNodes(basictypes.NodeListOptions) ([]types.Node, error) { + return nil, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) GetNode(string) (types.Node, error) { + return types.Node{}, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) UpdateNode(string, uint64, types.NodeSpec) error { + return fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) RemoveNode(string, bool) error { + return fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) GetTasks(basictypes.TaskListOptions) ([]types.Task, error) { + return nil, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) GetTask(string) (types.Task, error) { + return types.Task{}, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) GetSecrets(opts basictypes.SecretListOptions) ([]types.Secret, error) { + return nil, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) CreateSecret(sp types.SecretSpec) (string, error) { + return "", fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) RemoveSecret(id string) error { + return fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) GetSecret(id string) (types.Secret, error) { + return types.Secret{}, fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} + +func (s *Swarm) UpdateSecret(id string, version uint64, spec types.SecretSpec) error { + return fmt.Errorf("%s does not yet support Docker Swarm", ProductName()) +} diff --git a/lib/apiservers/engine/backends/system.go b/lib/apiservers/engine/backends/system.go index 8156bc50a2..3e2d4962ce 100644 --- a/lib/apiservers/engine/backends/system.go +++ b/lib/apiservers/engine/backends/system.go @@ -43,10 +43,10 @@ import ( "github.com/vmware/vic/pkg/trace" "github.com/vmware/vic/pkg/version" + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/events" + "github.com/docker/docker/api/types/filters" "github.com/docker/docker/pkg/platform" - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/events" - "github.com/docker/engine-api/types/filters" "github.com/docker/go-units" ) @@ -96,7 +96,6 @@ func (s *System) SystemInfo() (*types.Info, error) { Debug: VchConfig().Diagnostics.DebugLevel > 0, NGoroutines: runtime.NumGoroutine(), SystemTime: time.Now().Format(time.RFC3339Nano), - ExecutionDriver: PortLayerName(), LoggingDriver: "", CgroupDriver: "", DockerRootDir: "", @@ -244,7 +243,11 @@ func (s *System) SystemVersion() types.Version { return version } -func (s *System) SubscribeToEvents(since, sinceNano int64, ef filters.Args) ([]events.Message, chan interface{}) { +func (s *System) SystemDiskUsage() (*types.DiskUsage, error) { + return nil, fmt.Errorf("%s does not yet implement SystemDiskUsage", ProductName()) +} + +func (s *System) SubscribeToEvents(since, until time.Time, ef filters.Args) ([]events.Message, chan interface{}) { return make([]events.Message, 0, 0), make(chan interface{}) } diff --git a/lib/apiservers/engine/backends/system_portlayer.go b/lib/apiservers/engine/backends/system_portlayer.go index 0790ca6046..d4c6438fe9 100644 --- a/lib/apiservers/engine/backends/system_portlayer.go +++ b/lib/apiservers/engine/backends/system_portlayer.go @@ -36,7 +36,7 @@ import ( "net/http" log "github.com/Sirupsen/logrus" - derr "github.com/docker/docker/errors" + derr "github.com/docker/docker/api/errors" "github.com/vmware/vic/lib/apiservers/portlayer/client/containers" "github.com/vmware/vic/lib/apiservers/portlayer/client/misc" diff --git a/lib/apiservers/engine/backends/volume.go b/lib/apiservers/engine/backends/volume.go index 32553ddaab..a03788fd44 100644 --- a/lib/apiservers/engine/backends/volume.go +++ b/lib/apiservers/engine/backends/volume.go @@ -19,14 +19,14 @@ import ( "fmt" log "github.com/Sirupsen/logrus" - derr "github.com/docker/docker/errors" + derr "github.com/docker/docker/api/errors" "regexp" "strconv" "strings" - "github.com/docker/engine-api/types" - "github.com/docker/engine-api/types/filters" + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/filters" "github.com/docker/go-units" "github.com/google/uuid" @@ -79,6 +79,10 @@ var acceptedVolumeFilters = map[string]bool{ var errPortlayerClient = fmt.Errorf("failed to get a portlayer client") +func NewVolumeBackend() *Volume { + return &Volume{} +} + // Volumes docker personality implementation for VIC func (v *Volume) Volumes(filter string) ([]*types.Volume, []string, error) { defer trace.End(trace.Begin("Volume.Volumes")) @@ -270,7 +274,7 @@ func (v *Volume) VolumeCreate(name, driverName string, volumeData, labels map[st } // VolumeRm : docker personality for VIC -func (v *Volume) VolumeRm(name string) error { +func (v *Volume) VolumeRm(name string, force bool) error { defer trace.End(trace.Begin("Volume.VolumeRm")) client := PortLayerClient() @@ -298,6 +302,10 @@ func (v *Volume) VolumeRm(name string) error { return nil } +func (v *Volume) VolumesPrune(pruneFilters filters.Args) (*types.VolumesPruneReport, error) { + return nil, fmt.Errorf("%s does not yet implement VolumesPrune", ProductName()) +} + type volumeMetadata struct { Driver string DriverOpts map[string]string diff --git a/lib/install/management/appliance.go b/lib/install/management/appliance.go index c87d4cf5fa..6a9744edaf 100644 --- a/lib/install/management/appliance.go +++ b/lib/install/management/appliance.go @@ -33,7 +33,7 @@ import ( log "github.com/Sirupsen/logrus" "github.com/docker/docker/opts" - dockertypes "github.com/docker/engine-api/types" + dockertypes "github.com/docker/docker/api/types" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/vim25/soap" diff --git a/tests/test-cases/Group1-Docker-Commands/1-15-Docker-Network-Create.robot b/tests/test-cases/Group1-Docker-Commands/1-15-Docker-Network-Create.robot index 66cd849643..35f52b87d9 100644 --- a/tests/test-cases/Group1-Docker-Commands/1-15-Docker-Network-Create.robot +++ b/tests/test-cases/Group1-Docker-Commands/1-15-Docker-Network-Create.robot @@ -15,7 +15,7 @@ Basic network create Create already created network ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} network create test-network Should Be Equal As Integers ${rc} 1 - Should Contain ${output} Error response from daemon: network with name test-network already exists + Should Contain ${output} already exists Create overlay network ${status}= Get State Of Github Issue 1222 diff --git a/tests/test-cases/Group1-Docker-Commands/1-17-Docker-Network-Connect.robot b/tests/test-cases/Group1-Docker-Commands/1-17-Docker-Network-Connect.robot index be7af3d55a..b3b0ad4b5f 100644 --- a/tests/test-cases/Group1-Docker-Commands/1-17-Docker-Network-Connect.robot +++ b/tests/test-cases/Group1-Docker-Commands/1-17-Docker-Network-Connect.robot @@ -26,7 +26,7 @@ Connect container to a new network Connect to non-existent container ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} network connect test-network fakeContainer Should Be Equal As Integers ${rc} 1 - Should Contain ${output} Error response from daemon: container fakeContainer not found + Should Contain ${output} not found Connect to non-existent network ${rc} ${containerID}= Run And Return Rc And Output docker %{VCH-PARAMS} pull busybox @@ -36,7 +36,7 @@ Connect to non-existent network Should Be Equal As Integers ${rc} 0 ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} network connect fakeNetwork connectTest3 Should Be Equal As Integers ${rc} 1 - Should Contain ${output} Error response from daemon: network fakeNetwork not found + Should Contain ${output} not found Connect containers to multiple networks overlapping ${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} network create cross1-network diff --git a/tests/test-cases/Group1-Docker-Commands/1-28-Docker-Secret.md b/tests/test-cases/Group1-Docker-Commands/1-28-Docker-Secret.md new file mode 100644 index 0000000000..57cbc4007b --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-28-Docker-Secret.md @@ -0,0 +1,24 @@ +Test 1-28 - Docker Secret +======= + +#Purpose: +To verify that VIC appliance responds appropriately to docker secrets APIs. + +#References: +[1 - Docker Command Line Reference](https://docs.docker.com/engine/reference/commandline/secret/) + +#Environment: +This test requires that a vSphere server is running and available + +#Test Steps: +1. Deploy VIC appliance to vSphere server +2. Issue docker secret ls +3. Issue docker secret create +4. Issue docker secret inspect +5. Issue docker secret rm + +#Expected Outcome: +* Step 2-5 should result in an error of not supported + +#Possible Problems: +None \ No newline at end of file diff --git a/tests/test-cases/Group1-Docker-Commands/1-28-Docker-Secret.robot b/tests/test-cases/Group1-Docker-Commands/1-28-Docker-Secret.robot new file mode 100644 index 0000000000..c730596b69 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-28-Docker-Secret.robot @@ -0,0 +1,31 @@ +*** Settings *** +Documentation Test 1-28 - Docker Secret +Resource ../../resources/Util.robot +Suite Setup Install VIC Appliance To Test Server certs=${false} +Suite Teardown Cleanup VIC Appliance On Test Server + +*** Variables *** +${fake-secret} test + +*** Test Cases *** +Docker secret ls + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} secret ls + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} vSphere Integrated Containers does not yet support Docker Swarm + +Docker secret create + Run echo '${fake-secret}' > secret.file + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} secret create mysecret ./secret.file + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} vSphere Integrated Containers does not yet support Docker Swarm + +Docker secret inspect + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} secret inspect my_secret + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} vSphere Integrated Containers does not yet support Docker Swarm + +Docker secret rm + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} secret rm my_secret + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} vSphere Integrated Containers does not yet support Docker Swarm + diff --git a/tests/test-cases/Group1-Docker-Commands/1-29-Docker-Checkpoint.md b/tests/test-cases/Group1-Docker-Commands/1-29-Docker-Checkpoint.md new file mode 100644 index 0000000000..2c979539e6 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-29-Docker-Checkpoint.md @@ -0,0 +1,23 @@ +Test 1-29 - Docker Checkpoint +======= + +#Purpose: +To verify that VIC appliance responds appropriately to docker checkpoint APIs + +#References: +[1 - Docker Command Line Reference](https://docs.docker.com/engine/reference/commandline/checkpoint/) + +#Environment: +This test requires that a vSphere server is running and available + +#Test Steps: +1. Deploy VIC appliance to vSphere server +2. Issue docker checkpoint create +3. Issue docker checkpoint ls +4. Issue docker checkpoint rm + +#Expected Outcome: +* Step 2-4 should result in an error of not supported + +#Possible Problems: +None \ No newline at end of file diff --git a/tests/test-cases/Group1-Docker-Commands/1-29-Docker-Checkpoint.robot b/tests/test-cases/Group1-Docker-Commands/1-29-Docker-Checkpoint.robot new file mode 100644 index 0000000000..def3e45a22 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-29-Docker-Checkpoint.robot @@ -0,0 +1,26 @@ +*** Settings *** +Documentation Test 1-29 - Docker Checkpoint +Resource ../../resources/Util.robot +Suite Setup Install VIC Appliance To Test Server certs=${false} +Suite Teardown Cleanup VIC Appliance On Test Server + +*** Test Cases *** +Docker checkpoint create + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} pull busybox + Should Be Equal As Integers ${rc} 0 + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} create --name=test-busybox busybox + Should Be Equal As Integers ${rc} 0 + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} checkpoint create test-busybox new-checkpoint + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} vSphere Integrated Containers does not yet implement checkpointing + +Docker checkpoint ls + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} checkpoint ls test-busybox + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} vSphere Integrated Containers does not yet implement checkpointing + +Docker checkpoint rm + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} checkpoint rm test-busybox new-checkpoint + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} No such container + diff --git a/tests/test-cases/Group1-Docker-Commands/1-30-Docker-Deploy.md b/tests/test-cases/Group1-Docker-Commands/1-30-Docker-Deploy.md new file mode 100644 index 0000000000..bbb25d62a4 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-30-Docker-Deploy.md @@ -0,0 +1,21 @@ +Test 1-30 - Docker Deploy +======= + +#Purpose: +To verify that VIC appliance responds appropriately to docker deploy APIs + +#References: +[1 - Docker Command Line Reference](https://docs.docker.com/engine/reference/commandline/deploy/) + +#Environment: +This test requires that a vSphere server is running and available + +#Test Steps: +1. Deploy VIC appliance to vSphere server +2. Issue docker deploy + +#Expected Outcome: +* Step 2 should result in an error of not supported + +#Possible Problems: +None \ No newline at end of file diff --git a/tests/test-cases/Group1-Docker-Commands/1-30-Docker-Deploy.robot b/tests/test-cases/Group1-Docker-Commands/1-30-Docker-Deploy.robot new file mode 100644 index 0000000000..e198b2f7f7 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-30-Docker-Deploy.robot @@ -0,0 +1,12 @@ +*** Settings *** +Documentation Test 1-30 - Docker Deploy +Resource ../../resources/Util.robot +Suite Setup Install VIC Appliance To Test Server certs=${false} +Suite Teardown Cleanup VIC Appliance On Test Server + +*** Test Cases *** +Docker deploy + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} deploy %{GOPATH}/src/github.com/vmware/vic/demos/compose/voting-app/votingapp.dab + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} only supported with experimental daemon + diff --git a/tests/test-cases/Group1-Docker-Commands/1-31-Docker-Node.md b/tests/test-cases/Group1-Docker-Commands/1-31-Docker-Node.md new file mode 100644 index 0000000000..2463d864be --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-31-Docker-Node.md @@ -0,0 +1,28 @@ +Test 1-31 - Docker Node +======= + +#Purpose: +To verify that VIC appliance responds appropriately to docker node APIs + +#References: +[1 - Docker Command Line Reference](https://docs.docker.com/engine/reference/commandline/node/) + +#Environment: +This test requires that a vSphere server is running and available + +#Test Steps: +1. Deploy VIC appliance to vSphere server +2. Issue docker node demote +3. Issue docker node ls +4. Issue docker node promote +5. Issue docker node rm +6. Issue docker node update +7. Issue docker node ps +8. Issue docker node inspect + +#Expected Outcome: +* Step 2-6 should result in an error that contains does not yet support Docker Swarm +* Step 7-8 should result in an error that contains No such node + +#Possible Problems: +None \ No newline at end of file diff --git a/tests/test-cases/Group1-Docker-Commands/1-31-Docker-Node.robot b/tests/test-cases/Group1-Docker-Commands/1-31-Docker-Node.robot new file mode 100644 index 0000000000..0869e8a4d8 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-31-Docker-Node.robot @@ -0,0 +1,42 @@ +*** Settings *** +Documentation Test 1-31 - Docker Node +Resource ../../resources/Util.robot +Suite Setup Install VIC Appliance To Test Server certs=${false} +Suite Teardown Cleanup VIC Appliance On Test Server + +*** Test Cases *** +Docker node demote + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} node demote self + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker node ls + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} node ls + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker node promote + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} node promote self + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker node rm + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} node rm self + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker node update + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} node update self + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker node ps + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} node ps + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} No such node + +Docker node inspect + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} node inspect self + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} No such node + diff --git a/tests/test-cases/Group1-Docker-Commands/1-32-Docker-Plugin.md b/tests/test-cases/Group1-Docker-Commands/1-32-Docker-Plugin.md new file mode 100644 index 0000000000..6e18739325 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-32-Docker-Plugin.md @@ -0,0 +1,29 @@ +Test 1-32 - Docker Plugin +======= + +#Purpose: +To verify that VIC appliance responds appropriately to docker plugin APIs + +#References: +[1 - Docker Command Line Reference](https://docs.docker.com/engine/reference/commandline/plugin_create/) + +#Environment: +This test requires that a vSphere server is running and available + +#Test Steps: +1. Deploy VIC appliance to vSphere server +2. Issue docker plugin install +3. Issue docker plugin create +4. Issue docker plugin enable +5. Issue docker plugin disable +6. Issue docker plugin inspect +7. Issue docker plugin ls +8. Issue docker plugin push +9. Issue docker plugin rm +10. Issue docker plugin set + +#Expected Outcome: +* Step 2-10 should result in an error that contains does not yet support plugins + +#Possible Problems: +None \ No newline at end of file diff --git a/tests/test-cases/Group1-Docker-Commands/1-32-Docker-Plugin.robot b/tests/test-cases/Group1-Docker-Commands/1-32-Docker-Plugin.robot new file mode 100644 index 0000000000..784e7556e0 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-32-Docker-Plugin.robot @@ -0,0 +1,52 @@ +*** Settings *** +Documentation Test 1-32 - Docker plugin +Resource ../../resources/Util.robot +Suite Setup Install VIC Appliance To Test Server certs=${false} +Suite Teardown Cleanup VIC Appliance On Test Server + +*** Test Cases *** +Docker plugin install + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} plugin install vieux/sshfs + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support plugins + +Docker plugin create + Run echo '{}' > config.json + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} plugin create test-plugin . + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support plugins + +Docker plugin enable + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} plugin enable test-plugin + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support plugins + +Docker plugin disable + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} plugin disable test-plugin + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support plugins + +Docker plugin inspect + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} plugin inspect test-plugin + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support plugins + +Docker plugin ls + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} plugin ls + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support plugins + +Docker plugin push + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} plugin push test-plugin + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support plugins + +Docker plugin rm + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} plugin rm test-plugin + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support plugins + +Docker plugin set + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} plugin set test-plugin test-data + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support plugins diff --git a/tests/test-cases/Group1-Docker-Commands/1-33-Docker-Service.md b/tests/test-cases/Group1-Docker-Commands/1-33-Docker-Service.md new file mode 100644 index 0000000000..cad030d3ce --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-33-Docker-Service.md @@ -0,0 +1,29 @@ +Test 1-33 - Docker Service +======= + +#Purpose: +To verify that VIC appliance responds appropriately to docker service APIs + +#References: +[1 - Docker Command Line Reference](https://docs.docker.com/engine/reference/commandline/service/) + +#Environment: +This test requires that a vSphere server is running and available + +#Test Steps: +1. Deploy VIC appliance to vSphere server +2. Issue docker service create +3. Issue docker service inspect +4. Issue docker service ls +5. Issue docker service ps +6. Issue docker service rm +7. Issue docker service scale +8. Issue docker service update +9. Issue docker service logs + +#Expected Outcome: +* Step 2-8 should result in an error that contains does not yet support Docker Swarm +* Step 9 should result in an error that contains only supported with experimental daemon + +#Possible Problems: +None \ No newline at end of file diff --git a/tests/test-cases/Group1-Docker-Commands/1-33-Docker-Service.robot b/tests/test-cases/Group1-Docker-Commands/1-33-Docker-Service.robot new file mode 100644 index 0000000000..bb1646d303 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-33-Docker-Service.robot @@ -0,0 +1,42 @@ +*** Settings *** +Documentation Test 1-33 - Docker Service +Resource ../../resources/Util.robot +Suite Setup Install VIC Appliance To Test Server certs=${false} +Suite Teardown Cleanup VIC Appliance On Test Server + +*** Test Cases *** +Docker service create + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} service create test-service + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker service ls + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} service ls + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker service ps + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} service ps test-service + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker serivce rm + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} service rm test-service + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker service scale + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} service scale test-service=3 + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker service update + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} service update test-service + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker service logs + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} service logs test + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} only supported with experimental daemon + diff --git a/tests/test-cases/Group1-Docker-Commands/1-34-Docker-Stack.md b/tests/test-cases/Group1-Docker-Commands/1-34-Docker-Stack.md new file mode 100644 index 0000000000..0faf59bc06 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-34-Docker-Stack.md @@ -0,0 +1,25 @@ +Test 1-34 - Docker Node +======= + +#Purpose: +To verify that VIC appliance responds appropriately to docker stack APIs + +#References: +[1 - Docker Command Line Reference](https://docs.docker.com/engine/reference/commandline/stack/) + +#Environment: +This test requires that a vSphere server is running and available + +#Test Steps: +1. Deploy VIC appliance to vSphere server +2. Issue docker stack deploy +3. Issue docker stack ls +4. Issue docker stack ps +5. Issue docker stack rm +6. Issue docker stack services + +#Expected Outcome: +* Step 2-6 should result in an error that contains does not yet support Docker Swarm + +#Possible Problems: +None \ No newline at end of file diff --git a/tests/test-cases/Group1-Docker-Commands/1-34-Docker-Stack.robot b/tests/test-cases/Group1-Docker-Commands/1-34-Docker-Stack.robot new file mode 100644 index 0000000000..45c6d15d6f --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-34-Docker-Stack.robot @@ -0,0 +1,33 @@ +*** Settings *** +Documentation Test 1-34 - Docker Stack +Resource ../../resources/Util.robot +Suite Setup Install VIC Appliance To Test Server certs=${false} +Suite Teardown Cleanup VIC Appliance On Test Server + +*** Test Cases *** +#Docker stack deploy + #${rc} ${output}= Run And Return Rc And Output wget #https://raw.githubusercontent.com/vfarcic/docker-flow-proxy/master/docker-compose-stack.yml + #Should Be Equal As Integers ${rc} 0 + #${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} stack deploy -c #./docker-compose-stack.yml proxy + #Should Be Equal As Integers ${rc} 1 + #Should Contain ${output} does not yet support Docker Swarm + +Docker stack ls + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} stack ls + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker stack ps + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} stack ps test-stack + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker stack rm + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} stack rm test-stack + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker stack services + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} stack services test-stack + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm diff --git a/tests/test-cases/Group1-Docker-Commands/1-35-Docker-Swarm.md b/tests/test-cases/Group1-Docker-Commands/1-35-Docker-Swarm.md new file mode 100644 index 0000000000..3987d35dac --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-35-Docker-Swarm.md @@ -0,0 +1,27 @@ +Test 1-35 - Docker Swarm +======= + +#Purpose: +To verify that VIC appliance responds appropriately to docker swarm APIs + +#References: +[1 - Docker Command Line Reference](https://docs.docker.com/engine/reference/commandline/node/) + +#Environment: +This test requires that a vSphere server is running and available + +#Test Steps: +1. Deploy VIC appliance to vSphere server +2. Issue docker swarm init +3. Issue docker swarm join +4. Issue docker swarm join-token +5. Issue docker swarm leave +6. Issue docker swarm unlock +7. Issue docker swarm unlock-key +8. Issue docker swarm update + +#Expected Outcome: +* Step 2-8 should result in an error that contains does not yet support Docker Swarm + +#Possible Problems: +None \ No newline at end of file diff --git a/tests/test-cases/Group1-Docker-Commands/1-35-Docker-Swarm.robot b/tests/test-cases/Group1-Docker-Commands/1-35-Docker-Swarm.robot new file mode 100644 index 0000000000..00bc3df749 --- /dev/null +++ b/tests/test-cases/Group1-Docker-Commands/1-35-Docker-Swarm.robot @@ -0,0 +1,40 @@ +*** Settings *** +Documentation Test 1-35 - Docker Swarm +Resource ../../resources/Util.robot +Suite Setup Install VIC Appliance To Test Server certs=${false} +Suite Teardown Cleanup VIC Appliance On Test Server + +*** Test Cases *** +Docker swarm init + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} swarm init + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker swarm join + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} swarm join 127.0.0.1:2375 + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker swarm join-token + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} swarm join-token worker + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} swarm join-token manager + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker swarm leave + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} swarm leave + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker swarm unlock-key + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} swarm unlock-key + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + +Docker swarm update + ${rc} ${output}= Run And Return Rc And Output docker1.13 %{VCH-PARAMS} swarm update --autolock + Should Be Equal As Integers ${rc} 1 + Should Contain ${output} does not yet support Docker Swarm + diff --git a/tests/test-cases/Group1-Docker-Commands/TestCases.md b/tests/test-cases/Group1-Docker-Commands/TestCases.md index 4190b37482..c31aaa2918 100644 --- a/tests/test-cases/Group1-Docker-Commands/TestCases.md +++ b/tests/test-cases/Group1-Docker-Commands/TestCases.md @@ -51,4 +51,20 @@ Group 1 - Docker Commands [Test 1-24 - Docker Link](1-24-Docker-Link.md) - [Test 1-27 - Docker Login](1-27-Docker-Login.md) +- +[Test 1-28 - Docker Secret](1-28-Docker-Secret.md) +- +[Test 1-29 - Docker Service](1-29-Docker-Service.md) +- +[Test 1-30 - Docker Deploy](1-30-Docker-Deploy.md) +- +[Test 1-31 - Docker Node](1-31-Docker-Node.md) +- +[Test 1-32 - Docker Plugin](1-32-Docker-Plugin.md) +- +[Test 1-33 - Docker Service](1-33-Docker-Service.md) +- +[Test 1-34 - Docker Stack](1-34-Docker-Stack.md) +- +[Test 1-35 - Docker Swarm](1-35-Docker-Swarm.md) - \ No newline at end of file diff --git a/vendor/github.com/docker/engine-api/types/types.go b/vendor/github.com/docker/engine-api/types/types.go deleted file mode 100644 index e69de29bb2..0000000000