From eb241bb0f0ba3cad775d1798c06cfac75969e06d Mon Sep 17 00:00:00 2001 From: Fabio Rauber Date: Tue, 4 Feb 2020 10:47:40 -0300 Subject: [PATCH] First version of docker-machine-driver-xcp --- Makefile | 28 +- README.md | 83 +++--- docker-machine-driver-xcp.go | 12 + docker-machine-driver-xenserver.go | 10 - .../build-docker-machine-driver-xenserver.sh | 8 +- xenserver/xenserver.go => xcp/xcp.go | 254 +++++++++--------- {xenserver => xcp}/xenapiclient.go | 3 +- 7 files changed, 208 insertions(+), 190 deletions(-) create mode 100644 docker-machine-driver-xcp.go delete mode 100644 docker-machine-driver-xenserver.go rename xenserver/xenserver.go => xcp/xcp.go (79%) rename {xenserver => xcp}/xenapiclient.go (95%) diff --git a/Makefile b/Makefile index bb7e411..f4b9cd5 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +#This file was modified from the original work, https://github.com/xenserver/docker-machine-driver-xenserver + .PHONY: build build: go get ./... @@ -9,13 +11,13 @@ build: .PHONY: clean clean: - rm -f docker-machine-driver-xenserver \ - docker-machine-driver-xenserver_darwin-386.tar.gz \ - docker-machine-driver-xenserver_darwin-amd64.tar.gz \ - docker-machine-driver-xenserver_linux-386.tar.gz \ - docker-machine-driver-xenserver_linux-amd64.tar.gz \ - docker-machine-driver-xenserver_windows-386.zip \ - docker-machine-driver-xenserver_windows-amd64.zip + rm -f docker-machine-driver-xcp \ + docker-machine-driver-xcp_darwin-386.tar.gz \ + docker-machine-driver-xcp_darwin-amd64.tar.gz \ + docker-machine-driver-xcp_linux-386.tar.gz \ + docker-machine-driver-xcp_linux-amd64.tar.gz \ + docker-machine-driver-xcp_windows-386.zip \ + docker-machine-driver-xcp_windows-amd64.zip .PHONY: release release: @@ -23,14 +25,14 @@ release: # Unix for arch in 386 amd64 ; do \ for os in darwin linux ; do \ - GOOS=$$os GOARCH=$$arch go build -o docker-machine-driver-xenserver; \ - tar -cvzf docker-machine-driver-xenserver_$$os-$$arch.tar.gz docker-machine-driver-xenserver; \ - rm -f docker-machine-driver-xenserver; \ + GOOS=$$os GOARCH=$$arch go build -o docker-machine-driver-xcp; \ + tar -cvzf docker-machine-driver-xcp_$$os-$$arch.tar.gz docker-machine-driver-xcp; \ + rm -f docker-machine-driver-xcp; \ done \ done # Windows for arch in 386 amd64 ; do \ - GOOS=windows GOARCH=$$arch go build -o docker-machine-driver-xenserver.exe; \ - zip docker-machine-driver-xenserver_windows-$$arch.zip docker-machine-driver-xenserver.exe; \ - rm -f docker-machine-driver-xenserver; \ + GOOS=windows GOARCH=$$arch go build -o docker-machine-driver-xcp.exe; \ + zip docker-machine-driver-xcp_windows-$$arch.zip docker-machine-driver-xcp.exe; \ + rm -f docker-machine-driver-xcp; \ done diff --git a/README.md b/README.md index cec89f9..9b944f6 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,69 @@ -[![Build Status](https://travis-ci.org/xenserver/docker-machine-driver-xenserver.svg?branch=master)](https://travis-ci.org/xenserver/docker-machine-driver-xenserver) +# 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 driver plugin for Docker Machine. It allows the -orchestration of machines on Citrix XenServer 6.5SP1 and later. +This work is derived from https://github.com/xenserver/docker-machine-driver-xenserver. # Installation from binary -Please refer to the -[documentation for a release](https://github.com/xenserver/docker-machine-driver-xenserver/releases). + +The installation steps are: + +1. If not done already - download the Docker Machine binary for your OS and architecture +2. If not done already - move the binary to your PATH. +3. Download the driver archive for your OS and architecture. +4. Extract the archive +5. Move the driver binary to your PATH, so it can be found by docker-machine. + # Installation from source Following the installation of Golang and Docker Machine, you can install the -docker-machine-xenserver-driver: +docker-machine-xcp-driver: ```bash -go get github.com/xenserver/docker-machine-driver-xenserver +go get github.com/interlegis/docker-machine-driver-xcp ``` # Usage The usual Docker Machine commands apply: ```bash -docker-machine create -d xenserver --xenserver-server myip --xenserver-username myusername --xenserver-password mypassword mynewmmachine +docker-machine create -d xcp --xcp-server myip --xcp-username myusername --xcp-password mypassword mynewmmachine docker-machine env mynewmmachine ``` # CLI Options: - - `--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. + - `--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. # Environment variables and default values: -| 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` | +| 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` | diff --git a/docker-machine-driver-xcp.go b/docker-machine-driver-xcp.go new file mode 100644 index 0000000..d2de878 --- /dev/null +++ b/docker-machine-driver-xcp.go @@ -0,0 +1,12 @@ +//This file was modified from the original work, https://github.com/xenserver/docker-machine-driver-xenserver + +package main + +import ( + "github.com/docker/machine/libmachine/drivers/plugin" + "github.com/interlegis/docker-machine-driver-xcp/xcp" +) + +func main() { + plugin.RegisterDriver(xcp.NewDriver()) +} diff --git a/docker-machine-driver-xenserver.go b/docker-machine-driver-xenserver.go deleted file mode 100644 index 464cff3..0000000 --- a/docker-machine-driver-xenserver.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -import ( - "github.com/docker/machine/libmachine/drivers/plugin" - "github.com/interlegis/docker-machine-driver-xenserver/xenserver" -) - -func main() { - plugin.RegisterDriver(xenserver.NewDriver()) -} diff --git a/patches/build-docker-machine-driver-xenserver.sh b/patches/build-docker-machine-driver-xenserver.sh index 90ca05d..e341aff 100644 --- a/patches/build-docker-machine-driver-xenserver.sh +++ b/patches/build-docker-machine-driver-xenserver.sh @@ -1,7 +1,7 @@ #!/bin/bash -export GITHUB_USER=${GITHUB_USER:-xenserver} -export GITHUB_REPO=${GITHUB_REPO:-docker-machine-driver-xenserver} +export GITHUB_USER=${GITHUB_USER:-xcp} +export GITHUB_REPO=${GITHUB_REPO:-docker-machine-driver-xcp} export GITHUB_COMMIT_ID=${TRAVIS_COMMIT:-${COMMIT_ID:-master}} export WORKING_DIR=/tmp/tmp.$(date "+%Y%m%d%H%M%S").${RANDOM:-$$}.${GITHUB_REPO} export GOROOT_BOOTSTRAP=${WORKING_DIR}/go1.6 @@ -43,8 +43,8 @@ function release_repo() { pushd ${WORKING_DIR} if [ -d "${WORKSPACE}" ]; then - local FILENAME=docker-machine-driver-xenserver_$(go env GOOS)-$(go env GOARCH) - cp -rf $GOPATH/bin/docker-machine-driver-xenserver ${WORKSPACE}/${FILENAME} + local FILENAME=docker-machine-driver-xcp_$(go env GOOS)-$(go env GOARCH) + cp -rf $GOPATH/bin/docker-machine-driver-xcp ${WORKSPACE}/${FILENAME} fi popd diff --git a/xenserver/xenserver.go b/xcp/xcp.go similarity index 79% rename from xenserver/xenserver.go rename to xcp/xcp.go index 236f367..c377467 100644 --- a/xenserver/xenserver.go +++ b/xcp/xcp.go @@ -1,4 +1,6 @@ -package xenserver +//This file was modified from the original work, https://github.com/xenserver/docker-machine-driver-xenserver + +package xcp import ( "archive/tar" @@ -23,16 +25,15 @@ import ( "github.com/docker/machine/libmachine/ssh" "github.com/docker/machine/libmachine/state" "github.com/nilshell/xmlrpc" - "golang.org/x/net/context" - xsclient "github.com/xenserver/go-xenserver-client" + "golang.org/x/net/context" ) const ( - isoFilename = "boot2docker.iso" - tarFilename = "boot2docker.tar" - B2D_USER = "docker" - B2D_PASS = "tcuser" + isoFilename = "boot2docker.iso" + tarFilename = "boot2docker.tar" + B2D_USER = "docker" + B2D_PASS = "tcuser" ) type Driver struct { @@ -65,88 +66,87 @@ type Driver struct { func (d *Driver) GetCreateFlags() []mcnflag.Flag { return []mcnflag.Flag{ mcnflag.StringFlag{ - EnvVar: "XENSERVER_SERVER", - Name: "xenserver-server", - Usage: "XenServer server hostname/IP for docker VM", + EnvVar: "XCP_SERVER", + Name: "xcp-server", + Usage: "XCP server hostname/IP for docker VM", }, mcnflag.StringFlag{ - EnvVar: "XENSERVER_USERNAME", - Name: "xenserver-username", - Usage: "XenServer username", + EnvVar: "XCP_USERNAME", + Name: "xcp-username", + Usage: "XCP username", }, mcnflag.StringFlag{ - EnvVar: "XENSERVER_PASSWORD", - Name: "xenserver-password", - Usage: "XenServer password", + EnvVar: "XCP_PASSWORD", + Name: "xcp-password", + Usage: "XCP password", }, mcnflag.StringFlag{ - EnvVar: "XENSERVER_BOOT2DOCKER_URL", - Name: "xenserver-boot2docker-url", - Usage: "XenServer URL for boot2docker image", + EnvVar: "XCP_BOOT2DOCKER_URL", + Name: "xcp-boot2docker-url", + Usage: "XCP URL for boot2docker image", }, mcnflag.IntFlag{ - EnvVar: "XENSERVER_VCPU_COUNT", - Name: "xenserver-vcpu-count", - Usage: "XenServer vCPU number for docker VM", + EnvVar: "XCP_VCPU_COUNT", + Name: "xcp-vcpu-count", + Usage: "XCP vCPU number for docker VM", Value: 1, }, mcnflag.IntFlag{ - EnvVar: "XENSERVER_MEMORY_SIZE", - Name: "xenserver-memory-size", - Usage: "XenServer size of memory for docker VM (in MB)", + EnvVar: "XCP_MEMORY_SIZE", + Name: "xcp-memory-size", + Usage: "XCP size of memory for docker VM (in MB)", Value: 1024, }, mcnflag.IntFlag{ - EnvVar: "XENSERVER_DISK_SIZE", - Name: "xenserver-disk-size", - Usage: "XenServer size of disk for docker VM (in MB)", + EnvVar: "XCP_DISK_SIZE", + Name: "xcp-disk-size", + Usage: "XCP size of disk for docker VM (in MB)", Value: 5120, }, mcnflag.StringFlag{ - EnvVar: "XENSERVER_SR_LABEL", - Name: "xenserver-sr-label", - Usage: "XenServer SR label where the docker VM will be attached", + EnvVar: "XCP_SR_LABEL", + Name: "xcp-sr-label", + Usage: "XCP SR label where the docker VM will be attached", }, mcnflag.StringFlag{ - EnvVar: "XENSERVER_NETWORK_LABEL", - Name: "xenserver-network-label", - Usage: "XenServer network label where the docker VM will be attached", + EnvVar: "XCP_NETWORK_LABEL", + Name: "xcp-network-label", + Usage: "XCP network label where the docker VM will be attached", }, mcnflag.StringFlag{ - EnvVar: "XENSERVER_HOST_LABEL", - Name: "xenserver-host-label", - Usage: "XenServer host label where the docker VM will be run", + EnvVar: "XCP_HOST_LABEL", + Name: "xcp-host-label", + Usage: "XCP host label where the docker VM will be run", }, mcnflag.IntFlag{ - EnvVar: "XENSERVER_UPLOAD_TIMEOUT", - Name: "xenserver-upload-timeout", - Usage: "XenServer upload VDI timeout(seconds)", + EnvVar: "XCP_UPLOAD_TIMEOUT", + Name: "xcp-upload-timeout", + Usage: "XCP upload VDI timeout(seconds)", Value: 5 * 60, }, mcnflag.IntFlag{ - EnvVar: "XENSERVER_WAIT_TIMEOUT", - Name: "xenserver-wait-timeout", - Usage: "XenServer wait VM start timeout(seconds)", + EnvVar: "XCP_WAIT_TIMEOUT", + Name: "xcp-wait-timeout", + Usage: "XCP wait VM start timeout(seconds)", Value: 30 * 60, }, - mcnflag.StringFlag{ - EnvVar: "XENSERVER_OS_TEMPLATE", - Name: "xenserver-os-template", - Usage: "XenServer OS Template Label Name", + mcnflag.StringFlag{ + EnvVar: "XCP_OS_TEMPLATE", + Name: "xcp-os-template", + Usage: "XCP OS Template Label Name", Value: "Other install media", - }, - mcnflag.StringFlag{ - EnvVar: "XENSERVER_OS_USERNAME", - Name: "xenserver-os-username", - Usage: "XenServer Username used to SSH into guest OS", - Value: B2D_USER, - }, - mcnflag.BoolFlag{ - EnvVar: "XENSERVER_COREOS_CONFIGDRIVE", - Name: "xenserver-coreos-configdrive", - Usage: "XenServer Enable CoreOS specific ConfigDrive (requires xscontainer supplemental pack)", - }, - + }, + mcnflag.StringFlag{ + EnvVar: "XCP_OS_USERNAME", + Name: "xcp-os-username", + Usage: "XCP 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)", + }, } } @@ -179,31 +179,31 @@ func (d *Driver) GetSSHUsername() string { } func (d *Driver) DriverName() string { - return "xenserver" + return "xcp" } func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { - d.SSHUser = flags.String("xenserver-os-username") + d.SSHUser = flags.String("xcp-os-username") d.SSHPort = 22 - 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.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.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("xenserver-os-template") - d.CoreosConfigDrive = flags.Bool("xenserver-coreos-configdrive") + d.osTemplateLabelName = flags.String("xcp-os-template") + d.CoreosConfigDrive = flags.Bool("xcp-coreos-configdrive") return nil } @@ -343,24 +343,24 @@ func (d *Driver) Create() error { // Only upload ISO image if using Other install media, otherwise use existing VM template var sr *xsclient.SR - var isoVdiUuid,diskVdiUuid string + var isoVdiUuid, diskVdiUuid string - // Get the SR - if d.SR == "" { + // Get the SR + if d.SR == "" { sr, err = c.GetDefaultSR() if sr.Ref == "OpaqueRef:NULL" { err := errors.New("No default SR found. Please configure a " + - "default or specify the SR explicitly using " + - "--xenserver-sr-label.") + "default or specify the SR explicitly using " + + "--xcp-sr-label.") log.Errorf("%v", err) - return err - } - } else { + return err + } + } else { sr, err = c.GetUniqueSRByNameLabel(d.SR) - } - if err != nil { + } + if err != nil { return err - } + } if d.osTemplateLabelName == "Other install media" { @@ -514,30 +514,30 @@ func (d *Driver) Create() error { return err } } else { - pubKey, err := ioutil.ReadFile(d.publicSSHKeyPath()) - if err != nil { - return err - } + pubKey, err := ioutil.ReadFile(d.publicSSHKeyPath()) + if err != nil { + return err + } vmUuid, err := vm.GetUuid() - if err != nil { - return err - } - srUuid,err := sr.GetUuid() - if err != nil { - return err - } - - if d.CoreosConfigDrive { - err := d.createCoreOSConfigDrive(pubKey, vmUuid, srUuid) - if err != nil { - return err - } - } else { - log.Infof("Creating Config Drive...") - isoVdiUuid, err := d.createGenericConfigDrive(pubKey, vmUuid, sr) - if err != nil { - return err - } + if err != nil { + return err + } + srUuid, err := sr.GetUuid() + if err != nil { + return err + } + + if d.CoreosConfigDrive { + err := d.createCoreOSConfigDrive(pubKey, vmUuid, srUuid) + if err != nil { + return err + } + } else { + log.Infof("Creating Config Drive...") + isoVdiUuid, err := d.createGenericConfigDrive(pubKey, vmUuid, sr) + if err != nil { + return err + } log.Infof("Add ConfigDrive ISO VDI to VM...") diskVdi, err := c.GetVdiByUuid(isoVdiUuid) @@ -906,7 +906,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("xenserver reply %s: %v", resp.Status, string(msg)) + err = fmt.Errorf("xcp reply %s: %v", resp.Status, string(msg)) log.Errorf("Unable to upload VDI: %v", err) return err } @@ -999,13 +999,13 @@ ssh_authorized_keys: if err != nil { log.Errorf("Could not retrieve hosts in the pool: %s", err) return err - } - ahost := hosts[0] - args := make(map[string]string) - args["vmuuid"] = vmuuid - args["sruuid"] = sruuid - args["configuration"] = userdatatext - ahost.CallPlugin("xscontainer","create_config_drive",args) + } + ahost := hosts[0] + args := make(map[string]string) + args["vmuuid"] = vmuuid + args["sruuid"] = sruuid + args["configuration"] = userdatatext + ahost.CallPlugin("xscontainer", "create_config_drive", args) return nil } @@ -1015,20 +1015,20 @@ func (d *Driver) createGenericConfigDrive(pubKey []byte, vmUuid string, sr *xscl ssh_authorized_keys: - ` + string(pubKey) - metadatatext := `{ "uuid": "` + vmUuid + `"}` + metadatatext := `{ "uuid": "` + vmUuid + `"}` - tempDir := d.ResolveStorePath("configdrive") + tempDir := d.ResolveStorePath("configdrive") - //Create the folder structure inside the temp folder - path := filepath.Join(tempDir, "openstack", "latest") - os.MkdirAll(path, os.ModePerm) - f, err := os.OpenFile(filepath.Join(path, "user_data"), os.O_WRONLY|os.O_CREATE, 0666) - if err != nil { + //Create the folder structure inside the temp folder + path := filepath.Join(tempDir, "openstack", "latest") + os.MkdirAll(path, os.ModePerm) + f, err := os.OpenFile(filepath.Join(path, "user_data"), os.O_WRONLY|os.O_CREATE, 0666) + if err != nil { log.Errorf("Unable to open user_data config drive file '%s': %v", path, err) return "", err } - io.WriteString(f, userdatatext) - f.Close() + io.WriteString(f, userdatatext) + f.Close() fmetadata, err := os.OpenFile(filepath.Join(path, "meta_data.json"), os.O_WRONLY|os.O_CREATE, 0666) if err != nil { diff --git a/xenserver/xenapiclient.go b/xcp/xenapiclient.go similarity index 95% rename from xenserver/xenapiclient.go rename to xcp/xenapiclient.go index e8e06e4..2bd4472 100644 --- a/xenserver/xenapiclient.go +++ b/xcp/xenapiclient.go @@ -1,4 +1,5 @@ -package xenserver +//This file was modified from the original work, https://github.com/xenserver/docker-machine-driver-xenserver +package xcp import ( "crypto/tls"