public AssetGlusterModule() { Get["/gluster"] = x => { var model = new PageGlusterModel { Gluster = GlusterConfiguration.Get() }; return(JsonConvert.SerializeObject(model)); }; Post["/gluster/set"] = x => { GlusterConfiguration.Set(); return(HttpStatusCode.OK); }; Post["/gluster/restart"] = x => { GlusterConfiguration.Launch(); return(HttpStatusCode.OK); }; Post["/gluster/stop"] = x => { GlusterConfiguration.Stop(); return(HttpStatusCode.OK); }; Post["/gluster/enable"] = x => { GlusterConfiguration.Enable(); GlusterConfiguration.Start(); return(HttpStatusCode.OK); }; Post["/gluster/disable"] = x => { GlusterConfiguration.Disable(); GlusterConfiguration.Stop(); return(HttpStatusCode.OK); }; Post["/gluster/save"] = x => { string config = Request.Form.Config; var model = JsonConvert.DeserializeObject <GlusterConfigurationModel>(config); GlusterConfiguration.Save(model); return(HttpStatusCode.OK); }; }
private static void ManagedProcedures() { Logger.Info("[config] managed procedures"); if (!Parameter.IsUnix) { return; } #region [ Samba ] if (SambaConfiguration.IsActive()) { SambaConfiguration.Set(); } #endregion #region [ Syslog ] if (SyslogNgConfiguration.IsActive()) { SyslogNgConfiguration.Set(); } #endregion #region [ Storage ] foreach (var pool in Zpool.ImportList().ToList()) { if (string.IsNullOrEmpty(pool)) { continue; } Logger.Info($"pool {pool} imported"); Zpool.Import(pool); } Logger.Info("storage ready"); #endregion #region [ Scheduler ] Timers.Setup(); Timers.Import(); Timers.Export(); foreach (var zp in Zpool.List()) { Timers.Create(zp.Name.ToLower() + "snap", "hourly", $"/sbin/zfs snap -r {zp.Name}@${{TTDATE}}"); } Timers.StartAll(); new SnapshotCleanup().Start(new TimeSpan(2, 00, 00)); new SyncTime().Start(new TimeSpan(0, 42, 00)); new RemoveUnusedModules().Start(new TimeSpan(2, 15, 00)); Logger.Info("scheduled events ready"); #endregion #region [ Acl ] if (AclConfiguration.IsActive()) { AclConfiguration.Set(); AclConfiguration.ScriptSetup(); } #endregion #region [ Sync ] if (GlusterConfiguration.IsActive()) { GlusterConfiguration.Set(); } if (RsyncConfiguration.IsActive()) { RsyncConfiguration.Set(); } #endregion #region [ SyncMachine ] if (SyncMachineConfiguration.IsActive()) { SyncMachineConfiguration.Set(); } #endregion #region [ C A ] if (CaConfiguration.IsActive()) { CaConfiguration.Set(); } #endregion #region [ Apps ] AppTarget.Setup(); var apps = AppsConfiguration.Get().Apps; foreach (var app in apps) { var units = app.UnitLauncher; foreach (var unit in units) { if (Systemctl.IsActive(unit) == false) { Systemctl.Restart(unit); } } } //AppTarget.StartAll(); Logger.Info("apps ready"); #endregion }
public AntdGlusterModule() { Get["/gluster"] = x => { var glusterConfiguration = new GlusterConfiguration(); var glusterIsActive = glusterConfiguration.IsActive(); var model = new PageGlusterModel { GlusterIsActive = glusterIsActive, Nodes = glusterConfiguration.Get()?.Nodes, Volumes = glusterConfiguration.Get()?.Volumes }; return(JsonConvert.SerializeObject(model)); }; Post["/gluster/set"] = x => { var glusterConfiguration = new GlusterConfiguration(); glusterConfiguration.Set(); return(HttpStatusCode.OK); }; Post["/gluster/restart"] = x => { var glusterConfiguration = new GlusterConfiguration(); glusterConfiguration.Start(); return(HttpStatusCode.OK); }; Post["/gluster/stop"] = x => { var glusterConfiguration = new GlusterConfiguration(); glusterConfiguration.Stop(); return(HttpStatusCode.OK); }; Post["/gluster/enable"] = x => { var glusterConfiguration = new GlusterConfiguration(); glusterConfiguration.Enable(); glusterConfiguration.Start(); return(HttpStatusCode.OK); }; Post["/gluster/disable"] = x => { var glusterConfiguration = new GlusterConfiguration(); glusterConfiguration.Disable(); glusterConfiguration.Stop(); return(HttpStatusCode.OK); }; Post["/gluster/options"] = x => { string nodes = Request.Form.GlusterNode; var nodelist = nodes.Split(new[] { "," }, StringSplitOptions.None).ToList(); string volumeNames = Request.Form.GlusterVolumeName; string volumeBrick = Request.Form.GlusterVolumeBrick; string volumeMountPoint = Request.Form.GlusterVolumeMountPoint; var volumeNamesList = volumeNames.Split(new[] { "," }, StringSplitOptions.None); var volumeBrickList = volumeBrick.Split(new[] { "," }, StringSplitOptions.None); var volumeMountPointList = volumeMountPoint.Split(new[] { "," }, StringSplitOptions.None); var volumelist = new List <GlusterVolume>(); for (var i = 0; i < 20; i++) { if (volumeNamesList.Length < i - 1 || volumeBrickList.Length < i - 1 || volumeMountPointList.Length < i - 1) { continue; } try { var vol = new GlusterVolume { Name = volumeNamesList[i], Brick = volumeBrickList[i], MountPoint = volumeMountPointList[i], }; volumelist.Add(vol); } catch (Exception) { continue; } } var config = new GlusterConfigurationModel { Nodes = nodelist.ToArray(), Volumes = volumelist.ToArray() }; var glusterConfiguration = new GlusterConfiguration(); glusterConfiguration.Save(config); return(HttpStatusCode.OK); }; Post["/gluster/node"] = x => { string node = Request.Form.Node; if (string.IsNullOrWhiteSpace(node)) { return(HttpStatusCode.BadRequest); } var glusterConfiguration = new GlusterConfiguration(); glusterConfiguration.AddNode(node); return(HttpStatusCode.OK); }; Post["/gluster/node/del"] = x => { string node = Request.Form.Node; if (string.IsNullOrWhiteSpace(node)) { return(HttpStatusCode.BadRequest); } var glusterConfiguration = new GlusterConfiguration(); glusterConfiguration.RemoveNode(node); return(HttpStatusCode.OK); }; }