|
@@ -5,6 +5,7 @@
|
|
|
#include "cJSON.h"
|
|
|
#include "libipmi_storlead_OEM.h"
|
|
|
#include "libsensor.h"
|
|
|
+#include "com_BMCCfg.h"
|
|
|
#include <stdio.h>
|
|
|
#include <sys/socket.h>
|
|
|
#include <sys/un.h>
|
|
@@ -373,51 +374,6 @@ void buy(Webs *wp)
|
|
|
|
|
|
|
|
|
|
|
|
-// /*
|
|
|
-// Implement /action/actionTest. Parse the form variables: name, address and echo back.
|
|
|
-// */
|
|
|
-// void actionTest(Webs *wp)
|
|
|
-// {
|
|
|
-
|
|
|
-// printf("sid value is >>>>>>>>>>>>>: %d<<<<<<<<<<<\n", wp->sid);
|
|
|
-// IPMI20_UDS_SESSION_T UDSSession;
|
|
|
-// GetDevIDRes_T DeviceID;
|
|
|
-
|
|
|
-// //Create session
|
|
|
-// printf("actionTest!\n");
|
|
|
-// LIBIPMI_CreateSession(&UDSSession, 10);
|
|
|
-// IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
|
|
|
-
|
|
|
-// printf("sid value is >>>>>1>>>>>>>>: %d<<<<<<<\n", wp->sid);
|
|
|
-
|
|
|
-
|
|
|
-// char *pStr;
|
|
|
-
|
|
|
-// char *testStr;
|
|
|
-// testStr = malloc(500);
|
|
|
-// //sprintf(testStr, "{data: {\"Version\": \"%s\", \"MAC\": \"%s\", \"IP\": \"%s\"}, \"msg\":\"\"}", FwVersion, MacAddr, IpAddr);
|
|
|
-
|
|
|
-// sprintf(testStr, "{\"data\": {\"buildTime\":\"%s\",\"fwVersion\":\"%s\",\"macAddr\":\"%s\",\"ipAddr\":\"%s\"},\"msg\":\"\",\"code\": %d}", \
|
|
|
-// BuildTime, FwVersion, MacAddr, IpAddr, 200);
|
|
|
-
|
|
|
-
|
|
|
-// //sprintf(testStr, "jimbo and lusa are very confused, please git me some tips, my god!");
|
|
|
-
|
|
|
-// pStr = testStr;
|
|
|
-
|
|
|
-
|
|
|
-// char name[] = "jimbo";
|
|
|
-// char address[] = "shanghai";
|
|
|
-// printf("name: %s, address: %s\n", name, address);
|
|
|
-// websSetStatus(wp, 200);
|
|
|
-// websWriteHeaders(wp, -1, 0);
|
|
|
-// websWriteEndHeaders(wp);
|
|
|
-// websWrite(wp, testStr);
|
|
|
-// websFlush(wp, 0);
|
|
|
-// websDone(wp);
|
|
|
-// // LIBIPMI_CloseSession(&UDSSession );
|
|
|
-// }
|
|
|
-
|
|
|
|
|
|
void actionTest(Webs *wp)
|
|
|
{
|
|
@@ -487,22 +443,7 @@ void actionTest(Webs *wp)
|
|
|
// cJSON * root = cJSON_CreateObject();
|
|
|
// cJSON * data = cJSON_CreateObject();
|
|
|
printf("log1\n");
|
|
|
- // cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
- // cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
|
|
|
- // cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
|
|
|
- // cJSON_AddStringToObject(data, "buildTime", BuildTime);
|
|
|
- // cJSON_AddStringToObject(data, "fwVersion", FwVersion);
|
|
|
- // cJSON_AddStringToObject(data, "macAddr", MacAddr);
|
|
|
- // cJSON_AddStringToObject(data, "ipAddr", IpAddr);
|
|
|
- // pStr = cJSON_Print(root); //include malloc
|
|
|
- // cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
- // cJSON_AddStringToObject(root, "msg", NULL);
|
|
|
- // cJSON_AddNumberToObject(root, "code", 200);
|
|
|
- // // cJSON_AddStringToObject(data, "buildTime", BuildTime);
|
|
|
- // // cJSON_AddStringToObject(data, "fwVersion", FwVersion);
|
|
|
- // // cJSON_AddStringToObject(data, "macAddr", MacAddr);
|
|
|
- // // cJSON_AddStringToObject(data, "ipAddr", IpAddr);
|
|
|
- // pStr = cJSON_Print(root); //include malloc
|
|
|
+
|
|
|
|
|
|
printf("%s\n", pStr);
|
|
|
websSetStatus(wp, 200);
|
|
@@ -519,4 +460,212 @@ void actionTest(Webs *wp)
|
|
|
// cJSON_Delete(data);
|
|
|
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
+void getAllBladeInfo(Webs *wp){
|
|
|
+ uint16_t wRet = LIBIPMI_E_SUCCESS;
|
|
|
+
|
|
|
+ IPMI20_UDS_SESSION_T UDSSession;
|
|
|
+ BladeStatus_T *pBladeStatus = walloc(BLADE_NUMBERS*sizeof(BladeStatus_T));
|
|
|
+
|
|
|
+ //Create session
|
|
|
+ LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+
|
|
|
+ wRet = LIBIPMI_HL_GetBladeStatus(&UDSSession, pBladeStatus, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ printf("Get Blade status error!\n");
|
|
|
+ websError(wp, 404, "Get Blade status error!");
|
|
|
+ wfree(pBladeStatus);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //Close session
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
+
|
|
|
+ char *pStr;
|
|
|
+ cJSON * root = cJSON_CreateObject();
|
|
|
+ cJSON *pJsonArry,*pJsonsub;
|
|
|
+ pJsonArry=cJSON_CreateArray(); /*创建数组*/
|
|
|
+ cJSON_AddItemToObject(root, "data", pJsonArry);//根节点下添加
|
|
|
+ cJSON_AddStringToObject(root, "msg", "");
|
|
|
+ cJSON_AddNumberToObject(root, "code", 200);
|
|
|
+
|
|
|
+ int i;
|
|
|
+ for(i=0;i<BLADE_NUMBERS;i++)
|
|
|
+ {
|
|
|
+ cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
|
|
|
+ cJSON_AddNumberToObject(pJsonsub, "status", pBladeStatus[i].healthStatus); //0:灰色, 1: 绿色 2:红色
|
|
|
+ cJSON_AddNumberToObject(pJsonsub, "slot", pBladeStatus[i].slotID);
|
|
|
+ cJSON_AddNumberToObject(pJsonsub, "power", pBladeStatus[i].pwrStatus);
|
|
|
+ cJSON_AddStringToObject(pJsonsub, "name", pBladeStatus[i].bladeName);
|
|
|
+ }
|
|
|
+
|
|
|
+ pStr = cJSON_PrintUnformatted(root);
|
|
|
+
|
|
|
+ printf("---> cJSON Str:\n%s\n", pStr);
|
|
|
+ websSetStatus(wp, 200);
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
+ websWrite(wp, "%s", pStr);
|
|
|
+ websFlush(wp, 0);
|
|
|
+ websDone(wp);
|
|
|
+
|
|
|
+ if(pStr)
|
|
|
+ wfree(pStr);
|
|
|
+ if(root)
|
|
|
+ cJSON_Delete(root);
|
|
|
+ if(pBladeStatus)
|
|
|
+ wfree(pBladeStatus);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void setBladeManage(Webs *wp){
|
|
|
+ uint16_t wRet = LIBIPMI_E_SUCCESS;
|
|
|
+ IPMI20_UDS_SESSION_T UDSSession;
|
|
|
+
|
|
|
+ char *strEnable = websGetVar(wp, "enable", NULL);
|
|
|
+ uint8_t enable = atoi(strEnable);
|
|
|
+
|
|
|
+ if(enable > 1)
|
|
|
+ {
|
|
|
+ websError(wp, 404, "Invalid param");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //Create session
|
|
|
+ LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+
|
|
|
+ wRet = LIBIPMI_HL_SetBladeManageFn(&UDSSession, enable, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ printf("Set Blade Manage error!\n");
|
|
|
+ websError(wp, 404, "Set Blade Manage Error!");
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Close session
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
+
|
|
|
+
|
|
|
+ char *pStr;
|
|
|
+ cJSON * root = cJSON_CreateObject();
|
|
|
+ cJSON * data = cJSON_CreateObject();
|
|
|
+ cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
+ cJSON_AddStringToObject(root, "msg", "");
|
|
|
+ cJSON_AddNumberToObject(root, "code", 200);
|
|
|
+
|
|
|
+ pStr = cJSON_PrintUnformatted(root);
|
|
|
+
|
|
|
+ printf("---> cJSON Str:\n%s\n", pStr);
|
|
|
+ websSetStatus(wp, 200);
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
+ websWrite(wp, "%s", pStr);
|
|
|
+ websFlush(wp, 0);
|
|
|
+ websDone(wp);
|
|
|
+
|
|
|
+ if(pStr)
|
|
|
+ wfree(pStr);
|
|
|
+ if(root)
|
|
|
+ cJSON_Delete(root);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void getBladeManage(Webs *wp){
|
|
|
+ uint16_t wRet = LIBIPMI_E_SUCCESS;
|
|
|
+ IPMI20_UDS_SESSION_T UDSSession;
|
|
|
+ uint8_t enable = 0;
|
|
|
+
|
|
|
+ //Create session
|
|
|
+ LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+
|
|
|
+ wRet = LIBIPMI_HL_GetBladeManageFn(&UDSSession, &enable, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ printf("Set Blade Manage error!\n");
|
|
|
+ websError(wp, 404, "Set Blade Manage Error!");
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Close session
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
+
|
|
|
+
|
|
|
+ char *pStr;
|
|
|
+ cJSON * root = cJSON_CreateObject();
|
|
|
+ cJSON * data = cJSON_CreateObject();
|
|
|
+ cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
+ cJSON_AddStringToObject(root, "msg", "");
|
|
|
+ cJSON_AddNumberToObject(root, "code", 200);
|
|
|
+
|
|
|
+ cJSON_AddNumberToObject(data, "isEnable", enable); //机箱管理功能是否已经打开
|
|
|
+
|
|
|
+ pStr = cJSON_PrintUnformatted(root);
|
|
|
+
|
|
|
+ printf("---> cJSON Str:\n%s\n", pStr);
|
|
|
+ websSetStatus(wp, 200);
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
+ websWrite(wp, "%s", pStr);
|
|
|
+ websFlush(wp, 0);
|
|
|
+ websDone(wp);
|
|
|
+
|
|
|
+ if(pStr)
|
|
|
+ wfree(pStr);
|
|
|
+ if(root)
|
|
|
+ cJSON_Delete(root);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void getChassisInfo(Webs *wp){
|
|
|
+ uint16_t wRet = LIBIPMI_E_SUCCESS;
|
|
|
+ IPMI20_UDS_SESSION_T UDSSession;
|
|
|
+ OemChassisInfo_T ChassisInfo;
|
|
|
+
|
|
|
+ //Create session
|
|
|
+ LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+
|
|
|
+ wRet = LIBIPMI_HL_GetChassisInfo(&UDSSession, &ChassisInfo, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ websError(wp, 404, "Get Chassis Info Error!");
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Close session
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
+
|
|
|
+
|
|
|
+ char *pStr;
|
|
|
+ cJSON * root = cJSON_CreateObject();
|
|
|
+ cJSON * data = cJSON_CreateObject();
|
|
|
+ cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
+ cJSON_AddStringToObject(root, "msg", "");
|
|
|
+ cJSON_AddNumberToObject(root, "code", 200);
|
|
|
+
|
|
|
+ cJSON_AddNumberToObject(data, "slotNum", ChassisInfo.slotNum); //机箱内一共有多少个槽位
|
|
|
+ cJSON_AddNumberToObject(data, "supportManage", ChassisInfo.supportChassisManageFn); //是否支持机箱管理功能。 0:不支持, 1:支持
|
|
|
+ cJSON_AddNumberToObject(data, "ManageEn", ChassisInfo.chassisManageFnEnable); //是否打开机箱管理功能。0:关闭, 1:打开
|
|
|
+ cJSON_AddNumberToObject(data, "curIndex", ChassisInfo.curIndex); //当前刀片插在第几个槽位。
|
|
|
+
|
|
|
+ pStr = cJSON_PrintUnformatted(root);
|
|
|
+
|
|
|
+ printf("---> cJSON Str:\n%s\n", pStr);
|
|
|
+ websSetStatus(wp, 200);
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
+ websWrite(wp, "%s", pStr);
|
|
|
+ websFlush(wp, 0);
|
|
|
+ websDone(wp);
|
|
|
+
|
|
|
+ if(pStr)
|
|
|
+ wfree(pStr);
|
|
|
+ if(root)
|
|
|
+ cJSON_Delete(root);
|
|
|
+
|
|
|
}
|