From 1e9416ea88ce3a1aae7630dae7b948825465cd69 Mon Sep 17 00:00:00 2001 From: Fabio Rauber Date: Wed, 5 Feb 2020 11:41:16 -0300 Subject: [PATCH] Renamed XCP to XenServer, for compatibility --- README.md | 76 +++++------ ...p.go => docker-machine-driver-xenserver.go | 4 +- go.mod | 2 +- go.sum | 1 + {xcp => xenserver}/xenapiclient.go | 2 +- xcp/xcp.go => xenserver/xenserver.go | 128 +++++++++--------- 6 files changed, 107 insertions(+), 106 deletions(-) rename docker-machine-driver-xcp.go => docker-machine-driver-xenserver.go (63%) rename {xcp => xenserver}/xenapiclient.go (99%) rename xcp/xcp.go => xenserver/xenserver.go (89%) diff --git a/README.md b/README.md index 1f329cc..bc214cf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# docker-machine-driver-xcp -This is the XCP-ng driver plugin for Docker Machine. It allows the -orchestration of machines on XCP-ng (all versions) and probably compatible with Citrix XenServer 6.5SP1 or later. +# docker-machine-driver-xenserver +This is the XENSERVER-ng driver plugin for Docker Machine, renamed to XenServer for compatibility with Rancher clusters +created with the old XenServer Driver. This work is derived from https://github.com/xenserver/docker-machine-driver-xenserver. @@ -16,53 +16,53 @@ The installation steps are: # Installation from source Following the installation of Golang and Docker Machine, you can install the -docker-machine-xcp-driver: +docker-machine-xenserver-driver: ```bash -go get github.com/interlegis/docker-machine-driver-xcp +go get github.com/interlegis/docker-machine-driver-xenserver ``` # Usage The usual Docker Machine commands apply: ```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 ``` # CLI Options: - - `--xcp-vcpu-count`: vCPU number for docker VM. - - `--xcp-memory-size`: Size of memory for Docker VM (in MB). - - `--xcp-boot2docker-url`: URL for boot2docker ISO image. - - `--xcp-server`: **required for create** XenServer hostname/IP for docker VM. - - `--xcp-disk-size`: Size of disk for Docker VM (in MB). - - `--xcp-username`: **required** XenServer Username. - - `--xcp-password`: **required** XenServer Password. - - `--xcp-network-label`: Network label where the docker VM will be attached - - `--xcp-sr-label`: SR label where the docker VM will be attached. - - `--xcp-host-label`: Host label where the docker VM will be run. - - `--xcp-upload-timeout`: Timeout uploading VDI. - - `--xcp-wait-timeout`: Timeout wating for VM start. - - `--xcp-os-template`: XCP template name for the new VM. - - `--xcp-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-vcpu-count`: vCPU number for docker VM. + - `--xenserver-memory-size`: Size of memory for Docker VM (in MB). + - `--xenserver-boot2docker-url`: URL for boot2docker ISO image. + - `--xenserver-server`: **required for create** XenServer hostname/IP for docker VM. + - `--xenserver-disk-size`: Size of disk for Docker VM (in MB). + - `--xenserver-username`: **required** XenServer Username. + - `--xenserver-password`: **required** XenServer Password. + - `--xenserver-network-label`: Network label where the docker VM will be attached + - `--xenserver-sr-label`: SR label where the docker VM will be attached. + - `--xenserver-host-label`: Host label where the docker VM will be run. + - `--xenserver-upload-timeout`: Timeout uploading VDI. + - `--xenserver-wait-timeout`: Timeout wating for VM start. + - `--xenserver-os-template`: XenServer template name for the new VM. + - `--xenserver-os-username`: Username used by docker-machine to SSH to the new VM. + - `--xenserver-coreos-configdrive`: Whether to use a CoreOS ConfigDrive or (default) a generic one. # Environment variables and default values: -| CLI option | Environment variable | Default | -|-----------------------------|--------------------------|------------------------------| -| `--xcp-vcpu-count` | `XCP_VCPU_COUNT` | `1` | -| `--xcp-memory-size` | `XCP_MEMORY_SIZE` | `2048` | -| `--xcp-disk-size` | `XCP_DISK_SIZE` | `5120` | -| `--xcp-boot2docker-url` | `XCP_BOOT2DOCKER_URL` | *boot2docker URL* | -| `--xcp-server` | `XCP_SERVER` | - | -| `--xcp-host-label` | `XCP_HOST_LABEL` | - | -| **`--xcp-username`** | `XCP_USERNAME` | - | -| **`--xcp-password`** | `XCP_PASSWORD` | - | -| `--xcp-network-label` | `XCP_NETWORK_LABEL` | - | -| `--xcp-sr-label` | `XCP_SR_LABEL` | - | -| `--xcp-upload-timeout` | `XCP_UPLOAD_TIMEOUT` | `300` | -| `--xcp-wait-timeout` | `XCP_WAIT_TIMEOUT` | `1800` | -| `--xcp-os-template` | `XCP_OS_TEMPLATE` | `Other install media` | -| `--xcp-os-username` | `XCP_OS_USERNAME` | `docker` | -| `--xcp-coreos-configdrive` | `XCP_COREOS_CONFIGDRIVE` | `false` | +| CLI option | Environment variable | Default | +|-----------------------------------|--------------------------------|------------------------------| +| `--xenserver-vcpu-count` | `XENSERVER_VCPU_COUNT` | `1` | +| `--xenserver-memory-size` | `XENSERVER_MEMORY_SIZE` | `2048` | +| `--xenserver-disk-size` | `XENSERVER_DISK_SIZE` | `5120` | +| `--xenserver-boot2docker-url` | `XENSERVER_BOOT2DOCKER_URL` | *boot2docker URL* | +| `--xenserver-server` | `XENSERVER_SERVER` | - | +| `--xenserver-host-label` | `XENSERVER_HOST_LABEL` | - | +| **`--xenserver-username`** | `XENSERVER_USERNAME` | - | +| **`--xenserver-password`** | `XENSERVER_PASSWORD` | - | +| `--xenserver-network-label` | `XENSERVER_NETWORK_LABEL` | - | +| `--xenserver-sr-label` | `XENSERVER_SR_LABEL` | - | +| `--xenserver-upload-timeout` | `XENSERVER_UPLOAD_TIMEOUT` | `300` | +| `--xenserver-wait-timeout` | `XENSERVER_WAIT_TIMEOUT` | `1800` | +| `--xenserver-os-template` | `XENSERVER_OS_TEMPLATE` | `Other install media` | +| `--xenserver-os-username` | `XENSERVER_OS_USERNAME` | `docker` | +| `--xenserver-coreos-configdrive` | `XENSERVER_COREOS_CONFIGDRIVE` | `false` | diff --git a/docker-machine-driver-xcp.go b/docker-machine-driver-xenserver.go similarity index 63% rename from docker-machine-driver-xcp.go rename to docker-machine-driver-xenserver.go index d2de878..245cc7c 100644 --- a/docker-machine-driver-xcp.go +++ b/docker-machine-driver-xenserver.go @@ -4,9 +4,9 @@ package main import ( "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() { - plugin.RegisterDriver(xcp.NewDriver()) + plugin.RegisterDriver(xenserver.NewDriver()) } diff --git a/go.mod b/go.mod index ca59cb8..48aa30d 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index 8575210..55712bf 100644 --- a/go.sum +++ b/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/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/xcp/xenapiclient.go b/xenserver/xenapiclient.go similarity index 99% rename from xcp/xenapiclient.go rename to xenserver/xenapiclient.go index 2bd4472..ab8f03d 100644 --- a/xcp/xenapiclient.go +++ b/xenserver/xenapiclient.go @@ -1,5 +1,5 @@ //This file was modified from the original work, https://github.com/xenserver/docker-machine-driver-xenserver -package xcp +package xenserver import ( "crypto/tls" diff --git a/xcp/xcp.go b/xenserver/xenserver.go similarity index 89% rename from xcp/xcp.go rename to xenserver/xenserver.go index 9a538cf..c8505db 100644 --- a/xcp/xcp.go +++ b/xenserver/xenserver.go @@ -1,6 +1,6 @@ //This file was modified from the original work, https://github.com/xenserver/docker-machine-driver-xenserver -package xcp +package xenserver import ( "archive/tar" @@ -70,86 +70,86 @@ type Driver struct { func (d *Driver) GetCreateFlags() []mcnflag.Flag { return []mcnflag.Flag{ mcnflag.StringFlag{ - EnvVar: "XCP_SERVER", - Name: "xcp-server", - Usage: "XCP server hostname/IP for docker VM", + EnvVar: "XENSERVER_SERVER", + Name: "xenserver-server", + Usage: "XENSERVER server hostname/IP for docker VM", }, mcnflag.StringFlag{ - EnvVar: "XCP_USERNAME", - Name: "xcp-username", - Usage: "XCP username", + EnvVar: "XENSERVER_USERNAME", + Name: "xenserver-username", + Usage: "XENSERVER username", }, mcnflag.StringFlag{ - EnvVar: "XCP_PASSWORD", - Name: "xcp-password", - Usage: "XCP password", + EnvVar: "XENSERVER_PASSWORD", + Name: "xenserver-password", + Usage: "XENSERVER password", }, mcnflag.StringFlag{ - EnvVar: "XCP_BOOT2DOCKER_URL", - Name: "xcp-boot2docker-url", - Usage: "XCP URL for boot2docker image", + EnvVar: "XENSERVER_BOOT2DOCKER_URL", + Name: "xenserver-boot2docker-url", + Usage: "XENSERVER URL for boot2docker image", }, mcnflag.IntFlag{ - EnvVar: "XCP_VCPU_COUNT", - Name: "xcp-vcpu-count", - Usage: "XCP vCPU number for docker VM", + EnvVar: "XENSERVER_VCPU_COUNT", + Name: "xenserver-vcpu-count", + Usage: "XENSERVER vCPU number for docker VM", Value: 1, }, mcnflag.IntFlag{ - EnvVar: "XCP_MEMORY_SIZE", - Name: "xcp-memory-size", - Usage: "XCP size of memory for docker VM (in MB)", + EnvVar: "XENSERVER_MEMORY_SIZE", + Name: "xenserver-memory-size", + Usage: "XENSERVER size of memory for docker VM (in MB)", Value: 1024, }, mcnflag.IntFlag{ - EnvVar: "XCP_DISK_SIZE", - Name: "xcp-disk-size", - Usage: "XCP size of disk for docker VM (in MB)", + EnvVar: "XENSERVER_DISK_SIZE", + Name: "xenserver-disk-size", + Usage: "XENSERVER size of disk for docker VM (in MB)", Value: 5120, }, mcnflag.StringFlag{ - EnvVar: "XCP_SR_LABEL", - Name: "xcp-sr-label", - Usage: "XCP SR label where the docker VM will be attached", + EnvVar: "XENSERVER_SR_LABEL", + Name: "xenserver-sr-label", + Usage: "XENSERVER SR label where the docker VM will be attached", }, mcnflag.StringFlag{ - EnvVar: "XCP_NETWORK_LABEL", - Name: "xcp-network-label", - Usage: "XCP network label where the docker VM will be attached", + EnvVar: "XENSERVER_NETWORK_LABEL", + Name: "xenserver-network-label", + Usage: "XENSERVER network label where the docker VM will be attached", }, mcnflag.StringFlag{ - EnvVar: "XCP_HOST_LABEL", - Name: "xcp-host-label", - Usage: "XCP host label where the docker VM will be run", + EnvVar: "XENSERVER_HOST_LABEL", + Name: "xenserver-host-label", + Usage: "XENSERVER host label where the docker VM will be run", }, mcnflag.IntFlag{ - EnvVar: "XCP_UPLOAD_TIMEOUT", - Name: "xcp-upload-timeout", - Usage: "XCP upload VDI timeout(seconds)", + EnvVar: "XENSERVER_UPLOAD_TIMEOUT", + Name: "xenserver-upload-timeout", + Usage: "XENSERVER upload VDI timeout(seconds)", Value: 5 * 60, }, mcnflag.IntFlag{ - EnvVar: "XCP_WAIT_TIMEOUT", - Name: "xcp-wait-timeout", - Usage: "XCP wait VM start timeout(seconds)", + EnvVar: "XENSERVER_WAIT_TIMEOUT", + Name: "xenserver-wait-timeout", + Usage: "XENSERVER wait VM start timeout(seconds)", Value: 30 * 60, }, mcnflag.StringFlag{ - EnvVar: "XCP_OS_TEMPLATE", - Name: "xcp-os-template", - Usage: "XCP OS Template Label Name", + EnvVar: "XENSERVER_OS_TEMPLATE", + Name: "xenserver-os-template", + Usage: "XENSERVER OS Template Label Name", Value: "Other install media", }, mcnflag.StringFlag{ - EnvVar: "XCP_OS_USERNAME", - Name: "xcp-os-username", - Usage: "XCP Username used to SSH into guest OS", + EnvVar: "XENSERVER_OS_USERNAME", + Name: "xenserver-os-username", + Usage: "XENSERVER Username used to SSH into guest OS", Value: B2D_USER, }, mcnflag.BoolFlag{ - EnvVar: "XCP_COREOS_CONFIGDRIVE", - Name: "xcp-coreos-configdrive", - Usage: "XCP Enable CoreOS specific ConfigDrive (requires xscontainer supplemental pack)", + EnvVar: "XENSERVER_COREOS_CONFIGDRIVE", + Name: "xenserver-coreos-configdrive", + Usage: "XENSERVER Enable CoreOS specific ConfigDrive (requires xscontainer supplemental pack)", }, } } @@ -183,31 +183,31 @@ func (d *Driver) GetSSHUsername() string { } func (d *Driver) DriverName() string { - return "xcp" + return "xenserver" } 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.Server = flags.String("xcp-server") - d.Username = flags.String("xcp-username") - d.Password = flags.String("xcp-password") - d.Boot2DockerURL = flags.String("xcp-boot2docker-url") - d.CPU = uint(flags.Int("xcp-vcpu-count")) - d.Memory = uint(flags.Int("xcp-memory-size")) - d.DiskSize = uint(flags.Int("xcp-disk-size")) - d.SR = flags.String("xcp-sr-label") - d.Network = flags.String("xcp-network-label") - d.Host = flags.String("xcp-host-label") - d.UploadTimeout = uint(flags.Int("xcp-upload-timeout")) - d.WaitTimeout = uint(flags.Int("xcp-wait-timeout")) + d.Server = flags.String("xenserver-server") + d.Username = flags.String("xenserver-username") + d.Password = flags.String("xenserver-password") + d.Boot2DockerURL = flags.String("xenserver-boot2docker-url") + d.CPU = uint(flags.Int("xenserver-vcpu-count")) + d.Memory = uint(flags.Int("xenserver-memory-size")) + d.DiskSize = uint(flags.Int("xenserver-disk-size")) + d.SR = flags.String("xenserver-sr-label") + d.Network = flags.String("xenserver-network-label") + d.Host = flags.String("xenserver-host-label") + d.UploadTimeout = uint(flags.Int("xenserver-upload-timeout")) + d.WaitTimeout = uint(flags.Int("xenserver-wait-timeout")) d.SwarmMaster = flags.Bool("swarm-master") d.SwarmHost = flags.String("swarm-host") d.SwarmDiscovery = flags.String("swarm-discovery") d.ISO = d.ResolveStorePath(isoFilename) d.TAR = d.ResolveStorePath(tarFilename) - d.osTemplateLabelName = flags.String("xcp-os-template") - d.CoreosConfigDrive = flags.Bool("xcp-coreos-configdrive") + d.osTemplateLabelName = flags.String("xenserver-os-template") + d.CoreosConfigDrive = flags.Bool("xenserver-coreos-configdrive") return nil } @@ -355,7 +355,7 @@ func (d *Driver) Create() error { if sr.Ref == "OpaqueRef:NULL" { err := errors.New("No default SR found. Please configure a " + "default or specify the SR explicitly using " + - "--xcp-sr-label.") + "--xenserver-sr-label.") log.Errorf("%v", err) return err } @@ -910,7 +910,7 @@ func (d *Driver) importVdi(vdi *xsclient.VDI, filename string, timeout time.Dura if resp.StatusCode != 200 { 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) return err }