しょんぼり技術メモ

まいにちがしょんぼり

Intel vProのAMTのRemoteControlで電源のON/OFFをリモートから行う

Intel AMTのSDKは適当に探してダウンロードしておいてください。今回はバージョン6を使用。

LinuxSOAP版の電源操作を行うコマンドはLinux/Intel_AMT/Samples/Soap/RemoteControlにある。
というわけで早速コンパイルしてみる。方法については、Linux/Intel_AMT/Samples/Soap/README を参照。
RemoteControlのディレクトリにMakefileがあるからっていきなりmakeしてもダメです。悲しい。

Prerequisite:
1. Navigate to the root directory of the Linux SDK and perform the following
   command:
     chmod a+rwx -R <root directory of linux sdk>

In order to compile all the samples you will need to perform the following
steps:
        1. Invoke the command - "make" inside the directory
           'Intel_AMT/Src/StorageLib'
           Note: This step isn't always required as compiled versions of the
                 storage library already exist.
        2. Invoke the command - "make wsdls" inside the directory
           'Intel_AMT/Samples/Soap'
        3. Invoke the command - "make" inside the directory
           'Intel_AMT/Samples/Soap'

というわけで、おとなしく従います。おまけに、そのままじゃコンパイル通らないので、以下のパッチを当てます。
(というか、これも「コンパイルを無理矢理通すだけのやっつけパッチ」なので、constをぞんざいに扱うなとかそういうご指摘は勘弁を…)

diff -Nuw Linux_org/Common/ThirdParty/gSOAP/httpDigest.cpp Linux/Common/ThirdParty/gSOAP/httpDigest.cpp
--- Linux_org/Common/ThirdParty/gSOAP/httpDigest.cpp    2009-03-25 22:06:32.000000000 +0900
+++ Linux/Common/ThirdParty/gSOAP/httpDigest.cpp        2011-05-12 15:21:43.000000000 +0900
@@ -41,6 +41,7 @@
 #include "httpDigest.h"
 #include "digcalc.h"
 #include <string.h>
+#include <sys/stat.h>

 #if 0  // ifdef out to avoid compiler warning
 // Debugging macros and variable:
@@ -536,7 +537,7 @@
             return soap->error = SOAP_EOM;
        }

-        s1 = strstr(key, " ");
+        s1 = (char*)strstr(key, " ");
         if (!s1) {
             return soap->error = SOAP_EOM;
         }
diff -Nuw Linux_org/Common/ThirdParty/gSOAP/stdsoap2.cpp Linux/Common/ThirdParty/gSOAP/stdsoap2.cpp
--- Linux_org/Common/ThirdParty/gSOAP/stdsoap2.cpp      2008-01-17 15:35:48.000000000 +0900
+++ Linux/Common/ThirdParty/gSOAP/stdsoap2.cpp  2011-05-12 15:20:46.000000000 +0900
@@ -4001,7 +4001,7 @@
           { X509_EXTENSION *ext = X509_get_ext(peer, i);
             const char *ext_str = OBJ_nid2sn(OBJ_obj2nid(X509_EXTENSION_get_object(ext)));
             if (ext_str && !strcmp(ext_str, "subjectAltName"))
-            { X509V3_EXT_METHOD *meth = X509V3_EXT_get(ext);
+            { const X509V3_EXT_METHOD *meth = X509V3_EXT_get(ext);
              void *ext_data;
 #if (OPENSSL_VERSION_NUMBER >= 0x0090800fL)
               const unsigned char *data;

パッチを当てたら、READMEに従って作業を進めます:
1. Linux/Intel_AMT/Src/StorageLib で make

2. Linux/Intel_AMT/Samples/Soap で make wsdls

3. Linux/Intel_AMT/Samples/Soap/RemoteControl/C++/Makefileに、

LIBS = -lssl -lcrypto

を追加してmake

4. Linux/Intel_AMT/Samples/Soap/RemoteControl/C++/remoteControl ができる

実際に使ってみる

ターゲットのIPアドレスを192.0.2.1、ポートを16992、ユーザ名をadmin、パスワードをPassWorDと仮定します。

"-p"オプションで電源状態の取得を行います。

$ ./remoteControl -p -user admin -pass PassWorD http://192.0.2.1:16992/RemoteControlService

Calling function GetSystemPowerState...
SystemPowerstate is: 0

"-r"オプションで、電源のリモートコントロールを行います。
処理は対話的に行われます。

$ ./remoteControl -r -user admin -pass PassWorD http://192.0.2.1:16992/RemoteControlService
Please specify the following parameters

        Command
        =======
Possible values:
        16 (Reset)
        17 (PowerUp)
        18 (PowerDown)
        19 (PowerCycleReset)
        33 (SetBootOptions)
>16

Iana OEM Number is IntelIanaNumber (343)

        Special Command
        ===============
Possible values:
        -1 (No Special Command)
        0 (NOP)
        1 (ForcePxeBoot)
        2 (ForceHardDriveBoot)
        3 (ForceHardDriveSafeModeBoot)
        4 (ForceDiagnosticsBoot)
        5 (ForceCdOrDvdBoot)
        193 (IntelOemCommand)
>-1

        OEM Parameters
        ==============
Possible values:
        -1 (No OEM Parameters)
        0 (Undefined OEM Parameter)
        1 (UseSol)
>-1

        Special Command Parameters
        ==========================
Possible values:
        Special command not equal to 193

        -1 (No Special Command Parameter)
>-1

        Boot Options
        ============
Possible values:
        -1 (No boot options)
        2 (LockPowerButton)
        4 (LockResetButton)
        32 (LockKeyboard)
        64 (LockSleepButton)
        2048 (UserPasswordBypass)
        4096 (ForceProgressEvents)

        Firmware Verbosity Options:
        ---------------------------
        0 (FirmwareVerbositySystemDefault)
        8192 (FirmwareVerbosityQuiet)
        16384 (FirmwareVerbosityVerbose)
        24576 (FirmwareVerbosityScreen)

        32768 (ConfigurationDataReset)

You can choose several options by using bitwise OR operation

>-1

Calling function RemoteControl...   success

コマンド一発で電源を操作したい場合には、次のようなファイルを作っておいて、入力をリダイレクトすればOKです。

reset.command

16
-1
-1
-1
-1

powercycle.command

19
-1
-1
-1
-1

powerdown.command

18

次のようにして実行すると、入力の必要なしに電源の操作ができます。

$ ./remoteControl -r -user admin -pass PassWorD http://192.0.2.1:16992/RemoteControlService < reset.command > /dev/null