bwsw / cs-entities   4.9.3

Apache License 2.0 GitHub

Simple CloudStack Entities Framework

Scala versions: 2.12


Simple CloudStack Entities Framework

The library provides the convenient way of working with Apache CloudStack entities through the following mechanisms:

  1. Creating and retrieving the declared entities on/from Apache CloudStack server, such as users, accounts, virtual machines, tags. It based on the extensible request builders which simplify creating CloudStack requests.
  2. Base set of Apache CloudStack events to work with CloudStack Event Log (see official documentation).

Install with SBT

Add the following to your build.sbt

libraryDependencies += "com.bwsw" %% "cs-entities" % "1.410np.0"

Getting Started

  1. Create Executor instance with specified parameters to interact with Apache CloudStack server. \
  2. Create JsonSerializer instance for parsing json responses from the server. \
  3. Use Executor and JsonSerializer to create a GenericDao instance, it may be an existing GenericDao or a custom implementation
    (if you implement GenericDao, first of all you have to implement one Request for each DAO method).
  4. Use existing Entity response hierarchy to work with users, accounts, vms or tags
    (if you create a new GenericDao implementation for another Apache CloudStack entity then you have to implement a new Entity response hierarchy).

The diagrams are provided for you to understand the process of library classes relationships.

Example Usage

The example below shows how to create new user entity in CloudStack server and then retrieve it:

val creatorSettings = PasswordAuthenticationClientCreator.Settings("admin","password","/")
val executorSettings = Executor.Settings(Array(s"http://localhost:8888/client/api"), retryDelay = 1000)

val creator = new PasswordAuthenticationClientCreator(creatorSettings)
val executor = new Executor(executorSettings, creator, true)
val mapper = new JsonMapper(true)

val userId = UUID.randomUUID()
val userCreationSettings = UserCreateRequest.Settings(
      email = "[email protected]",
      firstName = "first",
      lastName = "last",
      password = "passwd",
      username = "username"

val userCreateRequest = new UserCreateRequest(userCreationSettings).withId(userId)

val findRequest = new UserFindRequest().withId(userId)
val users = userDao.find(findRequest)


Unit tests

Run tests: sbt test

Integration tests

  1. Add local environment variables:

    • CS_PORT - port of Apache CloudStack simulator server, by default - 8888
    • CS_HOST - host of Apache CloudStack simulator server, by default - localhost
    • KAFKA_HOST - host of Kafka, by default - localhost
    • KAFKA_PORT - port of Kafka, by default - 9092
    • KAFKA_TOPIC - kafka topic containing cloudstack events, by default - cs
    • ZK_PORT - port of Zookeeper, e.g. 2181
  2. Run Apache CloudStack simulator in docker container:

    docker run --rm --name spotify-kafka -d --tty=true \
                    -e ADVERTISED_HOST=$KAFKA_HOST \
                    -e ADVERTISED_PORT=$KAFKA_PORT \
                    -p $ZK_PORT:2181 \
                    -p $KAFKA_PORT:9092 \
    docker run --rm --name cs-simulator-kafka -d \
                    -e KAFKA_HOST="${KAFKA_HOST}" \
                    -e KAFKA_PORT="${KAFKA_PORT}" \
                    -e KAFKA_TOPIC="${KAFKA_TOPIC}" \
                    -p $CS_PORT:8888 \
  1. After the end of the cloudstack simulator deploying (you can check it like this) execute: sbt it:test


Library includes the minor version which depends on CloudStack version.
For example 1.410.0 version depends on CloudStack 4.10


This project is licensed under the Apache License - see the LICENSE file for details