/// <summary> /// Uploads the configuration files for the target operating system to the server. /// </summary> /// <typeparam name="Metadata">The node metadata type.</typeparam> /// <param name="node">The remote node.</param> /// <param name="hiveDefinition">The hive definition or <c>null</c>.</param> public static void UploadConfigFiles <Metadata>(this SshProxy <Metadata> node, HiveDefinition hiveDefinition = null) where Metadata : class { Covenant.Requires <ArgumentNullException>(node != null); // Clear the contents of the configuration folder. node.Status = $"clear: {HiveHostFolders.Config}"; node.SudoCommand($"rm -rf {HiveHostFolders.Config}/*.*"); // Upload the files. node.Status = "upload: config files"; foreach (var file in Program.LinuxFolder.GetFolder("conf").Files()) { node.UploadFile(hiveDefinition, file, $"{HiveHostFolders.Config}/{file.Name}"); } // Secure the files and make the scripts executable. node.SudoCommand($"chmod 644 {HiveHostFolders.Config}/*.*"); node.SudoCommand($"chmod 744 {HiveHostFolders.Config}/*.sh"); node.Status = "copied"; }
/// <summary> /// Uploads the setup and other scripts and tools for the target operating system to the server. /// </summary> /// <typeparam name="TMetadata">The server's metadata type.</typeparam> /// <param name="server">The remote server.</param> /// <param name="clusterDefinition">The cluster definition.</param> /// <param name="kubeSetupInfo">The Kubernetes setup details.</param> public static void UploadResources <TMetadata>(this SshProxy <TMetadata> server, ClusterDefinition clusterDefinition, KubeSetupInfo kubeSetupInfo) where TMetadata : class { Covenant.Requires <ArgumentNullException>(server != null, nameof(server)); Covenant.Requires <ArgumentNullException>(clusterDefinition != null, nameof(clusterDefinition)); Covenant.Requires <ArgumentNullException>(kubeSetupInfo != null, nameof(kubeSetupInfo)); //----------------------------------------------------------------- // Upload resource files to the setup folder. server.Status = $"clear: {KubeHostFolders.Setup}"; server.SudoCommand($"rm -rf {KubeHostFolders.Setup}/*.*"); // Upload the setup files. server.Status = "upload: setup scripts"; foreach (var file in Program.LinuxFolder.GetFolder("setup").Files()) { server.UploadFile(clusterDefinition, kubeSetupInfo, file, $"{KubeHostFolders.Setup}/{file.Name}"); } // Make the setup scripts executable. server.SudoCommand($"chmod 744 {KubeHostFolders.Setup}/*"); //----------------------------------------------------------------- // Upload files to the bin folder. server.Status = $"clear: {KubeHostFolders.Bin}"; server.SudoCommand($"rm -rf {KubeHostFolders.Bin}/*.*"); // Upload the tool files. Note that we're going to strip out the [.sh] // file type to make these easier to run. server.Status = "upload: binary files"; foreach (var file in Program.LinuxFolder.GetFolder("binary").Files()) { server.UploadFile(clusterDefinition, kubeSetupInfo, file, $"{KubeHostFolders.Bin}/{file.Name.Replace(".sh", string.Empty)}"); } // Make the scripts executable. server.SudoCommand($"chmod 744 {KubeHostFolders.Bin}/*"); }
/// <summary> /// Uploads the setup and other scripts and tools for the target operating system to the server. /// </summary> /// <typeparam name="TMetadata">The server's metadata type.</typeparam> /// <param name="server">The remote server.</param> /// <param name="hiveDefinition">The hive definition or <c>null</c>.</param> public static void UploadResources <TMetadata>(this SshProxy <TMetadata> server, HiveDefinition hiveDefinition = null) where TMetadata : class { Covenant.Requires <ArgumentNullException>(server != null); //----------------------------------------------------------------- // Upload resource files to the setup folder. server.Status = $"clear: {HiveHostFolders.Setup}"; server.SudoCommand($"rm -rf {HiveHostFolders.Setup}/*.*"); // Upload the setup files. server.Status = "upload: setup files"; foreach (var file in Program.LinuxFolder.GetFolder("setup").Files()) { server.UploadFile(hiveDefinition, file, $"{HiveHostFolders.Setup}/{file.Name}"); } // Make the setup scripts executable. server.SudoCommand($"chmod 744 {HiveHostFolders.Setup}/*"); // Uncomment this if/when we have to upload source files. #if FALSE //----------------------------------------------------------------- // Upload resource files to the source folder. Note that we're going // to convert to Linux style line endings and we're going to convert // leading spaces into TABs (4 spaces == 1 TAB). // $hack(jeff.lill): // // This is hardcoded to assume that the source consists of a single level // folder with the source files. If the folders nest eny further, we'll // need to implement a recursive method to handle this properly. // // This code also assumes that the folder and file names do not include // any spaces. server.Status = $"clear: {HiveHostFolders.Source}"; server.SudoCommand($"rm -rf {HiveHostFolders.Source}/*.*"); // Upload the source files. server.Status = "upload: source files"; foreach (var folder in Program.LinuxFolder.GetFolder("source").Folders()) { foreach (var file in folder.Files()) { var targetPath = $"{HiveHostFolders.Source}/{folder.Name}/{file.Name}"; server.UploadText(targetPath, file.Contents, tabStop: -4); server.SudoCommand("chmod 664", targetPath); } } #endif //----------------------------------------------------------------- // Upload files to the tools folder. server.Status = $"clear: {HiveHostFolders.Tools}"; server.SudoCommand($"rm -rf {HiveHostFolders.Tools}/*.*"); // Upload the tool files. Note that we're going to strip out the [.sh] // file type to make these easier to run. server.Status = "upload: tool files"; foreach (var file in Program.LinuxFolder.GetFolder("tools").Files()) { server.UploadFile(hiveDefinition, file, $"{HiveHostFolders.Tools}/{file.Name.Replace(".sh", string.Empty)}"); } // Make the scripts executable. server.SudoCommand($"chmod 744 {HiveHostFolders.Tools}/*"); }