Docker image - Service Virtualization Server

This topic describes how to install the Service Virtualization server on Linux using a Docker image.

Run the SV Server

The Service Virtualization server requires a PostgreSQL or Oracle Database. For non-production cases, Oracle XE is sufficient. Since we are running the database and the Service Virtualization server on the same host, we can create a common docker network for them:

 docker network create sv

Environment Variables

The Service Virtualization server accepts the following optional environment variables:

  • SV_USER - the username account which is created or updated before the server is started
  • WAIT_FOR_DB - the database host and port (like sv-db:5432) which the server waits for before starting
  • SV_PASSWORD - the password of the user above
  • SV_GROUPS - the SV groups for the user above (like SVM Users, SV Server Administrators)
  • SV_SERVER_AGENT_PORTS - the port range which the server uses for agent ports (like 7000-7019)

Ports

The Service Virtualization server uses these ports:

  • 6085 - secure server management REST API
  • ${SV_SERVER_AGENT_PORTS} - see the SV_SERVER_AGENT_PORTS variable above.

The Service Virtualization server has several directories which should persist data using docker volumes:

  • /etc/hpe-sv-server/ - server configuration files
  • /var/log/hpe-sv-server/ - server logs
  • /var/lib/hpe-sv-server/ - agent configuration files, scripted rules, etc.
  • /var/cache/hpe-sv-server/ - cache files

The following example shows how to run the SV Server with all parameters:

docker run -d --name sv-server \
-e SV_SERVER_AGENT_PORTS=7000-7019 \
-e SV_USER=demo \
-e SV_PASSWORD=changeit \
-e SV_GROUPS="SVM Users,SV Server Administrators" \
--network sv -p 6085:6085 -p 7000-7019:7000-7019 -h $(hostname) \
-v /etc/hpe-sv-server/ \
-v /var/log/hpe-sv-server/ \
-v /var/lib/hpe-sv-server/ \
-v /var/cache/hpe-sv-server/ \
virtualization/sv-server

Back to top

SV Server Configuration

The Service Virtualization server configuration files are stored in the /etc/hpe-sv-server/ directory. If you need to edit a configuration file you can use the following docker command, for example for the server configuration file (you may need to restart the server after some configuration changes):

docker run -it --volumes-from sv-server --rm \
-u root \
virtualization/sv-server: \
vi /etc/hpe-sv-server/app.config/HP.SV.StandaloneServer.exe.config

docker restart sv-server

The Service Virtualization server image backs up the original configuration files in the /etc/hpe-sv-server.bak folder. It can be used for updating configuration files from a new image or restoring all of the configuration files.

The following example will update the configuration files in the docker volume with configuration files from a new image version. Existing files are preserved.

docker run --volumes-from sv-server --rm \
-u root \
virtualization/sv-server \
sh -c 'cp -vrpn /etc/hpe-sv-server.bak/* /etc/hpe-sv-server/'

docker restart sv-server

This example will restore all of the configuration files, overwriting all existing files.

docker run --volumes-from sv-server --rm \
-u root \
virtualization/sv-server \
sh -c 'cp -vrp /etc/hpe-sv-server.bak/* /etc/hpe-sv-server/'

docker restart sv-server

Back to top

How to Run SV Server with the Default Oracle XE Docker Image

For non-production cases, Oracle XE is sufficient. prepared docker image such as the postgres image, to run a database instance:

docker run -d --name sv-db \

--network sv \

-v /u01/app/oracle/ \

wnameless/oracle-xe-11g

The default Oracle XE database configuration is:

userName: system

userPass: oracle

dbDataSource: sv-db:1521/xe

To change the SV server database configuration to point to the Oracle XE Docker image run:

docker run --volumes-from sv-server --rm \

virtualization/sv-server \

/usr/bin/sv-ConfigTool db-setProperties server oracle "sv-db:1521/xe" "" "" SqlAuth system oracle

Back to top

How to Run SV Server with an Existing PostgreSQL Database

The database configuration is stored in /etc/hpe-sv-server/app.config/HP.SV.StandaloneServer.exe.database.config and can be changed using sv-ConfigTool in the following way:

docker run --volumes-from sv-server --rm \
virtualization/sv-server \
/usr/bin/sv-ConfigTool db-setProperties server postgresql
" ;Host=mypostgresql.mycompany.net;Database=db1" "" "" SqlAuth UserName Password

Back to top

How to Run the SV Server with an Existing Oracle Database

The database configuration is stored in /etc/hpe-sv-server/app.config/HP.SV.StandaloneServer.exe.database.config and can be changed using sv-ConfigTool in the following way:

docker run --volumes-from sv-server --rm \
virtualization/sv-server \
/usr/bin/sv-ConfigTool db-setProperties server oracle "myoracle.mycompany.net:1521/db1" "" "" SqlAuth UserName Password

Alternatively, you can change database settings by specifying environment variables when running the sv-server image:

docker run

-e "SV_DB_TYPE=oracle" \

-e "SV_DB_DATASOURCE=myOracle.hostname:1521/xe;" \

--volumes-from sv-server --rm \

virtualization/sv-server

The available database related environment variables are:

SV_DB_TYPE: “oracle"|”postgres“

SV_DB_DATASOURCE: database connection string

SV_DB_PROPERTIES: database properties

SV_DB_NAME: database name

SV_DB_USERNAME: username

SV_DB_PASSWORD: password

To revert back to the original database configuration, run:

docker run --volumes-from sv-server --rm \
-u root \
virtualization/sv-server \
cp -vp /etc/hpe-sv- server.bak/app.config/HP.SV.StandaloneServer.exe.database.config /etc/hpe-sv-server/app.config/

To recreate the database when the Service Virtualization Server starts, the use SV_DB_PARAMS option. The parameters are applied to the Service Virtualization Server executable upon startup.

docker run

-e "SV_SERVER_PARAMS=recreateDatabase=true" \

-e "SV_DB_TYPE=oracle" \

-e "SV_DB_DATASOURCE=myOracle.hostname:1521/xe;"

--volumes-from sv-server --rm \

virtualization/sv-server

Back to top

How to use your own Server Certificate

The Service Virtualization server (and Service Virtualization Management) use self-signed "localhost" certificate/key for HTTPS by default. To use own certificate/key which will work correctly with your domain, you need to have the following files:

  • server-cert.p12 - server certificate and private key in PKCS12 format.
  • server-key.pass - password in plain text for the server private key.

To replace the default certificate/key by your ones, you need to import these files into the Service Virtualization server certificates directory in the /etc/hpe-sv-server/ volume using sv-ImportCertificates script. For example, if you have server-cert.p12 and server-key.pass in the certificates directory, run the following:

docker run --volumes-from sv-server --rm \
-v $(pwd)/certificates/:/etc/hpe-sv-server/my-certificates/ \
virtualization/sv-server \
sv-ImportCertificates /etc/hpe-sv-server/my-certificates/

docker restart sv-server

How to Enable LDAP Authentication

To enable LDAP authentication, edit HP.SV.StandaloneServer.exe.membership.config and change the membershipProvider to Ldap. Edit the config file in the following way:

docker run -it --volumes-from sv-server --rm \
-u root \
virtualization/sv-server \
vi /etc/hpe-sv-server/app.config/HP.SV.StandaloneServer.exe.membership.config

Then you need to edit HP.SV.StandaloneServer.exe.ldap.config with your LDAP configuration:

docker run -it --volumes-from sv-server --rm \
-u root \
virtualization/sv-server \
vi /etc/hpe-sv-server/app.config/HP.SV.StandaloneServer.exe.ldap.config

How to Run SV with Docker Compose

The following example illustrates how to run PostgreSQL DB, Service Virtualization Server container, Service Virtualization Lab Server container, and the Service Virtualization Management container using the docker-compose tool. Create a docker-compose.yml file with the following content:

version: '3'

volumes:
  etc:
  var_log:
  var_lib:
  var_cache:
  db:

services:
  sv-server:
    image: virtualization/sv-server
    container_name: sv-server
    hostname: ${HOST_NAME}
    environment:
      - WAIT_FOR_DB=sv-db:5432
      - SV_SERVER_AGENT_PORTS=7000-7019
      - SV_USER=demo
      - SV_PASSWORD=changeit
      - SV_GROUPS=SVM Users,SV Server Administrators
    ports:
      - 6085:6085 # secure REST
      - 7000-7019:7000-7019 # SV agents
    volumes:
      - etc:/etc/hpe-sv-server/
      - var_log:/var/log/hpe-sv-server/
      - var_lib:/var/lib/hpe-sv-server/
      - var_cache:/var/cache/hpe-sv-server/
      # SV Agent binaries
#      - ./some-library.so:/usr/lib/hpe-sv-server/bin/some-library.so
#      - ./another-library.dll:/usr/lib/hpe-sv-server/bin/another-library.dll
    stop_grace_period: 2m
    depends_on:
      - sv-db
  sv-lab-server:
    image: virtualization/sv-lab-server
    container_name: sv-lab-server
    hostname: ${HOST_NAME}
    environment:
      - SV_LAB_SERVER_CONNECTOR_PORTS=9000-9019
    ports:
      - 8445:8445 # secure REST
      - 9000-9019:9000-9019 # SV connectors
    volumes:
      - var_log:/opt/LabServer/log/
    stop_grace_period: 2m
  sv-svm:
    image: virtualization/sv-svm
    container_name: sv-svm
    hostname: ${HOST_NAME}
    ports:
      - 6086:6086 # secure web
    volumes:
      - etc:/etc/hpe-sv-server/
      - var_log:/var/log/hpe-sv-server/
      - var_cache:/var/cache/hpe-sv-server/
    stop_grace_period: 2m
  sv-db:
    image: postgres
    volumes:
      - db:/var/lib/postgresql/data
    container_name: sv-db

To start all containers:

HOST_NAME=$(hostname) docker-compose up

How to Customize the SV Server Image

It can be useful to prepare own docker image based on the SV Server one when it's required to add or customize some files in the docker image. For example, if we want to add custom agent libraries to the image. To achieve this, you need to create a custom Dockerfile. For example:

FROM virtualization/sv-server:latest

COPY some-library.so /usr/lib/hpe-sv-server/bin/
COPY another-library.dll /usr/lib/hpe-sv-server/bin/

The Dockerfile and the files used there must be placed in a directory, for example my-sv-server. To build the new docker image use the docker build command:

docker build ./my-sv-server -t my/sv-server:latest

How to Run SV Tools

You can use the following command to run SV tools which are part of the SV Server distribution, for example running SVConfigurator tool:

docker run --rm \
virtualization/sv-server \
/usr/lib/hpe-sv-server/Tools/SVConfigurator/bin/SVConfigurator.sh <command>

Back to top

See also: