public ImageProfileEntity SeedDefaultImageProfile(int imageId) { var image = GetImage(imageId); var imageProfile = new ImageProfileEntity(); imageProfile.Kernel = SettingStrings.DefaultKernel64; imageProfile.BootImage = "initrd.xz"; imageProfile.Name = "default"; imageProfile.Description = "Auto Generated Via New Image."; imageProfile.SkipCore = 0; imageProfile.SkipClock = 0; imageProfile.RemoveGPT = 0; imageProfile.SkipShrinkVolumes = 0; imageProfile.SkipShrinkLvm = 0; imageProfile.SkipExpandVolumes = 0; imageProfile.FixBcd = 0; imageProfile.FixBootloader = 1; imageProfile.PartitionMethod = "Dynamic"; imageProfile.Compression = "lz4"; imageProfile.CompressionLevel = "1"; imageProfile.TaskCompletedAction = "Reboot"; imageProfile.ChangeName = 1; if (image.Environment == "macOS") { imageProfile.OsxTargetVolume = "Macintosh HD"; } return(imageProfile); }
public ActionResultDTO UpdateProfile(ImageProfileEntity profile) { var existingProfile = ReadProfile(profile.Id); if (existingProfile == null) { return new ActionResultDTO { ErrorMessage = "Image Profile Not Found", Id = 0 } } ; var actionResult = new ActionResultDTO(); var validationResult = ValidateImageProfile(profile, false); if (validationResult.Success) { if (!string.IsNullOrEmpty(profile.ModelMatch)) { profile.ModelMatch = profile.ModelMatch.ToLower(); } _uow.ImageProfileRepository.Update(profile, profile.Id); _uow.Save(); actionResult.Success = true; actionResult.Id = profile.Id; } else { actionResult.ErrorMessage = validationResult.ErrorMessage; } return(actionResult); }
public TaskBootMenu(ComputerEntity computer, ImageProfileEntity imageProfile) { _computer = computer; _imageProfile = imageProfile; _clusterGroupServices = new ClusterGroupServices(); _secondaryServerServices = new SecondaryServerServices(); }
public ActionResultDTO UpdateProfile(ImageProfileEntity profile) { var existingProfile = ReadProfile(profile.Id); if (existingProfile == null) { return new ActionResultDTO { ErrorMessage = "Image Profile Not Found", Id = 0 } } ; var actionResult = new ActionResultDTO(); var validationResult = ValidateImageProfile(profile, false); if (!string.IsNullOrEmpty(profile.MunkiAuthPassword)) { profile.MunkiAuthPassword = new EncryptionServices().EncryptText(profile.MunkiAuthPassword); } if (validationResult.Success) { _uow.ImageProfileRepository.Update(profile, profile.Id); _uow.Save(); actionResult.Success = true; actionResult.Id = profile.Id; } else { actionResult.ErrorMessage = validationResult.ErrorMessage; } return(actionResult); }
public void Page_Load(object sender, EventArgs e) { imageBasePage = Page as Images; ImageProfile = imageBasePage.ImageProfile; Image = imageBasePage.Image; if (ImageProfile == null) { linux_profile.Visible = false; winpe_profile.Visible = false; return; } if (Image == null) { Response.Redirect("~/", true); } divProfiles.Visible = false; if (Image.Environment == "linux" || Image.Environment == "") { linux_profile.Visible = true; winpe_profile.Visible = false; } else if (Image.Environment == "winpe") { linux_profile.Visible = false; winpe_profile.Visible = true; } }
private ValidationResultDTO ValidateImageProfile(ImageProfileEntity imageProfile, bool isNewImageProfile) { var validationResult = new ValidationResultDTO { Success = true }; if (string.IsNullOrEmpty(imageProfile.Name) || !imageProfile.Name.All(c => char.IsLetterOrDigit(c) || c == '_')) { validationResult.Success = false; validationResult.ErrorMessage = "Image Profile Name Is Not Valid"; return(validationResult); } if (isNewImageProfile) { if ( _uow.ImageProfileRepository.Exists( h => h.Name == imageProfile.Name && h.ImageId == imageProfile.ImageId)) { validationResult.Success = false; validationResult.ErrorMessage = "This Image Profile Already Exists"; return(validationResult); } } else { var originalImageProfile = _uow.ImageProfileRepository.GetById(imageProfile.Id); if (originalImageProfile.Name != imageProfile.Name) { if ( _uow.ImageProfileRepository.Exists( h => h.Name == imageProfile.Name && h.ImageId == imageProfile.ImageId)) { validationResult.Success = false; validationResult.ErrorMessage = "This Image Profile Already Exists"; return(validationResult); } } if (!string.IsNullOrEmpty(imageProfile.ModelMatch)) { var profilesWithModelMatch = _uow.ImageProfileRepository.Get(x => x.ModelMatch.Equals(imageProfile.ModelMatch.ToLower()) && x.Id != imageProfile.Id); if (profilesWithModelMatch.Any()) { var image = _uow.ImageRepository.GetById(profilesWithModelMatch.First().ImageId); validationResult.Success = false; validationResult.ErrorMessage = "This Model Match Already Exists On Image: " + image.Name; } } } return(validationResult); }
public ActionResultDTO Put(int id, ImageProfileEntity imageProfile) { imageProfile.Id = id; var result = _imageProfileServices.UpdateProfile(imageProfile); if (result == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(result); }
public ActionResultDTO Put(int id, ImageProfileEntity tObject) { Request.Method = Method.PUT; Request.AddJsonBody(tObject); Request.Resource = string.Format("api/{0}/Put/{1}", Resource, id); var response = _apiRequest.Execute <ActionResultDTO>(Request); if (response.Id == 0) { response.Success = false; } return(response); }
public ActionResultDTO AddProfile(ImageProfileEntity profile) { var validationResult = ValidateImageProfile(profile, true); var actionResult = new ActionResultDTO(); if (validationResult.Success) { _uow.ImageProfileRepository.Insert(profile); _uow.Save(); actionResult.Success = true; actionResult.Id = profile.Id; } return(actionResult); }
public ActionResultDTO AddProfile(ImageProfileEntity profile) { var validationResult = ValidateImageProfile(profile, true); var actionResult = new ActionResultDTO(); if (!string.IsNullOrEmpty(profile.MunkiAuthPassword)) { profile.MunkiAuthPassword = new EncryptionServices().EncryptText(profile.MunkiAuthPassword); } if (validationResult.Success) { _uow.ImageProfileRepository.Insert(profile); _uow.Save(); actionResult.Success = true; actionResult.Id = profile.Id; } return(actionResult); }
private ValidationResultDTO ValidateImageProfile(ImageProfileEntity imageProfile, bool isNewImageProfile) { var validationResult = new ValidationResultDTO { Success = true }; if (string.IsNullOrEmpty(imageProfile.Name) || !imageProfile.Name.All(c => char.IsLetterOrDigit(c) || c == '_')) { validationResult.Success = false; validationResult.ErrorMessage = "Image Profile Name Is Not Valid"; return(validationResult); } if (isNewImageProfile) { if ( _uow.ImageProfileRepository.Exists( h => h.Name == imageProfile.Name && h.ImageId == imageProfile.ImageId)) { validationResult.Success = false; validationResult.ErrorMessage = "This Image Profile Already Exists"; return(validationResult); } } else { var originalImageProfile = _uow.ImageProfileRepository.GetById(imageProfile.Id); if (originalImageProfile.Name != imageProfile.Name) { if ( _uow.ImageProfileRepository.Exists( h => h.Name == imageProfile.Name && h.ImageId == imageProfile.ImageId)) { validationResult.Success = false; validationResult.ErrorMessage = "This Image Profile Already Exists"; return(validationResult); } } } return(validationResult); }
public ActionResultDTO Post(ImageProfileEntity imageProfile) { return(_imageProfileServices.AddProfile(imageProfile)); }
public ClobberBootMenu(int imageProfileId, bool promptComputerName) { _promptComputerName = promptComputerName; _imageProfile = new ImageProfileServices().ReadProfile(imageProfileId); _secondaryServerServices = new SecondaryServerServices(); }