README
¶
Computing Infrastructure Migration Model
This repository provides computing infrastructure migration features. This is a sub-system of Cloud-Barista platform, and intended to deploy a multi-cloud infra as a target computing infrastructure.
Overview
The Cloud Computing Infrastructure Migration Model Framework (codename: cm-damselfly) manages the migration user models used across the Cloud-Migrator subsystems. It stores and serves the models through a REST API, and supports:
- Infra migration models (on-premise / cloud), defined by cm-beetle/imdl
- Software migration models (source / target), defined by cm-grasshopper/smdl
- RDBMS migration models (source / planning:
SourceRDBMS, target:RecommendedRDBMS), defined by cm-beetle/imdl/rdbms-model - Object storage migration models (source / planning:
SourceObjectStorage, target:RecommendedObjectStorage), defined by cm-beetle/imdl/storage-model - Model stages :
source→planning→target - Model version management : create and validate models against any tagged version of the model definitions
- Migration lineage : track which models were derived from which (source → planning → target)
Key features
Model stages
Every migration user model belongs to one of the three stages, given by the modelStage query parameter.
| Stage | Description |
|---|---|
source |
Model of the source (e.g. on-premise) computing environment |
planning |
Intermediate model being designed/recommended for migration |
target |
Final model of the target cloud environment |
Model version management
GET /damselfly/model/versionreturns all tagged versions of the migration models.onpremModelVersion/cloudModelVersion: theimdl/vX.Y.Ztags of cm-beetlesoftwareModelVersion: thesmdl/vX.Y.Ztags of cm-grasshopperrdbmsModelVersion: theimdl/vX.Y.Ztags of cm-beetle which have the RDBMS model (rdbms-model,v0.1.13or later)objectStorageModelVersion: theimdl/vX.Y.Ztags of cm-beetle which have the object storage model (storage-model,v0.1.3or later)
- When creating a model, the model version can be selected by the query parameter
modelVersion(infra model),softwareModelVersion(software model),rdbmsModelVersion(RDBMS model) orobjectStorageModelVersion(object storage model). If omitted, the latest tag is used.POST /damselfly/infra-modelno longer accepts the former query parametersonpremModelVersionandcloudModelVersion(400). The fields of the same names in the responses are unchanged.
- The model body is validated against (and stored in the form of) the struct of the selected tagged version. The Go source of that version is downloaded and parsed at runtime (pkg/modelschema), so a new model version can be used without rebuilding CM-Damselfly.
- On update, the stored model version is preserved and the body is validated against that version.
GET /damselfly/infra-model/{id}/convert?modelType=onprem&modelVersion=v0.1.19returns a stored infra model converted to the struct of a newer version, for backward compatibility. IfmodelVersionis omitted, the latest tag is used. The stored model is not changed.- Only the conversion to the same or a newer version is allowed.
- A cloud model cannot be converted to a version older than
v0.1.2, and a model whose stored version is not a tag cannot be converted (400). - The
conversionfield of the response showsoriginVersion(the stored version),currentVersion(the version of the returned model),converted,droppedFields(the fields which the requested version does not have) andwarnings(what could not be converted as it was).
GET /damselfly/software-model/{id}/convert?modelStage=source&modelVersion=v0.1.4returns a stored software model converted to the struct of a newer version in the same way. IfmodelVersionis omitted, the latest tag is used. The stored model is not changed.- Only the conversion to the same or a newer version is allowed, and a model whose stored version is not a tag cannot be converted (
400). - The fields which the requested version does not have are removed and listed in
droppedFieldsof theconversionfield. If a value does not match the type of its field in the requested version (e.g. the free-form Kubernetesresourcesbeforev0.1.4), the model is not converted (400).
- Only the conversion to the same or a newer version is allowed, and a model whose stored version is not a tag cannot be converted (
GET /damselfly/rdbms-model/{id}/convert?modelStage=source&rdbmsModelVersion=v0.1.20returns a stored RDBMS model converted to the struct of a newer version in the same way. IfrdbmsModelVersionis omitted, the latest tag is used. The stored model is not changed.- Only the conversion to the same or a newer version is allowed, and a model whose stored version is not a tag with the RDBMS model (
v0.1.13or later) cannot be converted (400). v0.1.14: the instances of a source/planning model (sourceRDBMSModel) are restructured intodbNodeanddbEngine(instanceName→displayName,databases→innerDatabases).vcpu,memoryMbandstorageSizeGbare converted as estimates and reported inwarnings, and the fields without a counterpart (e.g.highAvailability) are dropped.v0.1.18:characterSetof the target databases (targetRDBMSModel, removed inv0.1.17) is converted tocharset.
- Only the conversion to the same or a newer version is allowed, and a model whose stored version is not a tag with the RDBMS model (
GET /damselfly/object-storage-model/{id}/convert?modelStage=source&objectStorageModelVersion=v0.1.20returns a stored object storage model converted to the struct of a newer version in the same way. IfobjectStorageModelVersionis omitted, the latest tag is used. The stored model is not changed.- Only the conversion to the same or a newer version is allowed, and a model whose stored version is not a tag with the object storage model (
v0.1.3or later) cannot be converted (400). v0.1.6:nameSeedof a target model (targetObjectStorageModel) was removed. It is reported indroppedFields(and inwarningsif it has a value); give it as thenameSeedquery parameter of the cm-beetle object storage migration API instead.v0.1.11: a source/planning model (sourceObjectStorageModel), which described a single bucket (bucketName,versioningEnabled, ...), is converted to a group of buckets: the bucket fields are moved intosourceObjectStorages[0].
- Only the conversion to the same or a newer version is allowed, and a model whose stored version is not a tag with the object storage model (
- Swagger UI lists an API definition per tagged version (
imdl/{version}/doc.json,smdl/{version}/doc.json) in the Select a definition drop-down, so that the request body schema of each version can be checked. Theimdl/{version}/doc.jsondefinitions also show the RDBMS model (v0.1.13or later) and the object storage model (v0.1.3or later) of that version.
[!NOTE] The tagged versions and their source code are fetched from GitHub (
api.github.com) and the Go module proxy (proxy.golang.org, or the proxies inGOPROXY). CM-Damselfly needs outbound internet access to use the model version features. Fetched results are cached in memory.
Migration lineage
The models derived from one another are linked by the lineage field (sourceGroupId, sourceModelId, planningModelId, targetModelId).
(Refer to Damselfly model metadata - lineage)
- On create/update, give
parentId(the ID of a model of the same category — infra, software, RDBMS or object storage — in the previous stage) to derive the upstream lineage fields from the parent.lineagecan also be given explicitly. - The lineage field of the model's own stage (e.g.
planningModelIdof a planning model) is set by the server. - The list APIs can be filtered by
sourceGroupId,sourceModelId,planningModelIdandtargetModelIdto find all the models derived from a model. - A model referred to by the lineage of other models cannot be deleted (409 Conflict) unless
force=true, and its stage cannot be changed.
REST API overview
All APIs are served under http://localhost:8088/damselfly with basic auth (default: default / default).
Migration user models (unified APIs, recommended)
| Method | Path | Description |
|---|---|---|
| GET | /model/version |
Get all tagged versions of the migration models |
| GET | /model |
Get migration user models of all categories (filters: modelStage, category=infra|software|rdbms|objectStorage, lineage) |
| GET / POST | /infra-model |
List / create infra models (modelType=onprem|cloud, modelStage) |
| GET / PUT / DELETE | /infra-model/{id} |
Get / update / delete an infra model |
| GET | /infra-model/{id}/convert |
Get an infra model converted to a newer model version (modelType=onprem|cloud, modelVersion) |
| GET / POST | /software-model |
List / create software models (modelStage) |
| GET / PUT / DELETE | /software-model/{id} |
Get / update / delete a software model |
| GET | /software-model/{id}/convert |
Get a software model converted to a newer model version (modelStage, modelVersion) |
| GET / POST | /rdbms-model |
List / create RDBMS models (modelStage, rdbmsModelVersion) |
| GET / PUT / DELETE | /rdbms-model/{id} |
Get / update / delete an RDBMS model |
| GET | /rdbms-model/{id}/convert |
Get an RDBMS model converted to a newer model version (modelStage, rdbmsModelVersion) |
| GET / POST | /object-storage-model |
List / create object storage models (modelStage, objectStorageModelVersion) |
| GET / PUT / DELETE | /object-storage-model/{id} |
Get / update / delete an object storage model |
| GET | /object-storage-model/{id}/convert |
Get an object storage model converted to a newer model version (modelStage, objectStorageModelVersion) |
Legacy APIs
The following APIs are kept for compatibility. They distinguish source and target models by isTargetModel only, and do not support the planning stage, model version selection or lineage. Use the unified APIs above for those features.
| Path | Description |
|---|---|
/onpremmodel, /onpremmodel/{id} |
On-premise migration user models |
/cloudmodel, /cloudmodel/{id} |
Cloud migration user models |
/softwaremodel/source, /softwaremodel/source/{id} |
Source software migration user models |
/softwaremodel/target, /softwaremodel/target/{id} |
Target software migration user models |
System
| Method | Path | Description |
|---|---|---|
| GET | /readyz |
Check CM-Damselfly is ready |
| GET | /httpVersion |
Check HTTP version of incoming request |
Example : source → planning → target
# 1. Create a source (on-premise) infra model -> returns "id": "<SOURCE_ID>"
curl -u default:default -X POST -H "Content-Type: application/json" \
"http://localhost:8088/damselfly/infra-model?modelType=onprem&modelStage=source" \
-d '{ "userModelName": "my-source", "lineage": { "sourceGroupId": "sg-01" }, "onpremiseInfraModel": { ... } }'
# 2. Create a planning (cloud) infra model derived from the source model -> returns "id": "<PLANNING_ID>"
curl -u default:default -X POST -H "Content-Type: application/json" \
"http://localhost:8088/damselfly/infra-model?modelType=cloud&modelStage=planning&modelVersion=v0.1.18" \
-d '{ "userModelName": "my-plan", "parentId": "<SOURCE_ID>", "cloudInfraModel": { ... } }'
# 3. Create a target (cloud) infra model derived from the planning model
curl -u default:default -X POST -H "Content-Type: application/json" \
"http://localhost:8088/damselfly/infra-model?modelType=cloud&modelStage=target" \
-d '{ "userModelName": "my-target", "parentId": "<PLANNING_ID>", "cloudInfraModel": { ... } }'
# 4. Get all the models derived from the source model
curl -u default:default "http://localhost:8088/damselfly/model?sourceModelId=<SOURCE_ID>"
Recommended execution and development environment
- Operating system (OS):
- Ubuntu 24.04
- Programming Language:
- Go 1.26.2+ (for building from source code)
- Docker Container & Docker Compose:
- Latest stable version
- API doc:
- Swag v1.16.3
How to run CM-Damselfly
Configure build environment
- Install dependencies
# Ensure that your system is up to date
sudo apt update -y
# Ensure that you have installed the dependencies,
# such as `ca-certificates`, `curl`, and `gnupg` packages.
sudo apt install make gcc git
- Install Go
NOTE : Install the stable version of Go. For example, Go v1.26.2
# Set Go version
GO_VERSION=1.26.2
# Get Go archive
wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz
# Remove any previous Go installation and
# Extract the archive into /usr/local/
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
# Append /usr/local/go/bin to .bashrc
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
# Apply the .bashrc changes
source ~/.bashrc
# Verify the installation
echo $GOPATH
go version
Download the source code
# Clone CM-Damselfly repository
git clone https://github.com/cloud-barista/cm-damselfly.git ${HOME}/cm-damselfly
Build and Run with docker compose
- Open ubuntu firewall TCP 8088 port on the system to access to the API(If need)
sudo ufw allow 8088/tcp
- Ensure that Docker and Docker Compose are installed on your system
docker --version
docker compose version
- Run CM-Damselfly container and related components
cd [DAMSELFLY_ROOT]
sudo docker compose up
- With the
-doption runs the container in the background (in detached mode)
cd [DAMSELFLY_ROOT]
sudo docker compose up -d
- Build the current Damselfly source code into a container image
cd [DAMSELFLY_ROOT]
sudo docker compose up -d --build
- Stop CM-Damselfly
sudo docker compose down cm-damselfly
- The easiest way to run the container
cd [DAMSELFLY_ROOT]
sudo make compose-up
Build and Run from source code
cd [DAMSELFLY_ROOT]
# (Optional) Regenerate the Swagger API docs
make swag
# Build and run the binary (with the environment variables in conf/setup.env)
make run
- Run
make helpto see the other targets (build,prod,arm,lint,stop,clean,compose,compose-down, etc.).
Configuration
The configuration is set in conf/config.yaml and can be overridden by the environment variables (see conf/setup.env and docker-compose.yaml).
| Environment variable | Default | Description |
|---|---|---|
DAMSELFLY_ROOT |
(set at runtime) | Root directory of CM-Damselfly |
DAMSELFLY_SELF_ENDPOINT |
localhost:8088 |
Endpoint to access the Swagger API dashboard from outside |
DAMSELFLY_API_ALLOW_ORIGINS |
* |
Allowed CORS origins |
DAMSELFLY_API_AUTH_ENABLED |
true |
Enable basic auth for all routes |
DAMSELFLY_API_USERNAME / DAMSELFLY_API_PASSWORD |
default / default |
Basic auth credentials |
DAMSELFLY_LKVSTORE_PATH |
./db/damselfly.db |
Path of the K/V DB file |
DAMSELFLY_LOGFILE_PATH |
./log/damselfly.log |
Path of the log file |
DAMSELFLY_LOGLEVEL |
debug |
Log level (trace, debug, info, warn, error, fatal, panic) |
DAMSELFLY_LOGWRITER |
both |
Log writer (file, stdout, both) |
DAMSELFLY_NODE_ENV |
development |
Execution environment (development, production) |
GOPROXY |
https://proxy.golang.org |
Go module proxies used to download the tagged model definitions |
Default REST API URL and DB/log file path
-
Swagger API URL
- http://localhost:8088/damselfly/api (username: default / password: default)
- To see the request body schema of a specific model version, choose
imdl/{version}/doc.jsonorsmdl/{version}/doc.jsonin Select a definition at the top of Swagger UI.
-
Swagger web UI URL
-
Default DB file path (The created and updated user migration models are stored to K/V DB as a file in the following location.)
- When running from source code : ./cm-damselfly/cmd/cm-damselfly/db/damselfly.db
- When running with docker compose : ./cm-damselfly/container-volume/cb-damselfly-container/db/damselfly.db
-
Default log file path
- When running from source code : ./cm-damselfly/cmd/cm-damselfly/log/damselfly.log
- When running with docker compose : ./cm-damselfly/container-volume/cb-damselfly-container/log/damselfly.log
Versions of migration models applied to the released Damselfly
| cm-damselfly version | OnpremInfraModel /CloudInfraModel |
SoftwareModel | RDBMSModel /ObjectStorageModel |
|---|---|---|---|
| v0.2.0 | v0.0.3 | - | - |
| v0.2.1 | v0.0.3 | - | - |
| v0.2.2 | v0.0.3 | - | - |
| v0.3.0 | v0.0.3 | - | - |
| v0.3.1 | v0.0.10 | - | - |
| v0.3.2 | v0.0.10 | - | - |
| v0.3.3 | v0.0.11 | - | - |
| v0.3.4 | v0.0.12 | - | - |
| v0.3.5 | v0.0.13 | - | - |
| v0.3.6 | v0.0.14 | - | - |
| v0.4.0 | v0.0.14 | - | - |
| v0.4.1 | v0.0.15 | - | - |
| v0.5.0 | v0.0.21 | v0.0.21 | - |
| v0.5.1 | v0.1.6 | v0.1.0 | - |
| v0.5.2 | v0.1.9 | v0.1.1 | - |
| v0.5.3 | v0.1.10 | v0.1.1 | - |
| v0.6.0 | v0.1.10 | v0.1.1 | - |
| v0.6.1 | v0.1.11 | v0.1.1 | - |
| v0.6.2 | v0.1.12 | v0.1.3 | - |
| v0.6.3 | v0.1.15 | v0.1.3 | - |
| v0.6.4 | v0.1.18 | v0.1.4 | - |
| main : v0.6.5 | v0.1.20 | v0.1.4 | v0.1.20 |
NOTE : Since the model version management features (after v0.6.3), the versions above are the ones built into CM-Damselfly (used for the default Swagger API definition). Models of any other tagged version can be created by specifying the model version (see Model version management).
CM-Damselfly REST API user guide
- Discussion link : How to use and test CM-Damselfly APIs (with test examples)
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api Code generated by swaggo/swag.
|
Package api Code generated by swaggo/swag. |
|
pkg
|
|
|
api/rest
Package server is to handle REST API
|
Package server is to handle REST API |
|
example/lkvstore
command
|
|
|
lkvstore
Local Key-Value Store based on sync.Map and file I/O
|
Local Key-Value Store based on sync.Map and file I/O |
|
modelschema
Package modelschema loads the Go struct definitions of a tagged model module (e.g.
|
Package modelschema loads the Go struct definitions of a tagged model module (e.g. |