private static void GenerateConfigDriveDisk(string configDriveIsoPath, string hostname, JObject userData) { try { GeneratorBuilder.Init() .NoCloud(new NoCloudConfigDriveMetaData(hostname)) .SwapFile() .UserData(userData) .Processing() .Image().ImageFile(configDriveIsoPath) .Generate(); } catch (Exception ex) { return; } return; }
private static int RunNoCloudAndReturnExitCode(NoCloudOptions opts) { try { var noCloudBuilder = GeneratorBuilder.Init() .NoCloud(new NoCloudConfigDriveMetaData(opts.Hostname)); if (!opts.NoSwapFile) { noCloudBuilder.SwapFile(); } if (!string.IsNullOrWhiteSpace(opts.Proxy)) { noCloudBuilder.ProxySettings(new ConfigDriveProxySettings(opts.Proxy) { NoProxy = opts.NoProxy }); } if (!string.IsNullOrWhiteSpace(opts.UserData)) { noCloudBuilder.UserData(ReadJsonFile(opts.UserData)); } if (!string.IsNullOrWhiteSpace(opts.NetworkData)) { noCloudBuilder.NetworkData(ReadJsonFile(opts.NetworkData)); } if (!string.IsNullOrWhiteSpace(opts.Content)) { noCloudBuilder.Content(opts.Content); } var processingBuilder = noCloudBuilder.Processing(); if (!string.IsNullOrWhiteSpace(opts.ImagePath)) { processingBuilder.Image().ImageFile(opts.ImagePath); } else { processingBuilder.Callback(result => { Console.WriteLine(result.MediaName); foreach (var resultFile in result.Files) { using (var reader = new StreamReader(resultFile.Content, Encoding.UTF8)) { reader.BaseStream.Seek(0, SeekOrigin.Begin); Console.WriteLine(reader.ReadToEnd()); } } }); } processingBuilder.Generate(); return(0); } catch (Exception ex) { Console.WriteLine(ex.Message); return(-1); } }