-
Notifications
You must be signed in to change notification settings - Fork 3
CVMWebAPI.js Reference
The CVMWebAPI.js library provides a high-level interface to the CernVM Web API plugin. It takes care most of the demanding operations, letting you enjoy only the useful functionality.
First thing you should do after you include the library is to request API Access using the CVM.startCVMWebAPI() function:
<script type="text/javascript" src="http://labs.wavesoft.gr/micro/js/cvmwebapi-1.0.js"></script>
<script type="text/javascript">
// Start CernVM Web API
CVM.startCVMWebAPI(
function(plugin) {
}
);
</script>The the successCallback is called after the plugin is instantiated and initialised. The first argument is a WebAPIPlugin object. Using this object you can request the creation of a session using the requestSession function:
function(plugin) {
plugin.requestSession("http://example.com/vmcp.cgi?vm=33123", function(session) {
// Now you can use your session in the 'session' variable.
}
}This function will either resume a previous instance of the given session or create a new one. In both cases, the configuration obtained from the VMCP endpoint. You can check the VMCP Reference for more details on this topic.
The following methods are exposed under the CVM namespace.
| void startCVMWebAPI | ( function( pluginInstance ) successCallback, function( message, code ) failureCallback ) |
|---|---|
Initialise application and connect to it.
|
|
| void startCVMWebAPI | ( function( sessionInstance ) successCallback ) |
The following methods are exposed under the CVM.WebAPIPlugin class:
| bool stopService | ( ) |
|---|---|
| void requestSession | ( string configURL, function( ) successCallback, function( message, code ) failureCallback ) |
| void addEventListener | ( string eventName, function( ... ) eventHandler ) |
| void removeEventListener | ( string eventName, function( ... ) eventHandler ) |
The following methods are exposed under the CVM.WebAPISession class:
| bool start | ( Object macroValues = { }, function( ) successCallback = undef, function( message, code ) failureCallback = undef ) |
|---|---|
| bool stop | ( function( ) successCallback = undef, function( message, code ) failureCallback = undef ) |
| bool pause | ( function( ) successCallback = undef, function( message, code ) failureCallback = undef ) |
| bool resume | ( function( ) successCallback = undef, function( message, code ) failureCallback = undef ) |
| bool hibernate | ( function( ) successCallback = undef, function( message, code ) failureCallback = undef ) |
| bool reset | ( function( ) successCallback = undef, function( message, code ) failureCallback = undef ) |
| bool close | ( function( ) completedCallback = undef ) |
The following properties are exposed under the CVM.WebAPISession class:
| (read-only) | int | state |
|---|---|---|
| (read-only) | string | stateName |
| (read-only) | string | ip |
| (read-only) | int | ram |
| (read-only) | int | disk |
| (read-only) | string | version |
| (read-only) | string | diskURL |
| (read-only) | string | apiURL |
| (read-only) | string | rdpURL |
| (writable) | SessionFlags | flags |
| (writable) | int | executionCap |
| (writable) | bool | daemonControlled |
| (writable) | int | daemonMinCap |
| (writable) | int | daemonMaxCap |
| (writable) | DaemonFlags | daemonFlags |