14807: Move secret-tag host key verify mechanism out of Azure driver.
[arvados.git] / lib / cloud / interfaces.go
index 3f03b650b4100f7dfe89126cada79b921681ea20..792e737a914a1ce7d39d98c05c1a9428e77fb1ff 100644 (file)
@@ -6,6 +6,7 @@ package cloud
 
 import (
        "encoding/json"
+       "errors"
        "io"
        "time"
 
@@ -57,6 +58,8 @@ type Executor interface {
        Execute(cmd string, stdin io.Reader) (stdout, stderr []byte, err error)
 }
 
+var ErrNotImplemented = errors.New("not implemented")
+
 // An ExecutorTarget is a remote command execution service.
 type ExecutorTarget interface {
        // SSH server hostname or IP address, or empty string if
@@ -71,6 +74,9 @@ type ExecutorTarget interface {
        // VerifyHostKey can use it to make outgoing network
        // connections from the instance -- e.g., to use the cloud's
        // "this instance's metadata" API.
+       //
+       // Return ErrNotImplemented if no verification mechanism is
+       // available.
        VerifyHostKey(ssh.PublicKey, *ssh.Client) error
 }
 
@@ -105,12 +111,18 @@ type Instance interface {
 // All public methods of an InstanceSet, and all public methods of the
 // instances it returns, are goroutine safe.
 type InstanceSet interface {
-       // Create a new instance. If supported by the driver, add the
+       // Create a new instance with the given type, image, and
+       // initial set of tags. If supported by the driver, add the
        // provided public key to /root/.ssh/authorized_keys.
        //
+       // The given InitCommand should be executed on the newly
+       // created instance. This is optional for a driver whose
+       // instances' VerifyHostKey() method never returns
+       // ErrNotImplemented. InitCommand will be under 1 KiB.
+       //
        // The returned error should implement RateLimitError and
        // QuotaError where applicable.
-       Create(arvados.InstanceType, ImageID, InstanceTags, ssh.PublicKey) (Instance, error)
+       Create(arvados.InstanceType, ImageID, InstanceTags, InitCommand, ssh.PublicKey) (Instance, error)
 
        // Return all instances, including ones that are booting or
        // shutting down. Optionally, filter out nodes that don't have
@@ -128,6 +140,8 @@ type InstanceSet interface {
        Stop()
 }
 
+type InitCommand string
+
 // A Driver returns an InstanceSet that uses the given InstanceSetID
 // and driver-dependent configuration parameters.
 //