mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-25 15:03:25 +03:00
1 line
42 KiB
JavaScript
1 line
42 KiB
JavaScript
|
function AmtStackCreateService(R){var J=new Object();J._ObjectID="AMT";J.wsman=R;J.pfx=["http://intel.com/wbem/wscim/1/amt-schema/1/","http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/","http://intel.com/wbem/wscim/1/ips-schema/1/"];J.PendingEnums=[];J.PendingBatchOperations=0;J.ActiveEnumsCount=0;J.MaxActiveEnumsCount=1;J.onProcessChanged=null;var n=0;var m=0;J.GetPendingActions=function(){return(J.PendingEnums.length*2)+(J.ActiveEnumsCount)+J.wsman.comm.PendingAjax.length+J.wsman.comm.ActiveAjaxCount+J.PendingBatchOperations};function r(){var S=J.GetPendingActions();if(n<S){n=S}if(J.onProcessChanged!=null&&m!=S){m=S;J.onProcessChanged(S,n)}if(S==0){n=0}}J.Subscribe=function P(U,T,aa,S,Z,X,Y,V,ab,W){J.wsman.ExecSubscribe(J.CompleteName(U),T,aa,function(ae,ad,ac,af){r();S.call(J,J,U,ac,af,Z)},0,X,Y,V,ab,W);r()};J.UnSubscribe=function Q(T,S,W,U,V){J.wsman.ExecUnSubscribe(J.CompleteName(T),function(Z,Y,X,aa){r();S.call(J,J,T,X,aa,W)},0,U,V);r()};J.Get=function E(T,S,V,U){J.wsman.ExecGet(J.CompleteName(T),function(Y,X,W,Z){r();S.call(J,J,T,W,Z,V)},0,U);r()};J.Put=function K(T,V,S,X,U,W){J.wsman.ExecPut(J.CompleteName(T),V,function(aa,Z,Y,ab){r();S.call(J,J,T,Y,ab,X)},0,U,W);r()};J.Create=function y(T,V,S,W,U){J.wsman.ExecCreate(J.CompleteName(T),V,function(Z,Y,X,aa){r();S.call(J,J,T,X,aa,W)},0,U);r()};J.Delete=function z(T,V,S,W,U){J.wsman.ExecDelete(J.CompleteName(T),V,function(Z,Y,X,aa){r();S.call(J,J,T,X,aa,W)},0,U);r()};J.Exec=function B(V,U,S,T,Y,W,X){J.wsman.ExecMethod(J.CompleteName(V),U,S,function(ab,aa,Z,ac){r();T.call(J,J,V,J.CompleteExecResponse(Z),ac,Y)},0,W,X);r()};J.ExecWithXml=function D(V,U,S,T,Y,W,X){J.wsman.ExecMethodXml(J.CompleteName(V),U,C(S),function(ab,aa,Z,ac){r();T.call(J,J,V,J.CompleteExecResponse(Z),ac,Y)},0,W,X);r()};J.Enum=function A(T,S,V,U){if(J.ActiveEnumsCount<J.MaxActiveEnumsCount){J.ActiveEnumsCount++;J.wsman.ExecEnum(J.CompleteName(T),function(Z,X,W,aa,Y){r();e(T,W,S,X,aa,Y)},V,U)}else{J.PendingEnums.push([T,S,V,U])}r()};function e(U,W,S,X,Y,Z,V){if(Y!=200){S.call(J,J,U,null,Y,Z);d(1);return}if(W==null||W.Header.Method!="EnumerateResponse"||!W.Body.EnumerationContext){S.call(J,J,U,null,603,Z);d(1);return}var T=W.Body.EnumerationContext;J.wsman.ExecPull(X,T,function(ac,ab,aa,ad){c(U,aa,S,ab,[],ad,Z,V)})}function c(X,Z,S,aa,V,ab,ac,Y){if(ab!=200){S.call(J,J,X,null,ab,ac);d(1);return}if(Z==null||Z.Header.Method!="PullResponse"){S.call(J,J,X,null,604,ac);d(1);return}for(var U in Z.Body.Items){if(Z.Body.Items[U] instanceof Array){for(var W in Z.Body.Items[U]){V.push(Z.Body.Items[U][W])}}else{V.push(Z.Body.Items[U])}}if(Z.Body.EnumerationContext){var T=Z.Body.EnumerationContext;J.wsman.ExecPull(aa,T,function(af,ae,ad,ag){c(X,ad,S,ae,V,ag,ac,1)})}else{d(1);S.call(J,J,X,V,ab,ac);r()}}function d(S){J.ActiveEnumsCount-=S;if(J.ActiveEnumsCount>=J.MaxActiveEnumsCount||J.PendingEnums.length==0){return}var T=J.PendingEnums.shift();J.Enum(T[0],T[1],T[2]);d(0)}J.BatchEnum=function(S,V,T,X,U,W){J.PendingBatchOperations+=(V.length*2);b(S,x(V),T,X,{},U,W);r()};function x(S){return JSON.parse(JSON.stringify(S))}function b(S,X,T,aa,Z,U,Y){J.PendingBatchOperations-=2;var W=X.shift(),V=J.Enum;if(W[0]=="*"){V=J.Get;W=W.substring(1)}V(W,function(ad,ab,ac,ae,af){af[2][ab]={response:(ac==null?null:ac.Body),responses:ac,status:ae};if(af[1].length==0||ae==401||(U!=true&&ae!=200&&ae!=400)){J.PendingBatchOperations-=(X.length*2);r();T.call(J,J,S,af[2],ae,aa)}else{r();b(S,X,T,aa,af[2],Y)}},[S,X,Z],Y);r()}J.BatchGet=function(S,U,T,W,V){h({name:S,names:U,callback:T,current:0,responses:{},tag:W,pri:V});r()};function h(S){if(S.names.length<=S.current){S.callback.call(J,J,S.name,S.responses,200,S.tag)}else{J.wsman.ExecGet(J.CompleteName(S.names[S.current]),function(V,U,T,W){g(S,T,W)},S.pri);S.current++}r()}function g(S,T,U){if(T==null||U!=200){S.callback.call(J,J,S.name,null,U,S.tag)}else{S.responses[T.Header.Method]=T;h(S)}}J.CompleteName=function(S){if(S.indexOf("AMT_")==0){return J.pfx[0]+S}if(S.indexOf("CIM_")==0){return J.pfx[1]+S}if(S.indexOf("IPS_")==0){return J.pfx[2]+S}};J.CompleteExecResponse=function(S){if(S&&S!
|