Skip to content

Commit

Permalink
add serialport feature (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxtof authored Jun 3, 2022
1 parent 4eab785 commit 5a93e26
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------
Expand Down
16 changes: 16 additions & 0 deletions machine/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type NutanixDriver struct {
StorageContainer string
DiskSize int
CloudInit string
SerialPort bool
}

// NewDriver create new instance
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)",
},
}
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 5a93e26

Please sign in to comment.