What are environments?

One of the powerful features of Opereto are virtual environments. An environment is a set of logical agent members. Each member is a combination of logical name and a set of properties. Environments are not independent entities. They are defined on the agent level as properties. For example, you may declare that a given agent is a member of a given virtual environment ENV_ID by adding the following properties to the agent:   

environment.ENV_ID.role: ROLE
environment.ENV_ID.type: TYPE

    

ENV_ID is any unique string identifying the new virtual environment; TYPE is any string classifying a given environment to some logical type (e.g. tool_x, single_node_test_topology, my_custom_env etc.); ROLE is any string identifying the logical role of this agent in that environment type (e.g. Node1, web_server, DB, etc..). A role must be unique within the environment.



Opereto environments are virtual entities providing a logical representation to a group of one or more agents





Example 1: create an environment from existing agents

John is an automation engineer developing a set of system tests. His test topology comprises of a cluster of three components:

John had set up a physical test cluster (manually or automatically) and installed Opereto agent on each member. Now He has three agents as follows:

Agent-1: running on the web virtual machine

Agent-2: running on the database virtual machine

Agent-3: running on the engine virtual machine


To group all three virtual machines into a single test environment, John has to add the following properties to each agent (via user interface of REST API):   

## Add these properties to Agent-1
environment.test001.role: web
environment.test001.type: my_test_topology


## Add these properties to Agent-2
environment.test001.role: db
environment.test001.type: my_test_topology


## Add these properties to Agent-3
environment.test001.role: engine
environment.test001.type: my_test_topology

    

If John uses the REST API, he does not have to modify every agent separately. Instead, he may use the Set Environment API. Environments can be added, modified and deleted dynamically via API. Please look at the Opereto REST API for more details.


Additional environments properties

You must specify both role and type properties in the format shown above to include an agent in a given environment. Other environment properties may be defined if needed in the same way role and type are. As you can see in the example bellow, an environment property called 'version' appears in all agent members and a boolean property called 'is_master' appear in the first agent member only. Environment properties provide a flexible and dynamic way to add any meaningful information on that environment that a developer can use in his service code.


   

## Agent 1
environment.test001.role: web
environment.test001.is_master: true
environment.test001.version: 4.3.0


## Agent 2
environment.test001.role: db
environment.test001.type: my_test_topology
environment.test001.version: 4.3.0

## Agent 3
environment.test001.role: engine
environment.test001.type: my_test_topology
environment.test001.version: 4.3.2

   


Agent <> Environments relations

An agent may be a member of one or more environments. The following chart demonstrates the environment concept:


Example 2: multi environments per agent



As you can see, there are two test environments specified where Agent-1 is a member of both.

  1. Actual environment test13543 that is an instance of a type called two_nodes_topology.
  2. Actual environment test54321 that is an instance of a type called three_nodes_topology.

Logical roles (e.g. N1, N2..) assigned to the physical agents in each environment.


The environment GET API for environment test13543 will return a JSON including all members and their properties:        

{
  "status": "success",
  "data": {
    "N1": {
            ....
            ....
            "environment.test54321.role": "N1",
            "environment.test54321.type": "three_nodes_topology",
            "environment.test13543.role": "N1",
            "environment.test13543.type": "two_nodes_topology"
    },
    "N2": {
            ....
            ....
            "environment.test13543.role": "N2",
            "environment.test13543.type": "two_nodes_topology"
    }
  }
}

      


How to use environments in automation services?

Opereto enables to map environments and automation services by using a particular service property type called 'environment'. There may be zero or more logical environments specified as service properties. For each logical environment defined in a given service, Opereto will expect to get a name of a matching physical environment upon initiation of that service.


Environment logical-to-physical mechanism enables to write a complex flow that performs subsequent actions on multi-tier logical endpoints in a most simple way. Such a flow will receive a physical environment upon execution that matches the logical one. In this way, the same automated flow logic, a test case, for instance, can be executed on different physical configurations. 


To learn more about environments, please check out at the following tutorial: Creating a multi-tier automated flow.