1.8 Integrating the CLI into Your Applications

CLI-based integration is a popular and inexpensive way to integrate Oracle VM into your own applications. It is far easier and faster than using the Web Services API, and for smaller integrations is a very good option.

There are two Expect scripts, eovmcli and eovmclixml that enable you to easily execute CLI commands from the operating system shell. All you need to do is install the Expect RPM (free) on your Oracle VM Manager host and you are ready to execute scripts against the CLI.

The eovmclixml script take three command line arguments (username, password and command, for example:

 # eovmclixml “admin” “password” “list Server” 

The results are returned in XML format at the shell prompt. XML is useful for parsing the results in another application.

The connection information is cached on the Oracle VM Manager host for 15 minutes, so subsequent calls with the same login credentials are faster than the initial connection.

You can write your own CLI scripts and take advantage of all the rich constructs that the operating system shell provides: variables, looping, conditional execution, parsing, and so on.

An easy way to integrate with Java is to use the exec method within the Runtime class, then parse the XML output with an XML parser such as SAX.

The eovmcli script does the same thing but pretty prints the results to the screen, just like when you run the CLI using an SSH connection.

The CLI does not support regular expressions. If you want to use regular expressions, you should use them in your script that calls the CLI.