feat(config-drive): Add support for reading user-data from config-drive
The -config-drive flag tells cloudinit to read the user-data from within the config-drive (./openstack/latest/user-data).
This commit is contained in:
27
datasource/configdrive.go
Normal file
27
datasource/configdrive.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package datasource
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
type configDrive struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func NewConfigDrive(path string) *configDrive {
|
||||
return &configDrive{path}
|
||||
}
|
||||
|
||||
func (self *configDrive) Fetch() ([]byte, error) {
|
||||
data, err := ioutil.ReadFile(path.Join(self.path, "openstack", "latest", "user_data"))
|
||||
if os.IsNotExist(err) {
|
||||
err = nil
|
||||
}
|
||||
return data, err
|
||||
}
|
||||
|
||||
func (self *configDrive) Type() string {
|
||||
return "cloud-drive"
|
||||
}
|
Reference in New Issue
Block a user