Beispiel #1
0
 /// <summary>
 /// 插入FD
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool Insert(FusionDirectorModel entity)
 {
     entity.CreateTime     = DateTime.Now;
     entity.LastModifyTime = DateTime.Now;
     entity.LoginPwd       = EncryptUtil.EncryptPwd(entity.LoginPwd);
     return(FusionDirectorDal.Instance.InsertEntity(entity) > 0);
 }
Beispiel #2
0
 /// <summary>
 /// 测试链接FD
 /// </summary>
 /// <returns></returns>
 public bool TestLinkFD(FusionDirectorModel fusionDirector)
 {
     try
     {
         //IsCrtExist();
         // TrustCertificate();
         SetCertificateValidation();
         HttpResponseMessage response = new HttpResponseMessage();
         using (HttpClient httpClient = new HttpClient())
         {
             var    remoteUrl = "https://" + fusionDirector.HostIP + ":" + fusionDirector.Port + "/redfish/v1/SessionService/Sessions";
             byte[] bytes     = System.Text.Encoding.UTF8.GetBytes(fusionDirector.LoginAccount + ":" + fusionDirector.LoginPwd);
             var    authStr   = "Basic " + Convert.ToBase64String(bytes);
             httpClient.DefaultRequestHeaders.Add("Authorization", authStr);
             response = httpClient.GetAsync(remoteUrl).Result;
             var statusCode = ((int)response.StatusCode).ToString();
             if (statusCode.StartsWith("2"))
             {
                 return(true);
             }
             else if (statusCode == "430" || statusCode == "400")
             {
                 throw new BaseException(ErrorCode.SYS_USER_LOGING, "FD用户名或者密码错误");
             }
             else if (statusCode == "445")
             {
                 throw new BaseException(ErrorCode.SYS_USER_LOCK, "FD用户被加锁");
             }
             else if (statusCode == "431")
             {
                 throw new BaseException(ErrorCode.SYS_USER_LOCK, "FD用户类型错误");
             }
             else if (statusCode == "429")
             {
                 throw new BaseException(ErrorCode.HW_LOGIN_AUTH, "系统错误");
             }
             else if (statusCode == "432")
             {
                 throw new BaseException(ErrorCode.HW_LOGIN_AUTH, "会话创建达到上限");
             }
             else
             {
                 throw new BaseException(ErrorCode.SYS_USER_LOGING, "FD用户名或者密码错误");
             }
         }
     }
     catch (AggregateException ex)
     {
         LogUtil.HWLogger.API.Error("TestLinkFD Error", ex);
         throw HandleException(ex);
     }
     catch (Exception ex)
     {
         LogUtil.HWLogger.API.Error("TestLinkFD Error", ex);
         throw ex;
     }
 }
Beispiel #3
0
 /// <summary>
 /// 更新FD
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool Update(FusionDirectorModel entity)
 {
     entity.LastModifyTime = DateTime.Now;
     return(FusionDirectorDal.Instance.UpdateEntity(entity) > 0);
 }