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