Browse Source

Renamed XCP to XenServer, for compatibility

master v0.2.0
Fábio Kaiser Rauber 5 years ago
parent
commit
1e9416ea88
  1. 76
      README.md
  2. 4
      docker-machine-driver-xenserver.go
  3. 2
      go.mod
  4. 1
      go.sum
  5. 2
      xenserver/xenapiclient.go
  6. 128
      xenserver/xenserver.go

76
README.md

@ -1,6 +1,6 @@
# docker-machine-driver-xcp # docker-machine-driver-xenserver
This is the XCP-ng driver plugin for Docker Machine. It allows the This is the XENSERVER-ng driver plugin for Docker Machine, renamed to XenServer for compatibility with Rancher clusters
orchestration of machines on XCP-ng (all versions) and probably compatible with Citrix XenServer 6.5SP1 or later. created with the old XenServer Driver.
This work is derived from https://github.com/xenserver/docker-machine-driver-xenserver. This work is derived from https://github.com/xenserver/docker-machine-driver-xenserver.
@ -16,53 +16,53 @@ The installation steps are:
# Installation from source # Installation from source
Following the installation of Golang and Docker Machine, you can install the Following the installation of Golang and Docker Machine, you can install the
docker-machine-xcp-driver: docker-machine-xenserver-driver:
```bash ```bash
go get github.com/interlegis/docker-machine-driver-xcp go get github.com/interlegis/docker-machine-driver-xenserver
``` ```
# Usage # Usage
The usual Docker Machine commands apply: The usual Docker Machine commands apply:
```bash ```bash
docker-machine create -d xcp --xcp-server myip --xcp-username myusername --xcp-password mypassword mynewmmachine docker-machine create -d xenserver --xenserver-server myip --xenserver-username myusername --xenserver-password mypassword mynewmmachine
docker-machine env mynewmmachine docker-machine env mynewmmachine
``` ```
# CLI Options: # CLI Options:
- `--xcp-vcpu-count`: vCPU number for docker VM. - `--xenserver-vcpu-count`: vCPU number for docker VM.
- `--xcp-memory-size`: Size of memory for Docker VM (in MB). - `--xenserver-memory-size`: Size of memory for Docker VM (in MB).
- `--xcp-boot2docker-url`: URL for boot2docker ISO image. - `--xenserver-boot2docker-url`: URL for boot2docker ISO image.
- `--xcp-server`: **required for create** XenServer hostname/IP for docker VM. - `--xenserver-server`: **required for create** XenServer hostname/IP for docker VM.
- `--xcp-disk-size`: Size of disk for Docker VM (in MB). - `--xenserver-disk-size`: Size of disk for Docker VM (in MB).
- `--xcp-username`: **required** XenServer Username. - `--xenserver-username`: **required** XenServer Username.
- `--xcp-password`: **required** XenServer Password. - `--xenserver-password`: **required** XenServer Password.
- `--xcp-network-label`: Network label where the docker VM will be attached - `--xenserver-network-label`: Network label where the docker VM will be attached
- `--xcp-sr-label`: SR label where the docker VM will be attached. - `--xenserver-sr-label`: SR label where the docker VM will be attached.
- `--xcp-host-label`: Host label where the docker VM will be run. - `--xenserver-host-label`: Host label where the docker VM will be run.
- `--xcp-upload-timeout`: Timeout uploading VDI. - `--xenserver-upload-timeout`: Timeout uploading VDI.
- `--xcp-wait-timeout`: Timeout wating for VM start. - `--xenserver-wait-timeout`: Timeout wating for VM start.
- `--xcp-os-template`: XCP template name for the new VM. - `--xenserver-os-template`: XenServer template name for the new VM.
- `--xcp-os-username`: Username used by docker-machine to SSH to the new VM. - `--xenserver-os-username`: Username used by docker-machine to SSH to the new VM.
- `--xcp-coreos-configdrive`: Whether to use a CoreOS ConfigDrive or (default) a generic one. - `--xenserver-coreos-configdrive`: Whether to use a CoreOS ConfigDrive or (default) a generic one.
# Environment variables and default values: # Environment variables and default values:
| CLI option | Environment variable | Default | | CLI option | Environment variable | Default |
|-----------------------------|--------------------------|------------------------------| |-----------------------------------|--------------------------------|------------------------------|
| `--xcp-vcpu-count` | `XCP_VCPU_COUNT` | `1` | | `--xenserver-vcpu-count` | `XENSERVER_VCPU_COUNT` | `1` |
| `--xcp-memory-size` | `XCP_MEMORY_SIZE` | `2048` | | `--xenserver-memory-size` | `XENSERVER_MEMORY_SIZE` | `2048` |
| `--xcp-disk-size` | `XCP_DISK_SIZE` | `5120` | | `--xenserver-disk-size` | `XENSERVER_DISK_SIZE` | `5120` |
| `--xcp-boot2docker-url` | `XCP_BOOT2DOCKER_URL` | *boot2docker URL* | | `--xenserver-boot2docker-url` | `XENSERVER_BOOT2DOCKER_URL` | *boot2docker URL* |
| `--xcp-server` | `XCP_SERVER` | - | | `--xenserver-server` | `XENSERVER_SERVER` | - |
| `--xcp-host-label` | `XCP_HOST_LABEL` | - | | `--xenserver-host-label` | `XENSERVER_HOST_LABEL` | - |
| **`--xcp-username`** | `XCP_USERNAME` | - | | **`--xenserver-username`** | `XENSERVER_USERNAME` | - |
| **`--xcp-password`** | `XCP_PASSWORD` | - | | **`--xenserver-password`** | `XENSERVER_PASSWORD` | - |
| `--xcp-network-label` | `XCP_NETWORK_LABEL` | - | | `--xenserver-network-label` | `XENSERVER_NETWORK_LABEL` | - |
| `--xcp-sr-label` | `XCP_SR_LABEL` | - | | `--xenserver-sr-label` | `XENSERVER_SR_LABEL` | - |
| `--xcp-upload-timeout` | `XCP_UPLOAD_TIMEOUT` | `300` | | `--xenserver-upload-timeout` | `XENSERVER_UPLOAD_TIMEOUT` | `300` |
| `--xcp-wait-timeout` | `XCP_WAIT_TIMEOUT` | `1800` | | `--xenserver-wait-timeout` | `XENSERVER_WAIT_TIMEOUT` | `1800` |
| `--xcp-os-template` | `XCP_OS_TEMPLATE` | `Other install media` | | `--xenserver-os-template` | `XENSERVER_OS_TEMPLATE` | `Other install media` |
| `--xcp-os-username` | `XCP_OS_USERNAME` | `docker` | | `--xenserver-os-username` | `XENSERVER_OS_USERNAME` | `docker` |
| `--xcp-coreos-configdrive` | `XCP_COREOS_CONFIGDRIVE` | `false` | | `--xenserver-coreos-configdrive` | `XENSERVER_COREOS_CONFIGDRIVE` | `false` |

4
docker-machine-driver-xcp.go → docker-machine-driver-xenserver.go

@ -4,9 +4,9 @@ package main
import ( import (
"github.com/docker/machine/libmachine/drivers/plugin" "github.com/docker/machine/libmachine/drivers/plugin"
"github.com/interlegis/docker-machine-driver-xcp/xcp" "git.interlegis.leg.br/SEIT/docker-machine-driver-xenserver/xenserver"
) )
func main() { func main() {
plugin.RegisterDriver(xcp.NewDriver()) plugin.RegisterDriver(xenserver.NewDriver())
} }

2
go.mod

@ -1,4 +1,4 @@
module github.com/interlegis/docker-machine-driver-xcp module github.com/interlegis/docker-machine-driver-xenserver
go 1.13 go 1.13

1
go.sum

@ -1,3 +1,4 @@
git.interlegis.leg.br/SEIT/docker-machine-driver-xenserver v0.2.0 h1:CywVfWWImxV51lxoVKzVIgQKKR8sj+IkjrYNhDKKqMM=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

2
xcp/xenapiclient.go → xenserver/xenapiclient.go

@ -1,5 +1,5 @@
//This file was modified from the original work, https://github.com/xenserver/docker-machine-driver-xenserver //This file was modified from the original work, https://github.com/xenserver/docker-machine-driver-xenserver
package xcp package xenserver
import ( import (
"crypto/tls" "crypto/tls"

128
xcp/xcp.go → xenserver/xenserver.go

@ -1,6 +1,6 @@
//This file was modified from the original work, https://github.com/xenserver/docker-machine-driver-xenserver //This file was modified from the original work, https://github.com/xenserver/docker-machine-driver-xenserver
package xcp package xenserver
import ( import (
"archive/tar" "archive/tar"
@ -70,86 +70,86 @@ type Driver struct {
func (d *Driver) GetCreateFlags() []mcnflag.Flag { func (d *Driver) GetCreateFlags() []mcnflag.Flag {
return []mcnflag.Flag{ return []mcnflag.Flag{
mcnflag.StringFlag{ mcnflag.StringFlag{
EnvVar: "XCP_SERVER", EnvVar: "XENSERVER_SERVER",
Name: "xcp-server", Name: "xenserver-server",
Usage: "XCP server hostname/IP for docker VM", Usage: "XENSERVER server hostname/IP for docker VM",
}, },
mcnflag.StringFlag{ mcnflag.StringFlag{
EnvVar: "XCP_USERNAME", EnvVar: "XENSERVER_USERNAME",
Name: "xcp-username", Name: "xenserver-username",
Usage: "XCP username", Usage: "XENSERVER username",
}, },
mcnflag.StringFlag{ mcnflag.StringFlag{
EnvVar: "XCP_PASSWORD", EnvVar: "XENSERVER_PASSWORD",
Name: "xcp-password", Name: "xenserver-password",
Usage: "XCP password", Usage: "XENSERVER password",
}, },
mcnflag.StringFlag{ mcnflag.StringFlag{
EnvVar: "XCP_BOOT2DOCKER_URL", EnvVar: "XENSERVER_BOOT2DOCKER_URL",
Name: "xcp-boot2docker-url", Name: "xenserver-boot2docker-url",
Usage: "XCP URL for boot2docker image", Usage: "XENSERVER URL for boot2docker image",
}, },
mcnflag.IntFlag{ mcnflag.IntFlag{
EnvVar: "XCP_VCPU_COUNT", EnvVar: "XENSERVER_VCPU_COUNT",
Name: "xcp-vcpu-count", Name: "xenserver-vcpu-count",
Usage: "XCP vCPU number for docker VM", Usage: "XENSERVER vCPU number for docker VM",
Value: 1, Value: 1,
}, },
mcnflag.IntFlag{ mcnflag.IntFlag{
EnvVar: "XCP_MEMORY_SIZE", EnvVar: "XENSERVER_MEMORY_SIZE",
Name: "xcp-memory-size", Name: "xenserver-memory-size",
Usage: "XCP size of memory for docker VM (in MB)", Usage: "XENSERVER size of memory for docker VM (in MB)",
Value: 1024, Value: 1024,
}, },
mcnflag.IntFlag{ mcnflag.IntFlag{
EnvVar: "XCP_DISK_SIZE", EnvVar: "XENSERVER_DISK_SIZE",
Name: "xcp-disk-size", Name: "xenserver-disk-size",
Usage: "XCP size of disk for docker VM (in MB)", Usage: "XENSERVER size of disk for docker VM (in MB)",
Value: 5120, Value: 5120,
}, },
mcnflag.StringFlag{ mcnflag.StringFlag{
EnvVar: "XCP_SR_LABEL", EnvVar: "XENSERVER_SR_LABEL",
Name: "xcp-sr-label", Name: "xenserver-sr-label",
Usage: "XCP SR label where the docker VM will be attached", Usage: "XENSERVER SR label where the docker VM will be attached",
}, },
mcnflag.StringFlag{ mcnflag.StringFlag{
EnvVar: "XCP_NETWORK_LABEL", EnvVar: "XENSERVER_NETWORK_LABEL",
Name: "xcp-network-label", Name: "xenserver-network-label",
Usage: "XCP network label where the docker VM will be attached", Usage: "XENSERVER network label where the docker VM will be attached",
}, },
mcnflag.StringFlag{ mcnflag.StringFlag{
EnvVar: "XCP_HOST_LABEL", EnvVar: "XENSERVER_HOST_LABEL",
Name: "xcp-host-label", Name: "xenserver-host-label",
Usage: "XCP host label where the docker VM will be run", Usage: "XENSERVER host label where the docker VM will be run",
}, },
mcnflag.IntFlag{ mcnflag.IntFlag{
EnvVar: "XCP_UPLOAD_TIMEOUT", EnvVar: "XENSERVER_UPLOAD_TIMEOUT",
Name: "xcp-upload-timeout", Name: "xenserver-upload-timeout",
Usage: "XCP upload VDI timeout(seconds)", Usage: "XENSERVER upload VDI timeout(seconds)",
Value: 5 * 60, Value: 5 * 60,
}, },
mcnflag.IntFlag{ mcnflag.IntFlag{
EnvVar: "XCP_WAIT_TIMEOUT", EnvVar: "XENSERVER_WAIT_TIMEOUT",
Name: "xcp-wait-timeout", Name: "xenserver-wait-timeout",
Usage: "XCP wait VM start timeout(seconds)", Usage: "XENSERVER wait VM start timeout(seconds)",
Value: 30 * 60, Value: 30 * 60,
}, },
mcnflag.StringFlag{ mcnflag.StringFlag{
EnvVar: "XCP_OS_TEMPLATE", EnvVar: "XENSERVER_OS_TEMPLATE",
Name: "xcp-os-template", Name: "xenserver-os-template",
Usage: "XCP OS Template Label Name", Usage: "XENSERVER OS Template Label Name",
Value: "Other install media", Value: "Other install media",
}, },
mcnflag.StringFlag{ mcnflag.StringFlag{
EnvVar: "XCP_OS_USERNAME", EnvVar: "XENSERVER_OS_USERNAME",
Name: "xcp-os-username", Name: "xenserver-os-username",
Usage: "XCP Username used to SSH into guest OS", Usage: "XENSERVER Username used to SSH into guest OS",
Value: B2D_USER, Value: B2D_USER,
}, },
mcnflag.BoolFlag{ mcnflag.BoolFlag{
EnvVar: "XCP_COREOS_CONFIGDRIVE", EnvVar: "XENSERVER_COREOS_CONFIGDRIVE",
Name: "xcp-coreos-configdrive", Name: "xenserver-coreos-configdrive",
Usage: "XCP Enable CoreOS specific ConfigDrive (requires xscontainer supplemental pack)", Usage: "XENSERVER Enable CoreOS specific ConfigDrive (requires xscontainer supplemental pack)",
}, },
} }
} }
@ -183,31 +183,31 @@ func (d *Driver) GetSSHUsername() string {
} }
func (d *Driver) DriverName() string { func (d *Driver) DriverName() string {
return "xcp" return "xenserver"
} }
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.SSHUser = flags.String("xcp-os-username") d.SSHUser = flags.String("xenserver-os-username")
d.SSHPort = 22 d.SSHPort = 22
d.Server = flags.String("xcp-server") d.Server = flags.String("xenserver-server")
d.Username = flags.String("xcp-username") d.Username = flags.String("xenserver-username")
d.Password = flags.String("xcp-password") d.Password = flags.String("xenserver-password")
d.Boot2DockerURL = flags.String("xcp-boot2docker-url") d.Boot2DockerURL = flags.String("xenserver-boot2docker-url")
d.CPU = uint(flags.Int("xcp-vcpu-count")) d.CPU = uint(flags.Int("xenserver-vcpu-count"))
d.Memory = uint(flags.Int("xcp-memory-size")) d.Memory = uint(flags.Int("xenserver-memory-size"))
d.DiskSize = uint(flags.Int("xcp-disk-size")) d.DiskSize = uint(flags.Int("xenserver-disk-size"))
d.SR = flags.String("xcp-sr-label") d.SR = flags.String("xenserver-sr-label")
d.Network = flags.String("xcp-network-label") d.Network = flags.String("xenserver-network-label")
d.Host = flags.String("xcp-host-label") d.Host = flags.String("xenserver-host-label")
d.UploadTimeout = uint(flags.Int("xcp-upload-timeout")) d.UploadTimeout = uint(flags.Int("xenserver-upload-timeout"))
d.WaitTimeout = uint(flags.Int("xcp-wait-timeout")) d.WaitTimeout = uint(flags.Int("xenserver-wait-timeout"))
d.SwarmMaster = flags.Bool("swarm-master") d.SwarmMaster = flags.Bool("swarm-master")
d.SwarmHost = flags.String("swarm-host") d.SwarmHost = flags.String("swarm-host")
d.SwarmDiscovery = flags.String("swarm-discovery") d.SwarmDiscovery = flags.String("swarm-discovery")
d.ISO = d.ResolveStorePath(isoFilename) d.ISO = d.ResolveStorePath(isoFilename)
d.TAR = d.ResolveStorePath(tarFilename) d.TAR = d.ResolveStorePath(tarFilename)
d.osTemplateLabelName = flags.String("xcp-os-template") d.osTemplateLabelName = flags.String("xenserver-os-template")
d.CoreosConfigDrive = flags.Bool("xcp-coreos-configdrive") d.CoreosConfigDrive = flags.Bool("xenserver-coreos-configdrive")
return nil return nil
} }
@ -355,7 +355,7 @@ func (d *Driver) Create() error {
if sr.Ref == "OpaqueRef:NULL" { if sr.Ref == "OpaqueRef:NULL" {
err := errors.New("No default SR found. Please configure a " + err := errors.New("No default SR found. Please configure a " +
"default or specify the SR explicitly using " + "default or specify the SR explicitly using " +
"--xcp-sr-label.") "--xenserver-sr-label.")
log.Errorf("%v", err) log.Errorf("%v", err)
return err return err
} }
@ -910,7 +910,7 @@ func (d *Driver) importVdi(vdi *xsclient.VDI, filename string, timeout time.Dura
if resp.StatusCode != 200 { if resp.StatusCode != 200 {
msg, _ := ioutil.ReadAll(resp.Body) msg, _ := ioutil.ReadAll(resp.Body)
err = fmt.Errorf("xcp reply %s: %v", resp.Status, string(msg)) err = fmt.Errorf("xenserver reply %s: %v", resp.Status, string(msg))
log.Errorf("Unable to upload VDI: %v", err) log.Errorf("Unable to upload VDI: %v", err)
return err return err
} }
Loading…
Cancel
Save