Skip to content

Commit aa70338

Browse files
authored
Merge pull request #13 from tmuskal/development/v1.0
Added: parameters for customizing target machine's spec (cpu & memory)
2 parents cddfb5b + 0648d78 commit aa70338

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ docker-machine create --driver ddcloud \
2121
--ddcloud-networkdomain 'my-docker-domain' \
2222
--ddcloud-vlan 'my-docker-vlan' \
2323
--ddcloud-ssh-key ~/.ssh/id_rsa \
24+
--ddcloud-memorygb 8 \
25+
--ddcloud-cpucount 4 \
26+
--ddcloud-corespersocket 4 \
2427
--ddcloud-ssh-bootstrap-password 'throw-away-password' \
2528
mydockermachine
2629
```
@@ -40,6 +43,9 @@ Environment: `MCP_REGION`.
4043
* `ddcloud-networkdomain` - The name of the target CloudControl network domain.
4144
* `ddcloud-datacenter` - The name of the CloudControl datacenter (e.g. NA1, AU9) in which the network domain is located.
4245
* `ddcloud-vlan` - The name of the target CloudControl VLAN.
46+
* `ddcloud-memorygb` - The amount of RAM in GB for the target machine. (Default 4GB)
47+
* `ddcloud-cpucount` - The amount of CPUs for the target machine. (Default: 2)
48+
* `ddcloud-corespersocket` - The amount of cores per socket for the target machine. (Default: 2)
4349
* `ddcloud-image-name` - The name of the image used to create the target machine.
4450
Additionally, the OS must be a Linux distribution supported by docker-machine (Ubuntu 12.04 and above are supported, but RedHat 6 and 7 are not supported due to iptables configuration issues).
4551
* `ddcloud-ssh-user` - The SSH username to use.

client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,14 @@ func (driver *Driver) buildDeploymentConfiguration() (deploymentConfiguration co
332332

333333
Start: true,
334334
}
335+
335336
image.ApplyTo(&deploymentConfiguration)
336337

338+
// Customise memory and / or CPU (if required).
339+
deploymentConfiguration.MemoryGB = driver.MemoryGB
340+
deploymentConfiguration.CPU.Count = driver.CPUCount
341+
deploymentConfiguration.CPU.CoresPerSocket = driver.CoresPerSocket
342+
337343
return
338344
}
339345

driver.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ type Driver struct {
102102
// The client's public (external) IP address.
103103
ClientPublicIPAddress string
104104

105+
// The amount of RAM in GB for the target machine
106+
MemoryGB int
107+
// The amount of CPUs for the target machine
108+
CPUCount int
109+
// The amount of cores per socket for the target machine.
110+
CoresPerSocket int
111+
105112
// The CloudControl API client.
106113
client *compute.Client
107114
}
@@ -201,6 +208,21 @@ func (driver *Driver) GetCreateFlags() []mcnflag.Flag {
201208
Name: "ddcloud-use-private-ip",
202209
Usage: "Don't create NAT and firewall rules for target server (you will need to be connected to the VPN for your target data centre). Default: false",
203210
},
211+
mcnflag.IntFlag{
212+
Name: "ddcloud-memorygb",
213+
Usage: "The amount of RAM in GB for the target machine. Default: 4",
214+
Value: 4,
215+
},
216+
mcnflag.IntFlag{
217+
Name: "ddcloud-cpucount",
218+
Usage: "The amount of CPUs for the target machine. Default: 2",
219+
Value: 2,
220+
},
221+
mcnflag.IntFlag{
222+
Name: "ddcloud-corespersocket",
223+
Usage: "The amount of cores per socket for the target machine. Default: 2",
224+
Value: 2,
225+
},
204226
}
205227
}
206228

@@ -234,6 +256,10 @@ func (driver *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
234256
driver.ClientPublicIPAddress = flags.String("ddcloud-client-public-ip")
235257
driver.UsePrivateIP = flags.Bool("ddcloud-use-private-ip")
236258

259+
driver.MemoryGB = flags.Int("ddcloud-memorygb")
260+
driver.CPUCount = flags.Int("ddcloud-cpucount")
261+
driver.CoresPerSocket = flags.Int("ddcloud-corespersocket")
262+
237263
log.Debugf("docker-machine-driver-ddcloud %s", DriverVersion)
238264

239265
return nil

0 commit comments

Comments
 (0)