Esempio n. 1
0
        public bool Create(DtoBootMenuGenOptions bootOptions)
        {
            _defaultBoot = bootOptions;
            var mode = ServiceSetting.GetSettingValue(SettingStrings.PxeBootloader);

            var guid = ConfigurationManager.AppSettings["ComServerUniqueId"];

            _thisComServer = new ServiceClientComServer().GetServerByGuid(guid);
            if (_thisComServer == null)
            {
                log.Error($"Com Server With Guid {guid} Not Found");
                return(false);
            }

            if (string.IsNullOrEmpty(_thisComServer.TftpPath))
            {
                log.Error($"Com Server With Guid {guid} Does Not Have A Valid Tftp Path");
                return(false);
            }

            _bootEntryServices  = new ServiceCustomBootMenu();
            _globalComputerArgs = ServiceSetting.GetSettingValue(SettingStrings.GlobalImagingArguments);

            var defaultCluster        = new UnitOfWork().ComServerClusterRepository.Get(x => x.IsDefault).FirstOrDefault();
            var defaultImagingServers = new UnitOfWork().ComServerClusterServerRepository.GetImagingClusterServers(defaultCluster.Id);

            _webPath = "\"";

            //the global default menu doesn't really have a way of knowing which imaging server to connect to since it's not related to a computer /group with
            // the com server assigned.  Instead use this server if it's an imaging server, otherwise use the default cluster.
            if (_thisComServer.IsImagingServer)
            {
                _webPath += _thisComServer.Url + "clientimaging/ ";
            }
            else
            {
                foreach (var imageServer in defaultImagingServers)
                {
                    var url = new ServiceClientComServer().GetServer(imageServer.ComServerId).Url;
                    _webPath += url + "clientimaging/ "; //adds a space delimiter
                }
            }
            _webPath  = _webPath.Trim(' ');
            _webPath += "\"";

            var webRequiresLogin     = ServiceSetting.GetSettingValue(SettingStrings.WebTasksRequireLogin);
            var consoleRequiresLogin = ServiceSetting.GetSettingValue(SettingStrings.ConsoleTasksRequireLogin);
            var globalToken          = ServiceSetting.GetSettingValue(SettingStrings.GlobalImagingToken);

            if (webRequiresLogin.Equals("False") || consoleRequiresLogin.Equals("False"))
            {
                _userToken = globalToken;
            }
            else
            {
                _userToken = "";
            }

            if (_defaultBoot.Type == "standard")
            {
                if (mode.Contains("ipxe"))
                {
                    CreateIpxeMenu(defaultCluster.Id);
                }
                else if (mode.Contains("grub"))
                {
                    CreateGrubMenu();
                }
                else
                {
                    CreateSyslinuxMenu();
                }
            }
            else
            {
                foreach (var proxyMode in new[] { "bios", "efi32", "efi64" })
                {
                    bootOptions.Type = proxyMode;
                    if (proxyMode.Equals("bios"))
                    {
                        bootOptions.Kernel    = bootOptions.BiosKernel;
                        bootOptions.BootImage = bootOptions.BiosBootImage;
                    }
                    else if (proxyMode.Equals("efi32"))
                    {
                        bootOptions.Kernel    = bootOptions.Efi32Kernel;
                        bootOptions.BootImage = bootOptions.Efi32BootImage;
                    }
                    else
                    {
                        bootOptions.Kernel    = bootOptions.Efi64Kernel;
                        bootOptions.BootImage = bootOptions.Efi64BootImage;
                    }
                    CreateIpxeMenu(defaultCluster.Id);
                    CreateSyslinuxMenu();
                    CreateGrubMenu();
                }
            }

            return(true);
        }
Esempio n. 2
0
 public CustomBootMenuController()
 {
     _customBootMenuService = new ServiceCustomBootMenu();
 }