Skip to content

Service VMs

Sebastian Echeverria edited this page May 22, 2018 · 24 revisions

Target Version: pycloud 0.4.0

Services

Services and Service VMs

Services are defined as capabilities that are remotely available to cloudlet-ready apps through a predefined port on a host machine (cloudlet). Each service has its own communication protocol and will typically be implemented as a server program that is listening on the predefined port. A service is uniquely identified by a Service ID that is used by cloudlet-ready apps when selecting the service that contains the capabilities that they require. The cloudlet-ready app has the responsibility of being able to understand the communication protocol used by the service as well as its interface.

A Guest VM that provides a Service is called a Service VM. Clients can query for available Services on cloudlets without having to know that it is provided by a Service VM.

Service Repository and VM Images

Services are stored in a repository inside a Cloudlet so that they are available to clients that request access to them. When a mobile device wants to access a Service from a Cloudlet, it will first query nearby cloudlets to see if the Service is available. If found, the Cloudlet Server will then start the corresponding Service VM to provide the service to the client.

A Service in the repository is composed of:

  • Service Metadata: Information describing the service that is stored in an internal database managed by the Cloudlet Manager.

    • There are two mandatory fields for a Service that are required in the Service Creation process:

      • Service ID (string): unique identifier for the service; a recommendation is to use a reversed-URL string, similar to the ID used to identify Java packages

      • Service Port (integer): port on which the server, inside the VM, will be listening for connections

    • There are several optional fields:

      • Version (string): version number of the service

      • Description (string): text description of the service

      • Tags (string): tags that describe the service that are used by the service query capability

      • Number of Clients Supported (integer): number of clients that the server designed to support. If this is more than one, a Cloudlet server may use running Service VMs to serve multiple clients. Otherwise, it will spawn a separate Service VM for each client.

      • Minimum Memory (MB) (decimal): minimum amount of RAM that the Service requires in order to run properly

      • Ideal Memory (MB) (decimal): ideal amount of RAM space for this Service to run properly

  • VM Image: corresponds to two image files – one for the disk image and one for the state/memory image – that contain a suspended Service VM. This VM Image is used to create a Service VM that provides access to the Service. In particular:

    • Disk Image file (.qcow2): qcow2 file containing an image of the hard drive of a Service VM. It contains the installed server files of the program that provides the service.

    • VM State Image file (.lqs): VM state image in the format that libvirt.save() generates when saving a memory image. The format is called Libvirt Qemu Saved (lqs) and includes both the description of the VM that was suspended, as well as the memory state of the VM. That memory state includes the running server listening on the defined port to provide the required service.

A VM Image contains a Service VM that is suspended in a state in which the server is running and waiting for connections. VM Images in the repository are read-only. A copy of the disk and saved state images are created each time a client wants access to the service (if there is no shareable running Service VM available). A running Service VM is loaded from this copy which provides the service defined in its metadata. When a Service VM is created from a VM Image, it is immediately started and ready to accept incoming Service requests.

Service Management

Service Creation

The following are pre-conditions for creating a Service:

  • Cloudlet Server is correctly installed and running on a Cloudlet Host (details at Cloudlet Server - pycloud).

  • Access to a browser is available on the Cloudlet Host so that the Cloudlet Manager can be accessed.

  • A base VM disk image that has a basic OS installation. Image files in .raw (or .img) and .qcow2 formats should work correctly.

  • The server code that is going to provide the service is either already installed on the base disk image above or is available to be installed on a new VM.

The following steps must be followed to create a new Service and its associated VM Image:

  1. Access the Cloudlet Manager web app and select Services from the navigation bar.

  2. Click on the Create New Service button.

  3. A new page will appear in which details about the service can be added. The mandatory fields in this page are:

    • Service ID: ID that will be used by cloudlet-ready apps to identify the service. If a Service changes its ID, the cloudlet-ready apps that use it will have to be reconfigured to map to this new ID.

    • Port: Port that the server will be listening on to provide access to its capabilities.

  4. If a full VM image does NOT exist, after adding the mandatory fields, click on the Create New VM Image button and proceed to Step 6. Keep in mind that a full VM image means that there are two files for the service: the disk image (.qcow2) and the VM state image (.lqs).

  5. If a full VM image does exist, after adding the mandatory fields, click on the Select Existing VM Image button, enter the path to the folder with the VM Image, and proceed to Step 10.

  6. Depending on whether you have a prepared VM or not:

    • If you don't have a prepared VM yet:

      • Type/paste the full path of a disk image file that can be used as a base for the VM (typically containing an installed OS).

      • Select the OS that is installed on this source disk image file from the drop-down menu.

    • If you have a VM prepared with a server already installed on it:

      • Type/paste the full path for the disk image that contains your server on it.

      • Select the OS that is installed on this disk image file.

  7. Click on Create and wait for the message confirming the creation of a temporary Service VM to create the VM Image from.

  8. If your disk image did not have the server already installed on it, VNC or SSH can be used to access the Service VM and install what is required.

    • Transfer all required files for the server to the VM. This can be done downloading it through the Internet if possible, or in different ways depeding on the OS of the VM:

      • On Linux, this can be done using SSH using the scp command. This would allow the transfer of the server files. Where to connect to depends on the networking mode being used.

        • The IP and port to connect to through SSH will be shown on the Service creation page.

        • A sample command to copy /FolderToCopy in the cloudlet to /home/cloudlet inside the VM with the SSH port mapped to 9022 is the following:

          scp -P9022 -r ./FolderToCopy cloudlet@192.168.1.10:/home/cloudlet/

      • On Windows, the files will have to be downloaded either from the Internet or from a shared folder on a server that is available on the same LAN.

    • Perform any other server-specific installation procedures, if any.

    • If VNC is preferred, any VNC client should work. However, it has to connect to the IP of the Cloudlet Server, not of the Service VM (which can be different if the system is using bridge networking). The VNC IP and port will be shown on the Service creation page.

  9. Start the server inside the Service VM and ensure it has some auto-start configuration, ensuring that the port that it is listening on is the same one defined as the Service port above.

  10. Click the Save from Service VM button to save the changes to a permanent VM Image.

  11. Click on Save to add the Service to the repository.

  12. To test the service:

    • If all is correct, the new Service should appear in the Services list.
    • Click on the New Service VM button.
    • Once the instance is started, start the matching cloudlet-ready app and check that it works correctly.

Service Modification

  1. Access the Cloudlet Manager web app and select Services from the navigation bar.

  2. Click on the Edit Service button next to the Service that you want to edit.

  3. Change any metadata for the Service.

  4. If changes to the VM Image are needed, click on the Edit Current VM Image

    • Optionally, a new VM Image could also be created from scratch here, using the Create New VM Image button. If this is done, follow the related steps in the previous section.

    • Optionally, another existing VM Image could also be selected here. In that case, use the Select Existing VM Image button and enter the path of the folder with the VM.

  5. Perform modifications to the Service VM, if required, using procedures similar to step 8 of the previous section to create a service.

  6. When finished, click the Save from Service VM button to save the changes (or the Discard SVM button if you want to ignore the changes.

  7. If metadata was changed, click the Save button on the button to store those changes too.

Note that as long as the interface and protocol of the server do not change (and the server is kept running), any changes to the VM Image will not affect any cloudlet-ready apps that are configured to work with this service. Changes to the Service metadata should not affect cloudlet-ready apps, except for the Service ID, which, if changed, will have to be changed on each app to allow them to find the corresponding service (see next section).

Cloudlet-Ready Apps and Service ID Modification

A Cloudlet also contains a repository of cloudlet-ready apps. This can be added to the Cloudlet through the Cloudlet Manager, selecting the Cloudlet-Ready Apps option and then clicking on the Add button. The only metadata of an app that is related to the stored services is the Service ID, which will have to be selected from the Services in the repository. These apps can be queried and downloaded by a mobile device with the Cloudlet Client app. If a Service ID changes, an app would have to be re-downloaded by a mobile device to ensure that it will be looking for the correct service.

Service Export and Import

Services can be exported into a portable format from a Cloudlet Server. These exported files can later be imported into another Cloudlet Server. The exported service file format is .csvm, which is a .tar.gz file that contains a JSON file with the metadata from the Service, a two image files (disk and state) which compose the VM Image associated to the Service. Services can be exported and imported from the Cloudlet Manager.

Service Export

  1. Go to Cloudlet Manager, and go to the Services page.
  2. For the service that needs to be exported, click on the Export Service icon (blue icon on the far left).
  3. Wait several minutes until the export process finishes (a window with the text Exporting Service will be visible during this time).
  4. The exported service .csvm file will be located in the ./data/temp/export folder. The name of the file will be the Service ID.

Service Import

  1. The .csvm file to import has to be locally reachable from the Cloudlet Host.
  2. Go to Cloudlet Manager, and go to the Services page.
  3. Click on the Import a Service button.
  4. Enter the full path for the csvm file.
  5. Wait until the import process finishes (a window with the text Importing Service will be visible during this time).