Add sleep command

Add Sleep command

Signed-off-by: Pradeep K Surisetty <psuriset@linux.vnet.ibm.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http Server: Use const for operation names

Operation names are used to mapped operation to path, it is now possible
to use a constant instead of a string. This will result in a compilation
failure instead of a run time failure.

For example instead of using "getFile" to locate the operation, it is
possible to use: file_json::getFile

If for some reason the operation name will changed, the compilation will
fail.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: Change file.cc to use constants over string

The code generation now produces constants for the operation name. The
file.cc was modified to use those constants.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: Makefile should depend on the code generation script

When changing the code generation script, the generated code should be
recompiled.

The generated code is now depends on the code generation script.

clean now cleans the auto generated files as well

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http Server: Override the default error message

When a non default error message is return (like in the case of
exception) That message needs to be used as the content body.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: Add enum support to code generation

When a parameter is declare as enum in the swagger definition file, the
code generation will create an enum internal namespace to the operation.

To the set of values a NUM_ITEMS value is added as the last value, so
if an enum op is declared as:
"enum":["MKDIRS", "RENAME"] in an operation putFile
The declared enum would be:

namespace ns_putFile {

enum class op {
MKDIRS, RENAME, NUM_ITEMS
};

For each enum a translation from string is created for it. The
translation function return the enum value if it is found or NUM_ITEMS
if it is not found, similar to string method that returns npos.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http server: Additional file support

The patch series change the file api implementation to use enum over
string.

It also introduce the following operation:
GET
GETFILESTATUS - return information on a file
LISTSTATUS -  return information on all files in a directory

PUT
MKDIRS - create a directory
RENAME - rename a file or a directory
COPY - copy a file

The simplest way of testing the changes is to use the Swagger-UI file
operation.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: Testing to support additional os version

Support os version of type: v0.06-rc4

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server testing: Adding file API testing

Add testing for LISTSTATUS, STATUS, COPY, RENAME, DELETE

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Shell: Make `cd -` return to the last active dir

Fixes #40.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Or Cohen <orc@fewbytes.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
api-doc: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
add handler for /os/dmesg and add dmesg as a command

A minimal implementation for dmesg.

Signed-off-by: Jaspal Singh Dhillon <jaspal.iiith@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
shell: fix missing cleanup in "perf stat"

Our "perf stat ..." shell command installs a tracepoint counter
(implemented by the com.cloudius.trace.Counter) but neglects to
close() it when done.

So when the "perf stat" command is interrupted, the counter is left
behind, causing a waste of time at best (as we keep counting the tracepoint
even when perf stat is not running) - and a crash at worst (when
a GC frees the counter object, the kernel continues to count in it).

So this patch adds the missing close() calls in a "finally" section.
This "finally" is called when the perf stat command is interrupted
with a ^C.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http Server: Move exception to their own file

Exception handling in the httpserver is cover by http exception, and
general exception.

Http exception are mainly a result of bad input: a resource is not found
or arguments are wrong General exception results from some error in the
code.

The exception file holds a base class for the exception and the basic
derivation from it (not found, bad request and missing parameter).  All
the http server exception has a message and a status code that will be
used in the reply.

The exception handler will now use the message and status from the
exception in all httpserver exception.

Other exception will result a 500 (internal server error) reply.

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Fix options for command: free

Right now, free -k is no different from free -m and free -g. free -b
gives the output for free -h. This patch fixes the above problem.

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http Server: File upload handled by the handler

File upload via multi part message is now handled by the handler.

For that a few changes have been made:
The request holds a reference to the connection, to be able to complete
the upload.

To retain the async nature of the reading a call back interface was
added to the multi-part message parser.

This allows the handler to load the file directly to the file position,
or to upload it to a temporary file inside the target directory and
rename the file after the download is complete.

The new behavior of the connection is to stop parsing after the first
part of the message was parsed. Copy the remaining buffer to the
multipart parser and call the handler to continue processing.

If the handler wishes to continue the upload, it should set the
temporary file name, either immediately or by registering a call back
function and call upload.

If the upload function is called, the connection will not return a
response immediately but will wait for the upload to complete.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: file api - file upload

To upload a file, the file API handler register two function, one that
sets a temporary file inside the target directory and one that move the
temporary file, when the upload is complete, it then call upload to
resume the file upload.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: Testing the file upload API

This test creates a temporary file, upload it, download it back and
check that the file is identical.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
run: don't pass extra null argument

Fixes #47
Check size of the string before calling split on it, else
we end up adding a null argument to the command.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Jaspal Singh Dhillon <jaspal.iiith@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Http server: Add stub for debugger buffer

The debug buffer needs to be stub so the stand alone server would be able
to compile.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>