|
|
@ -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 |
|
|
|
} |