To retrieve a list of Virtuozzo Containers from the Hardware Node, we will use the get_list
call from the vzaenvm
interface (Virtuozzo Container management).
#XML message. Getting a list of Virtuozzo Containers.
$request=qq~
<packet version="4.0.0" id="4">
<target>vzaenvm</target>
<data>
<vzaenvm>
<get_list/>
</vzaenvm>
</data>
</packet>
~;
#Write the XML message to the socket.
$socket->printflush($request.&MSG_TERMINATOR);
#Read the response and display it on the screen.
$response = $socket->getline;
chomp($response);
print $response;
The response will contain the list of Server IDs. The following is an example of the response message:
<packet id="4" time="2007-08-29T22:51:52+0000" priority="0" version="4.0.0">
<origin>vzaenvm</origin>
<target>vzclient24-4fce28dd-0cd3-1345-bb94-3192b940fb90</target>
<dst>
<director>gend</director>
</dst>
<data>
<vzaenvm>
<eid>ba92bfb3-d97b-014f-a754-5b30528477c3</eid>
<eid>e9ab2834-ed97-1f4b-bd41-81c27facfc30</eid>
<eid>72145bf0-7562-43d4-b707-cc33d37e3f10</eid>
<eid>6dbd99dc-f212-45de-a5f4-ddb78a2b5280</eid>
</vzaenvm>
</data>
<src>
<director>gend</director>
</src>
</packet>
To complete this demonstration, we'll add a code to our program that will restart one of the Virtuozzo Containers from the list above.