From 5a93e26d5dbfbf41ab03552edf553a177d8d7fa4 Mon Sep 17 00:00:00 2001 From: Christophe Jauffret Date: Fri, 3 Jun 2022 19:01:34 +0200 Subject: [PATCH] add serialport feature (#25) --- README.md | 39 ++++++++++++++++++++------------------- machine/driver/driver.go | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 3db5e76..a424635 100755 --- a/README.md +++ b/README.md @@ -56,25 +56,26 @@ If you want to use Nutanix Node Driver, you need add it in order to start using Driver Args ----------- -|Arg |Description |Required |Default | -|------------------------------|:------------------------------------------------------------------------|:-----------------|--------| -| `nutanix-endpoint` |The hostname/ip-address of the Prism Central |yes || -| `nutanix-port` |The port to connect to Prism Central |no |9440 -| `nutanix-username` |The username of the nutanix management account |yes || -| `nutanix-password` |The password of the nutanix management account |yes || -| `nutanix-insecure` |Set to true to force SSL insecure connection |no |false| -| `nutanix-cluster` |The name of the cluster where deploy the VM (case sensitive) |yes || -| `nutanix-vm-mem` |The amount of RAM of the newly created VM (MB) |no | 2 GB| -| `nutanix-vm-cpus` |The number of cpus in the newly created VM (core) |no | 2| -| `nutanix-vm-cores` |The number of cores per vCPU |no | 1| -| `nutanix-vm-network` |The network(s) to which the VM is attached to |yes || -| `nutanix-vm-image` |The name of the Disk Image template we use for the newly created VM (must support cloud-init)|yes || -| `nutanix-vm-image-size` |The new size of the Image we use as a template (in GiB) |no || -| `nutanix-vm-categories` |The name of the categories who will be applied to the newly created VM |no || -| `nutanix-disk-size` |The size of the additional disk to add to the VM (in GiB) |no || -| `nutanix-storage-container` |The storage container UUID of the additional disk to add to the VM |no || -| `nutanix-cloud-init` |Cloud-init to provide to the VM (will be patched with rancher root user) |no || -| `nutanix-vm-cpu-passthrough` |Enable passthrough the host's CPU features to the newly created VM |no |false| +| Arg | Description | Required | Default | +|------------------------------|:----------------------------------------------------------------------------------------------|:---------|---------| +| `nutanix-endpoint` | The hostname/ip-address of the Prism Central | yes | | +| `nutanix-port` | The port to connect to Prism Central | no | 9440 | +| `nutanix-username` | The username of the nutanix management account | yes | | +| `nutanix-password` | The password of the nutanix management account | yes | | +| `nutanix-insecure` | Set to true to force SSL insecure connection | no | false | +| `nutanix-cluster` | The name of the cluster where deploy the VM (case sensitive) | yes | | +| `nutanix-vm-mem` | The amount of RAM of the newly created VM (MB) | no | 2 GB | +| `nutanix-vm-cpus` | The number of cpus in the newly created VM (core) | no | 2 | +| `nutanix-vm-cores` | The number of cores per vCPU | no | 1 | +| `nutanix-vm-network` | The network(s) to which the VM is attached to | yes | | +| `nutanix-vm-image` | The name of the Disk Image template we use for the newly created VM (must support cloud-init) | yes | | +| `nutanix-vm-image-size` | The new size of the Image we use as a template (in GiB) | no | | +| `nutanix-vm-categories` | The name of the categories who will be applied to the newly created VM | no | | +| `nutanix-disk-size` | The size of the additional disk to add to the VM (in GiB) | no | | +| `nutanix-storage-container` | The storage container UUID of the additional disk to add to the VM | no | | +| `nutanix-cloud-init` | Cloud-init to provide to the VM (will be patched with rancher root user) | no | | +| `nutanix-vm-cpu-passthrough` | Enable passthrough the host's CPU features to the newly created VM | no | false | +| `nutanix-vm-serial-port` | Attach a serial port to the newly created VM | no | false | Build Instructions -------------------- diff --git a/machine/driver/driver.go b/machine/driver/driver.go index c9809b2..5ff66cc 100755 --- a/machine/driver/driver.go +++ b/machine/driver/driver.go @@ -53,6 +53,7 @@ type NutanixDriver struct { StorageContainer string DiskSize int CloudInit string + SerialPort bool } // NewDriver create new instance @@ -101,6 +102,15 @@ func (d *NutanixDriver) Create() error { res.EnableCPUPassthrough = utils.BoolPtr(d.VMCPUPassthrough) } + if d.SerialPort { + SerialPort := &v3.VMSerialPort{ + Index: utils.Int64Ptr(0), + IsConnected: utils.BoolPtr(true), + } + + res.SerialPortList = append(res.SerialPortList, SerialPort) + } + // Search target cluster c := &url.URL{Path: d.Cluster} encodedCluster := c.String() @@ -475,6 +485,11 @@ func (d *NutanixDriver) GetCreateFlags() []mcnflag.Flag { Name: "nutanix-cloud-init", Usage: "Cloud-init configuration", }, + mcnflag.BoolFlag{ + EnvVar: "NUTANIX_VM_SERIAL_PORT", + Name: "nutanix-vm-serial-port", + Usage: "Attach a serial port to the newly created VM (type Null)", + }, } } @@ -627,6 +642,7 @@ func (d *NutanixDriver) SetConfigFromFlags(opts drivers.DriverOptions) error { } d.ImageSize = opts.Int("nutanix-vm-image-size") d.CloudInit = opts.String("nutanix-cloud-init") + d.SerialPort = opts.Bool("nutanix-vm-serial-port") return nil }