Skip to content

Latest commit

 

History

History
191 lines (138 loc) · 6.75 KB

CentOSVZAdapter.org

File metadata and controls

191 lines (138 loc) · 6.75 KB

CentOSVZAdapter for ADS

Introduction

Adapter is an ADS component, which is responsible for creating and managing VMs on a particular platform.

The CentOSVZAdapter is an adapter for the CentOS OpenVZ platform. In this document, the term VM and container are used interchangeably.

Functional Requirements

  1. CentOSVZAdapter will create a container on CentOS OpenVZ platform based on the specification given in the lab spec of a particular lab.
  2. CentOSVZAdapter will copy the ADS code to the newly created container and start the VMManager service.

Design

CentOSVZAdapter is required to create, start, stop and restart the container but in the current release, it creates container and intializes the VMManager service.

CentOSVZAdapter works by issuing multiple commands to create, set and start a VM. It utilizes the vzctl API to execute commands. CentOSVZAdapter contacts base machine through SSH to executes commands.

Interfaces

In the current design of ADS, a fixed set of interfaces to an adapter is already defined. An adapter is required to implement these interfaces. This enables other components/services of ADS to communicate with the adapter. The interfaces implemented by the CentOSVZAdapter are listed below:

  1. create_vm (self, lab_spec, vm_id=”“) Creates a new VM.

    Parameters:

    • lab_spec - Lists the lab and VM related reqirements.
    • vm_id - If no vm_id is specified, it is computed using the last two segments of an available IP address.

    Returns: VM id of the newly created VM.

  2. start_vm (self, vm_id)

    Starts the VM identified by vm_id.

    Parameters:

    • vm_id - vm_id of the VM to be started.

    Returns: List of VMs that got started.

  3. start_vm_manager (self, vm_id )

    Starts the VM manager service inside the VM identified by vm_id.

    Parameters:

    • vm_id - VM id of the VM to be started.

    Returns: True if the VM Manager service has successfully started.

Configuration <<configuration>>

Set the proxies:

To set the proxies, edit the file ovpl/config/config.json and ovpl/src/VMManager/config.json.

"ENVIRONMENT": { "HTTP_PROXY":"http://proxy.vlabs.ac.in:8080", "HTTPS_PROXY":"http://proxy.vlabs.ac.in:8080" },

if no proxies are used,

"ENVIRONMENT": { "HTTP_PROXY":"", "HTTPS_PROXY":"" },

Set the Base Machine details:

Also set the SERVER_IP in LOGSERVER_CONFIGURATION to the IP address of the machine on which the ADS services are running.

Edit the file ovpl/src/adapters/settings.py

If the services are running on the base machine,
set ADS_ON_CONTAINER to False.

If the services are running on a container,
set ADS_ON_CONTAINER to True.

Set BASE_IP_ADDRESS = "root@<IP>" where IP is the ip address of
base machine on which containers are created.

Set ADS_SERVER_VM_ID to CTID of container running ADS.
ADS_SERVER_VM_ID = "<CTID>" 

SUBNET field to match with the subnet of your base machine
If the ip address of your base machine is 10.2.58.XXX, 
SUBNET = ["10.2.58.12/28"]

Share the public key:

SSH access using key based authentication is allowed on base machine. So to run the test cases, copy public key from ~/.ssh/id_rsa.pub of local machine and paste the public key in authorized_keys ~./ssh/authorized_keys of Base Machine.

Scenarios of CentOSVZAdapter

The following sequence diagram depicts the work flow for creation and intilization of the VM. It takes the lab spec through http request and creates the VM. CentOSVZAdapter returns vm_id, vm_ip and vm_manager_port as a http response to the VMPoolmanager.

./sequence-diagram-of-centos-openvzadapter.png

Following is the sequence of events that occur when a lab is deployed on CentOS platform using CentOSVZAdapter:

  1. VMPoolManager sends an HTTP Request to AdapterServer indicating that a VM needs to be created. It also passes the lab spec that includes VM requirements.
  2. On receiving this request, the AdapterServer calls the create_vm() function of CentOSVZAdapter and hands over the lab spec to it.
  3. Based on lab spec, the CentOSVZAdapter selects OS template.
  4. It creates a VM on Base Machine.
  5. The vm_id of the newly created VM is returned to the AdapterServer.
  6. The AdapterServer now calls the init_vm() function of CentOSVZAdapter.
  7. This initializes the newly created VM on CentOSVZAdapter by copying relevant ADS component (VM Manager) and lab sources, and starting the VM Manager.
  8. Once this service has started, the CentOSVZAdapter sends back vm_id of the VM, vm_ip of the VM and port on which the VM Manager service is running to AdapterServer.
  9. Later three parameters (vm_id, vm_ip, vm_manager_port) are forwarded by AdapterServer as HTTP response to the VMPoolManager.

Implementation

The implementation of the CentOSVZAdapter can be found here.

Testing

Objective

  • To validate the creation of a VM.
  • To validate the intilization of a VM.
  • To ensure that the VMManagerService is running on this VM.

This is achieved through unit testing.

Testing Environment

  1. A VM is provisioned on Base Machine, such that it is able to access the internet.
  2. Edit the config.json and setting.py as mention above in configuration
  3. ADS is configured and running in the provisioned VM.
  4. Share the public key as metioned above in configuration

Test Cases

Unit Test Structure

All unit tests should follow the same basic structure as follows:

  • Set up all conditions for testing.
  • Call the method (or Trigger) being tested.
  • Verify that the results are correct.
  • Clean up modified records.

Case 01: Creation of a VM

The objective of this test case is to test the creation of a VM on Base Machine. test_create_vm() is responsible for testing the creation of VM and returns vm_id.

Case 02: Intialization of VM

The objective of this test is to validate the intialization of a VM on Base Machine. test_init_vm() is responsible for testing the intilization of VM. It returns vm_ip, vm_id, vmm_port and return the status as boolean value.

Case 03: Checking if VMManager service is running successfully

After the VM is initialized, it is necessary to validate if the VMManager sevice is running or not. It returns the status code.

Implementation of test cases

The implementation code for all above test case scenarios can be found here.