Beispiel #1
0
        public BootModulesModule()
        {
            Get["/boot/modules"] = x => {
                var hostcfg = new HostConfiguration();
                var model   = new PageBootModulesModel {
                    Modules   = string.Join(Environment.NewLine, hostcfg.GetHostModprobes()),
                    RmModules = string.Join(Environment.NewLine, hostcfg.GetHostRemoveModules()),
                    Blacklist = string.Join(Environment.NewLine, hostcfg.GetHostBlacklistModules())
                };
                return(JsonConvert.SerializeObject(model));
            };

            Post["/boot/modules"] = x => {
                string modulesText = Request.Form.Config;
                var    modules     = modulesText.SplitToList(Environment.NewLine).Where(_ => !string.IsNullOrEmpty(_));
                var    hostcfg     = new HostConfiguration();
                hostcfg.SetHostModprobes(modules);
                hostcfg.ApplyHostModprobes();
                return(HttpStatusCode.OK);
            };

            Post["/boot/rmmodules"] = x => {
                string modulesText = Request.Form.Config;
                var    modules     = modulesText.SplitToList(Environment.NewLine).Where(_ => !string.IsNullOrEmpty(_));
                var    hostcfg     = new HostConfiguration();
                hostcfg.SetHostRemoveModules(modules);
                hostcfg.ApplyHostRemoveModules();
                return(HttpStatusCode.OK);
            };

            Post["/boot/modblacklist"] = x => {
                string modulesText = Request.Form.Config;
                var    modules     = modulesText.SplitToList(Environment.NewLine).Where(_ => !string.IsNullOrEmpty(_));
                var    hostcfg     = new HostConfiguration();
                hostcfg.SetHostBlacklistModules(modules);
                hostcfg.ApplyHostBlacklistModules();
                return(HttpStatusCode.OK);
            };
        }