move plugin network creation into weaveutil
Note that we remove the ability to set the weavemesh network name, or disabling it altogether. This was always poorly support, since the removal operation only ever operated on the default name. The option was also not listed in the usage, though it was in the docs.
This commit is contained in:
1 parent
9578798ec0
commit
31b303a419
5 files changed
+36
-33
No files matched your search
@@ -7,6 +7,36 @@ import (
|
||||
"github.com/fsouza/go-dockerclient"
|
||||
)
|
||||
|
||||
func createPluginNetwork(args []string) error {
|
||||
if len(args) != 2 {
|
||||
cmdUsage("create-plugin-network", "<network-name> <driver-name>")
|
||||
}
|
||||
networkName := args[0]
|
||||
driverName := args[1]
|
||||
d, err := newDockerClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = d.NetworkInfo(networkName)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if _, ok := err.(*docker.NoSuchNetwork); !ok {
|
||||
return nil // TODO is this right?
|
||||
}
|
||||
_, err = d.CreateNetwork(
|
||||
docker.CreateNetworkOptions{
|
||||
Name: networkName,
|
||||
CheckDuplicate: true,
|
||||
Driver: driverName,
|
||||
IPAM: docker.IPAMOptions{Driver: driverName},
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create network: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func removePluginNetwork(args []string) error {
|
||||
if len(args) != 1 {
|
||||
cmdUsage("remove-plugin-network", "<network-name>")
|
||||
|
||||
Reference in new issue
Block a user