public IActionResult GetLaunchScript() { var maxIdleTimeSec = _context.Configuration.SingleOrDefault().MaxIdleTimeSec; var launchScript = _directoryOptions.GetFileContents("AppData/CloudInit/bootstrap.sh") .Replace("{{Backend}}", getOwnUrl()) .Replace("{{Capabilities}}", "replaceIfRequired") .Replace("{{MaxIdleTime}}", maxIdleTimeSec.ToString()); return(new ContentResult { Content = launchScript }); }
public ExperimentFileDto Get(string name) { var filename = relativeFolder + "/" + name + "/script.py"; var filenameInstall = relativeFolder + "/" + name + "/install.py"; var dirname = relativeFolder + "/" + name + "/configurations"; if (isValidPath(filename)) { var scriptInstall = ""; try { scriptInstall = _directoryOptions.GetFileContents(filenameInstall); } catch (IOException) { // nothing to do } try { return(new ExperimentFileDto() { Name = name, Script = _directoryOptions.GetFileContents(filename), ScriptInstall = scriptInstall, Configurations = new DirectoryInfo(dirname).EnumerateFiles() .Where(fileInfo => !fileInfo.Name.StartsWith(DeletedPrefix)) .ToDictionary(f => f.Name.Replace(".json", ""), f => _directoryOptions.GetFileContents(f.FullName)) }); } catch (IOException) { return(null); } } else { return(null); } }
private IEnumerable <IWorkerHost> InstantiateWorkerHostsFromConfig(IConfigurationSection config) { foreach (var workerHostConfig in config.GetChildren()) { var type = workerHostConfig.GetRequiredSetting("Type"); if (type == "aws") { _logger.LogInformation($"Instantiated AWS worker host. (Key: {workerHostConfig.GetRequiredSetting("AccessKey").Substring(0, 8)}...)"); var accessKey = workerHostConfig.GetRequiredSetting("AccessKey"); var secretKey = workerHostConfig.GetRequiredSetting("SecretKey"); var backend = workerHostConfig.GetRequiredSetting("Backend"); var instanceType = workerHostConfig.GetRequiredSetting("InstanceType"); var script = _directoryOptions.GetFileContents("AppData/CloudInit/bootstrap.sh"); var keyName = workerHostConfig.GetSetting("KeyName", ""); var securityGroup = workerHostConfig.GetSetting("SecurityGroup", ""); yield return(new AwsWorkerHost(accessKey, secretKey, backend, instanceType, script, keyName)); } else if (type == "proxmox") { var username = workerHostConfig.GetRequiredSetting("Username"); var password = workerHostConfig.GetRequiredSetting("Password"); var server = workerHostConfig.GetRequiredSetting("Server"); var port = workerHostConfig.GetRequiredSetting("Port"); var node = workerHostConfig.GetRequiredSetting("Node"); var realm = workerHostConfig.GetRequiredSetting("ReAlm"); yield return(new ProxmoxWorkerHost(username, password, server, port, node, realm)); } else if (type == "openstack") { throw new NotImplementedException(); } else { throw new ArgumentException($"Unknown worker host type '{type}'."); } } }