Hello, I created simple proof-of-concept mock of node driver which I will develop in future.
Using this mock with rancher-machine I am able to connect to another machine via ssh.
But I got problem using this node-driver in Rancher GUI.
It seems the driver is downloaded but there is another problem with address.
logs from Rancher:
2024/07/25 10:09:22 [INFO] Download
https://github.com/adrian-driver/node-driver/releases/download/mock_tag/docker-machine-driver-poc
2024/07/25 10:09:27 [INFO] Found driver docker-machine-driver-poc
2024/07/25 10:09:27 [INFO] Copying management-state/machine-drivers/6c51786ebf07322d211c11db375c99473e8a10ec5d982f0fb6f589f278779cbf-docker-machine-driver-poc => /opt/drivers/management-state/bin/docker-machine-driver-poc-tmp
2024/07/25 10:09:27 [INFO] Copying management-state/machine-drivers/6c51786ebf07322d211c11db375c99473e8a10ec5d982f0fb6f589f278779cbf-docker-machine-driver-poc => /opt/drivers/management-state/bin/docker-machine-driver-poc-tmp
2024/07/25 10:09:27 [ERROR] error syncing 'nd-z9mth': handler node-driver-controller: Error dialing to plugin server's address(), err=dial tcp: missing address, requeuing
code of node-driver poc:
package poc
import (
"fmt"
"github.com/rancher/machine/libmachine/drivers"
"github.com/rancher/machine/libmachine/log"
"github.com/rancher/machine/libmachine/mcnflag"
// "github.com/rancher/machine/libmachine/ssh"
"github.com/rancher/machine/libmachine/state"
)
type Driver struct {
*drivers.BaseDriver
}
func NewDriver() *Driver {
return &Driver{
BaseDriver: &drivers.BaseDriver{},
}
}
func (d *Driver) GetCreateFlags() []mcnflag.Flag {
log.Info("GetCreateFlags():")
return []mcnflag.Flag{
mcnflag.StringFlag{
EnvVar: "POC_USERNAME",
Name: "poc-username",
Usage: "POC username used to login into machine",
Value: "user",
},
mcnflag.StringFlag{
EnvVar: "POC_HOSTNAME",
Name: "poc-hostname",
Usage: "IP address of machine",
Value: "192.168.8.112",
},
mcnflag.StringFlag{
EnvVar: "POC_KEYPATH",
Name: "poc-keypath",
Usage: "Path to key",
Value: "path/to/key",
},
}
}
func (d *Driver) DriverName() string {
log.Info("DriverName():")
driver_name := "poc"
log.Info(driver_name)
return driver_name
}
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
log.Info("SetConfigFromFlags():")
d.IPAddress = flags.String("poc-hostname")
d.SSHUser = flags.String("poc-username")
d.SSHKeyPath = flags.String("poc-keypath")
log.Info("d.IPAddress:", d.IPAddress)
log.Info("d.SSHUser:", d.SSHUser)
log.Info("d.SSHKeyPath:", d.SSHKeyPath)
return nil
}
func (d *Driver) Create() error {
log.Info("Create(): Creating machine instance...")
return nil
}
func (d *Driver) GetSSHHostname() (string, error) {
log.Info("GetSSHHostname():")
return d.GetIP()
}
func (d *Driver) GetState() (state.State, error) {
log.Info("GetState():")
return state.Running, nil
}
func (d *Driver) GetURL() (string, error) {
log.Info("GetURL():")
ip, err := d.GetIP()
if err != nil {
return "", err
}
if ip == "" {
return "", nil
}
return fmt.Sprintf("tcp://%s:%d", ip, 2376), nil
}
func (d *Driver) Kill() error {
log.Info("Kill():")
return nil
}
func (d *Driver) Remove() error {
log.Infof("Removing machine instance")
return nil
}
func (d *Driver) Restart() error {
log.Info("Rebooting machine instance...")
return nil
}
func (d *Driver) Start() error {
log.Info("Starting machine instance...")
return nil
}
func (d *Driver) Stop() error {
log.Info("Stopping machine instance...")
return nil
}
func (d *Driver) PreCreateCheck() error {
log.Info("PreCreateCheck():")
return nil
}
func (d *Driver) GetSSHUsername() string {
log.Info("GetSSHUsername():")
return d.SSHUser
}