Add utilities for working with exceptions

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: run before httpserver

Cloud init needs to run before anything else because it reads
configuration for anything else. Since httpserver, when included, will
now be run from /init, we need to make sure that cloud init runs
before it.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: client: make connection time out after 1 second

The default timeout seems too long. 1 second seems more than enough to
ping the local meta data service.

Note on the implementation: There really seems to be no way to set
timeout using boost asio sync api. The author recommends using async
API and a timer to achieve that. This makes the code more bloated but
if we want to stick with boost asio we don't have a choice according
to my research.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: client: support for setting HTTP headers

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: client: introduce text() method for getting response contents

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: client: do not throw when response code is not 200

Response code is not 200 should not be, in general, considered an
error of HTTP request. It is up to the higher layer to interpret it.
If we alwasy throw then the higher layer will have no chance of making
an interpretation of the result.

For example 404 when requesting an attribute may be perfectly fine (it
means the attribute is missing). We want to distinguish that from
actual connection error.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: call load*() methods directly

It's simpler to call load() directly rather than fake user config by
constructing YAML nodes.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: turn 'once' flag to a standard behavior

This is to simplify things which will make further refactorings
easier. Apparently this is the behavior we always want.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: add support for pluggable configuration modules

This is a preparation for allowing simple configuration syntax like this:

  files:
     /etc/hosts: |
        localhost 127.0.0.1

The current pseudo-REST commands are moved under "run" section,
preserving all the functionality:

 run:
    - POST: /os/shutdown

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: introduce meta-data service abstraction

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: load config from cloud's user data by default

On EC2 we load from /latest/user-data.
On GCE we load from "user-data" attribute.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: link with boost_filesystem

This is achieved by fixing placement of libraries on gcc command line.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: add support for "files" syntax

This allows to create files in the guest with the following syntax:

files:
   /path/to/file: |
      this will be the
      file's content
   /path/to/yet/another/file: content

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
cloud-init: clean up error handling

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Merge branch 'cloud-init-improvements'

Tomek writes the following:

  This series adds necessary grounds needed to set SSL keys via user-data (but
  not only that). I decided to split the series into two independent parts to
  speed up review.

  When cloud-init module is included in the image it will fetch the
  configuration from cloud's metadata service and parse it. Currently only EC2
  and GCE clouds are supported.

  This series also adds support for pluggable YAML configuration modules. As an
  example this series adds a "files" module which can be quite useful to set content
  of the files during boot using syntax like this:

  files:
    /etc/file1.txt: yoyoyo
    /etc/file2.txt: |
       this is a
       very large
       multi line
       content

  The old RESTful commands are moved to the new "run" section.

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