configdrive: return an empty network config when filename is empty

Additionally, don't bother checking for a network config if it isn't going to
be processed.
This commit is contained in:
Alex Crawford 2014-09-13 21:02:08 -07:00
parent 585ce5fcd9
commit a0fe6d0884
2 changed files with 4 additions and 1 deletions

View File

@ -163,7 +163,7 @@ func main() {
os.Exit(1)
}
if ccm != nil {
if ccm != nil && flags.convertNetconf != "" {
fmt.Printf("Fetching network config from datasource of type %q\n", ds.Type())
netconfBytes, err := ds.FetchNetworkConfig(ccm.NetworkConfigPath)
if err != nil {

View File

@ -42,6 +42,9 @@ func (cd *configDrive) FetchUserdata() ([]byte, error) {
}
func (cd *configDrive) FetchNetworkConfig(filename string) ([]byte, error) {
if filename == "" {
return []byte{}, nil
}
return cd.tryReadFile(path.Join(cd.openstackRoot(), filename))
}