diff --git a/.gitignore b/.gitignore
index c987cda..e0f702c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,4 +23,4 @@
cmd/cm-damselfly/cm-damselfly
# Ignore DB file (it's temporally used)
-.damselfly/*
\ No newline at end of file
+db/*
diff --git a/.migration_history_mdel/migration-history.json b/.migration_history_mdel/migration-history.json
deleted file mode 100644
index e988dd8..0000000
--- a/.migration_history_mdel/migration-history.json
+++ /dev/null
@@ -1,186 +0,0 @@
-{
- "migrationHistory": {
- "description": "Description of the Migration History",
- "name": "Performed Migration Model Name",
- "version": "Performed Migration Model ID",
- "sourceEnvironment": {
- "provider": "On-premises, or Private Cloud, or Public Cloud Name",
- "sourceMigrationModelName": "Source Migration Model Name",
- "sourceMigrationModelVersion": "Source Migration Model Verion",
- "details": {
- "location": "Data center location or Cloud provider Region code",
- "zone": "If cloud provider, Zone code is here",
- "resources": [
- {
- "id": "vm_001",
- "type": "VM",
- "specifications": {
- "cpu": "4 cores",
- "memory": "8 GB",
- "rootStorage": "200 GB",
- "os": "Ubuntu 20.04 64bit"
- }
- },
- {
- "id": "db_001",
- "type": "Database",
- "specifications": {
- "databaseType": "SQL",
- "version": "SQL Server 2019",
- "size": "200 GB",
- "tables": "50",
- "storedProcedures": "100"
- }
- },
- {
- "id": "storage_001",
- "type": "Storage",
- "specifications": {
- "storageType": "NAS",
- "capacity": "10 TB",
- "used": "6 TB",
- "protocol": "NFS"
- }
- },
- {
- "id": "app_001",
- "type": "Application",
- "specifications": {
- "name": "ERP System",
- "version": "5.2",
- "language": "Java",
- "dependencies": [
- "Java Runtime Environment",
- "MySQL Database"
- ]
- }
- },
- {
- "id": "web_server_001",
- "type": "Web Server",
- "specifications": {
- "software": "Apache",
- "version": "2.4.41",
- "hostedWebsites": "5",
- "traffic": "Approx. 1000 visits/day"
- }
- }
- ]
- }
- },
- "targetEnvironment": {
- "cloudProvider": "AWS or Azure or GCP or NCP VPC, ...",
- "configuration": {
- "region": "target_region",
- "zone": "target_zone",
- "networkSetup": "VPC configuration details",
- "security": "Security configurations like firewalls, IAM roles"
- }
- },
- "resourceMapping": {
- "mappings": [
- {
- "sourceResourceId": "vm_001",
- "targetResource": {
- "type": "VM",
- "size": "Equivalent or scaled as per need",
- "configuration": {
- "instanceType": "t2.medium",
- "storageType": "EBS",
- "network": "VPC settings"
- }
- }
- },
- {
- "sourceResourceId": "db_001",
- "targetResource": {
- "type": "Database",
- "size": "Scaled as per performance requirements",
- "configuration": {
- "service": "Amazon RDS / Azure SQL Database",
- "engine": "SQL Server",
- "version": "Latest compatible version",
- "storageType": "SSD-based"
- }
- }
- },
- {
- "sourceResourceId": "storage_001",
- "targetResource": {
- "type": "Storage",
- "configuration": {
- "service": "Amazon S3 / Azure Blob Storage",
- "storageClass": "Standard / Infrequent Access",
- "dataRedundancy": "Multi-region"
- }
- }
- },
- {
- "sourceResourceId": "app_001",
- "targetResource": {
- "type": "Managed Application Service",
- "configuration": {
- "platform": "AWS Elastic Beanstalk / Azure App Service",
- "runtime": "Java Environment",
- "scaling": "Auto-scaling setup"
- }
- }
- },
- {
- "sourceResourceId": "web_server_001",
- "targetResource": {
- "type": "Cloud-based Web Server",
- "configuration": {
- "service": "Amazon EC2 / Azure Virtual Machines",
- "instanceType": "Optimized for web traffic",
- "OS": "Latest compatible version"
- }
- }
- }
- ]
- },
- "dataTransferMethod": {
- "type": "Offline/Online",
- "details": {
- "offline": {
- "shippingMethod": "Physical drives/Dedicated connection",
- "encryption": "Encryption method if applicable"
- },
- "online": {
- "transferProtocol": "FTP/HTTP/S3/etc.",
- "bandwidth": "bandwidth_limitation",
- "encryption": "Encryption method"
- }
- }
- },
- "migrationExecution": {
- "schedule": "YYYY-MM-DD HH:MM",
- "downtime": "expected_downtime",
- "steps": [
- "Step 1: ...",
- "Step 2: ...",
- "Step 3: ...",
- "Step 4: ...",
- "Step 5: ...",
- "Step 6: ...",
- "Step 7: ...",
- "Step 8: ...",
- "Step 9: ...",
- "Step 10: ...",
- "Step 11: ...",
- "Step 12: ...",
- "Step 13: ...",
- "Step 14: ...",
- "Step 15: ..."
- ]
- },
- "postMigration": {
- "validation": {
- "dataIntegrityCheck": "Method to check data integrity",
- "performanceBenchmarking": "Performance comparison method"
- },
- "cleanupStatus": "Status of the Cleanup activities in the replication infra environment",
- "cleanupTime": "Date and TIme of the Cleanup activities in the replication infra environment"
- }
- }
-}
diff --git a/.migration_model/migratiion-model.json b/.migration_model/migratiion-model.json
deleted file mode 100644
index e949ce9..0000000
--- a/.migration_model/migratiion-model.json
+++ /dev/null
@@ -1,190 +0,0 @@
-{
- "migrationModel": {
- "description": "Description for this model",
- "name": "My-New-Model",
- "version": "v0.1",
- "modelId": "abcdefg0001",
- "migrationStep": "Step-01-abcdefg",
- "targetEnvironment": {
- "provider": "Private Cloud, or Public Cloud Name",
- "details": {
- "region": "Cloud provider Region code",
- "zone": "Zone code",
- "resources": [
- {
- "type": "Namespace",
- "nsSpecifications": {
- "description": "MyVPC_001",
- "name": "ns01"
- }
- },
- {
- "type": "vNet",
- "vNetSpecifications": {
- "cidrBlock": "string",
- "cspVNetId": "string",
- "description": "string",
- "name": "string",
- "subnetInfoList": [
- {
- "description": "string",
- "ipv4_CIDR": "string",
- "keyValueList": [
- {
- "key": "string",
- "value": "string"
- }
- ],
- "name": "string"
- }
- ]
- }
- },
- {
- "type": "MCIS",
- "mcisSpecifications": {
- "description": "MCIS descrition ...",
- "installMonAgent": "no",
- "label": "custom tag",
- "name": "mcis01",
- "placementAlgo": "string",
- "systemLabel": "",
- "vm": [
- {
- "dataDiskIds": [
- "string"
- ],
- "description": "Description",
- "idByCsp": "i-014fa6ede6ada0b2c",
- "imageId": "string",
- "label": "string",
- "name": "g1-1",
- "rootDiskSize": "default, 30, 42, ...",
- "rootDiskType": "default, TYPE1, ...",
- "securityGroupIds": [
- "string"
- ],
- "specId": "string",
- "sshKeyId": "string",
- "subGroupSize": "3",
- "vNetId": "string",
- "subnetId": "string",
- "vmUserAccount": "string",
- "vmUserPassword": "string"
- }
- ]
- }
- },
- {
- "type": "VMImage",
- "imgSpecifications": {
- "cspImageId": "string",
- "description": "string",
- "name": "string"
- }
- },
- {
- "type": "SecurityGroup",
- "sgSpecifications": {
- "cspSecurityGroupId": "string",
- "description": "string",
- "firewallRules": [
- {
- "cidr": "string",
- "direction": "string",
- "fromPort": "string",
- "ipprotocol": "string",
- "toPort": "string"
- }
- ],
- "name": "string",
- "vNetId": "string"
- }
- },
- {
- "type": "KeyPair",
- "keySpecifications": {
- "connectionName": "string",
- "cspSshKeyId": "string",
- "description": "string",
- "fingerprint": "string",
- "name": "string",
- "privateKey": "string",
- "publicKey": "string",
- "username": "string",
- "verifiedUsername": "string"
- }
- },
- {
- "type": "Database",
- "name": "db_001",
- "dbSpecifications": {
- "databaseType": "SQL",
- "version": "MySQL vXXX",
- "size": "200 GB",
- "tables": "50",
- "storedProcedures": "100"
- }
- },
- {
- "type": "DataDisk",
- "name": "MyStorage_001",
- "diskSpecifications": {
- "connectionName": "aws-ap-southeast-1",
- "cspDataDiskId": "string",
- "description": "string",
- "diskSize": "77",
- "diskType": "default",
- "name": "aws-ap-southeast-1-datadisk"
- }
- },
- {
- "type": "NLB",
- "name": "MyNLB_001",
- "nlbSpecifications": {
- "cspNLBId": "string",
- "description": "string",
- "healthChecker": {
- "interval": "default",
- "threshold": "default",
- "timeout": "default"
- },
- "listener": {
- "port": "80",
- "protocol": "TCP"
- },
- "scope": "REGION",
- "targetGroup": {
- "port": "80",
- "protocol": "TCP",
- "subGroupId": "g1"
- },
- "type": "PUBLIC"
- }
- },
- {
- "type": "Application-1",
- "appSpecifications": {
- "name": "ERP System",
- "version": "5.2",
- "language": "Java",
- "dependencies": [
- "Java Runtime Environment",
- "MySQL Database"
- ]
- }
- },
- {
- "type": "Web Server",
- "webSvrSpecifications": {
- "software": "Apache",
- "version": "2.4.41",
- "hostedWebsites": "5",
- "traffic": "Approx. 1000 visits/day"
- }
- }
- ]
- }
- }
- }
-}
diff --git a/.migration_model/migrationModel-test-1.json b/.migration_model/migrationModel-test-1.json
deleted file mode 100644
index a35034d..0000000
--- a/.migration_model/migrationModel-test-1.json
+++ /dev/null
@@ -1,84 +0,0 @@
-{
- "migrationModel": {
- "description": "Description for this model",
- "name": "migrationModel-test-1",
- "version": "v0.2",
- "modelId": "Otacbatcvafafa00100000000",
- "migrationStep": "Step-02-abcdefg",
- "targetEnvironment": {
- "provider": "AWS",
- "details": {
- "region": "Korea",
- "zone": "KR-1",
- "resources": [
- {
- "type": "Namespace",
- "nsSpecifications": {
- "description": "MyVPC_001",
- "name": "ns01"
- }
- },
- {
- "type": "vNet",
- "vNetSpecifications": {
- "cidrBlock": "string",
- "cspVNetId": "",
- "description": "",
- "name": "",
- "subnetInfoList": [
- {
- "description": "New Subnet Description",
- "ipv4_CIDR": "10.10.2.0/24",
- "keyValueList": [
- {
- "key": "NewKey",
- "value": "NewValue"
- }
- ],
- "name": "NewSubnetName"
- }
- ]
- }
- },
- {
- "type": "MCIS",
- "mcisSpecifications": {
- "description": "MCIS descrition ...",
- "installMonAgent": "no",
- "label": "custom tag",
- "name": "mcis01",
- "placementAlgo": "string",
- "systemLabel": "",
- "vm": [
- {
- "dataDiskIds": [
- "disk1",
- "disk2"
- ],
- "description": "Description",
- "idByCsp": "i-014fa6ede6ada0b2c",
- "imageId": "image1",
- "label": "label1",
- "name": "g1-1",
- "rootDiskSize": "42",
- "rootDiskType": "SSD",
- "securityGroupIds": [
- "sg1",
- "sg2"
- ],
- "specId": "spec1",
- "sshKeyId": "key1",
- "subGroupSize": "3",
- "vNetId": "vnet1",
- "subnetId": "subnet1",
- "vmUserAccount": "user1",
- "vmUserPassword": "pass1"
- }
- ]
- }
- }
- ]
- }
- }
- }
-}
\ No newline at end of file
diff --git a/.replication_model/replication.yaml b/.replication_model/replication.yaml
deleted file mode 100644
index 69d07ea..0000000
--- a/.replication_model/replication.yaml
+++ /dev/null
@@ -1,53 +0,0 @@
-ReplicationFormatVer: '20231110-1'
-Description: ReplicationFormat Version for Temperary Migration
-
-CSP:
- Name: 'AWS'
- Region: ap-northeast-2
- Zone: KR-1
-
-Resources:
- VMInstance:
- Name: 'AWS_EC2_Instance'
- ImageId: 'ami-0abcdef1234567890'
- VMSpecId: t2.micro
- KeyPairName: MyKeyPair
- SecurityGroups:
- - Name: 'AWS_SecurityGroup-1'
- GroupDescription: Enable SSH and HTTP access
- SecurityGroupIngress:
- - IpProtocol: tcp
- FromPort: '22'
- ToPort: '22'
- CidrIp: 0.0.0.0/0
- - IpProtocol: tcp
- FromPort: '80'
- ToPort: '80'
- CidrIp: 0.0.0.0/0
- VPCInstance:
- Name: 'AWS_VPC'
- CidrBlock: 10.0.0.0/16
- EnableDnsSupport: true
- EnableDnsHostnames: true
- Subnets:
- - Name: 'AWS_Subnet1'
- CidrBlock: 10.0.1.0/24
- AvailabilityZone: Seoul1
- - Name: 'AWS_Subnet2'
- CidrBlock: 10.0.2.0/24
- AvailabilityZone: Seoul2
-
- LoadBalancer:
- Name: 'AWS_LoadBalancer'
- Listeners:
- - LoadBalancerPort: '80'
- InstancePort: '80'
- Protocol: HTTP
- HealthCheck:
- Target: HTTP:80/
- HealthyThreshold: '3'
- UnhealthyThreshold: '5'
- Interval: '30'
- Timeout: '5'
- VMInstances:
- - Name: AWS_EC2_Instance
diff --git a/.source_model/source-model.json b/.source_model/source-model.json
deleted file mode 100644
index 502f2cd..0000000
--- a/.source_model/source-model.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
- "sourceMigrationModel": {
- "description": "Description of the Migration Model",
- "name": "Migration Model Name",
- "version": "Migration Model Verion",
- "sourceEnvironment": {
- "provider": "On-premises, or Private Cloud, or Public Cloud Name",
- "details": {
- "location": "Data center location or cloud provider details",
- "zone": "If cloud provider, Zone code is here",
- "resources": [
- {
- "id": "vm_001",
- "type": "VM",
- "specifications": {
- "cpu": "4 cores",
- "memory": "8 GB",
- "storage": "500 GB",
- "os": "Windows Server 2019"
- }
- },
- {
- "id": "db_001",
- "type": "Database",
- "specifications": {
- "databaseType": "SQL",
- "version": "SQL Server 2019",
- "size": "200 GB",
- "tables": "50",
- "storedProcedures": "100"
- }
- },
- {
- "id": "storage_001",
- "type": "Storage",
- "specifications": {
- "storageType": "NAS",
- "capacity": "10 TB",
- "used": "6 TB",
- "protocol": "NFS"
- }
- },
- {
- "id": "app_001",
- "type": "Application",
- "specifications": {
- "name": "ERP System",
- "version": "5.2",
- "language": "Java",
- "dependencies": [
- "Java Runtime Environment",
- "MySQL Database"
- ]
- }
- },
- {
- "id": "web_server_001",
- "type": "Web Server",
- "specifications": {
- "software": "Apache",
- "version": "2.4.41",
- "hostedWebsites": "5",
- "traffic": "Approx. 1000 visits/day"
- }
- }
- ]
- }
- }
- }
-}
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..fdc4010
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,97 @@
+##############################################################
+## Stage 1 - Go Build
+##############################################################
+
+FROM golang:1.23.0-bookworm AS builder
+
+ENV GO111MODULE=on
+
+# Set the Current Working Directory inside the container
+WORKDIR /go/src/github.com/cloud-barista/cm-damselfly
+
+# Copy dependency files to the container
+COPY go.mod go.sum go.work go.work.sum LICENSE ./
+RUN --mount=type=cache,target=/go/pkg/mod \
+ --mount=type=cache,target=/root/.cache/go-build \
+ go mod download
+
+# Copy some necessary files to the container
+COPY api ./api
+COPY cmd/cm-damselfly ./cmd/cm-damselfly
+# COPY conf ./conf
+COPY pkg ./pkg
+
+# Build the Go app
+RUN --mount=type=cache,target=/go/pkg/mod \
+ --mount=type=cache,target=/root/.cache/go-build \
+ cd cmd/cm-damselfly && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w' -tags cm-damselfly -v -o cm-damselfly main.go
+
+#############################################################
+## Stage 2 - Application Setup
+##############################################################
+
+FROM ubuntu:22.04 AS prod
+
+RUN rm /bin/sh && ln -s /bin/bash /bin/sh
+
+# Set the Current Working Directory inside the container
+WORKDIR /app
+
+# Installing necessary packages and cleaning up
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ ca-certificates \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/*
+
+## Copy the Pre-built binary and necessary files from the previous stage
+COPY --from=builder /go/src/github.com/cloud-barista/cm-damselfly/api/ /app/api/
+COPY --from=builder /go/src/github.com/cloud-barista/cm-damselfly/cmd/cm-damselfly/cm-damselfly /app/
+# COPY --from=builder /go/src/github.com/cloud-barista/cm-damselfly/conf/ /app/conf/
+
+## To get the version of go modules
+COPY --from=builder /go/src/github.com/cloud-barista/cm-damselfly/go.mod /app/
+
+## To prevent the Golang Error: 'missing Location in call to Time.In'
+# Copy timezone from Golang base image
+COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /
+# Specify timezone info location for Go application
+ENV ZONEINFO=/zoneinfo.zip
+
+## Set environment variables
+# Set system endpoints
+ENV DAMSELFLY_ROOT=/app
+
+## Set SELF_ENDPOINT, to access Swagger API dashboard outside (Ex: export SELF_ENDPOINT=x.x.x.x:8088)
+ENV DAMSELFLY_SELF_ENDPOINT=localhost:8088
+
+## Set API access config
+# API_ALLOW_ORIGINS (ex: https://cloud-barista.org,xxx.xxx.xxx.xxx or * for all)
+# Set ENABLE_AUTH=true currently for basic auth for all routes (i.e., url or path)
+ENV DAMSELFLY_API_ALLOW_ORIGINS=* \
+ DAMSELFLY_API_AUTH_ENABLED=true \
+ DAMSELFLY_API_USERNAME=default \
+ DAMSELFLY_API_PASSWORD=default
+
+## Set internal DB config (lkvstore: local key-value store, default file path: ./db/damselfly.db)
+ENV DAMSELFLY_LKVSTORE_PATH=/app/db/damselfly.db
+
+## Logger configuration
+# Set log file path (default logfile path: ./damselfly.log)
+# Set log level, such as trace, debug info, warn, error, fatal, and panic
+ENV DAMSELFLY_LOGFILE_PATH=/app/log/damselfly.log \
+ DAMSELFLY_LOGFILE_MAXSIZE=1000 \
+ DAMSELFLY_LOGFILE_MAXBACKUPS=3 \
+ DAMSELFLY_LOGFILE_MAXAGE=30 \
+ DAMSELFLY_LOGFILE_COMPRESS=false \
+ DAMSELFLY_LOGLEVEL=info \
+ DAMSELFLY_LOGWRITER=both
+
+# Set execution environment, such as development or production
+ENV DAMSELFLY_NODE_ENV=production
+
+## Set period for auto control goroutine invocation
+ENV DAMSELFLY_AUTOCONTROL_DURATION_MS=10000
+
+ENTRYPOINT [ "/app/cm-damselfly" ]
+
+EXPOSE 8088
diff --git a/Makefile b/Makefile
index 19cfd0c..32ea767 100644
--- a/Makefile
+++ b/Makefile
@@ -80,5 +80,17 @@ clean: ## Remove previous build
@cd cmd/$(MODULE_NAME) && $(GO) clean
@echo "Cleaned!"
+compose: swag ## Build and up services by docker compose
+ @echo "Building and starting services by docker compose..."
+ @cd deployments/docker-compose && DOCKER_BUILDKIT=1 docker compose up --build
+
+compose-up: ## Up services by docker compose
+ @echo "Starting services by docker compose..."
+ @cd deployments/docker-compose && docker compose up
+
+compose-down: ## Down services by docker compose
+ @echo "Removing services by docker compose..."
+ @cd deployments/docker-compose && docker compose down
+
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
diff --git a/README.md b/README.md
index fc26fd5..ad8d958 100644
--- a/README.md
+++ b/README.md
@@ -68,30 +68,45 @@ go version
git clone https://github.com/cloud-barista/cm-damselfly.git ${HOME}/cm-damselfly
```
-#### Build and Run
+#### Build and Run with docker compose
+- Open ubuntu firewall TCP 8088 port on the system to access to the API(If need)
```bash
-
-# Open ubuntu firewall TCP 8088 port to access to the API(If need)
sudo ufw allow 8088/tcp
+```
+
+- Ensure that Docker and Docker Compose are installed on your system
+```bash
+docker --version
+docker compose version
+```
+
+- Run CM-Damselfly and related components
-pwd
-/home/(user)/go/src/github.com/cloud-barista/cm-damselfly
+```bash
+cd [DAMSELFLY_ROOT]
+sudo docker compose up
+```
+- With the `-d` option runs the container in the background
-# Build and Create Swagger API docs
-make
-# included : swag init --parseDependency --parseInternal
+```bash
+cd [DAMSELFLY_ROOT]
+sudo docker compose up -d
+```
-# Run Damselfly and API server
-make run
+- Stop CM-Damselfly
+```bash
+sudo docker compose down cm-damselfly
```
+
+#### Default API URL and File Path
- Swagger API URL
- http://localhost:8088/damselfly/api (username: default / password: default)
- Swagger web UI URL
- https://cloud-barista.github.io/api/?url=https://raw.githubusercontent.com/cloud-barista/cm-damselfly/refs/heads/main/api/swagger.yaml
-- Default DB to store path (The user migration model is stored to K/V DB as a file in the following location.)
- - ./cloud-barista/cm-damselfly/.damselfly/lkvstore.db
+- Default DB file path (The user migration model is stored to K/V DB as a file in the following location.)
+ - ./cloud-barista/cm-damselfly/db/damselfly.db
- Default log file path
- - ./cloud-barista/cm-damselfly/cmd/cm-damselfly/log/damselfly.log
+ - ./cloud-barista/cm-damselfly/log/damselfly.log
diff --git a/Test/model-test.go b/Test/model-test.go
deleted file mode 100644
index 7eb3763..0000000
--- a/Test/model-test.go
+++ /dev/null
@@ -1,326 +0,0 @@
-package main
-
-import (
- // "encoding/json"
- // // "os"
- // "strings"
- // "log"
- "fmt"
- "github.com/davecgh/go-spew/spew"
- "github.com/sirupsen/logrus"
-
- cblog "github.com/cloud-barista/cb-log"
- model "github.com/cloud-barista/cm-damselfly"
-)
-
-var cblogger *logrus.Logger
-
-func init() {
- // cblog is a global variable.
- cblogger = cblog.GetLogger("Migration Model Test")
- cblog.SetLevel("info")
-}
-
-func handleModel() {
- cblogger.Debug("Start Migration Model Test")
-
- var modelIId model.IID
- modelIId.NameId = "migrationModel-test-1"
-
- for {
- fmt.Println("\n============================================================================================")
- fmt.Println("[ Migration Model Test ]")
- fmt.Println("1. WriteModel()")
- fmt.Println("2. GetModel()")
- fmt.Println("3. ListModel()")
- fmt.Println("4. UpdateModel()")
- fmt.Println("5. DeleteModel()")
- fmt.Println("6. UpdateSubnetInfoList()")
- fmt.Println("0. Exit")
- fmt.Println("\n Select a number above!! : ")
- fmt.Println("============================================================================================")
-
-
- var commandNum int
- inputCnt, err := fmt.Scan(&commandNum)
- if err != nil {
- panic(err)
- }
-
- if inputCnt == 1 {
- switch commandNum {
- case 1:
- fmt.Println("Start WriteModel() ...")
-
- var jsonModel model.JSON_Model
- jsonModel = model.JSON_Model {
- model.MigrationModel{
- Description: "Description for this model",
- Name: "My-New-Model",
- Version: "v0.1",
- ModelId: "Otacbatcvafafa001",
- MigrationStep: "Step-01-abcdefg",
- TargetEnvironment: model.TargetEnvironment{
- Provider: "NCP VPC",
- Details: model.EnvironmentDetails{
- Region: "Korea",
- Zone: "KR-1",
- Resources: []model.Resource{
- {
- Type: "Namespace",
- NsSpecifications: &model.Namespace{
- Description: "MyVPC_001",
- Name: "ns01",
- },
- },
- {
- Type: "vNet",
- VNetSpecifications: &model.VNet{
- CidrBlock: "string",
- SubnetInfoList : []model.SubnetInfo{
- {
- Description: "New Subnet Description",
- Ipv4CIDR: "192.168.1.0/24",
- KeyValueList: []model.KeyValue{
- {
- Key: "NewKey",
- Value: "NewValue",
- },
- },
- Name: "NewSubnetName",
- },
- },
- },
- },
- {
- Type: "MCIS",
- McisSpecifications: &model.MCIS{
- Description: "MCIS descrition ...",
- InstallMonAgent: "no",
- Label: "custom tag",
- Name: "mcis01",
- PlacementAlgo: "string",
- SystemLabel: "",
- VM: []model.VM{
- {
- DataDiskIds: []string{"disk1", "disk2"},
- Description: "Description",
- IdByCsp: "i-014fa6ede6ada0b2c",
- ImageId: "image1",
- Label: "label1",
- Name: "g1-1",
- RootDiskSize: "42",
- RootDiskType: "SSD",
- SecurityGroupIds: []string{"sg1", "sg2"},
- SpecId: "spec1",
- SshKeyId: "key1",
- SubGroupSize: "3",
- VNetId: "vnet1",
- SubnetId: "subnet1",
- VmUserAccount: "user1",
- VmUserPassword: "pass1",
- },
- },
- },
- },
- },
- },
- },
- },
- }
-
- modelInfo, err := model.WriteModel(modelIId.NameId, jsonModel)
- if err != nil {
- cblogger.Error(err)
- cblogger.Error("Model 쓰기 실패 : ", err)
- } else {
- fmt.Println("\n==================================================================================================================")
- cblogger.Debug("Model 쓰기 성공!!")
- spew.Dump(modelInfo)
- }
- fmt.Println("\nWriteModel Test Finished")
-
- case 2:
- fmt.Println("Start GetModel() ...")
- modelInfo, err := model.GetModel(modelIId)
- if err != nil {
- cblogger.Error(err)
- cblogger.Error("Model Info 조회 실패 : ", err)
- } else {
- fmt.Println("\n==================================================================================================================")
- spew.Dump(modelInfo)
- cblogger.Debug(modelInfo)
- //cblogger.Infof(modelInfo)
- }
- fmt.Println("\nGetModel() Test Finished")
-
- case 3:
- fmt.Println("Start ListModel() ...")
- modelList, err := model.ListModel()
- if err != nil {
- cblogger.Error(err)
- cblogger.Error("Model list 조회 실패 : ", err)
- } else {
- cblogger.Debug("Model list 조회 성공")
- spew.Dump(modelList)
- cblogger.Debug(modelList)
- //spew.Dump(result)
- //fmt.Println(result)
- //fmt.Println("=========================")
- //fmt.Println(result)
- cblogger.Infof("List 개수 : [%d]", len(modelList))
- }
- fmt.Println("\nListModel() Test Finished")
-
- case 4:
- fmt.Println("Start UpdateModel() ...")
-
- var jsonModel2 model.JSON_Model
- jsonModel2 = model.JSON_Model {
- model.MigrationModel{
- Description: "Description for this model",
- Name: "My-New-Model",
- Version: "v0.2",
- ModelId: "Otacbatcvafafa00100000000",
- MigrationStep: "Step-02-abcdefg",
- TargetEnvironment: model.TargetEnvironment{
- Provider: "AWS",
- Details: model.EnvironmentDetails{
- Region: "Korea",
- Zone: "KR-1",
- Resources: []model.Resource{
- {
- Type: "Namespace",
- NsSpecifications: &model.Namespace{
- Description: "MyVPC_001",
- Name: "ns01",
- },
- },
- {
- Type: "vNet",
- VNetSpecifications: &model.VNet{
- CidrBlock: "string",
- SubnetInfoList : []model.SubnetInfo{
- {
- Description: "New Subnet Description",
- Ipv4CIDR: "10.10.1.0/24",
- KeyValueList: []model.KeyValue{
- {
- Key: "NewKey",
- Value: "NewValue",
- },
- },
- Name: "NewSubnetName",
- },
- },
- },
- },
- {
- Type: "MCIS",
- McisSpecifications: &model.MCIS{
- Description: "MCIS descrition ...",
- InstallMonAgent: "no",
- Label: "custom tag",
- Name: "mcis01",
- PlacementAlgo: "string",
- SystemLabel: "",
- VM: []model.VM{
- {
- DataDiskIds: []string{"disk1", "disk2"},
- Description: "Description",
- IdByCsp: "i-014fa6ede6ada0b2c",
- ImageId: "image1",
- Label: "label1",
- Name: "g1-1",
- RootDiskSize: "42",
- RootDiskType: "SSD",
- SecurityGroupIds: []string{"sg1", "sg2"},
- SpecId: "spec1",
- SshKeyId: "key1",
- SubGroupSize: "3",
- VNetId: "vnet1",
- SubnetId: "subnet1",
- VmUserAccount: "user1",
- VmUserPassword: "pass1",
- },
- },
- },
- },
- },
- },
- },
- },
- }
-
- modelInfo, err := model.UpdateModel(modelIId, jsonModel2)
- if err != nil {
- cblogger.Error(err)
- cblogger.Error("Update Model 실패 : ", err)
- } else {
- cblogger.Debugf("Update Model 성공")
- spew.Dump(modelInfo)
- cblogger.Debug(modelInfo)
- //fmt.Println(modelInfo)
- }
- fmt.Println("\nUpdateModel() Test Finished")
-
- case 5:
- fmt.Println("Start DeleteModel() ...")
- result, err := model.DeleteModel(modelIId)
- if err != nil {
- cblogger.Error(err)
- cblogger.Error("DeleteModel 실패 : ", err)
- } else {
- cblogger.Debug("DeleteModel 성공")
- spew.Dump(result)
- cblogger.Debug(result)
- //spew.Dump(result)
- //fmt.Println(result)
- //fmt.Println("=========================")
- //fmt.Println(result)
- }
- fmt.Println("\nDeleteModel() Test Finished")
-
- case 6:
- fmt.Println("Start UpdateSubnetInfoList() ...")
-
- newSubnetInfoList := []model.SubnetInfo{
- {
- Description: "New Subnet Description",
- Ipv4CIDR: "10.10.2.0/24",
- KeyValueList: []model.KeyValue{
- {
- Key: "NewKey",
- Value: "NewValue",
- },
- },
- Name: "NewSubnetName",
- },
- }
-
- modelInfo, err := model.UpdateSubnetInfoList(modelIId, newSubnetInfoList)
- if err != nil {
- cblogger.Error(err)
- cblogger.Error("UpdateSubnetInfoList 실패 : ", err)
- } else {
- cblogger.Debug("UpdateSubnetInfoList 성공")
- spew.Dump(modelInfo)
- cblogger.Debug(modelInfo)
- //fmt.Println(result)
- //fmt.Println("=========================")
- //fmt.Println(result)
- }
- fmt.Println("\nUpdateSubnetInfoList() Test Finished")
-
- case 0:
- fmt.Println("Exit")
- return
- }
- }
- }
-}
-
-func main() {
- cblogger.Info("Migration Model Test")
- handleModel()
-}
diff --git a/Test/model-test.sh b/Test/model-test.sh
deleted file mode 100755
index 85d8fb2..0000000
--- a/Test/model-test.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-
-source ../setup.env
-go run model-test.go
diff --git a/Test/replication-test.go b/Test/replication-test.go
deleted file mode 100644
index 2cfb784..0000000
--- a/Test/replication-test.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package main
-
-import (
- "fmt"
- "github.com/davecgh/go-spew/spew"
-
- model "github.com/cloud-barista/cm-damselfly"
-)
-
-func main() {
- resources, err := model.GetReplicaResources("replication")
- if err != nil {
- fmt.Println("Error:", err)
- return
- }
- fmt.Println("\n### Resources for Replica :", err)
- spew.Dump(resources)
-}
diff --git a/Test/replication-test.sh b/Test/replication-test.sh
deleted file mode 100755
index 4c31083..0000000
--- a/Test/replication-test.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-
-source ../setup.env
-go run replication-test.go
diff --git a/api/docs.go b/api/docs.go
index 72e24b1..3e4bbce 100644
--- a/api/docs.go
+++ b/api/docs.go
@@ -33,14 +33,14 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] Cloud Migration Models"
+ "[API] Cloud Migration User Models"
],
"summary": "Get a list of cloud models",
"responses": {
"200": {
"description": "(sample) This is a list of models",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.GetCloudModelsResp"
+ "$ref": "#/definitions/handler.GetCloudModelsResp"
}
},
"404": {
@@ -60,7 +60,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] Cloud Migration Models"
+ "[API] Cloud Migration User Models"
],
"summary": "Create a new cloud model",
"parameters": [
@@ -70,7 +70,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.CreateCloudModelReq"
+ "$ref": "#/definitions/handler.CreateCloudModelReq"
}
}
],
@@ -78,7 +78,7 @@ const docTemplate = `{
"201": {
"description": "(Sample) This is a sample description for success response in Swagger UI",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.CreateCloudModelResp"
+ "$ref": "#/definitions/handler.CreateCloudModelResp"
}
},
"400": {
@@ -100,7 +100,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] Cloud Migration Models"
+ "[API] Cloud Migration User Models"
],
"summary": "Get a specific cloud model",
"parameters": [
@@ -116,7 +116,7 @@ const docTemplate = `{
"200": {
"description": "(Sample) a model",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.GetCloudModelResp"
+ "$ref": "#/definitions/handler.GetCloudModelResp"
}
},
"404": {
@@ -136,7 +136,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] Cloud Migration Models"
+ "[API] Cloud Migration User Models"
],
"summary": "Update a cloud model",
"parameters": [
@@ -153,7 +153,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.UpdateCloudModelReq"
+ "$ref": "#/definitions/handler.UpdateCloudModelReq"
}
}
],
@@ -161,7 +161,7 @@ const docTemplate = `{
"201": {
"description": "(Sample) This is a sample description for success response in Swagger UI",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.UpdateCloudModelResp"
+ "$ref": "#/definitions/handler.UpdateCloudModelResp"
}
},
"400": {
@@ -181,7 +181,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] Cloud Migration Models"
+ "[API] Cloud Migration User Models"
],
"summary": "Delete a cloud model",
"parameters": [
@@ -232,19 +232,48 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.ResHTTPVersion"
+ "$ref": "#/definitions/handler.ResHTTPVersion"
}
},
"404": {
"description": "Not Found",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.ResHTTPVersion"
+ "$ref": "#/definitions/handler.ResHTTPVersion"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.ResHTTPVersion"
+ "$ref": "#/definitions/handler.ResHTTPVersion"
+ }
+ }
+ }
+ }
+ },
+ "/model/version": {
+ "get": {
+ "description": "Get the versions of all models(schemata of on-premise/cloud migration models)",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "[API] Migration Models"
+ ],
+ "summary": "Get the versions of all models(schemata of on-premise/cloud migration models)",
+ "responses": {
+ "200": {
+ "description": "(sample) This is the versions of all models(schemata)",
+ "schema": {
+ "$ref": "#/definitions/handler.GetModelsVersionResp"
+ }
+ },
+ "404": {
+ "description": "verson of models not found",
+ "schema": {
+ "type": "object"
}
}
}
@@ -260,7 +289,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] Migration Models"
+ "[API] Migration User Models"
],
"summary": "Get a list of all user models",
"parameters": [
@@ -276,7 +305,7 @@ const docTemplate = `{
"200": {
"description": "(sample) This is a list of models",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.GetModelsResp"
+ "$ref": "#/definitions/handler.GetModelsResp"
}
},
"404": {
@@ -298,14 +327,14 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] On-Premise Migration Models"
+ "[API] On-Premise Migration User Models"
],
"summary": "Get a list of on-premise models",
"responses": {
"200": {
"description": "(sample) This is a list of models",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.GetOnPremModelsResp"
+ "$ref": "#/definitions/handler.GetOnPremModelsResp"
}
},
"404": {
@@ -325,7 +354,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] On-Premise Migration Models"
+ "[API] On-Premise Migration User Models"
],
"summary": "Create a new on-premise model",
"parameters": [
@@ -335,7 +364,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.CreateOnPremModelReq"
+ "$ref": "#/definitions/handler.CreateOnPremModelReq"
}
}
],
@@ -343,7 +372,7 @@ const docTemplate = `{
"201": {
"description": "(Sample) This is a sample description for success response in Swagger UI",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.CreateOnPremModelResp"
+ "$ref": "#/definitions/handler.CreateOnPremModelResp"
}
},
"400": {
@@ -365,7 +394,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] On-Premise Migration Models"
+ "[API] On-Premise Migration User Models"
],
"summary": "Get a specific on-premise model",
"parameters": [
@@ -381,7 +410,7 @@ const docTemplate = `{
"200": {
"description": "(Sample) a model",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.GetOnPremModelResp"
+ "$ref": "#/definitions/handler.GetOnPremModelResp"
}
},
"404": {
@@ -401,7 +430,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] On-Premise Migration Models"
+ "[API] On-Premise Migration User Models"
],
"summary": "Update a on-premise model",
"parameters": [
@@ -418,7 +447,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.UpdateOnPremModelReq"
+ "$ref": "#/definitions/handler.UpdateOnPremModelReq"
}
}
],
@@ -426,7 +455,7 @@ const docTemplate = `{
"201": {
"description": "(Sample) This is a sample description for success response in Swagger UI",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.UpdateOnPremModelResp"
+ "$ref": "#/definitions/handler.UpdateOnPremModelResp"
}
},
"400": {
@@ -446,7 +475,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
- "[API] On-Premise Migration Models"
+ "[API] On-Premise Migration User Models"
],
"summary": "Delete a on-premise model",
"parameters": [
@@ -497,13 +526,13 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.ResReadyz"
+ "$ref": "#/definitions/handler.ResReadyz"
}
},
"503": {
"description": "Service Unavailable",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.ResReadyz"
+ "$ref": "#/definitions/handler.ResReadyz"
}
}
}
@@ -511,400 +540,221 @@ const docTemplate = `{
}
},
"definitions": {
- "model.TbMciDynamicReq": {
+ "handler.CloudModelRespInfo": {
"type": "object",
"required": [
- "name",
- "vm"
+ "cloudInfraModel"
],
"properties": {
+ "cloudInfraModel": {
+ "$ref": "#/definitions/model.TbMciDynamicReq"
+ },
+ "cloudModelVersion": {
+ "type": "string"
+ },
+ "createTime": {
+ "type": "string"
+ },
+ "csp": {
+ "type": "string"
+ },
"description": {
- "type": "string",
- "example": "Made in CB-TB"
+ "type": "string"
},
- "installMonAgent": {
- "description": "InstallMonAgent Option for CB-Dragonfly agent installation ([yes/no] default:yes)",
- "type": "string",
- "default": "no",
- "enum": [
- "yes",
- "no"
- ],
- "example": "no"
+ "id": {
+ "type": "string"
},
- "label": {
- "description": "Label is for describing the object by keywords",
- "type": "object",
- "additionalProperties": {
- "type": "string"
- }
+ "isCloudModel": {
+ "type": "boolean"
},
- "name": {
- "type": "string",
- "example": "mci01"
+ "isInitUserModel": {
+ "type": "boolean"
},
- "systemLabel": {
- "description": "SystemLabel is for describing the mci in a keyword (any string can be used) for special System purpose",
- "type": "string",
- "example": ""
+ "isTargetModel": {
+ "type": "boolean"
},
- "vm": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/model.TbVmDynamicReq"
- }
+ "region": {
+ "type": "string"
+ },
+ "updateTime": {
+ "type": "string"
+ },
+ "userId": {
+ "type": "string"
+ },
+ "userModelName": {
+ "type": "string"
+ },
+ "userModelVersion": {
+ "type": "string"
+ },
+ "zone": {
+ "type": "string"
}
}
},
- "model.TbVmDynamicReq": {
+ "handler.CreateCloudModelReq": {
"type": "object",
"required": [
- "commonImage",
- "commonSpec"
+ "cloudInfraModel"
],
"properties": {
- "commonImage": {
- "description": "CommonImage is field for id of a image in common namespace",
- "type": "string",
- "example": "ubuntu18.04"
- },
- "commonSpec": {
- "description": "CommonSpec is field for id of a spec in common namespace",
- "type": "string",
- "example": "aws+ap-northeast-2+t2.small"
+ "cloudInfraModel": {
+ "$ref": "#/definitions/model.TbMciDynamicReq"
},
- "connectionName": {
- "description": "if ConnectionName is given, the VM tries to use associtated credential.\nif not, it will use predefined ConnectionName in Spec objects",
+ "csp": {
"type": "string"
},
"description": {
- "type": "string",
- "example": "Description"
+ "type": "string"
},
- "label": {
- "description": "Label is for describing the object by keywords",
- "type": "object",
- "additionalProperties": {
- "type": "string"
- }
+ "isInitUserModel": {
+ "type": "boolean"
},
- "name": {
- "description": "VM name or subGroup name if is (not empty) \u0026\u0026 (\u003e 0). If it is a group, actual VM name will be generated with -N postfix.",
- "type": "string",
- "example": "g1-1"
+ "isTargetModel": {
+ "type": "boolean"
},
- "rootDiskSize": {
- "description": "\"default\", Integer (GB): [\"50\", ..., \"1000\"]",
- "type": "string",
- "default": "default",
- "example": "default, 30, 42, ..."
+ "region": {
+ "type": "string"
},
- "rootDiskType": {
- "description": "\"\", \"default\", \"TYPE1\", AWS: [\"standard\", \"gp2\", \"gp3\"], Azure: [\"PremiumSSD\", \"StandardSSD\", \"StandardHDD\"], GCP: [\"pd-standard\", \"pd-balanced\", \"pd-ssd\", \"pd-extreme\"], ALIBABA: [\"cloud_efficiency\", \"cloud\", \"cloud_essd\"], TENCENT: [\"CLOUD_PREMIUM\", \"CLOUD_SSD\"]",
- "type": "string",
- "default": "default",
- "example": "default, TYPE1, ..."
+ "userId": {
+ "type": "string"
},
- "subGroupSize": {
- "description": "if subGroupSize is (not empty) \u0026\u0026 (\u003e 0), subGroup will be generated. VMs will be created accordingly.",
- "type": "string",
- "default": "1",
- "example": "3"
+ "userModelName": {
+ "type": "string"
},
- "vmUserPassword": {
+ "userModelVersion": {
+ "type": "string"
+ },
+ "zone": {
"type": "string"
}
}
},
- "onprem.CpuProperty": {
+ "handler.CreateCloudModelResp": {
"type": "object",
"required": [
- "cores",
- "cpus",
- "threads"
+ "cloudInfraModel"
],
"properties": {
- "architecture": {
- "type": "string",
- "example": "x86_64"
+ "cloudInfraModel": {
+ "$ref": "#/definitions/model.TbMciDynamicReq"
},
- "cores": {
- "description": "Number of physical cores per CPU",
- "type": "integer",
- "example": 18
+ "cloudModelVersion": {
+ "type": "string"
},
- "cpus": {
- "description": "Number of physical CPUs (sockets)",
- "type": "integer",
- "example": 2
+ "createTime": {
+ "type": "string"
},
- "maxSpeed": {
- "description": "Maximum speed in GHz",
- "type": "number",
- "example": 3.6
+ "csp": {
+ "type": "string"
},
- "model": {
- "type": "string",
- "example": "Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz"
+ "description": {
+ "type": "string"
},
- "threads": {
- "description": "Number of logical CPUs (threads) per CPU with hyper-threading enabled",
- "type": "integer",
- "example": 36
+ "id": {
+ "type": "string"
},
- "vendor": {
- "type": "string",
- "example": "GenuineIntel"
- }
- }
- },
- "onprem.DiskProperty": {
- "type": "object",
- "required": [
- "label",
- "totalSize",
- "type"
- ],
- "properties": {
- "available": {
- "description": "Unit GiB",
- "type": "integer"
+ "isCloudModel": {
+ "type": "boolean"
},
- "label": {
+ "isInitUserModel": {
+ "type": "boolean"
+ },
+ "isTargetModel": {
+ "type": "boolean"
+ },
+ "region": {
"type": "string"
},
- "totalSize": {
- "description": "Unit GiB",
- "type": "integer",
- "example": 1024
+ "updateTime": {
+ "type": "string"
},
- "type": {
- "description": "SSD, HDD",
- "type": "string",
- "example": "SSD"
+ "userId": {
+ "type": "string"
},
- "used": {
- "description": "Unit GiB",
- "type": "integer"
+ "userModelName": {
+ "type": "string"
+ },
+ "userModelVersion": {
+ "type": "string"
+ },
+ "zone": {
+ "type": "string"
}
}
},
- "onprem.MemoryProperty": {
+ "handler.CreateOnPremModelReq": {
"type": "object",
"required": [
- "totalSize",
- "type"
+ "onpremiseInfraModel"
],
"properties": {
- "available": {
- "description": "Unit GiB",
- "type": "integer"
+ "description": {
+ "type": "string"
},
- "totalSize": {
- "description": "Unit GiB",
- "type": "integer",
- "example": 128
- },
- "type": {
- "type": "string",
- "example": "DDR4"
- },
- "used": {
- "description": "Unit GiB",
- "type": "integer"
- }
- }
- },
- "onprem.NetworkInterfaceProperty": {
- "type": "object",
- "required": [
- "name"
- ],
- "properties": {
- "ipv4CidrBlocks": {
- "description": "IPv4 address with prefix length (e.g., 192.168.0.21/24), instead of inet addr, Bcast, and Mask",
- "type": "array",
- "items": {
- "type": "string"
- }
+ "isInitUserModel": {
+ "type": "boolean"
},
- "ipv6CidrBlocks": {
- "description": "IPv6 address with prefix length (e.g., \"2001:db8::1/64\")",
- "type": "array",
- "items": {
- "type": "string"
- }
+ "onpremiseInfraModel": {
+ "$ref": "#/definitions/onprem.OnPremInfra"
},
- "macAddress": {
- "description": "MAC address",
+ "userId": {
"type": "string"
},
- "mtu": {
- "description": "Maximum Transmission Unit (MTU) in bytes",
- "type": "integer"
- },
- "name": {
- "description": "Interface name (e.g., eth0, ens01, enp0s3)",
+ "userModelName": {
"type": "string"
},
- "state": {
- "description": "Interface state (e.g., UP, DOWN)",
+ "userModelVersion": {
"type": "string"
}
}
},
- "onprem.NetworkProperty": {
- "type": "object",
- "properties": {
- "ipv4Networks": {
- "type": "array",
- "items": {
- "type": "string"
- },
- "example": [
- "172.26.240.0/20"
- ]
- },
- "ipv6Networks": {
- "description": "TBD",
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- }
- },
- "onprem.OnPremInfra": {
- "type": "object",
- "required": [
- "servers"
- ],
- "properties": {
- "network": {
- "$ref": "#/definitions/onprem.NetworkProperty"
- },
- "servers": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/onprem.ServerProperty"
- }
- }
- }
- },
- "onprem.OsProperty": {
+ "handler.CreateOnPremModelResp": {
"type": "object",
"required": [
- "prettyName"
+ "onpremiseInfraModel"
],
"properties": {
- "id": {
- "type": "string",
- "example": "ubuntu"
- },
- "idLike": {
- "type": "string",
- "example": "debian"
- },
- "name": {
- "type": "string",
- "example": "Ubuntu"
- },
- "prettyName": {
- "description": "Pretty name",
- "type": "string",
- "example": "Ubuntu 22.04.3 LTS"
- },
- "version": {
- "description": "Full version string",
- "type": "string",
- "example": "22.04.3 LTS (Jammy Jellyfish)"
- },
- "versionCodename": {
- "type": "string",
- "example": "jammy"
- },
- "versionId": {
- "type": "string",
- "example": "22.04"
- }
- }
- },
- "onprem.RouteProperty": {
- "type": "object",
- "properties": {
- "destination": {
- "description": "Destination network, expressed in CIDR format",
- "type": "string"
- },
- "gateway": {
- "description": "Gateway address to which packets are forwarded",
+ "createTime": {
"type": "string"
},
- "interface": {
- "description": "Network interface associated with the route",
+ "description": {
"type": "string"
},
- "linkState": {
- "description": "Link state of the route (e.g., UP, DOWN)",
+ "id": {
"type": "string"
},
- "metric": {
- "description": "Metric value indicating the priority of the route",
- "type": "integer"
+ "isCloudModel": {
+ "type": "boolean"
},
- "protocol": {
- "description": "Protocol used to set the route (e.g., kernel, static)",
- "type": "string"
+ "isInitUserModel": {
+ "type": "boolean"
},
- "scope": {
- "description": "Scope of the route (e.g., global, link, host)",
- "type": "string"
+ "isTargetModel": {
+ "type": "boolean"
},
- "source": {
- "description": "Optionally stores the source address (used for policy-based routing)",
+ "onpremModelVersion": {
"type": "string"
- }
- }
- },
- "onprem.ServerProperty": {
- "type": "object",
- "properties": {
- "cpu": {
- "$ref": "#/definitions/onprem.CpuProperty"
},
- "dataDisks": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/onprem.DiskProperty"
- }
+ "onpremiseInfraModel": {
+ "$ref": "#/definitions/onprem.OnPremInfra"
},
- "hostname": {
+ "updateTime": {
"type": "string"
},
- "interfaces": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/onprem.NetworkInterfaceProperty"
- }
- },
- "memory": {
- "$ref": "#/definitions/onprem.MemoryProperty"
- },
- "os": {
- "$ref": "#/definitions/onprem.OsProperty"
+ "userId": {
+ "type": "string"
},
- "rootDisk": {
- "$ref": "#/definitions/onprem.DiskProperty"
+ "userModelName": {
+ "type": "string"
},
- "routingTable": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/onprem.RouteProperty"
- }
+ "userModelVersion": {
+ "type": "string"
}
}
},
- "pkg_api_rest_handler.CloudModelRespInfo": {
+ "handler.GetCloudModelResp": {
"type": "object",
"required": [
"cloudInfraModel"
@@ -957,28 +807,67 @@ const docTemplate = `{
}
}
},
- "pkg_api_rest_handler.CreateCloudModelReq": {
+ "handler.GetCloudModelsResp": {
+ "type": "object",
+ "properties": {
+ "models": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/handler.CloudModelRespInfo"
+ }
+ }
+ }
+ },
+ "handler.GetModelsResp": {
+ "type": "object",
+ "properties": {
+ "models": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/handler.ModelRespInfo"
+ }
+ }
+ }
+ },
+ "handler.GetModelsVersionResp": {
+ "type": "object",
+ "properties": {
+ "modelsVersion": {
+ "$ref": "#/definitions/handler.ModelsVersionRespInfo"
+ }
+ }
+ },
+ "handler.GetOnPremModelResp": {
"type": "object",
"required": [
- "cloudInfraModel"
+ "onpremiseInfraModel"
],
"properties": {
- "cloudInfraModel": {
- "$ref": "#/definitions/model.TbMciDynamicReq"
- },
- "csp": {
+ "createTime": {
"type": "string"
},
"description": {
"type": "string"
},
+ "id": {
+ "type": "string"
+ },
+ "isCloudModel": {
+ "type": "boolean"
+ },
"isInitUserModel": {
"type": "boolean"
},
"isTargetModel": {
"type": "boolean"
},
- "region": {
+ "onpremModelVersion": {
+ "type": "string"
+ },
+ "onpremiseInfraModel": {
+ "$ref": "#/definitions/onprem.OnPremInfra"
+ },
+ "updateTime": {
"type": "string"
},
"userId": {
@@ -989,16 +878,25 @@ const docTemplate = `{
},
"userModelVersion": {
"type": "string"
- },
- "zone": {
- "type": "string"
}
}
},
- "pkg_api_rest_handler.CreateCloudModelResp": {
+ "handler.GetOnPremModelsResp": {
+ "type": "object",
+ "properties": {
+ "models": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/handler.OnPremModelRespInfo"
+ }
+ }
+ }
+ },
+ "handler.ModelRespInfo": {
"type": "object",
"required": [
- "cloudInfraModel"
+ "cloudInfraModel",
+ "onpremiseInfraModel"
],
"properties": {
"cloudInfraModel": {
@@ -1028,129 +926,12 @@ const docTemplate = `{
"isTargetModel": {
"type": "boolean"
},
- "region": {
- "type": "string"
- },
- "updateTime": {
- "type": "string"
- },
- "userId": {
- "type": "string"
- },
- "userModelName": {
- "type": "string"
- },
- "userModelVersion": {
- "type": "string"
- },
- "zone": {
- "type": "string"
- }
- }
- },
- "pkg_api_rest_handler.CreateOnPremModelReq": {
- "type": "object",
- "required": [
- "onpremiseInfraModel"
- ],
- "properties": {
- "description": {
- "type": "string"
- },
- "isInitUserModel": {
- "type": "boolean"
- },
- "onpremiseInfraModel": {
- "$ref": "#/definitions/onprem.OnPremInfra"
- },
- "userId": {
- "type": "string"
- },
- "userModelName": {
- "type": "string"
- },
- "userModelVersion": {
- "type": "string"
- }
- }
- },
- "pkg_api_rest_handler.CreateOnPremModelResp": {
- "type": "object",
- "required": [
- "onpremiseInfraModel"
- ],
- "properties": {
- "createTime": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "id": {
- "type": "string"
- },
- "isCloudModel": {
- "type": "boolean"
- },
- "isInitUserModel": {
- "type": "boolean"
- },
- "isTargetModel": {
- "type": "boolean"
- },
"onpremModelVersion": {
"type": "string"
},
"onpremiseInfraModel": {
"$ref": "#/definitions/onprem.OnPremInfra"
},
- "updateTime": {
- "type": "string"
- },
- "userId": {
- "type": "string"
- },
- "userModelName": {
- "type": "string"
- },
- "userModelVersion": {
- "type": "string"
- }
- }
- },
- "pkg_api_rest_handler.GetCloudModelResp": {
- "type": "object",
- "required": [
- "cloudInfraModel"
- ],
- "properties": {
- "cloudInfraModel": {
- "$ref": "#/definitions/model.TbMciDynamicReq"
- },
- "cloudModelVersion": {
- "type": "string"
- },
- "createTime": {
- "type": "string"
- },
- "csp": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "id": {
- "type": "string"
- },
- "isCloudModel": {
- "type": "boolean"
- },
- "isInitUserModel": {
- "type": "boolean"
- },
- "isTargetModel": {
- "type": "boolean"
- },
"region": {
"type": "string"
},
@@ -1171,144 +952,18 @@ const docTemplate = `{
}
}
},
- "pkg_api_rest_handler.GetCloudModelsResp": {
- "type": "object",
- "properties": {
- "models": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/pkg_api_rest_handler.CloudModelRespInfo"
- }
- }
- }
- },
- "pkg_api_rest_handler.GetModelsResp": {
- "type": "object",
- "properties": {
- "models": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/pkg_api_rest_handler.ModelRespInfo"
- }
- }
- }
- },
- "pkg_api_rest_handler.GetOnPremModelResp": {
- "type": "object",
- "required": [
- "onpremiseInfraModel"
- ],
- "properties": {
- "createTime": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "id": {
- "type": "string"
- },
- "isCloudModel": {
- "type": "boolean"
- },
- "isInitUserModel": {
- "type": "boolean"
- },
- "isTargetModel": {
- "type": "boolean"
- },
- "onpremModelVersion": {
- "type": "string"
- },
- "onpremiseInfraModel": {
- "$ref": "#/definitions/onprem.OnPremInfra"
- },
- "updateTime": {
- "type": "string"
- },
- "userId": {
- "type": "string"
- },
- "userModelName": {
- "type": "string"
- },
- "userModelVersion": {
- "type": "string"
- }
- }
- },
- "pkg_api_rest_handler.GetOnPremModelsResp": {
- "type": "object",
- "properties": {
- "models": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/pkg_api_rest_handler.OnPremModelRespInfo"
- }
- }
- }
- },
- "pkg_api_rest_handler.ModelRespInfo": {
+ "handler.ModelsVersionRespInfo": {
"type": "object",
- "required": [
- "cloudInfraModel",
- "onpremiseInfraModel"
- ],
"properties": {
- "cloudInfraModel": {
- "$ref": "#/definitions/model.TbMciDynamicReq"
- },
"cloudModelVersion": {
"type": "string"
},
- "createTime": {
- "type": "string"
- },
- "csp": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "id": {
- "type": "string"
- },
- "isCloudModel": {
- "type": "boolean"
- },
- "isInitUserModel": {
- "type": "boolean"
- },
- "isTargetModel": {
- "type": "boolean"
- },
"onpremModelVersion": {
"type": "string"
- },
- "onpremiseInfraModel": {
- "$ref": "#/definitions/onprem.OnPremInfra"
- },
- "region": {
- "type": "string"
- },
- "updateTime": {
- "type": "string"
- },
- "userId": {
- "type": "string"
- },
- "userModelName": {
- "type": "string"
- },
- "userModelVersion": {
- "type": "string"
- },
- "zone": {
- "type": "string"
}
}
},
- "pkg_api_rest_handler.OnPremModelRespInfo": {
+ "handler.OnPremModelRespInfo": {
"type": "object",
"required": [
"onpremiseInfraModel"
@@ -1352,7 +1007,7 @@ const docTemplate = `{
}
}
},
- "pkg_api_rest_handler.ResHTTPVersion": {
+ "handler.ResHTTPVersion": {
"type": "object",
"properties": {
"message": {
@@ -1360,7 +1015,7 @@ const docTemplate = `{
}
}
},
- "pkg_api_rest_handler.ResReadyz": {
+ "handler.ResReadyz": {
"type": "object",
"properties": {
"message": {
@@ -1368,7 +1023,7 @@ const docTemplate = `{
}
}
},
- "pkg_api_rest_handler.UpdateCloudModelReq": {
+ "handler.UpdateCloudModelReq": {
"type": "object",
"required": [
"cloudInfraModel"
@@ -1406,7 +1061,7 @@ const docTemplate = `{
}
}
},
- "pkg_api_rest_handler.UpdateCloudModelResp": {
+ "handler.UpdateCloudModelResp": {
"type": "object",
"required": [
"cloudInfraModel"
@@ -1459,7 +1114,7 @@ const docTemplate = `{
}
}
},
- "pkg_api_rest_handler.UpdateOnPremModelReq": {
+ "handler.UpdateOnPremModelReq": {
"type": "object",
"required": [
"onpremiseInfraModel"
@@ -1485,7 +1140,7 @@ const docTemplate = `{
}
}
},
- "pkg_api_rest_handler.UpdateOnPremModelResp": {
+ "handler.UpdateOnPremModelResp": {
"type": "object",
"required": [
"onpremiseInfraModel"
@@ -1528,6 +1183,399 @@ const docTemplate = `{
"type": "string"
}
}
+ },
+ "model.TbMciDynamicReq": {
+ "type": "object",
+ "required": [
+ "name",
+ "vm"
+ ],
+ "properties": {
+ "description": {
+ "type": "string",
+ "example": "Made in CB-TB"
+ },
+ "installMonAgent": {
+ "description": "InstallMonAgent Option for CB-Dragonfly agent installation ([yes/no] default:yes)",
+ "type": "string",
+ "default": "no",
+ "enum": [
+ "yes",
+ "no"
+ ],
+ "example": "no"
+ },
+ "label": {
+ "description": "Label is for describing the object by keywords",
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "name": {
+ "type": "string",
+ "example": "mci01"
+ },
+ "systemLabel": {
+ "description": "SystemLabel is for describing the mci in a keyword (any string can be used) for special System purpose",
+ "type": "string",
+ "example": ""
+ },
+ "vm": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.TbVmDynamicReq"
+ }
+ }
+ }
+ },
+ "model.TbVmDynamicReq": {
+ "type": "object",
+ "required": [
+ "commonImage",
+ "commonSpec"
+ ],
+ "properties": {
+ "commonImage": {
+ "description": "CommonImage is field for id of a image in common namespace",
+ "type": "string",
+ "example": "ubuntu18.04"
+ },
+ "commonSpec": {
+ "description": "CommonSpec is field for id of a spec in common namespace",
+ "type": "string",
+ "example": "aws+ap-northeast-2+t2.small"
+ },
+ "connectionName": {
+ "description": "if ConnectionName is given, the VM tries to use associtated credential.\nif not, it will use predefined ConnectionName in Spec objects",
+ "type": "string"
+ },
+ "description": {
+ "type": "string",
+ "example": "Description"
+ },
+ "label": {
+ "description": "Label is for describing the object by keywords",
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "name": {
+ "description": "VM name or subGroup name if is (not empty) \u0026\u0026 (\u003e 0). If it is a group, actual VM name will be generated with -N postfix.",
+ "type": "string",
+ "example": "g1-1"
+ },
+ "rootDiskSize": {
+ "description": "\"default\", Integer (GB): [\"50\", ..., \"1000\"]",
+ "type": "string",
+ "default": "default",
+ "example": "default, 30, 42, ..."
+ },
+ "rootDiskType": {
+ "description": "\"\", \"default\", \"TYPE1\", AWS: [\"standard\", \"gp2\", \"gp3\"], Azure: [\"PremiumSSD\", \"StandardSSD\", \"StandardHDD\"], GCP: [\"pd-standard\", \"pd-balanced\", \"pd-ssd\", \"pd-extreme\"], ALIBABA: [\"cloud_efficiency\", \"cloud\", \"cloud_essd\"], TENCENT: [\"CLOUD_PREMIUM\", \"CLOUD_SSD\"]",
+ "type": "string",
+ "default": "default",
+ "example": "default, TYPE1, ..."
+ },
+ "subGroupSize": {
+ "description": "if subGroupSize is (not empty) \u0026\u0026 (\u003e 0), subGroup will be generated. VMs will be created accordingly.",
+ "type": "string",
+ "default": "1",
+ "example": "3"
+ },
+ "vmUserPassword": {
+ "type": "string"
+ }
+ }
+ },
+ "onprem.CpuProperty": {
+ "type": "object",
+ "required": [
+ "cores",
+ "cpus",
+ "threads"
+ ],
+ "properties": {
+ "architecture": {
+ "type": "string",
+ "example": "x86_64"
+ },
+ "cores": {
+ "description": "Number of physical cores per CPU",
+ "type": "integer",
+ "example": 18
+ },
+ "cpus": {
+ "description": "Number of physical CPUs (sockets)",
+ "type": "integer",
+ "example": 2
+ },
+ "maxSpeed": {
+ "description": "Maximum speed in GHz",
+ "type": "number",
+ "example": 3.6
+ },
+ "model": {
+ "type": "string",
+ "example": "Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz"
+ },
+ "threads": {
+ "description": "Number of logical CPUs (threads) per CPU with hyper-threading enabled",
+ "type": "integer",
+ "example": 36
+ },
+ "vendor": {
+ "type": "string",
+ "example": "GenuineIntel"
+ }
+ }
+ },
+ "onprem.DiskProperty": {
+ "type": "object",
+ "required": [
+ "label",
+ "totalSize",
+ "type"
+ ],
+ "properties": {
+ "available": {
+ "description": "Unit GiB",
+ "type": "integer"
+ },
+ "label": {
+ "type": "string"
+ },
+ "totalSize": {
+ "description": "Unit GiB",
+ "type": "integer",
+ "example": 1024
+ },
+ "type": {
+ "description": "SSD, HDD",
+ "type": "string",
+ "example": "SSD"
+ },
+ "used": {
+ "description": "Unit GiB",
+ "type": "integer"
+ }
+ }
+ },
+ "onprem.MemoryProperty": {
+ "type": "object",
+ "required": [
+ "totalSize",
+ "type"
+ ],
+ "properties": {
+ "available": {
+ "description": "Unit GiB",
+ "type": "integer"
+ },
+ "totalSize": {
+ "description": "Unit GiB",
+ "type": "integer",
+ "example": 128
+ },
+ "type": {
+ "type": "string",
+ "example": "DDR4"
+ },
+ "used": {
+ "description": "Unit GiB",
+ "type": "integer"
+ }
+ }
+ },
+ "onprem.NetworkInterfaceProperty": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "ipv4CidrBlocks": {
+ "description": "IPv4 address with prefix length (e.g., 192.168.0.21/24), instead of inet addr, Bcast, and Mask",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ipv6CidrBlocks": {
+ "description": "IPv6 address with prefix length (e.g., \"2001:db8::1/64\")",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "macAddress": {
+ "description": "MAC address",
+ "type": "string"
+ },
+ "mtu": {
+ "description": "Maximum Transmission Unit (MTU) in bytes",
+ "type": "integer"
+ },
+ "name": {
+ "description": "Interface name (e.g., eth0, ens01, enp0s3)",
+ "type": "string"
+ },
+ "state": {
+ "description": "Interface state (e.g., UP, DOWN)",
+ "type": "string"
+ }
+ }
+ },
+ "onprem.NetworkProperty": {
+ "type": "object",
+ "properties": {
+ "ipv4Networks": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "example": [
+ "172.26.240.0/20"
+ ]
+ },
+ "ipv6Networks": {
+ "description": "TBD",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "onprem.OnPremInfra": {
+ "type": "object",
+ "required": [
+ "servers"
+ ],
+ "properties": {
+ "network": {
+ "$ref": "#/definitions/onprem.NetworkProperty"
+ },
+ "servers": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/onprem.ServerProperty"
+ }
+ }
+ }
+ },
+ "onprem.OsProperty": {
+ "type": "object",
+ "required": [
+ "prettyName"
+ ],
+ "properties": {
+ "id": {
+ "type": "string",
+ "example": "ubuntu"
+ },
+ "idLike": {
+ "type": "string",
+ "example": "debian"
+ },
+ "name": {
+ "type": "string",
+ "example": "Ubuntu"
+ },
+ "prettyName": {
+ "description": "Pretty name",
+ "type": "string",
+ "example": "Ubuntu 22.04.3 LTS"
+ },
+ "version": {
+ "description": "Full version string",
+ "type": "string",
+ "example": "22.04.3 LTS (Jammy Jellyfish)"
+ },
+ "versionCodename": {
+ "type": "string",
+ "example": "jammy"
+ },
+ "versionId": {
+ "type": "string",
+ "example": "22.04"
+ }
+ }
+ },
+ "onprem.RouteProperty": {
+ "type": "object",
+ "properties": {
+ "destination": {
+ "description": "Destination network, expressed in CIDR format",
+ "type": "string"
+ },
+ "gateway": {
+ "description": "Gateway address to which packets are forwarded",
+ "type": "string"
+ },
+ "interface": {
+ "description": "Network interface associated with the route",
+ "type": "string"
+ },
+ "linkState": {
+ "description": "Link state of the route (e.g., UP, DOWN)",
+ "type": "string"
+ },
+ "metric": {
+ "description": "Metric value indicating the priority of the route",
+ "type": "integer"
+ },
+ "protocol": {
+ "description": "Protocol used to set the route (e.g., kernel, static)",
+ "type": "string"
+ },
+ "scope": {
+ "description": "Scope of the route (e.g., global, link, host)",
+ "type": "string"
+ },
+ "source": {
+ "description": "Optionally stores the source address (used for policy-based routing)",
+ "type": "string"
+ }
+ }
+ },
+ "onprem.ServerProperty": {
+ "type": "object",
+ "properties": {
+ "cpu": {
+ "$ref": "#/definitions/onprem.CpuProperty"
+ },
+ "dataDisks": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/onprem.DiskProperty"
+ }
+ },
+ "hostname": {
+ "type": "string"
+ },
+ "interfaces": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/onprem.NetworkInterfaceProperty"
+ }
+ },
+ "memory": {
+ "$ref": "#/definitions/onprem.MemoryProperty"
+ },
+ "os": {
+ "$ref": "#/definitions/onprem.OsProperty"
+ },
+ "rootDisk": {
+ "$ref": "#/definitions/onprem.DiskProperty"
+ },
+ "routingTable": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/onprem.RouteProperty"
+ }
+ }
+ }
}
},
"securityDefinitions": {
diff --git a/api/swagger.json b/api/swagger.json
index 7375e96..4056b3b 100644
--- a/api/swagger.json
+++ b/api/swagger.json
@@ -26,14 +26,14 @@
"application/json"
],
"tags": [
- "[API] Cloud Migration Models"
+ "[API] Cloud Migration User Models"
],
"summary": "Get a list of cloud models",
"responses": {
"200": {
"description": "(sample) This is a list of models",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.GetCloudModelsResp"
+ "$ref": "#/definitions/handler.GetCloudModelsResp"
}
},
"404": {
@@ -53,7 +53,7 @@
"application/json"
],
"tags": [
- "[API] Cloud Migration Models"
+ "[API] Cloud Migration User Models"
],
"summary": "Create a new cloud model",
"parameters": [
@@ -63,7 +63,7 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.CreateCloudModelReq"
+ "$ref": "#/definitions/handler.CreateCloudModelReq"
}
}
],
@@ -71,7 +71,7 @@
"201": {
"description": "(Sample) This is a sample description for success response in Swagger UI",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.CreateCloudModelResp"
+ "$ref": "#/definitions/handler.CreateCloudModelResp"
}
},
"400": {
@@ -93,7 +93,7 @@
"application/json"
],
"tags": [
- "[API] Cloud Migration Models"
+ "[API] Cloud Migration User Models"
],
"summary": "Get a specific cloud model",
"parameters": [
@@ -109,7 +109,7 @@
"200": {
"description": "(Sample) a model",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.GetCloudModelResp"
+ "$ref": "#/definitions/handler.GetCloudModelResp"
}
},
"404": {
@@ -129,7 +129,7 @@
"application/json"
],
"tags": [
- "[API] Cloud Migration Models"
+ "[API] Cloud Migration User Models"
],
"summary": "Update a cloud model",
"parameters": [
@@ -146,7 +146,7 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.UpdateCloudModelReq"
+ "$ref": "#/definitions/handler.UpdateCloudModelReq"
}
}
],
@@ -154,7 +154,7 @@
"201": {
"description": "(Sample) This is a sample description for success response in Swagger UI",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.UpdateCloudModelResp"
+ "$ref": "#/definitions/handler.UpdateCloudModelResp"
}
},
"400": {
@@ -174,7 +174,7 @@
"application/json"
],
"tags": [
- "[API] Cloud Migration Models"
+ "[API] Cloud Migration User Models"
],
"summary": "Delete a cloud model",
"parameters": [
@@ -225,19 +225,48 @@
"200": {
"description": "OK",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.ResHTTPVersion"
+ "$ref": "#/definitions/handler.ResHTTPVersion"
}
},
"404": {
"description": "Not Found",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.ResHTTPVersion"
+ "$ref": "#/definitions/handler.ResHTTPVersion"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.ResHTTPVersion"
+ "$ref": "#/definitions/handler.ResHTTPVersion"
+ }
+ }
+ }
+ }
+ },
+ "/model/version": {
+ "get": {
+ "description": "Get the versions of all models(schemata of on-premise/cloud migration models)",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "[API] Migration Models"
+ ],
+ "summary": "Get the versions of all models(schemata of on-premise/cloud migration models)",
+ "responses": {
+ "200": {
+ "description": "(sample) This is the versions of all models(schemata)",
+ "schema": {
+ "$ref": "#/definitions/handler.GetModelsVersionResp"
+ }
+ },
+ "404": {
+ "description": "verson of models not found",
+ "schema": {
+ "type": "object"
}
}
}
@@ -253,7 +282,7 @@
"application/json"
],
"tags": [
- "[API] Migration Models"
+ "[API] Migration User Models"
],
"summary": "Get a list of all user models",
"parameters": [
@@ -269,7 +298,7 @@
"200": {
"description": "(sample) This is a list of models",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.GetModelsResp"
+ "$ref": "#/definitions/handler.GetModelsResp"
}
},
"404": {
@@ -291,14 +320,14 @@
"application/json"
],
"tags": [
- "[API] On-Premise Migration Models"
+ "[API] On-Premise Migration User Models"
],
"summary": "Get a list of on-premise models",
"responses": {
"200": {
"description": "(sample) This is a list of models",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.GetOnPremModelsResp"
+ "$ref": "#/definitions/handler.GetOnPremModelsResp"
}
},
"404": {
@@ -318,7 +347,7 @@
"application/json"
],
"tags": [
- "[API] On-Premise Migration Models"
+ "[API] On-Premise Migration User Models"
],
"summary": "Create a new on-premise model",
"parameters": [
@@ -328,7 +357,7 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.CreateOnPremModelReq"
+ "$ref": "#/definitions/handler.CreateOnPremModelReq"
}
}
],
@@ -336,7 +365,7 @@
"201": {
"description": "(Sample) This is a sample description for success response in Swagger UI",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.CreateOnPremModelResp"
+ "$ref": "#/definitions/handler.CreateOnPremModelResp"
}
},
"400": {
@@ -358,7 +387,7 @@
"application/json"
],
"tags": [
- "[API] On-Premise Migration Models"
+ "[API] On-Premise Migration User Models"
],
"summary": "Get a specific on-premise model",
"parameters": [
@@ -374,7 +403,7 @@
"200": {
"description": "(Sample) a model",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.GetOnPremModelResp"
+ "$ref": "#/definitions/handler.GetOnPremModelResp"
}
},
"404": {
@@ -394,7 +423,7 @@
"application/json"
],
"tags": [
- "[API] On-Premise Migration Models"
+ "[API] On-Premise Migration User Models"
],
"summary": "Update a on-premise model",
"parameters": [
@@ -411,7 +440,7 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.UpdateOnPremModelReq"
+ "$ref": "#/definitions/handler.UpdateOnPremModelReq"
}
}
],
@@ -419,7 +448,7 @@
"201": {
"description": "(Sample) This is a sample description for success response in Swagger UI",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.UpdateOnPremModelResp"
+ "$ref": "#/definitions/handler.UpdateOnPremModelResp"
}
},
"400": {
@@ -439,7 +468,7 @@
"application/json"
],
"tags": [
- "[API] On-Premise Migration Models"
+ "[API] On-Premise Migration User Models"
],
"summary": "Delete a on-premise model",
"parameters": [
@@ -490,13 +519,13 @@
"200": {
"description": "OK",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.ResReadyz"
+ "$ref": "#/definitions/handler.ResReadyz"
}
},
"503": {
"description": "Service Unavailable",
"schema": {
- "$ref": "#/definitions/pkg_api_rest_handler.ResReadyz"
+ "$ref": "#/definitions/handler.ResReadyz"
}
}
}
@@ -504,400 +533,221 @@
}
},
"definitions": {
- "model.TbMciDynamicReq": {
+ "handler.CloudModelRespInfo": {
"type": "object",
"required": [
- "name",
- "vm"
+ "cloudInfraModel"
],
"properties": {
+ "cloudInfraModel": {
+ "$ref": "#/definitions/model.TbMciDynamicReq"
+ },
+ "cloudModelVersion": {
+ "type": "string"
+ },
+ "createTime": {
+ "type": "string"
+ },
+ "csp": {
+ "type": "string"
+ },
"description": {
- "type": "string",
- "example": "Made in CB-TB"
+ "type": "string"
},
- "installMonAgent": {
- "description": "InstallMonAgent Option for CB-Dragonfly agent installation ([yes/no] default:yes)",
- "type": "string",
- "default": "no",
- "enum": [
- "yes",
- "no"
- ],
- "example": "no"
+ "id": {
+ "type": "string"
},
- "label": {
- "description": "Label is for describing the object by keywords",
- "type": "object",
- "additionalProperties": {
- "type": "string"
- }
+ "isCloudModel": {
+ "type": "boolean"
},
- "name": {
- "type": "string",
- "example": "mci01"
+ "isInitUserModel": {
+ "type": "boolean"
},
- "systemLabel": {
- "description": "SystemLabel is for describing the mci in a keyword (any string can be used) for special System purpose",
- "type": "string",
- "example": ""
+ "isTargetModel": {
+ "type": "boolean"
},
- "vm": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/model.TbVmDynamicReq"
- }
+ "region": {
+ "type": "string"
+ },
+ "updateTime": {
+ "type": "string"
+ },
+ "userId": {
+ "type": "string"
+ },
+ "userModelName": {
+ "type": "string"
+ },
+ "userModelVersion": {
+ "type": "string"
+ },
+ "zone": {
+ "type": "string"
}
}
},
- "model.TbVmDynamicReq": {
+ "handler.CreateCloudModelReq": {
"type": "object",
"required": [
- "commonImage",
- "commonSpec"
+ "cloudInfraModel"
],
"properties": {
- "commonImage": {
- "description": "CommonImage is field for id of a image in common namespace",
- "type": "string",
- "example": "ubuntu18.04"
- },
- "commonSpec": {
- "description": "CommonSpec is field for id of a spec in common namespace",
- "type": "string",
- "example": "aws+ap-northeast-2+t2.small"
+ "cloudInfraModel": {
+ "$ref": "#/definitions/model.TbMciDynamicReq"
},
- "connectionName": {
- "description": "if ConnectionName is given, the VM tries to use associtated credential.\nif not, it will use predefined ConnectionName in Spec objects",
+ "csp": {
"type": "string"
},
"description": {
- "type": "string",
- "example": "Description"
+ "type": "string"
},
- "label": {
- "description": "Label is for describing the object by keywords",
- "type": "object",
- "additionalProperties": {
- "type": "string"
- }
+ "isInitUserModel": {
+ "type": "boolean"
},
- "name": {
- "description": "VM name or subGroup name if is (not empty) \u0026\u0026 (\u003e 0). If it is a group, actual VM name will be generated with -N postfix.",
- "type": "string",
- "example": "g1-1"
+ "isTargetModel": {
+ "type": "boolean"
},
- "rootDiskSize": {
- "description": "\"default\", Integer (GB): [\"50\", ..., \"1000\"]",
- "type": "string",
- "default": "default",
- "example": "default, 30, 42, ..."
+ "region": {
+ "type": "string"
},
- "rootDiskType": {
- "description": "\"\", \"default\", \"TYPE1\", AWS: [\"standard\", \"gp2\", \"gp3\"], Azure: [\"PremiumSSD\", \"StandardSSD\", \"StandardHDD\"], GCP: [\"pd-standard\", \"pd-balanced\", \"pd-ssd\", \"pd-extreme\"], ALIBABA: [\"cloud_efficiency\", \"cloud\", \"cloud_essd\"], TENCENT: [\"CLOUD_PREMIUM\", \"CLOUD_SSD\"]",
- "type": "string",
- "default": "default",
- "example": "default, TYPE1, ..."
+ "userId": {
+ "type": "string"
},
- "subGroupSize": {
- "description": "if subGroupSize is (not empty) \u0026\u0026 (\u003e 0), subGroup will be generated. VMs will be created accordingly.",
- "type": "string",
- "default": "1",
- "example": "3"
+ "userModelName": {
+ "type": "string"
},
- "vmUserPassword": {
+ "userModelVersion": {
+ "type": "string"
+ },
+ "zone": {
"type": "string"
}
}
},
- "onprem.CpuProperty": {
+ "handler.CreateCloudModelResp": {
"type": "object",
"required": [
- "cores",
- "cpus",
- "threads"
+ "cloudInfraModel"
],
"properties": {
- "architecture": {
- "type": "string",
- "example": "x86_64"
+ "cloudInfraModel": {
+ "$ref": "#/definitions/model.TbMciDynamicReq"
},
- "cores": {
- "description": "Number of physical cores per CPU",
- "type": "integer",
- "example": 18
+ "cloudModelVersion": {
+ "type": "string"
},
- "cpus": {
- "description": "Number of physical CPUs (sockets)",
- "type": "integer",
- "example": 2
+ "createTime": {
+ "type": "string"
},
- "maxSpeed": {
- "description": "Maximum speed in GHz",
- "type": "number",
- "example": 3.6
+ "csp": {
+ "type": "string"
},
- "model": {
- "type": "string",
- "example": "Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz"
+ "description": {
+ "type": "string"
},
- "threads": {
- "description": "Number of logical CPUs (threads) per CPU with hyper-threading enabled",
- "type": "integer",
- "example": 36
+ "id": {
+ "type": "string"
},
- "vendor": {
- "type": "string",
- "example": "GenuineIntel"
- }
- }
- },
- "onprem.DiskProperty": {
- "type": "object",
- "required": [
- "label",
- "totalSize",
- "type"
- ],
- "properties": {
- "available": {
- "description": "Unit GiB",
- "type": "integer"
+ "isCloudModel": {
+ "type": "boolean"
},
- "label": {
+ "isInitUserModel": {
+ "type": "boolean"
+ },
+ "isTargetModel": {
+ "type": "boolean"
+ },
+ "region": {
"type": "string"
},
- "totalSize": {
- "description": "Unit GiB",
- "type": "integer",
- "example": 1024
+ "updateTime": {
+ "type": "string"
},
- "type": {
- "description": "SSD, HDD",
- "type": "string",
- "example": "SSD"
+ "userId": {
+ "type": "string"
},
- "used": {
- "description": "Unit GiB",
- "type": "integer"
+ "userModelName": {
+ "type": "string"
+ },
+ "userModelVersion": {
+ "type": "string"
+ },
+ "zone": {
+ "type": "string"
}
}
},
- "onprem.MemoryProperty": {
+ "handler.CreateOnPremModelReq": {
"type": "object",
"required": [
- "totalSize",
- "type"
+ "onpremiseInfraModel"
],
"properties": {
- "available": {
- "description": "Unit GiB",
- "type": "integer"
+ "description": {
+ "type": "string"
},
- "totalSize": {
- "description": "Unit GiB",
- "type": "integer",
- "example": 128
- },
- "type": {
- "type": "string",
- "example": "DDR4"
- },
- "used": {
- "description": "Unit GiB",
- "type": "integer"
- }
- }
- },
- "onprem.NetworkInterfaceProperty": {
- "type": "object",
- "required": [
- "name"
- ],
- "properties": {
- "ipv4CidrBlocks": {
- "description": "IPv4 address with prefix length (e.g., 192.168.0.21/24), instead of inet addr, Bcast, and Mask",
- "type": "array",
- "items": {
- "type": "string"
- }
+ "isInitUserModel": {
+ "type": "boolean"
},
- "ipv6CidrBlocks": {
- "description": "IPv6 address with prefix length (e.g., \"2001:db8::1/64\")",
- "type": "array",
- "items": {
- "type": "string"
- }
+ "onpremiseInfraModel": {
+ "$ref": "#/definitions/onprem.OnPremInfra"
},
- "macAddress": {
- "description": "MAC address",
+ "userId": {
"type": "string"
},
- "mtu": {
- "description": "Maximum Transmission Unit (MTU) in bytes",
- "type": "integer"
- },
- "name": {
- "description": "Interface name (e.g., eth0, ens01, enp0s3)",
+ "userModelName": {
"type": "string"
},
- "state": {
- "description": "Interface state (e.g., UP, DOWN)",
+ "userModelVersion": {
"type": "string"
}
}
},
- "onprem.NetworkProperty": {
- "type": "object",
- "properties": {
- "ipv4Networks": {
- "type": "array",
- "items": {
- "type": "string"
- },
- "example": [
- "172.26.240.0/20"
- ]
- },
- "ipv6Networks": {
- "description": "TBD",
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- }
- },
- "onprem.OnPremInfra": {
- "type": "object",
- "required": [
- "servers"
- ],
- "properties": {
- "network": {
- "$ref": "#/definitions/onprem.NetworkProperty"
- },
- "servers": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/onprem.ServerProperty"
- }
- }
- }
- },
- "onprem.OsProperty": {
+ "handler.CreateOnPremModelResp": {
"type": "object",
"required": [
- "prettyName"
+ "onpremiseInfraModel"
],
"properties": {
- "id": {
- "type": "string",
- "example": "ubuntu"
- },
- "idLike": {
- "type": "string",
- "example": "debian"
- },
- "name": {
- "type": "string",
- "example": "Ubuntu"
- },
- "prettyName": {
- "description": "Pretty name",
- "type": "string",
- "example": "Ubuntu 22.04.3 LTS"
- },
- "version": {
- "description": "Full version string",
- "type": "string",
- "example": "22.04.3 LTS (Jammy Jellyfish)"
- },
- "versionCodename": {
- "type": "string",
- "example": "jammy"
- },
- "versionId": {
- "type": "string",
- "example": "22.04"
- }
- }
- },
- "onprem.RouteProperty": {
- "type": "object",
- "properties": {
- "destination": {
- "description": "Destination network, expressed in CIDR format",
- "type": "string"
- },
- "gateway": {
- "description": "Gateway address to which packets are forwarded",
+ "createTime": {
"type": "string"
},
- "interface": {
- "description": "Network interface associated with the route",
+ "description": {
"type": "string"
},
- "linkState": {
- "description": "Link state of the route (e.g., UP, DOWN)",
+ "id": {
"type": "string"
},
- "metric": {
- "description": "Metric value indicating the priority of the route",
- "type": "integer"
+ "isCloudModel": {
+ "type": "boolean"
},
- "protocol": {
- "description": "Protocol used to set the route (e.g., kernel, static)",
- "type": "string"
+ "isInitUserModel": {
+ "type": "boolean"
},
- "scope": {
- "description": "Scope of the route (e.g., global, link, host)",
- "type": "string"
+ "isTargetModel": {
+ "type": "boolean"
},
- "source": {
- "description": "Optionally stores the source address (used for policy-based routing)",
+ "onpremModelVersion": {
"type": "string"
- }
- }
- },
- "onprem.ServerProperty": {
- "type": "object",
- "properties": {
- "cpu": {
- "$ref": "#/definitions/onprem.CpuProperty"
},
- "dataDisks": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/onprem.DiskProperty"
- }
+ "onpremiseInfraModel": {
+ "$ref": "#/definitions/onprem.OnPremInfra"
},
- "hostname": {
+ "updateTime": {
"type": "string"
},
- "interfaces": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/onprem.NetworkInterfaceProperty"
- }
- },
- "memory": {
- "$ref": "#/definitions/onprem.MemoryProperty"
- },
- "os": {
- "$ref": "#/definitions/onprem.OsProperty"
+ "userId": {
+ "type": "string"
},
- "rootDisk": {
- "$ref": "#/definitions/onprem.DiskProperty"
+ "userModelName": {
+ "type": "string"
},
- "routingTable": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/onprem.RouteProperty"
- }
+ "userModelVersion": {
+ "type": "string"
}
}
},
- "pkg_api_rest_handler.CloudModelRespInfo": {
+ "handler.GetCloudModelResp": {
"type": "object",
"required": [
"cloudInfraModel"
@@ -950,28 +800,67 @@
}
}
},
- "pkg_api_rest_handler.CreateCloudModelReq": {
+ "handler.GetCloudModelsResp": {
+ "type": "object",
+ "properties": {
+ "models": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/handler.CloudModelRespInfo"
+ }
+ }
+ }
+ },
+ "handler.GetModelsResp": {
+ "type": "object",
+ "properties": {
+ "models": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/handler.ModelRespInfo"
+ }
+ }
+ }
+ },
+ "handler.GetModelsVersionResp": {
+ "type": "object",
+ "properties": {
+ "modelsVersion": {
+ "$ref": "#/definitions/handler.ModelsVersionRespInfo"
+ }
+ }
+ },
+ "handler.GetOnPremModelResp": {
"type": "object",
"required": [
- "cloudInfraModel"
+ "onpremiseInfraModel"
],
"properties": {
- "cloudInfraModel": {
- "$ref": "#/definitions/model.TbMciDynamicReq"
- },
- "csp": {
+ "createTime": {
"type": "string"
},
"description": {
"type": "string"
},
+ "id": {
+ "type": "string"
+ },
+ "isCloudModel": {
+ "type": "boolean"
+ },
"isInitUserModel": {
"type": "boolean"
},
"isTargetModel": {
"type": "boolean"
},
- "region": {
+ "onpremModelVersion": {
+ "type": "string"
+ },
+ "onpremiseInfraModel": {
+ "$ref": "#/definitions/onprem.OnPremInfra"
+ },
+ "updateTime": {
"type": "string"
},
"userId": {
@@ -982,16 +871,25 @@
},
"userModelVersion": {
"type": "string"
- },
- "zone": {
- "type": "string"
}
}
},
- "pkg_api_rest_handler.CreateCloudModelResp": {
+ "handler.GetOnPremModelsResp": {
+ "type": "object",
+ "properties": {
+ "models": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/handler.OnPremModelRespInfo"
+ }
+ }
+ }
+ },
+ "handler.ModelRespInfo": {
"type": "object",
"required": [
- "cloudInfraModel"
+ "cloudInfraModel",
+ "onpremiseInfraModel"
],
"properties": {
"cloudInfraModel": {
@@ -1021,129 +919,12 @@
"isTargetModel": {
"type": "boolean"
},
- "region": {
- "type": "string"
- },
- "updateTime": {
- "type": "string"
- },
- "userId": {
- "type": "string"
- },
- "userModelName": {
- "type": "string"
- },
- "userModelVersion": {
- "type": "string"
- },
- "zone": {
- "type": "string"
- }
- }
- },
- "pkg_api_rest_handler.CreateOnPremModelReq": {
- "type": "object",
- "required": [
- "onpremiseInfraModel"
- ],
- "properties": {
- "description": {
- "type": "string"
- },
- "isInitUserModel": {
- "type": "boolean"
- },
- "onpremiseInfraModel": {
- "$ref": "#/definitions/onprem.OnPremInfra"
- },
- "userId": {
- "type": "string"
- },
- "userModelName": {
- "type": "string"
- },
- "userModelVersion": {
- "type": "string"
- }
- }
- },
- "pkg_api_rest_handler.CreateOnPremModelResp": {
- "type": "object",
- "required": [
- "onpremiseInfraModel"
- ],
- "properties": {
- "createTime": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "id": {
- "type": "string"
- },
- "isCloudModel": {
- "type": "boolean"
- },
- "isInitUserModel": {
- "type": "boolean"
- },
- "isTargetModel": {
- "type": "boolean"
- },
"onpremModelVersion": {
"type": "string"
},
"onpremiseInfraModel": {
"$ref": "#/definitions/onprem.OnPremInfra"
},
- "updateTime": {
- "type": "string"
- },
- "userId": {
- "type": "string"
- },
- "userModelName": {
- "type": "string"
- },
- "userModelVersion": {
- "type": "string"
- }
- }
- },
- "pkg_api_rest_handler.GetCloudModelResp": {
- "type": "object",
- "required": [
- "cloudInfraModel"
- ],
- "properties": {
- "cloudInfraModel": {
- "$ref": "#/definitions/model.TbMciDynamicReq"
- },
- "cloudModelVersion": {
- "type": "string"
- },
- "createTime": {
- "type": "string"
- },
- "csp": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "id": {
- "type": "string"
- },
- "isCloudModel": {
- "type": "boolean"
- },
- "isInitUserModel": {
- "type": "boolean"
- },
- "isTargetModel": {
- "type": "boolean"
- },
"region": {
"type": "string"
},
@@ -1164,144 +945,18 @@
}
}
},
- "pkg_api_rest_handler.GetCloudModelsResp": {
- "type": "object",
- "properties": {
- "models": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/pkg_api_rest_handler.CloudModelRespInfo"
- }
- }
- }
- },
- "pkg_api_rest_handler.GetModelsResp": {
- "type": "object",
- "properties": {
- "models": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/pkg_api_rest_handler.ModelRespInfo"
- }
- }
- }
- },
- "pkg_api_rest_handler.GetOnPremModelResp": {
- "type": "object",
- "required": [
- "onpremiseInfraModel"
- ],
- "properties": {
- "createTime": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "id": {
- "type": "string"
- },
- "isCloudModel": {
- "type": "boolean"
- },
- "isInitUserModel": {
- "type": "boolean"
- },
- "isTargetModel": {
- "type": "boolean"
- },
- "onpremModelVersion": {
- "type": "string"
- },
- "onpremiseInfraModel": {
- "$ref": "#/definitions/onprem.OnPremInfra"
- },
- "updateTime": {
- "type": "string"
- },
- "userId": {
- "type": "string"
- },
- "userModelName": {
- "type": "string"
- },
- "userModelVersion": {
- "type": "string"
- }
- }
- },
- "pkg_api_rest_handler.GetOnPremModelsResp": {
- "type": "object",
- "properties": {
- "models": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/pkg_api_rest_handler.OnPremModelRespInfo"
- }
- }
- }
- },
- "pkg_api_rest_handler.ModelRespInfo": {
+ "handler.ModelsVersionRespInfo": {
"type": "object",
- "required": [
- "cloudInfraModel",
- "onpremiseInfraModel"
- ],
"properties": {
- "cloudInfraModel": {
- "$ref": "#/definitions/model.TbMciDynamicReq"
- },
"cloudModelVersion": {
"type": "string"
},
- "createTime": {
- "type": "string"
- },
- "csp": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "id": {
- "type": "string"
- },
- "isCloudModel": {
- "type": "boolean"
- },
- "isInitUserModel": {
- "type": "boolean"
- },
- "isTargetModel": {
- "type": "boolean"
- },
"onpremModelVersion": {
"type": "string"
- },
- "onpremiseInfraModel": {
- "$ref": "#/definitions/onprem.OnPremInfra"
- },
- "region": {
- "type": "string"
- },
- "updateTime": {
- "type": "string"
- },
- "userId": {
- "type": "string"
- },
- "userModelName": {
- "type": "string"
- },
- "userModelVersion": {
- "type": "string"
- },
- "zone": {
- "type": "string"
}
}
},
- "pkg_api_rest_handler.OnPremModelRespInfo": {
+ "handler.OnPremModelRespInfo": {
"type": "object",
"required": [
"onpremiseInfraModel"
@@ -1345,7 +1000,7 @@
}
}
},
- "pkg_api_rest_handler.ResHTTPVersion": {
+ "handler.ResHTTPVersion": {
"type": "object",
"properties": {
"message": {
@@ -1353,7 +1008,7 @@
}
}
},
- "pkg_api_rest_handler.ResReadyz": {
+ "handler.ResReadyz": {
"type": "object",
"properties": {
"message": {
@@ -1361,7 +1016,7 @@
}
}
},
- "pkg_api_rest_handler.UpdateCloudModelReq": {
+ "handler.UpdateCloudModelReq": {
"type": "object",
"required": [
"cloudInfraModel"
@@ -1399,7 +1054,7 @@
}
}
},
- "pkg_api_rest_handler.UpdateCloudModelResp": {
+ "handler.UpdateCloudModelResp": {
"type": "object",
"required": [
"cloudInfraModel"
@@ -1452,7 +1107,7 @@
}
}
},
- "pkg_api_rest_handler.UpdateOnPremModelReq": {
+ "handler.UpdateOnPremModelReq": {
"type": "object",
"required": [
"onpremiseInfraModel"
@@ -1478,7 +1133,7 @@
}
}
},
- "pkg_api_rest_handler.UpdateOnPremModelResp": {
+ "handler.UpdateOnPremModelResp": {
"type": "object",
"required": [
"onpremiseInfraModel"
@@ -1521,6 +1176,399 @@
"type": "string"
}
}
+ },
+ "model.TbMciDynamicReq": {
+ "type": "object",
+ "required": [
+ "name",
+ "vm"
+ ],
+ "properties": {
+ "description": {
+ "type": "string",
+ "example": "Made in CB-TB"
+ },
+ "installMonAgent": {
+ "description": "InstallMonAgent Option for CB-Dragonfly agent installation ([yes/no] default:yes)",
+ "type": "string",
+ "default": "no",
+ "enum": [
+ "yes",
+ "no"
+ ],
+ "example": "no"
+ },
+ "label": {
+ "description": "Label is for describing the object by keywords",
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "name": {
+ "type": "string",
+ "example": "mci01"
+ },
+ "systemLabel": {
+ "description": "SystemLabel is for describing the mci in a keyword (any string can be used) for special System purpose",
+ "type": "string",
+ "example": ""
+ },
+ "vm": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/model.TbVmDynamicReq"
+ }
+ }
+ }
+ },
+ "model.TbVmDynamicReq": {
+ "type": "object",
+ "required": [
+ "commonImage",
+ "commonSpec"
+ ],
+ "properties": {
+ "commonImage": {
+ "description": "CommonImage is field for id of a image in common namespace",
+ "type": "string",
+ "example": "ubuntu18.04"
+ },
+ "commonSpec": {
+ "description": "CommonSpec is field for id of a spec in common namespace",
+ "type": "string",
+ "example": "aws+ap-northeast-2+t2.small"
+ },
+ "connectionName": {
+ "description": "if ConnectionName is given, the VM tries to use associtated credential.\nif not, it will use predefined ConnectionName in Spec objects",
+ "type": "string"
+ },
+ "description": {
+ "type": "string",
+ "example": "Description"
+ },
+ "label": {
+ "description": "Label is for describing the object by keywords",
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "name": {
+ "description": "VM name or subGroup name if is (not empty) \u0026\u0026 (\u003e 0). If it is a group, actual VM name will be generated with -N postfix.",
+ "type": "string",
+ "example": "g1-1"
+ },
+ "rootDiskSize": {
+ "description": "\"default\", Integer (GB): [\"50\", ..., \"1000\"]",
+ "type": "string",
+ "default": "default",
+ "example": "default, 30, 42, ..."
+ },
+ "rootDiskType": {
+ "description": "\"\", \"default\", \"TYPE1\", AWS: [\"standard\", \"gp2\", \"gp3\"], Azure: [\"PremiumSSD\", \"StandardSSD\", \"StandardHDD\"], GCP: [\"pd-standard\", \"pd-balanced\", \"pd-ssd\", \"pd-extreme\"], ALIBABA: [\"cloud_efficiency\", \"cloud\", \"cloud_essd\"], TENCENT: [\"CLOUD_PREMIUM\", \"CLOUD_SSD\"]",
+ "type": "string",
+ "default": "default",
+ "example": "default, TYPE1, ..."
+ },
+ "subGroupSize": {
+ "description": "if subGroupSize is (not empty) \u0026\u0026 (\u003e 0), subGroup will be generated. VMs will be created accordingly.",
+ "type": "string",
+ "default": "1",
+ "example": "3"
+ },
+ "vmUserPassword": {
+ "type": "string"
+ }
+ }
+ },
+ "onprem.CpuProperty": {
+ "type": "object",
+ "required": [
+ "cores",
+ "cpus",
+ "threads"
+ ],
+ "properties": {
+ "architecture": {
+ "type": "string",
+ "example": "x86_64"
+ },
+ "cores": {
+ "description": "Number of physical cores per CPU",
+ "type": "integer",
+ "example": 18
+ },
+ "cpus": {
+ "description": "Number of physical CPUs (sockets)",
+ "type": "integer",
+ "example": 2
+ },
+ "maxSpeed": {
+ "description": "Maximum speed in GHz",
+ "type": "number",
+ "example": 3.6
+ },
+ "model": {
+ "type": "string",
+ "example": "Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz"
+ },
+ "threads": {
+ "description": "Number of logical CPUs (threads) per CPU with hyper-threading enabled",
+ "type": "integer",
+ "example": 36
+ },
+ "vendor": {
+ "type": "string",
+ "example": "GenuineIntel"
+ }
+ }
+ },
+ "onprem.DiskProperty": {
+ "type": "object",
+ "required": [
+ "label",
+ "totalSize",
+ "type"
+ ],
+ "properties": {
+ "available": {
+ "description": "Unit GiB",
+ "type": "integer"
+ },
+ "label": {
+ "type": "string"
+ },
+ "totalSize": {
+ "description": "Unit GiB",
+ "type": "integer",
+ "example": 1024
+ },
+ "type": {
+ "description": "SSD, HDD",
+ "type": "string",
+ "example": "SSD"
+ },
+ "used": {
+ "description": "Unit GiB",
+ "type": "integer"
+ }
+ }
+ },
+ "onprem.MemoryProperty": {
+ "type": "object",
+ "required": [
+ "totalSize",
+ "type"
+ ],
+ "properties": {
+ "available": {
+ "description": "Unit GiB",
+ "type": "integer"
+ },
+ "totalSize": {
+ "description": "Unit GiB",
+ "type": "integer",
+ "example": 128
+ },
+ "type": {
+ "type": "string",
+ "example": "DDR4"
+ },
+ "used": {
+ "description": "Unit GiB",
+ "type": "integer"
+ }
+ }
+ },
+ "onprem.NetworkInterfaceProperty": {
+ "type": "object",
+ "required": [
+ "name"
+ ],
+ "properties": {
+ "ipv4CidrBlocks": {
+ "description": "IPv4 address with prefix length (e.g., 192.168.0.21/24), instead of inet addr, Bcast, and Mask",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ipv6CidrBlocks": {
+ "description": "IPv6 address with prefix length (e.g., \"2001:db8::1/64\")",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "macAddress": {
+ "description": "MAC address",
+ "type": "string"
+ },
+ "mtu": {
+ "description": "Maximum Transmission Unit (MTU) in bytes",
+ "type": "integer"
+ },
+ "name": {
+ "description": "Interface name (e.g., eth0, ens01, enp0s3)",
+ "type": "string"
+ },
+ "state": {
+ "description": "Interface state (e.g., UP, DOWN)",
+ "type": "string"
+ }
+ }
+ },
+ "onprem.NetworkProperty": {
+ "type": "object",
+ "properties": {
+ "ipv4Networks": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "example": [
+ "172.26.240.0/20"
+ ]
+ },
+ "ipv6Networks": {
+ "description": "TBD",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "onprem.OnPremInfra": {
+ "type": "object",
+ "required": [
+ "servers"
+ ],
+ "properties": {
+ "network": {
+ "$ref": "#/definitions/onprem.NetworkProperty"
+ },
+ "servers": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/onprem.ServerProperty"
+ }
+ }
+ }
+ },
+ "onprem.OsProperty": {
+ "type": "object",
+ "required": [
+ "prettyName"
+ ],
+ "properties": {
+ "id": {
+ "type": "string",
+ "example": "ubuntu"
+ },
+ "idLike": {
+ "type": "string",
+ "example": "debian"
+ },
+ "name": {
+ "type": "string",
+ "example": "Ubuntu"
+ },
+ "prettyName": {
+ "description": "Pretty name",
+ "type": "string",
+ "example": "Ubuntu 22.04.3 LTS"
+ },
+ "version": {
+ "description": "Full version string",
+ "type": "string",
+ "example": "22.04.3 LTS (Jammy Jellyfish)"
+ },
+ "versionCodename": {
+ "type": "string",
+ "example": "jammy"
+ },
+ "versionId": {
+ "type": "string",
+ "example": "22.04"
+ }
+ }
+ },
+ "onprem.RouteProperty": {
+ "type": "object",
+ "properties": {
+ "destination": {
+ "description": "Destination network, expressed in CIDR format",
+ "type": "string"
+ },
+ "gateway": {
+ "description": "Gateway address to which packets are forwarded",
+ "type": "string"
+ },
+ "interface": {
+ "description": "Network interface associated with the route",
+ "type": "string"
+ },
+ "linkState": {
+ "description": "Link state of the route (e.g., UP, DOWN)",
+ "type": "string"
+ },
+ "metric": {
+ "description": "Metric value indicating the priority of the route",
+ "type": "integer"
+ },
+ "protocol": {
+ "description": "Protocol used to set the route (e.g., kernel, static)",
+ "type": "string"
+ },
+ "scope": {
+ "description": "Scope of the route (e.g., global, link, host)",
+ "type": "string"
+ },
+ "source": {
+ "description": "Optionally stores the source address (used for policy-based routing)",
+ "type": "string"
+ }
+ }
+ },
+ "onprem.ServerProperty": {
+ "type": "object",
+ "properties": {
+ "cpu": {
+ "$ref": "#/definitions/onprem.CpuProperty"
+ },
+ "dataDisks": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/onprem.DiskProperty"
+ }
+ },
+ "hostname": {
+ "type": "string"
+ },
+ "interfaces": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/onprem.NetworkInterfaceProperty"
+ }
+ },
+ "memory": {
+ "$ref": "#/definitions/onprem.MemoryProperty"
+ },
+ "os": {
+ "$ref": "#/definitions/onprem.OsProperty"
+ },
+ "rootDisk": {
+ "$ref": "#/definitions/onprem.DiskProperty"
+ },
+ "routingTable": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/onprem.RouteProperty"
+ }
+ }
+ }
}
},
"securityDefinitions": {
diff --git a/api/swagger.yaml b/api/swagger.yaml
index 7371e6a..214a057 100644
--- a/api/swagger.yaml
+++ b/api/swagger.yaml
@@ -1,302 +1,6 @@
basePath: /damselfly
definitions:
- model.TbMciDynamicReq:
- properties:
- description:
- example: Made in CB-TB
- type: string
- installMonAgent:
- default: "no"
- description: InstallMonAgent Option for CB-Dragonfly agent installation ([yes/no]
- default:yes)
- enum:
- - "yes"
- - "no"
- example: "no"
- type: string
- label:
- additionalProperties:
- type: string
- description: Label is for describing the object by keywords
- type: object
- name:
- example: mci01
- type: string
- systemLabel:
- description: SystemLabel is for describing the mci in a keyword (any string
- can be used) for special System purpose
- example: ""
- type: string
- vm:
- items:
- $ref: '#/definitions/model.TbVmDynamicReq'
- type: array
- required:
- - name
- - vm
- type: object
- model.TbVmDynamicReq:
- properties:
- commonImage:
- description: CommonImage is field for id of a image in common namespace
- example: ubuntu18.04
- type: string
- commonSpec:
- description: CommonSpec is field for id of a spec in common namespace
- example: aws+ap-northeast-2+t2.small
- type: string
- connectionName:
- description: |-
- if ConnectionName is given, the VM tries to use associtated credential.
- if not, it will use predefined ConnectionName in Spec objects
- type: string
- description:
- example: Description
- type: string
- label:
- additionalProperties:
- type: string
- description: Label is for describing the object by keywords
- type: object
- name:
- description: VM name or subGroup name if is (not empty) && (> 0). If it is
- a group, actual VM name will be generated with -N postfix.
- example: g1-1
- type: string
- rootDiskSize:
- default: default
- description: '"default", Integer (GB): ["50", ..., "1000"]'
- example: default, 30, 42, ...
- type: string
- rootDiskType:
- default: default
- description: '"", "default", "TYPE1", AWS: ["standard", "gp2", "gp3"], Azure:
- ["PremiumSSD", "StandardSSD", "StandardHDD"], GCP: ["pd-standard", "pd-balanced",
- "pd-ssd", "pd-extreme"], ALIBABA: ["cloud_efficiency", "cloud", "cloud_essd"],
- TENCENT: ["CLOUD_PREMIUM", "CLOUD_SSD"]'
- example: default, TYPE1, ...
- type: string
- subGroupSize:
- default: "1"
- description: if subGroupSize is (not empty) && (> 0), subGroup will be generated.
- VMs will be created accordingly.
- example: "3"
- type: string
- vmUserPassword:
- type: string
- required:
- - commonImage
- - commonSpec
- type: object
- onprem.CpuProperty:
- properties:
- architecture:
- example: x86_64
- type: string
- cores:
- description: Number of physical cores per CPU
- example: 18
- type: integer
- cpus:
- description: Number of physical CPUs (sockets)
- example: 2
- type: integer
- maxSpeed:
- description: Maximum speed in GHz
- example: 3.6
- type: number
- model:
- example: Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz
- type: string
- threads:
- description: Number of logical CPUs (threads) per CPU with hyper-threading
- enabled
- example: 36
- type: integer
- vendor:
- example: GenuineIntel
- type: string
- required:
- - cores
- - cpus
- - threads
- type: object
- onprem.DiskProperty:
- properties:
- available:
- description: Unit GiB
- type: integer
- label:
- type: string
- totalSize:
- description: Unit GiB
- example: 1024
- type: integer
- type:
- description: SSD, HDD
- example: SSD
- type: string
- used:
- description: Unit GiB
- type: integer
- required:
- - label
- - totalSize
- - type
- type: object
- onprem.MemoryProperty:
- properties:
- available:
- description: Unit GiB
- type: integer
- totalSize:
- description: Unit GiB
- example: 128
- type: integer
- type:
- example: DDR4
- type: string
- used:
- description: Unit GiB
- type: integer
- required:
- - totalSize
- - type
- type: object
- onprem.NetworkInterfaceProperty:
- properties:
- ipv4CidrBlocks:
- description: IPv4 address with prefix length (e.g., 192.168.0.21/24), instead
- of inet addr, Bcast, and Mask
- items:
- type: string
- type: array
- ipv6CidrBlocks:
- description: IPv6 address with prefix length (e.g., "2001:db8::1/64")
- items:
- type: string
- type: array
- macAddress:
- description: MAC address
- type: string
- mtu:
- description: Maximum Transmission Unit (MTU) in bytes
- type: integer
- name:
- description: Interface name (e.g., eth0, ens01, enp0s3)
- type: string
- state:
- description: Interface state (e.g., UP, DOWN)
- type: string
- required:
- - name
- type: object
- onprem.NetworkProperty:
- properties:
- ipv4Networks:
- example:
- - 172.26.240.0/20
- items:
- type: string
- type: array
- ipv6Networks:
- description: TBD
- items:
- type: string
- type: array
- type: object
- onprem.OnPremInfra:
- properties:
- network:
- $ref: '#/definitions/onprem.NetworkProperty'
- servers:
- items:
- $ref: '#/definitions/onprem.ServerProperty'
- type: array
- required:
- - servers
- type: object
- onprem.OsProperty:
- properties:
- id:
- example: ubuntu
- type: string
- idLike:
- example: debian
- type: string
- name:
- example: Ubuntu
- type: string
- prettyName:
- description: Pretty name
- example: Ubuntu 22.04.3 LTS
- type: string
- version:
- description: Full version string
- example: 22.04.3 LTS (Jammy Jellyfish)
- type: string
- versionCodename:
- example: jammy
- type: string
- versionId:
- example: "22.04"
- type: string
- required:
- - prettyName
- type: object
- onprem.RouteProperty:
- properties:
- destination:
- description: Destination network, expressed in CIDR format
- type: string
- gateway:
- description: Gateway address to which packets are forwarded
- type: string
- interface:
- description: Network interface associated with the route
- type: string
- linkState:
- description: Link state of the route (e.g., UP, DOWN)
- type: string
- metric:
- description: Metric value indicating the priority of the route
- type: integer
- protocol:
- description: Protocol used to set the route (e.g., kernel, static)
- type: string
- scope:
- description: Scope of the route (e.g., global, link, host)
- type: string
- source:
- description: Optionally stores the source address (used for policy-based routing)
- type: string
- type: object
- onprem.ServerProperty:
- properties:
- cpu:
- $ref: '#/definitions/onprem.CpuProperty'
- dataDisks:
- items:
- $ref: '#/definitions/onprem.DiskProperty'
- type: array
- hostname:
- type: string
- interfaces:
- items:
- $ref: '#/definitions/onprem.NetworkInterfaceProperty'
- type: array
- memory:
- $ref: '#/definitions/onprem.MemoryProperty'
- os:
- $ref: '#/definitions/onprem.OsProperty'
- rootDisk:
- $ref: '#/definitions/onprem.DiskProperty'
- routingTable:
- items:
- $ref: '#/definitions/onprem.RouteProperty'
- type: array
- type: object
- pkg_api_rest_handler.CloudModelRespInfo:
+ handler.CloudModelRespInfo:
properties:
cloudInfraModel:
$ref: '#/definitions/model.TbMciDynamicReq'
@@ -331,7 +35,7 @@ definitions:
required:
- cloudInfraModel
type: object
- pkg_api_rest_handler.CreateCloudModelReq:
+ handler.CreateCloudModelReq:
properties:
cloudInfraModel:
$ref: '#/definitions/model.TbMciDynamicReq'
@@ -356,7 +60,7 @@ definitions:
required:
- cloudInfraModel
type: object
- pkg_api_rest_handler.CreateCloudModelResp:
+ handler.CreateCloudModelResp:
properties:
cloudInfraModel:
$ref: '#/definitions/model.TbMciDynamicReq'
@@ -391,7 +95,7 @@ definitions:
required:
- cloudInfraModel
type: object
- pkg_api_rest_handler.CreateOnPremModelReq:
+ handler.CreateOnPremModelReq:
properties:
description:
type: string
@@ -408,7 +112,7 @@ definitions:
required:
- onpremiseInfraModel
type: object
- pkg_api_rest_handler.CreateOnPremModelResp:
+ handler.CreateOnPremModelResp:
properties:
createTime:
type: string
@@ -437,7 +141,7 @@ definitions:
required:
- onpremiseInfraModel
type: object
- pkg_api_rest_handler.GetCloudModelResp:
+ handler.GetCloudModelResp:
properties:
cloudInfraModel:
$ref: '#/definitions/model.TbMciDynamicReq'
@@ -472,21 +176,26 @@ definitions:
required:
- cloudInfraModel
type: object
- pkg_api_rest_handler.GetCloudModelsResp:
+ handler.GetCloudModelsResp:
properties:
models:
items:
- $ref: '#/definitions/pkg_api_rest_handler.CloudModelRespInfo'
+ $ref: '#/definitions/handler.CloudModelRespInfo'
type: array
type: object
- pkg_api_rest_handler.GetModelsResp:
+ handler.GetModelsResp:
properties:
models:
items:
- $ref: '#/definitions/pkg_api_rest_handler.ModelRespInfo'
+ $ref: '#/definitions/handler.ModelRespInfo'
type: array
type: object
- pkg_api_rest_handler.GetOnPremModelResp:
+ handler.GetModelsVersionResp:
+ properties:
+ modelsVersion:
+ $ref: '#/definitions/handler.ModelsVersionRespInfo'
+ type: object
+ handler.GetOnPremModelResp:
properties:
createTime:
type: string
@@ -515,14 +224,14 @@ definitions:
required:
- onpremiseInfraModel
type: object
- pkg_api_rest_handler.GetOnPremModelsResp:
+ handler.GetOnPremModelsResp:
properties:
models:
items:
- $ref: '#/definitions/pkg_api_rest_handler.OnPremModelRespInfo'
+ $ref: '#/definitions/handler.OnPremModelRespInfo'
type: array
type: object
- pkg_api_rest_handler.ModelRespInfo:
+ handler.ModelRespInfo:
properties:
cloudInfraModel:
$ref: '#/definitions/model.TbMciDynamicReq'
@@ -562,7 +271,130 @@ definitions:
- cloudInfraModel
- onpremiseInfraModel
type: object
- pkg_api_rest_handler.OnPremModelRespInfo:
+ handler.ModelsVersionRespInfo:
+ properties:
+ cloudModelVersion:
+ type: string
+ onpremModelVersion:
+ type: string
+ type: object
+ handler.OnPremModelRespInfo:
+ properties:
+ createTime:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ isCloudModel:
+ type: boolean
+ isInitUserModel:
+ type: boolean
+ isTargetModel:
+ type: boolean
+ onpremModelVersion:
+ type: string
+ onpremiseInfraModel:
+ $ref: '#/definitions/onprem.OnPremInfra'
+ updateTime:
+ type: string
+ userId:
+ type: string
+ userModelName:
+ type: string
+ userModelVersion:
+ type: string
+ required:
+ - onpremiseInfraModel
+ type: object
+ handler.ResHTTPVersion:
+ properties:
+ message:
+ type: string
+ type: object
+ handler.ResReadyz:
+ properties:
+ message:
+ type: string
+ type: object
+ handler.UpdateCloudModelReq:
+ properties:
+ cloudInfraModel:
+ $ref: '#/definitions/model.TbMciDynamicReq'
+ csp:
+ type: string
+ description:
+ type: string
+ isInitUserModel:
+ type: boolean
+ isTargetModel:
+ type: boolean
+ region:
+ type: string
+ userId:
+ type: string
+ userModelName:
+ type: string
+ userModelVersion:
+ type: string
+ zone:
+ type: string
+ required:
+ - cloudInfraModel
+ type: object
+ handler.UpdateCloudModelResp:
+ properties:
+ cloudInfraModel:
+ $ref: '#/definitions/model.TbMciDynamicReq'
+ cloudModelVersion:
+ type: string
+ createTime:
+ type: string
+ csp:
+ type: string
+ description:
+ type: string
+ id:
+ type: string
+ isCloudModel:
+ type: boolean
+ isInitUserModel:
+ type: boolean
+ isTargetModel:
+ type: boolean
+ region:
+ type: string
+ updateTime:
+ type: string
+ userId:
+ type: string
+ userModelName:
+ type: string
+ userModelVersion:
+ type: string
+ zone:
+ type: string
+ required:
+ - cloudInfraModel
+ type: object
+ handler.UpdateOnPremModelReq:
+ properties:
+ description:
+ type: string
+ isInitUserModel:
+ type: boolean
+ onpremiseInfraModel:
+ $ref: '#/definitions/onprem.OnPremInfra'
+ userId:
+ type: string
+ userModelName:
+ type: string
+ userModelVersion:
+ type: string
+ required:
+ - onpremiseInfraModel
+ type: object
+ handler.UpdateOnPremModelResp:
properties:
createTime:
type: string
@@ -586,126 +418,306 @@ definitions:
type: string
userModelName:
type: string
- userModelVersion:
+ userModelVersion:
+ type: string
+ required:
+ - onpremiseInfraModel
+ type: object
+ model.TbMciDynamicReq:
+ properties:
+ description:
+ example: Made in CB-TB
+ type: string
+ installMonAgent:
+ default: "no"
+ description: InstallMonAgent Option for CB-Dragonfly agent installation ([yes/no]
+ default:yes)
+ enum:
+ - "yes"
+ - "no"
+ example: "no"
+ type: string
+ label:
+ additionalProperties:
+ type: string
+ description: Label is for describing the object by keywords
+ type: object
+ name:
+ example: mci01
+ type: string
+ systemLabel:
+ description: SystemLabel is for describing the mci in a keyword (any string
+ can be used) for special System purpose
+ example: ""
+ type: string
+ vm:
+ items:
+ $ref: '#/definitions/model.TbVmDynamicReq'
+ type: array
+ required:
+ - name
+ - vm
+ type: object
+ model.TbVmDynamicReq:
+ properties:
+ commonImage:
+ description: CommonImage is field for id of a image in common namespace
+ example: ubuntu18.04
+ type: string
+ commonSpec:
+ description: CommonSpec is field for id of a spec in common namespace
+ example: aws+ap-northeast-2+t2.small
+ type: string
+ connectionName:
+ description: |-
+ if ConnectionName is given, the VM tries to use associtated credential.
+ if not, it will use predefined ConnectionName in Spec objects
+ type: string
+ description:
+ example: Description
+ type: string
+ label:
+ additionalProperties:
+ type: string
+ description: Label is for describing the object by keywords
+ type: object
+ name:
+ description: VM name or subGroup name if is (not empty) && (> 0). If it is
+ a group, actual VM name will be generated with -N postfix.
+ example: g1-1
+ type: string
+ rootDiskSize:
+ default: default
+ description: '"default", Integer (GB): ["50", ..., "1000"]'
+ example: default, 30, 42, ...
+ type: string
+ rootDiskType:
+ default: default
+ description: '"", "default", "TYPE1", AWS: ["standard", "gp2", "gp3"], Azure:
+ ["PremiumSSD", "StandardSSD", "StandardHDD"], GCP: ["pd-standard", "pd-balanced",
+ "pd-ssd", "pd-extreme"], ALIBABA: ["cloud_efficiency", "cloud", "cloud_essd"],
+ TENCENT: ["CLOUD_PREMIUM", "CLOUD_SSD"]'
+ example: default, TYPE1, ...
+ type: string
+ subGroupSize:
+ default: "1"
+ description: if subGroupSize is (not empty) && (> 0), subGroup will be generated.
+ VMs will be created accordingly.
+ example: "3"
+ type: string
+ vmUserPassword:
+ type: string
+ required:
+ - commonImage
+ - commonSpec
+ type: object
+ onprem.CpuProperty:
+ properties:
+ architecture:
+ example: x86_64
+ type: string
+ cores:
+ description: Number of physical cores per CPU
+ example: 18
+ type: integer
+ cpus:
+ description: Number of physical CPUs (sockets)
+ example: 2
+ type: integer
+ maxSpeed:
+ description: Maximum speed in GHz
+ example: 3.6
+ type: number
+ model:
+ example: Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz
+ type: string
+ threads:
+ description: Number of logical CPUs (threads) per CPU with hyper-threading
+ enabled
+ example: 36
+ type: integer
+ vendor:
+ example: GenuineIntel
type: string
required:
- - onpremiseInfraModel
+ - cores
+ - cpus
+ - threads
type: object
- pkg_api_rest_handler.ResHTTPVersion:
+ onprem.DiskProperty:
properties:
- message:
+ available:
+ description: Unit GiB
+ type: integer
+ label:
+ type: string
+ totalSize:
+ description: Unit GiB
+ example: 1024
+ type: integer
+ type:
+ description: SSD, HDD
+ example: SSD
type: string
+ used:
+ description: Unit GiB
+ type: integer
+ required:
+ - label
+ - totalSize
+ - type
type: object
- pkg_api_rest_handler.ResReadyz:
+ onprem.MemoryProperty:
properties:
- message:
+ available:
+ description: Unit GiB
+ type: integer
+ totalSize:
+ description: Unit GiB
+ example: 128
+ type: integer
+ type:
+ example: DDR4
type: string
+ used:
+ description: Unit GiB
+ type: integer
+ required:
+ - totalSize
+ - type
type: object
- pkg_api_rest_handler.UpdateCloudModelReq:
+ onprem.NetworkInterfaceProperty:
properties:
- cloudInfraModel:
- $ref: '#/definitions/model.TbMciDynamicReq'
- csp:
- type: string
- description:
- type: string
- isInitUserModel:
- type: boolean
- isTargetModel:
- type: boolean
- region:
- type: string
- userId:
- type: string
- userModelName:
+ ipv4CidrBlocks:
+ description: IPv4 address with prefix length (e.g., 192.168.0.21/24), instead
+ of inet addr, Bcast, and Mask
+ items:
+ type: string
+ type: array
+ ipv6CidrBlocks:
+ description: IPv6 address with prefix length (e.g., "2001:db8::1/64")
+ items:
+ type: string
+ type: array
+ macAddress:
+ description: MAC address
type: string
- userModelVersion:
+ mtu:
+ description: Maximum Transmission Unit (MTU) in bytes
+ type: integer
+ name:
+ description: Interface name (e.g., eth0, ens01, enp0s3)
type: string
- zone:
+ state:
+ description: Interface state (e.g., UP, DOWN)
type: string
required:
- - cloudInfraModel
+ - name
type: object
- pkg_api_rest_handler.UpdateCloudModelResp:
+ onprem.NetworkProperty:
+ properties:
+ ipv4Networks:
+ example:
+ - 172.26.240.0/20
+ items:
+ type: string
+ type: array
+ ipv6Networks:
+ description: TBD
+ items:
+ type: string
+ type: array
+ type: object
+ onprem.OnPremInfra:
+ properties:
+ network:
+ $ref: '#/definitions/onprem.NetworkProperty'
+ servers:
+ items:
+ $ref: '#/definitions/onprem.ServerProperty'
+ type: array
+ required:
+ - servers
+ type: object
+ onprem.OsProperty:
properties:
- cloudInfraModel:
- $ref: '#/definitions/model.TbMciDynamicReq'
- cloudModelVersion:
- type: string
- createTime:
- type: string
- csp:
- type: string
- description:
- type: string
id:
+ example: ubuntu
type: string
- isCloudModel:
- type: boolean
- isInitUserModel:
- type: boolean
- isTargetModel:
- type: boolean
- region:
- type: string
- updateTime:
- type: string
- userId:
- type: string
- userModelName:
- type: string
- userModelVersion:
+ idLike:
+ example: debian
type: string
- zone:
+ name:
+ example: Ubuntu
type: string
- required:
- - cloudInfraModel
- type: object
- pkg_api_rest_handler.UpdateOnPremModelReq:
- properties:
- description:
+ prettyName:
+ description: Pretty name
+ example: Ubuntu 22.04.3 LTS
type: string
- isInitUserModel:
- type: boolean
- onpremiseInfraModel:
- $ref: '#/definitions/onprem.OnPremInfra'
- userId:
+ version:
+ description: Full version string
+ example: 22.04.3 LTS (Jammy Jellyfish)
type: string
- userModelName:
+ versionCodename:
+ example: jammy
type: string
- userModelVersion:
+ versionId:
+ example: "22.04"
type: string
required:
- - onpremiseInfraModel
+ - prettyName
type: object
- pkg_api_rest_handler.UpdateOnPremModelResp:
+ onprem.RouteProperty:
properties:
- createTime:
+ destination:
+ description: Destination network, expressed in CIDR format
type: string
- description:
+ gateway:
+ description: Gateway address to which packets are forwarded
type: string
- id:
+ interface:
+ description: Network interface associated with the route
type: string
- isCloudModel:
- type: boolean
- isInitUserModel:
- type: boolean
- isTargetModel:
- type: boolean
- onpremModelVersion:
+ linkState:
+ description: Link state of the route (e.g., UP, DOWN)
type: string
- onpremiseInfraModel:
- $ref: '#/definitions/onprem.OnPremInfra'
- updateTime:
+ metric:
+ description: Metric value indicating the priority of the route
+ type: integer
+ protocol:
+ description: Protocol used to set the route (e.g., kernel, static)
type: string
- userId:
+ scope:
+ description: Scope of the route (e.g., global, link, host)
type: string
- userModelName:
+ source:
+ description: Optionally stores the source address (used for policy-based routing)
type: string
- userModelVersion:
+ type: object
+ onprem.ServerProperty:
+ properties:
+ cpu:
+ $ref: '#/definitions/onprem.CpuProperty'
+ dataDisks:
+ items:
+ $ref: '#/definitions/onprem.DiskProperty'
+ type: array
+ hostname:
type: string
- required:
- - onpremiseInfraModel
+ interfaces:
+ items:
+ $ref: '#/definitions/onprem.NetworkInterfaceProperty'
+ type: array
+ memory:
+ $ref: '#/definitions/onprem.MemoryProperty'
+ os:
+ $ref: '#/definitions/onprem.OsProperty'
+ rootDisk:
+ $ref: '#/definitions/onprem.DiskProperty'
+ routingTable:
+ items:
+ $ref: '#/definitions/onprem.RouteProperty'
+ type: array
type: object
info:
contact:
@@ -730,14 +742,14 @@ paths:
"200":
description: (sample) This is a list of models
schema:
- $ref: '#/definitions/pkg_api_rest_handler.GetCloudModelsResp'
+ $ref: '#/definitions/handler.GetCloudModelsResp'
"404":
description: model not found
schema:
type: object
summary: Get a list of cloud models
tags:
- - '[API] Cloud Migration Models'
+ - '[API] Cloud Migration User Models'
post:
consumes:
- application/json
@@ -748,7 +760,7 @@ paths:
name: Model
required: true
schema:
- $ref: '#/definitions/pkg_api_rest_handler.CreateCloudModelReq'
+ $ref: '#/definitions/handler.CreateCloudModelReq'
produces:
- application/json
responses:
@@ -756,14 +768,14 @@ paths:
description: (Sample) This is a sample description for success response
in Swagger UI
schema:
- $ref: '#/definitions/pkg_api_rest_handler.CreateCloudModelResp'
+ $ref: '#/definitions/handler.CreateCloudModelResp'
"400":
description: Invalid Request
schema:
type: object
summary: Create a new cloud model
tags:
- - '[API] Cloud Migration Models'
+ - '[API] Cloud Migration User Models'
/cloudmodel/{id}:
delete:
consumes:
@@ -792,7 +804,7 @@ paths:
type: object
summary: Delete a cloud model
tags:
- - '[API] Cloud Migration Models'
+ - '[API] Cloud Migration User Models'
get:
consumes:
- application/json
@@ -809,14 +821,14 @@ paths:
"200":
description: (Sample) a model
schema:
- $ref: '#/definitions/pkg_api_rest_handler.GetCloudModelResp'
+ $ref: '#/definitions/handler.GetCloudModelResp'
"404":
description: model not found
schema:
type: object
summary: Get a specific cloud model
tags:
- - '[API] Cloud Migration Models'
+ - '[API] Cloud Migration User Models'
put:
consumes:
- application/json
@@ -832,7 +844,7 @@ paths:
name: Model
required: true
schema:
- $ref: '#/definitions/pkg_api_rest_handler.UpdateCloudModelReq'
+ $ref: '#/definitions/handler.UpdateCloudModelReq'
produces:
- application/json
responses:
@@ -840,14 +852,14 @@ paths:
description: (Sample) This is a sample description for success response
in Swagger UI
schema:
- $ref: '#/definitions/pkg_api_rest_handler.UpdateCloudModelResp'
+ $ref: '#/definitions/handler.UpdateCloudModelResp'
"400":
description: Invalid Request
schema:
type: object
summary: Update a cloud model
tags:
- - '[API] Cloud Migration Models'
+ - '[API] Cloud Migration User Models'
/httpVersion:
get:
consumes:
@@ -860,15 +872,15 @@ paths:
"200":
description: OK
schema:
- $ref: '#/definitions/pkg_api_rest_handler.ResHTTPVersion'
+ $ref: '#/definitions/handler.ResHTTPVersion'
"404":
description: Not Found
schema:
- $ref: '#/definitions/pkg_api_rest_handler.ResHTTPVersion'
+ $ref: '#/definitions/handler.ResHTTPVersion'
"500":
description: Internal Server Error
schema:
- $ref: '#/definitions/pkg_api_rest_handler.ResHTTPVersion'
+ $ref: '#/definitions/handler.ResHTTPVersion'
summary: Check HTTP version of incoming request
tags:
- '[Admin] System management'
@@ -889,13 +901,34 @@ paths:
"200":
description: (sample) This is a list of models
schema:
- $ref: '#/definitions/pkg_api_rest_handler.GetModelsResp'
+ $ref: '#/definitions/handler.GetModelsResp'
"404":
description: model not found
schema:
type: object
summary: Get a list of all user models
tags:
+ - '[API] Migration User Models'
+ /model/version:
+ get:
+ consumes:
+ - application/json
+ description: Get the versions of all models(schemata of on-premise/cloud migration
+ models)
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: (sample) This is the versions of all models(schemata)
+ schema:
+ $ref: '#/definitions/handler.GetModelsVersionResp'
+ "404":
+ description: verson of models not found
+ schema:
+ type: object
+ summary: Get the versions of all models(schemata of on-premise/cloud migration
+ models)
+ tags:
- '[API] Migration Models'
/onpremmodel:
get:
@@ -908,14 +941,14 @@ paths:
"200":
description: (sample) This is a list of models
schema:
- $ref: '#/definitions/pkg_api_rest_handler.GetOnPremModelsResp'
+ $ref: '#/definitions/handler.GetOnPremModelsResp'
"404":
description: model not found
schema:
type: object
summary: Get a list of on-premise models
tags:
- - '[API] On-Premise Migration Models'
+ - '[API] On-Premise Migration User Models'
post:
consumes:
- application/json
@@ -926,7 +959,7 @@ paths:
name: Model
required: true
schema:
- $ref: '#/definitions/pkg_api_rest_handler.CreateOnPremModelReq'
+ $ref: '#/definitions/handler.CreateOnPremModelReq'
produces:
- application/json
responses:
@@ -934,14 +967,14 @@ paths:
description: (Sample) This is a sample description for success response
in Swagger UI
schema:
- $ref: '#/definitions/pkg_api_rest_handler.CreateOnPremModelResp'
+ $ref: '#/definitions/handler.CreateOnPremModelResp'
"400":
description: Invalid Request
schema:
type: object
summary: Create a new on-premise model
tags:
- - '[API] On-Premise Migration Models'
+ - '[API] On-Premise Migration User Models'
/onpremmodel/{id}:
delete:
consumes:
@@ -970,7 +1003,7 @@ paths:
type: object
summary: Delete a on-premise model
tags:
- - '[API] On-Premise Migration Models'
+ - '[API] On-Premise Migration User Models'
get:
consumes:
- application/json
@@ -987,14 +1020,14 @@ paths:
"200":
description: (Sample) a model
schema:
- $ref: '#/definitions/pkg_api_rest_handler.GetOnPremModelResp'
+ $ref: '#/definitions/handler.GetOnPremModelResp'
"404":
description: model not found
schema:
type: object
summary: Get a specific on-premise model
tags:
- - '[API] On-Premise Migration Models'
+ - '[API] On-Premise Migration User Models'
put:
consumes:
- application/json
@@ -1010,7 +1043,7 @@ paths:
name: Model
required: true
schema:
- $ref: '#/definitions/pkg_api_rest_handler.UpdateOnPremModelReq'
+ $ref: '#/definitions/handler.UpdateOnPremModelReq'
produces:
- application/json
responses:
@@ -1018,14 +1051,14 @@ paths:
description: (Sample) This is a sample description for success response
in Swagger UI
schema:
- $ref: '#/definitions/pkg_api_rest_handler.UpdateOnPremModelResp'
+ $ref: '#/definitions/handler.UpdateOnPremModelResp'
"400":
description: Invalid Request
schema:
type: object
summary: Update a on-premise model
tags:
- - '[API] On-Premise Migration Models'
+ - '[API] On-Premise Migration User Models'
/readyz:
get:
consumes:
@@ -1037,11 +1070,11 @@ paths:
"200":
description: OK
schema:
- $ref: '#/definitions/pkg_api_rest_handler.ResReadyz'
+ $ref: '#/definitions/handler.ResReadyz'
"503":
description: Service Unavailable
schema:
- $ref: '#/definitions/pkg_api_rest_handler.ResReadyz'
+ $ref: '#/definitions/handler.ResReadyz'
summary: Check Damselfly is ready
tags:
- '[Admin] System management'
diff --git a/cmd/cm-damselfly/main.go b/cmd/cm-damselfly/main.go
index 55ffebb..2901870 100644
--- a/cmd/cm-damselfly/main.go
+++ b/cmd/cm-damselfly/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "os"
"flag"
"fmt"
"strconv"
@@ -11,6 +12,7 @@ import (
"github.com/cloud-barista/cm-damselfly/pkg/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
+ "path/filepath"
restServer "github.com/cloud-barista/cm-damselfly/pkg/api/rest"
)
@@ -36,9 +38,11 @@ func init() {
// Initialize the local key-value store with the specified file path
prjRoot := viper.GetString("damselfly.root")
- dbFilePath := prjRoot + "/.damselfly/lkvstore.db"
+ dbFilePath := viper.GetString("damselfly.lkvstore.path")
+ dbFileFullPath := prjRoot + dbFilePath // Caution) Need to Modify!!
+
lkvstore.Init(lkvstore.Config{
- DbFilePath: dbFilePath,
+ DbFilePath: dbFileFullPath,
})
}
@@ -61,6 +65,22 @@ func init() {
func main() {
log.Info().Msg("Preparing to run CM-Damselfly")
+ // Initialize the local key-value store with the specified file path
+ prjRoot := viper.GetString("damselfly.root")
+
+ dbFilePath := viper.GetString("damselfly.lkvstore.path")
+ dbFileFullPath := prjRoot + dbFilePath // Caution) Need to Modify!!
+
+ // Ensure the DB file directory exists before creating the log file
+ dir := filepath.Dir(dbFileFullPath)
+ if _, err := os.Stat(dir); os.IsNotExist(err) {
+ // Create the directory if it does not exist
+ err = os.MkdirAll(dir, 0755) // Set permissions as needed
+ if err != nil {
+ log.Error().Msgf("Failed to Create the DB Directory: : [%v]", err)
+ }
+ }
+
// Load the state from the file back into the key-value store
if err := lkvstore.LoadLkvStore(); err != nil {
fmt.Printf("Error loading: %v\n", err)
diff --git a/conf/config.yaml b/conf/config.yaml
index 19166f7..ed813f6 100644
--- a/conf/config.yaml
+++ b/conf/config.yaml
@@ -2,6 +2,10 @@
damselfly:
root: # To be set in runtime
+ ## Set internal DB config (lkvstore: local key-value store)
+ lkvstore:
+ path: /db/damselfly.db
+
## Logger configuration
logfile:
# Set log file path (default logfile path: ./damselfly.log)
diff --git a/conf/setup.env b/conf/setup.env
index 6a93d29..5b1b1d3 100644
--- a/conf/setup.env
+++ b/conf/setup.env
@@ -3,6 +3,9 @@
SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}`
export DAMSELFLY_ROOT=`cd $SCRIPT_DIR && cd .. && pwd`
+## Set DAMSELFLY_SELF_ENDPOINT, to access Swagger API dashboard outside (Ex: export SELF_ENDPOINT=x.x.x.x:8088)
+export DAMSELFLY_SELF_ENDPOINT=localhost:8088
+
## Set API access config
# DAMSELFLY_API_ALLOW_ORIGINS (ex: https://cloud-barista.org,http://localhost:8080 or * for all)
export DAMSELFLY_API_ALLOW_ORIGINS=*
@@ -11,12 +14,12 @@ export DAMSELFLY_API_AUTH_ENABLED=true
export DAMSELFLY_API_USERNAME=default
export DAMSELFLY_API_PASSWORD=default
-## Set DAMSELFLY_SELF_ENDPOINT, to access Swagger API dashboard outside (Ex: export SELF_ENDPOINT=x.x.x.x:8056)
-export DAMSELFLY_SELF_ENDPOINT=localhost:8056
+## Set internal DB config (lkvstore: local key-value store, default file path: ./db/beetle.db)
+export DAMSELFLY_LKVSTORE_PATH=db/damselfly.db
## Logger configuration
# Set log file path (default logfile path: ./damselfly.log)
-export DAMSELFLY_LOGFILE_PATH=./log/damselfly.log
+export DAMSELFLY_LOGFILE_PATH=log/damselfly.log
export DAMSELFLY_LOGFILE_MAXSIZE=10
export DAMSELFLY_LOGFILE_MAXBACKUPS=3
export DAMSELFLY_LOGFILE_MAXAGE=30
diff --git a/docker-compose.yaml b/docker-compose.yaml
new file mode 100644
index 0000000..db27e2a
--- /dev/null
+++ b/docker-compose.yaml
@@ -0,0 +1,56 @@
+services:
+ cm-damselfly:
+ container_name: cm-damselfly
+ pull_policy: missing
+ restart: always
+ build:
+ context: ./
+ dockerfile: Dockerfile
+ platform: linux/amd64
+ ports:
+ - target: 8088
+ published: 8088
+ protocol: tcp
+ image: cloudbaristaorg/cm-damselfly:latest
+ volumes:
+ # - ./.damselfly/lkvstore.db:/app/db/lkvstore.db:rw
+ # - ./log/damselfly.log:/app/log/damselfly.log:rw
+ - ./.damselfly/:/app/db/
+ - ./log/:/app/log/
+ network_mode: "host"
+ environment:
+ # - DAMSELFLY_ROOT=/app
+ ## Set API access config
+ # DAMSELFLY_API_ALLOW_ORIGINS (ex: https://cloud-barista.org,http://localhost:8080 or * for all)
+ - DAMSELFLY_API_ALLOW_ORIGINS=*
+ # Set DAMSELFLY_API_AUTH_ENABLED=true currently for basic auth for all routes (i.e., url or path)
+ - DAMSELFLY_API_AUTH_ENABLED=true
+ - DAMSELFLY_API_USERNAME=default
+ - DAMSELFLY_API_PASSWORD=default
+ # Set DAMSELFLY_SELF_ENDPOINT, to access Swagger API dashboard outside (Ex: export SELF_ENDPOINT=x.x.x.x:8056)
+ - DAMSELFLY_SELF_ENDPOINT=localhost:8088
+ ## Logger configuration
+ # Set log file path (default logfile path: ./damselfly.log)
+ - DAMSELFLY_LOGFILE_PATH=/app/log/damselfly.log
+ - DAMSELFLY_LOGFILE_MAXSIZE=10
+ - DAMSELFLY_LOGFILE_MAXBACKUPS=3
+ - DAMSELFLY_LOGFILE_MAXAGE=30
+ - DAMSELFLY_LOGFILE_COMPRESS=false
+ # Set log level, such as trace, debug info, warn, error, fatal, and panic
+ - DAMSELFLY_LOGLEVEL=debug
+ # Set log writer, such as file, stdout, or both
+ - DAMSELFLY_LOGWRITER=both
+
+ # Set DB file path
+ - DAMSELFLY_LKVSTORE_PATH=/app/db/damselfly.db
+
+ # Set execution environment, such as development or production
+ - DAMSELFLY_NODE_ENV=development
+ ## Set period for auto control goroutine invocation
+ - DAMSELFLY_AUTOCONTROL_DURATION_MS=10000
+ healthcheck: # for CM-Beetle
+ test: [ "CMD", "curl", "-f", "http://localhost:8088/damselfly/readyz" ]
+ interval: 1m
+ timeout: 5s
+ retries: 3
+ start_period: 10s
diff --git a/go.mod b/go.mod
index ac52a43..191adab 100644
--- a/go.mod
+++ b/go.mod
@@ -3,18 +3,14 @@ module github.com/cloud-barista/cm-damselfly
go 1.23.0
require (
- github.com/cloud-barista/cb-log v0.7.0
github.com/cloud-barista/cb-tumblebug v0.9.16
github.com/cloud-barista/cm-model v0.0.2
- github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/labstack/echo/v4 v4.12.0
github.com/rs/zerolog v1.33.0
- github.com/sirupsen/logrus v1.9.0
github.com/spf13/viper v1.19.0
github.com/swaggo/echo-swagger v1.4.1
github.com/swaggo/swag v1.16.3
gopkg.in/natefinch/lumberjack.v2 v2.2.1
- gopkg.in/yaml.v2 v2.4.0
)
require (
@@ -44,7 +40,6 @@ require (
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
- github.com/snowzach/rotatefilehook v0.0.0-20220211133110-53752135082d // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
@@ -63,6 +58,7 @@ require (
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.24.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
+ gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
xorm.io/builder v0.3.13 // indirect
xorm.io/xorm v1.3.6 // indirect
diff --git a/go.sum b/go.sum
index 3b35c64..e779305 100644
--- a/go.sum
+++ b/go.sum
@@ -13,8 +13,6 @@ github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0
github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY=
github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic=
github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
-github.com/cloud-barista/cb-log v0.7.0 h1:5ACU99hdSPKLp/rGUu3abumEomS2dVPujfdCOEWQ9j4=
-github.com/cloud-barista/cb-log v0.7.0/go.mod h1:nGgfTFMPwl1MpCO3FBjexUkNdOYA0BNJoyM9Pd0lMms=
github.com/cloud-barista/cb-tumblebug v0.9.16 h1:BRpYn+HOpJzC20oD5VMipyslMqePSc0Dx/GR/tefmOc=
github.com/cloud-barista/cb-tumblebug v0.9.16/go.mod h1:NId135dY2nPhzV69+v1AFLlIjFTD400smoht73lG58c=
github.com/cloud-barista/cm-model v0.0.2 h1:6qxrkENlGurVs20rywKoT7L8OlvK4KWegIpJHaPJN3M=
@@ -207,10 +205,6 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
-github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
-github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
-github.com/snowzach/rotatefilehook v0.0.0-20220211133110-53752135082d h1:4660u5vJtsyrn3QwJNfESwCws+TM1CMhRn123xjVyQ8=
-github.com/snowzach/rotatefilehook v0.0.0-20220211133110-53752135082d/go.mod h1:ZLVe3VfhAuMYLYWliGEydMBoRnfib8EFSqkBYu1ck9E=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
@@ -329,7 +323,6 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/go.work b/go.work
new file mode 100644
index 0000000..784f04a
--- /dev/null
+++ b/go.work
@@ -0,0 +1,3 @@
+go 1.23.0
+
+use .
diff --git a/go.work.sum b/go.work.sum
new file mode 100644
index 0000000..8b2b888
--- /dev/null
+++ b/go.work.sum
@@ -0,0 +1,93 @@
+cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4=
+cloud.google.com/go/compute v1.24.0/go.mod h1:kw1/T+h/+tK2LJK0wiPPx1intgdAM3j/g3hFDlscY40=
+cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
+cloud.google.com/go/firestore v1.15.0/go.mod h1:GWOxFXcv8GZUtYpWHw/w6IuYNux/BtmeVTMmjrm4yhk=
+cloud.google.com/go/iam v1.1.5/go.mod h1:rB6P/Ic3mykPbFio+vo7403drjlgvoWfYpJhMXEbzv8=
+cloud.google.com/go/longrunning v0.5.5/go.mod h1:WV2LAxD8/rg5Z1cNW6FJ/ZpX4E4VnDnoTk0yawPBB7s=
+cloud.google.com/go/storage v1.35.1/go.mod h1:M6M/3V/D3KpzMTJyPOR/HU6n2Si5QdaXYEsng2xgOs8=
+github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
+github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4=
+github.com/cloud-barista/mc-terrarium v0.0.7/go.mod h1:qey9GFrJidyJ3tVfeL/gcImgWLqsF64j/fVmBfaddDI=
+github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
+github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
+github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
+github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
+github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
+github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
+github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
+github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
+github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
+github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
+github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0=
+github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
+github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
+github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
+github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=
+github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
+github.com/googleapis/gax-go/v2 v2.12.3/go.mod h1:AKloxT6GtNbaLm8QTNSidHUVsHYcBHwWRvkNFJUQcS4=
+github.com/googleapis/google-cloud-go-testing v0.0.0-20210719221736-1c9a4c676720/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
+github.com/hashicorp/consul/api v1.28.2/go.mod h1:KyzqzgMEya+IZPcD65YFoOVAgPpbfERu4I/tzG6/ueE=
+github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
+github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
+github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
+github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
+github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
+github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
+github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4=
+github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/jedib0t/go-pretty/v6 v6.5.6/go.mod h1:5LQIxa52oJ/DlDSLv0HEkWOFMDGoWkJb9ss5KqPpJBg=
+github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
+github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
+github.com/labstack/echo-jwt v0.0.0-20221127215225-c84d41a71003/go.mod h1:ovRFgyKvi73jQIFCWz9ByQwzhIyohkzY0MFAlPGyr8Q=
+github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
+github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y=
+github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU=
+github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E=
+github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4=
+github.com/lestrrat-go/jwx v1.2.29/go.mod h1:hU8k2l6WF0ncx20uQdOmik/Gjg6E3/wIRtXSNFeZuB8=
+github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
+github.com/m-cmp/mc-iam-manager v0.2.7/go.mod h1:ES5A3mw32SIfHMzUodo6R6D+c3p+EYzP3ga11Fi6KE8=
+github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/nats-io/nats.go v1.34.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
+github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc=
+github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
+github.com/pkg/sftp v1.13.6/go.mod h1:tz1ryNURKu77RL+GuCzmoJYxQczL3wLNNpPWagdg4Qk=
+github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/sagikazarmark/crypt v0.19.0/go.mod h1:c6vimRziqqERhtSe0MhIvzE1w54FrCHtrXb5NH/ja78=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
+github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
+github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
+github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
+go.etcd.io/etcd/api/v3 v3.5.12/go.mod h1:Ot+o0SWSyT6uHhA56al1oCED0JImsRiU9Dc26+C2a+4=
+go.etcd.io/etcd/client/pkg/v3 v3.5.12/go.mod h1:seTzl2d9APP8R5Y2hFL3NVlD6qC/dOT+3kvrqPyTas4=
+go.etcd.io/etcd/client/v2 v2.305.12/go.mod h1:aQ/yhsxMu+Oht1FOupSr60oBvcS9cKXHrzBpDsPTf9E=
+go.etcd.io/etcd/client/v3 v3.5.12/go.mod h1:tSbBCakoWmmddL+BKVAJHa9km+O/E+bumDe9mSbPiqw=
+go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
+go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0=
+go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=
+go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
+go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
+go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
+go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
+go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
+golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8=
+golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
+golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
+golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
+google.golang.org/api v0.171.0/go.mod h1:Hnq5AHm4OTMt2BUVjael2CWZFD6vksJdWCWiUAmjC9o=
+google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
+google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s=
+google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
+google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
+google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
+sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
diff --git a/model/migration-model/migration_model.go b/model/migration-model/migration_model.go
deleted file mode 100644
index d55fa4a..0000000
--- a/model/migration-model/migration_model.go
+++ /dev/null
@@ -1,440 +0,0 @@
-package model
-
-import (
- "encoding/json"
- "fmt"
- "os"
- "strings"
-
- // "errors"
-
- cblog "github.com/cloud-barista/cb-log"
- "github.com/davecgh/go-spew/spew"
-)
-
-const (
- migrationModelDir string = "/.migration_model"
-)
-
-func init() {
- // cblog is a global variable.
- cblogger = cblog.GetLogger("Model Handler")
-}
-
-type JSON_Model struct {
- MigrationModel MigrationModel `json:"migrationModel"`
-}
-
-type MigrationModel struct {
- Description string `json:"description"`
- Name string `json:"name"`
- Version string `json:"version"`
- ModelId string `json:"modelId"`
- MigrationStep string `json:"migrationStep"`
- TargetEnvironment TargetEnvironment `json:"targetEnvironment"`
-}
-
-type TargetEnvironment struct {
- Provider string `json:"provider"`
- Details EnvironmentDetails `json:"details"`
-}
-
-type EnvironmentDetails struct {
- Region string `json:"region"`
- Zone string `json:"zone"`
- Resources []Resource `json:"resources"`
-}
-
-type Resource struct {
- Type string `json:"type"`
- NsSpecifications *Namespace `json:"nsSpecifications,omitempty"`
- VNetSpecifications *VNet `json:"vNetSpecifications,omitempty"`
- McisSpecifications *MCIS `json:"mcisSpecifications,omitempty"`
- ImgSpecifications *VMImage `json:"imgSpecifications,omitempty"`
- SgSpecifications *SG `json:"sgSpecifications,omitempty"`
- KeySpecifications *KeyPair `json:"keySpecifications,omitempty"`
- DbSpecifications *Database `json:"dbSpecifications,omitempty"`
- DiskSpecifications *DataDisk `json:"diskSpecifications,omitempty"`
- NlbSpecifications *NLB `json:"nlbSpecifications,omitempty"`
- AppSpecifications *Application `json:"appSpecifications,omitempty"`
- WebSvrSpecifications *WebServer `json:"webSvrSpecifications,omitempty"`
-}
-
-// Define structs for each specification
-type Namespace struct {
- Description string `json:"description"`
- Name string `json:"name"`
-}
-
-type VNet struct {
- CidrBlock string `json:"cidrBlock"`
- CspVNetId string `json:"cspVNetId"`
- Description string `json:"description"`
- Name string `json:"name"`
- SubnetInfoList []SubnetInfo `json:"subnetInfoList"`
-}
-
-type MCIS struct {
- Description string `json:"description"`
- InstallMonAgent string `json:"installMonAgent"`
- Label string `json:"label"`
- Name string `json:"name"`
- PlacementAlgo string `json:"placementAlgo"`
- SystemLabel string `json:"systemLabel"`
- VM []VM `json:"vm"`
-}
-
-type VMImage struct {
- CspImageId string `json:"cspImageId"`
- Description string `json:"description"`
- Name string `json:"name"`
-}
-
-type SG struct {
- CspSecurityGroupId string `json:"cspSecurityGroupId"`
- Description string `json:"description"`
- FirewallRules []FirewallRule `json:"firewallRules"`
- Name string `json:"name"`
- VNetId string `json:"vNetId"`
-}
-
-type KeyPair struct {
- ConnectionName string `json:"connectionName"`
- CspSshKeyId string `json:"cspSshKeyId"`
- Description string `json:"description"`
- Fingerprint string `json:"fingerprint"`
- Name string `json:"name"`
- PrivateKey string `json:"privateKey"`
- PublicKey string `json:"publicKey"`
- Username string `json:"username"`
- VerifiedUsername string `json:"verifiedUsername"`
-}
-
-type Database struct {
- DatabaseType string `json:"databaseType"`
- Version string `json:"version"`
- Size string `json:"size"`
- Tables string `json:"tables"`
- StoredProcedures string `json:"storedProcedures"`
-}
-
-type DataDisk struct {
- ConnectionName string `json:"connectionName"`
- CspDataDiskId string `json:"cspDataDiskId"`
- Description string `json:"description"`
- DiskSize string `json:"diskSize"`
- DiskType string `json:"diskType"`
- Name string `json:"name"`
-}
-
-type NLB struct {
- CspNLBId string `json:"cspNLBId"`
- Description string `json:"description"`
- HealthChecker HealthChecker `json:"healthChecker"`
- Listener Listener `json:"listener"`
- Scope string `json:"scope"`
- TargetGroup TargetGroup `json:"targetGroup"`
- Type string `json:"type"`
-}
-
-type Application struct {
- Name string `json:"name"`
- Version string `json:"version"`
- Language string `json:"language"`
- Dependencies []string `json:"dependencies"`
-}
-
-type WebServer struct {
- Software string `json:"software"`
- Version string `json:"version"`
- HostedWebsites string `json:"hostedWebsites"`
- Traffic string `json:"traffic"`
-}
-
-// Sub structs for nested objects in specifications
-type SubnetInfo struct {
- Description string `json:"description,omitempty"`
- Ipv4CIDR string `json:"ipv4_CIDR,omitempty"`
- KeyValueList []KeyValue `json:"keyValueList,omitempty"`
- Name string `json:"name,omitempty"`
-}
-
-type VM struct {
- DataDiskIds []string `json:"dataDiskIds,omitempty"`
- Description string `json:"description,omitempty"`
- IdByCsp string `json:"idByCsp,omitempty"`
- ImageId string `json:"imageId,omitempty"`
- Label string `json:"label,omitempty"`
- Name string `json:"name,omitempty"`
- RootDiskSize string `json:"rootDiskSize,omitempty"`
- RootDiskType string `json:"rootDiskType,omitempty"`
- SecurityGroupIds []string `json:"securityGroupIds,omitempty"`
- SpecId string `json:"specId,omitempty"`
- SshKeyId string `json:"sshKeyId,omitempty"`
- SubGroupSize string `json:"subGroupSize,omitempty"`
- VNetId string `json:"vNetId,omitempty"`
- SubnetId string `json:"subnetId,omitempty"`
- VmUserAccount string `json:"vmUserAccount,omitempty"`
- VmUserPassword string `json:"vmUserPassword,omitempty"`
-}
-
-type FirewallRule struct {
- Cidr string `json:"cidr,omitempty"`
- Direction string `json:"direction,omitempty"`
- FromPort string `json:"fromPort,omitempty"`
- IpProtocol string `json:"ipprotocol,omitempty"`
- ToPort string `json:"toPort,omitempty"`
-}
-
-type HealthChecker struct {
- Interval string `json:"interval,omitempty"`
- Threshold string `json:"threshold,omitempty"`
- Timeout string `json:"timeout,omitempty"`
-}
-
-type LbListener struct {
- Port string `json:"port,omitempty"`
- Protocol string `json:"protocol,omitempty"`
-}
-
-type TargetGroup struct {
- Port string `json:"port,omitempty"`
- Protocol string `json:"protocol,omitempty"`
- SubGroupId string `json:"subGroupId,omitempty"`
-}
-
-type KeyValue struct {
- Key string `json:"key,omitempty"`
- Value string `json:"value,omitempty"`
-}
-
-type IID struct {
- NameId string
- SystemId string
-}
-
-func WriteModel(modelName string, rsInfo JSON_Model) (JSON_Model, error) {
- cblogger.Info("Model Handler called CreateModel()!")
-
- var modelIId IID
- modelIId.NameId = modelName
- // Check if the Model Name already Exists
- modelInfo, _ := GetModel(modelIId)
- if modelInfo.MigrationModel.Name != "" {
- newErr := fmt.Errorf("The Model Name already exists!!")
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
-
- modelFilePath := os.Getenv("MODEL_ROOT") + migrationModelDir + "/"
- jsonFileName := modelFilePath + modelName + ".json"
-
- // Check if the Model file folder Exists, and Create it
- if err := CheckFolderAndCreate(modelFilePath); err != nil {
- newErr := fmt.Errorf("Failed to Create the Model Path : [%s] : [%v]"+modelFilePath, err)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
-
- rsInfo.MigrationModel.Name = modelName
- file, err := json.MarshalIndent(rsInfo, "", " ")
- if err != nil {
- return JSON_Model{}, err
- }
- writeErr := os.WriteFile(jsonFileName, file, 0644)
- if writeErr != nil {
- newErr := fmt.Errorf("Failed to write the file : [%s] : [%v]", jsonFileName, writeErr)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
-
- // Return the created Model Info.
- modelInfo, modelErr := GetModel(modelIId)
- if modelErr != nil {
- newErr := fmt.Errorf("Failed to Get the Model Info : [%v]", modelErr)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
- return modelInfo, nil
-}
-
-func GetModel(modelIID IID) (JSON_Model, error) {
- cblogger.Info("Model Handler called GetModel()!")
-
- if !strings.EqualFold(modelIID.SystemId, "") {
- modelIID.NameId = modelIID.SystemId
- }
-
- modelFilePath := os.Getenv("MODEL_ROOT") + migrationModelDir + "/"
- jsonFileName := modelFilePath + modelIID.NameId + ".json"
-
- // Check if the Model file Folder Exists, and Create it
- if err := CheckFolderAndCreate(modelFilePath); err != nil {
- newErr := fmt.Errorf("Failed to Create the Model Path : [%s] : [%v]"+modelFilePath, err)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
-
- file, err := os.ReadFile(jsonFileName)
- if err != nil {
- return JSON_Model{}, err
- }
-
- var rsData JSON_Model
- err = json.Unmarshal([]byte(file), &rsData)
- if err != nil {
- return JSON_Model{}, err
- }
- return rsData, nil
-}
-
-func ListModel() ([]*JSON_Model, error) {
- cblogger.Info("Model Handler : called ListModel()!")
-
- var modelIID IID
- var resourceInfoList []*JSON_Model
-
- medelFilePath := os.Getenv("MODEL_ROOT") + migrationModelDir + "/"
- dirFiles, readRrr := os.ReadDir(medelFilePath)
- if readRrr != nil {
- return nil, readRrr
- }
-
- spew.Dump(dirFiles)
-
- for _, file := range dirFiles {
- fileName := strings.TrimSuffix(file.Name(), ".json") // 접미사 제거
- modelIID.NameId = fileName
- cblogger.Infof("# Model Name : " + modelIID.NameId)
-
- rsInfo, getErr := GetModel(modelIID)
- if getErr != nil {
- newErr := fmt.Errorf("Failed to Get the Model Info : [%v]", getErr)
- cblogger.Error(newErr.Error())
- return nil, newErr
- }
- resourceInfoList = append(resourceInfoList, &rsInfo)
- }
- return resourceInfoList, nil
-}
-
-func UpdateModel(modelIId IID, rsInfo JSON_Model) (JSON_Model, error) {
- cblogger.Info("Model Handler called UpdateModel()!")
- var modelName = modelIId.NameId
-
- // Find the created Model Info.
- modelInfo, modelErr := GetModel(modelIId)
- if modelErr != nil {
- newErr := fmt.Errorf("Failed to Find the Model Info!! : [%v]", modelErr)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
-
- if modelInfo.MigrationModel.Name == "" {
- newErr := fmt.Errorf("Failed to Find the Model Info!!")
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
-
- modelFilePath := os.Getenv("MODEL_ROOT") + migrationModelDir + "/"
- jsonFileName := modelFilePath + modelName + ".json"
-
- // Check if the Model file Folder Exists, and Create it
- if err := CheckFolderAndCreate(modelFilePath); err != nil {
- newErr := fmt.Errorf("Failed to Create the Model Path : [%s] : [%v]"+modelFilePath, err)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
-
- rsInfo.MigrationModel.Name = modelName
- file, err := json.MarshalIndent(rsInfo, "", " ")
- if err != nil {
- return JSON_Model{}, err
- }
-
- writeErr := os.WriteFile(jsonFileName, file, 0644)
- if writeErr != nil {
- newErr := fmt.Errorf("Failed to write the file : [%s] : [%v]", jsonFileName, writeErr)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
-
- // Return the updated Model Info.
- modelInfo, getErr := GetModel(modelIId)
- if getErr != nil {
- newErr := fmt.Errorf("Failed to Get the Model Info : [%v]", getErr)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
- return modelInfo, nil
-}
-
-func DeleteModel(modelIID IID) (bool, error) {
- cblogger.Info("Model Handler called DelModel()!")
-
- if !strings.EqualFold(modelIID.SystemId, "") {
- modelIID.NameId = modelIID.SystemId
- }
-
- //To check whether the Model exists.
- _, modelErr := GetModel(modelIID)
- if modelErr != nil {
- newErr := fmt.Errorf("Failed to Get the Model Info : [%v]", modelErr)
- cblogger.Error(newErr.Error())
- return false, newErr
- }
-
- modelFilePath := os.Getenv("MODEL_ROOT") + migrationModelDir + "/"
- jsonFileName := modelFilePath + modelIID.NameId + ".json"
-
- // Check if the Model file Folder Exists, and Create it
- if err := CheckFolderAndCreate(modelFilePath); err != nil {
- newErr := fmt.Errorf("Failed to Create the Model Path : [%s] : [%v]"+modelFilePath, err)
- cblogger.Error(newErr.Error())
- return false, newErr
- }
-
- // To Remove the Model file on the Local machine.
- delErr := os.Remove(jsonFileName)
- if delErr != nil {
- newErr := fmt.Errorf("Failed to Delete the Model : [%s] : [%v]", jsonFileName, delErr)
- cblogger.Error(newErr.Error())
- return false, newErr
- }
- return true, nil
-}
-
-// Function to update SubnetInfoList in the first vNet resource
-func UpdateSubnetInfoList(modelIId IID, newSubnetInfoList []SubnetInfo) (JSON_Model, error) {
- modelInfo, getErr := GetModel(modelIId)
- if getErr != nil {
- newErr := fmt.Errorf("Failed to Get the Model Info : [%v]", getErr)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
-
- for i, resource := range modelInfo.MigrationModel.TargetEnvironment.Details.Resources {
- cblogger.Infof("# resource.Type : [%s]", resource.Type)
- if resource.Type == "vNet" {
- modelInfo.MigrationModel.TargetEnvironment.Details.Resources[i].VNetSpecifications.SubnetInfoList = newSubnetInfoList
- break
- }
- }
-
- _, err := UpdateModel(modelIId, modelInfo)
- if err != nil {
- newErr := fmt.Errorf("Failed to Update the Model Info : [%v]", err)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
- // spew.Dump(model)
-
- // Return the updated Model Info.
- model, getErr := GetModel(modelIId)
- if getErr != nil {
- newErr := fmt.Errorf("Failed to Get the Model Info : [%v]", getErr)
- cblogger.Error(newErr.Error())
- return JSON_Model{}, newErr
- }
- return model, nil
-}
diff --git a/model/replication-model/replicaton_model.go b/model/replication-model/replicaton_model.go
deleted file mode 100644
index 7c4727c..0000000
--- a/model/replication-model/replicaton_model.go
+++ /dev/null
@@ -1,120 +0,0 @@
-package model
-
-import (
- "fmt"
- "log"
- "os"
-
- "gopkg.in/yaml.v2"
- // "github.com/davecgh/go-spew/spew"
-)
-
-const (
- ReplicationModelDir string = "/.replication_model"
-)
-
-type Replication struct {
- TemplateFormatVersion string `yaml:"TemplateFormatVersion"`
- Description string `yaml:"Description"`
- CSP CSP `yaml:"CSP"`
- Resources Replica_RS `yaml:"Resources"`
-}
-
-type Replica_RS struct {
- VMInstance VMInstance `yaml:"VMInstance"`
- LoadBalancer LoadBalancer `yaml:"LoadBalancer"`
-}
-
-type CSP struct {
- Name string `yaml:"Name"`
- RegionCode string `yaml:"Region"`
- ZoneCode string `yaml:"Zone"`
-}
-
-type VMInstance struct {
- Name string `yaml:"Name"`
- ImageId string `yaml:"ImageId"`
- VMSpecId string `yaml:"VMSpecId"`
- KeyPairName string `yaml:"KeyPairName"`
- SecurityGroups []SecurityGroup `yaml:"SecurityGroups"`
- VPC VPCInstance `yaml:"VPCInstance"`
- Subnets []Subnet `yaml:"Subnets"`
-}
-
-type SecurityGroup struct {
- GroupDescription string `yaml:"GroupDescription"`
- SecurityGroupIngress []IngressRule `yaml:"SecurityGroupIngress"`
-}
-
-type VPCInstance struct {
- Name string `yaml:"Name"`
- CidrBlock string `yaml:"CidrBlock"`
- EnableDnsSupport bool `yaml:"EnableDnsSupport"`
- EnableDnsHostnames bool `yaml:"EnableDnsHostnames"`
-}
-
-type Subnet struct {
- Name string `yaml:"Name"`
- CidrBlock string `yaml:"CidrBlock"`
- AvailabilityZone string `yaml:"AvailabilityZone"`
-}
-
-type IngressRule struct {
- IpProtocol string `yaml:"IpProtocol"`
- FromPort string `yaml:"FromPort"`
- ToPort string `yaml:"ToPort"`
- CidrIp string `yaml:"CidrIp"`
-}
-
-type LoadBalancer struct {
- Name string `yaml:"Name"`
- Listeners []Listener `yaml:"Listeners"`
- HealthCheck HealthCheck `yaml:"HealthCheck"`
- VMInstances []VMInstance `yaml:"VMInstances"`
-}
-
-type Listener struct {
- LoadBalancerPort string `yaml:"LoadBalancerPort"`
- InstancePort string `yaml:"InstancePort"`
- Protocol string `yaml:"Protocol"`
-}
-
-type HealthCheck struct {
- Target string `yaml:"Target"`
- HealthyThreshold string `yaml:"HealthyThreshold"`
- UnhealthyThreshold string `yaml:"UnhealthyThreshold"`
- Interval string `yaml:"Interval"`
- Timeout string `yaml:"Timeout"`
-}
-
-func GetReplicaResources(yamlName string) (Replication, error) {
- cblogger.Info("Model Handler called GetReplicaResources()!")
-
- modelFilePath := os.Getenv("MODEL_ROOT") + ReplicationModelDir + "/"
- yamlFile := modelFilePath + yamlName + ".yaml"
- fmt.Printf("# Replica YAML File: %+s\n", yamlFile)
-
- // Check if the Model file folder Exists, and Create it
- if err := CheckFolderAndCreate(modelFilePath); err != nil {
- newErr := fmt.Errorf("Failed to Create the Model Path : [%s] : [%v]"+modelFilePath, err)
- cblogger.Error(newErr.Error())
- return Replication{}, newErr
- }
-
- // Read YAML
- data, err := os.ReadFile(yamlFile)
- if err != nil {
- log.Fatal(err)
- }
- // spew.Dump(data)
-
- // Unmarshal YAML
- var replica Replication
- err = yaml.Unmarshal(data, &replica)
- if err != nil {
- log.Fatalf("error: %v", err)
- }
- err = yaml.Unmarshal(data, &replica)
- // fmt.Printf("# Parsed Data: %+v\n", replica)
- return replica, nil
-}
diff --git a/obsolete/CommonFunc.go b/obsolete/CommonFunc.go
deleted file mode 100644
index 6a5ae34..0000000
--- a/obsolete/CommonFunc.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package model
-
-import (
- "encoding/json"
- "os"
- "sync"
-
- "github.com/sirupsen/logrus"
-
- cblog "github.com/cloud-barista/cb-log"
-)
-
-var once sync.Once
-var cblogger *logrus.Logger
-
-// Cloud Object를 JSON String 타입으로 변환
-func ConvertJsonString(v interface{}) (string, error) {
- jsonBytes, errJson := json.Marshal(v)
-
- if errJson != nil {
- cblogger.Error("Failed to Convert to JSON format.")
- cblogger.Error(errJson)
- return "", errJson
- }
-
- jsonString := string(jsonBytes)
- return jsonString, nil
-}
-
-func InitLog() {
- once.Do(func() {
- // cblog is a global variable.
- cblogger = cblog.GetLogger("Model Handler")
- })
-}
-
-// Check if the Folder Exists. If Not, Create it
-func CheckFolderAndCreate(folderPath string) error {
- if _, err := os.Stat(folderPath); os.IsNotExist(err) {
- if err := os.Mkdir(folderPath, 0700); err != nil {
- return err
- }
- }
- return nil
-}
diff --git a/pkg/api/rest/handler/common.go b/pkg/api/rest/handler/common.go
index f48062c..59f0190 100644
--- a/pkg/api/rest/handler/common.go
+++ b/pkg/api/rest/handler/common.go
@@ -9,6 +9,9 @@ import (
"bufio"
"os"
"strings"
+ "github.com/rs/zerolog/log"
+ "path/filepath"
+ "net"
)
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -80,21 +83,46 @@ func generateUnique15DigitString() (int, error) {
}
func getSeoulCurrentTime() string {
- loc, _ := time.LoadLocation("Asia/Seoul")
+ loc, err := time.LoadLocation("Asia/Seoul")
+ if err != nil {
+ log.Error().Msgf("Failed to Get the Time Value of the Location : [%v]", err)
+ }
+
currentTime := time.Now().In(loc)
return currentTime.Format("2006-01-02 15:04:05")
}
func getModuleVersion(moduleName string) (string, error) {
- file, err := os.Open("./../../go.mod")
- if err != nil {
- return "", err
- }
- defer file.Close()
-
- scanner := bufio.NewScanner(file)
+ var goFile *os.File
+ if isRunningInContainer() {
+ wd, err := os.Getwd()
+ if err != nil {
+ return "", err
+ }
+ goModPath := filepath.Join(wd, "go.mod")
+
+ log.Debug().Msgf("go.mod file path : [%s]", goModPath)
+
+ var openErr error
+ goFile, openErr = os.Open(goModPath)
+ if openErr != nil {
+ return "", openErr
+ }
+ defer goFile.Close()
+ } else {
+ var openErr error
+ goFile, openErr = os.Open("./../../go.mod")
+ if openErr != nil {
+ return "", openErr
+ }
+ defer goFile.Close()
+ }
+
+ scanner := bufio.NewScanner(goFile)
for scanner.Scan() {
line := scanner.Text()
+ // log.Debug().Msgf("go.mod line : [%s]", line)
+
if strings.Contains(line, moduleName) {
parts := strings.Fields(line)
if len(parts) >= 2 {
@@ -104,3 +132,28 @@ func getModuleVersion(moduleName string) (string, error) {
}
return "", fmt.Errorf("Module [%s] not found", moduleName)
}
+
+func isRunningInContainer() bool {
+ interfaces, _ := net.Interfaces()
+ for _, iface := range interfaces {
+ // log.Debug().Msgf("iface.Name: [%v]", iface.Name)
+ if strings.HasPrefix(iface.Name, "docker") {
+ return true
+ }
+ }
+ return false
+
+ // file, err := os.Open("/proc/1/cgroup")
+ // if err != nil {
+ // return false
+ // }
+ // defer file.Close()
+
+ // scanner := bufio.NewScanner(file)
+ // for scanner.Scan() {
+ // if strings.Contains(scanner.Text(), "docker") || strings.Contains(scanner.Text(), "kubepods") {
+ // return true
+ // }
+ // }
+ // return false
+}
diff --git a/pkg/api/rest/handler/model.go b/pkg/api/rest/handler/model.go
index 9dcce54..d6ff892 100644
--- a/pkg/api/rest/handler/model.go
+++ b/pkg/api/rest/handler/model.go
@@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
// "reflect"
+ // "encoding/json"
"strconv"
"strings"
"github.com/labstack/echo/v4"
@@ -16,7 +17,7 @@ import (
)
// ##############################################################################################
-// ### On-premise and Cloud Migration Model
+// ### On-premise and Cloud Migration User Model
// ##############################################################################################
type ModelRespInfo struct {
@@ -49,7 +50,7 @@ type GetModelsResp struct {
// GetModels godoc
// @Summary Get a list of all user models
// @Description Get a list of all user models.
-// @Tags [API] Migration Models
+// @Tags [API] Migration User Models
// @Accept json
// @Produce json
// @Param isTargetModel path bool true "Is TargetModel ?"
@@ -112,8 +113,50 @@ func GetModels(c echo.Context) error {
}
}
+type ModelsVersionRespInfo struct {
+ OnPremModelVer string `json:"onpremModelVersion"`
+ CloudModelVer string `json:"cloudModelVersion"`
+}
+
+type GetModelsVersionResp struct {
+ ModelsVersion ModelsVersionRespInfo `json:"modelsVersion"`
+}
+
+// GetModelsVersion godoc
+// @Summary Get the versions of all models(schemata of on-premise/cloud migration models)
+// @Description Get the versions of all models(schemata of on-premise/cloud migration models)
+// @Tags [API] Migration Models
+// @Accept json
+// @Produce json
+// @Success 200 {object} GetModelsVersionResp "(sample) This is the versions of all models(schemata)"
+// @Failure 404 {object} object "verson of models not found"
+// @Router /model/version [get]
+func GetModelsVersion(c echo.Context) error {
+
+ onpremModelVer, err := getModuleVersion("github.com/cloud-barista/cm-model")
+ if err != nil {
+ log.Error().Msgf("Failed to Get the Module Version : [%v]", err)
+ }
+
+ cloudModelVer, err := getModuleVersion("github.com/cloud-barista/cb-tumblebug")
+ if err != nil {
+ log.Error().Msgf("Failed to Get the Module Version : [%v]", err)
+ }
+
+ modelsVersionInfo := ModelsVersionRespInfo{
+ OnPremModelVer: onpremModelVer,
+ CloudModelVer: cloudModelVer,
+ }
+
+ response := GetModelsVersionResp{
+ ModelsVersion: modelsVersionInfo,
+ }
+
+ return c.JSON(http.StatusOK, response)
+}
+
// ##############################################################################################
-// ### On-premise Migration Model
+// ### On-premise Migration User Model
// ##############################################################################################
type OnPremModelReqInfo struct {
@@ -150,7 +193,7 @@ type GetOnPremModelsResp struct {
// GetOnPremModels godoc
// @Summary Get a list of on-premise models
// @Description Get a list of on-premise models.
-// @Tags [API] On-Premise Migration Models
+// @Tags [API] On-Premise Migration User Models
// @Accept json
// @Produce json
// @Success 200 {object} GetOnPremModelsResp "(sample) This is a list of models"
@@ -211,7 +254,7 @@ type GetOnPremModelResp struct {
// GetOnPremModel godoc
// @Summary Get a specific on-premise model
// @Description Get a specific on-premise model.
-// @Tags [API] On-Premise Migration Models
+// @Tags [API] On-Premise Migration User Models
// @Accept json
// @Produce json
// @Param id path string true "Model ID"
@@ -374,7 +417,7 @@ type CreateOnPremModelResp struct {
// CreateOnPremModel godoc
// @Summary Create a new on-premise model
// @Description Create a new on-premise model with the given information.
-// @Tags [API] On-Premise Migration Models
+// @Tags [API] On-Premise Migration User Models
// @Accept json
// @Produce json
// @Param Model body CreateOnPremModelReq true "model information"
@@ -441,7 +484,7 @@ type UpdateOnPremModelResp struct {
// UpdateOnPremModel godoc
// @Summary Update a on-premise model
// @Description Update a on-premise model with the given information.
-// @Tags [API] On-Premise Migration Models
+// @Tags [API] On-Premise Migration User Models
// @Accept json
// @Produce json
// @Param id path string true "Model ID"
@@ -596,7 +639,7 @@ func UpdateOnPremModel(c echo.Context) error {
// DeleteOnPremModel godoc
// @Summary Delete a on-premise model
// @Description Delete a on-premise model with the given information.
-// @Tags [API] On-Premise Migration Models
+// @Tags [API] On-Premise Migration User Models
// @Accept json
// @Produce json
// @Param id path string true "Model ID"
@@ -653,7 +696,7 @@ func DeleteOnPremModel(c echo.Context) error {
}
// ##############################################################################################
-// ### Cloud Migration Model
+// ### Cloud Migration User Model
// ##############################################################################################
type CloudModelReqInfo struct {
@@ -697,7 +740,7 @@ type GetCloudModelsResp struct {
// GetCloudModels godoc
// @Summary Get a list of cloud models
// @Description Get a list of cloud models.
-// @Tags [API] Cloud Migration Models
+// @Tags [API] Cloud Migration User Models
// @Accept json
// @Produce json
// @Success 200 {object} GetCloudModelsResp "(sample) This is a list of models"
@@ -739,7 +782,7 @@ type GetCloudModelResp struct {
// GetCloudModel godoc
// @Summary Get a specific cloud model
// @Description Get a specific cloud model.
-// @Tags [API] Cloud Migration Models
+// @Tags [API] Cloud Migration User Models
// @Accept json
// @Produce json
// @Param id path string true "Model ID"
@@ -799,7 +842,7 @@ type CreateCloudModelResp struct {
// CreateCloudModel godoc
// @Summary Create a new cloud model
// @Description Create a new cloud model with the given information.
-// @Tags [API] Cloud Migration Models
+// @Tags [API] Cloud Migration User Models
// @Accept json
// @Produce json
// @Param Model body CreateCloudModelReq true "model information"
@@ -866,7 +909,7 @@ type UpdateCloudModelResp struct {
// UpdateCloudModel godoc
// @Summary Update a cloud model
// @Description Update a cloud model with the given information.
-// @Tags [API] Cloud Migration Models
+// @Tags [API] Cloud Migration User Models
// @Accept json
// @Produce json
// @Param id path string true "Model ID"
@@ -993,7 +1036,7 @@ func UpdateCloudModel(c echo.Context) error {
// DeleteCloudModel godoc
// @Summary Delete a cloud model
// @Description Delete a cloud model with the given information.
-// @Tags [API] Cloud Migration Models
+// @Tags [API] Cloud Migration User Models
// @Accept json
// @Produce json
// @Param id path string true "Model ID"
diff --git a/pkg/api/rest/server.go b/pkg/api/rest/server.go
index 610384c..2d322a8 100644
--- a/pkg/api/rest/server.go
+++ b/pkg/api/rest/server.go
@@ -169,6 +169,7 @@ func RunServer(port string) {
// gModel := groupBase.Group("/model")
gModel.GET("/model/:isTargetModel", handler.GetModels)
+ gModel.GET("/model/version", handler.GetModelsVersion)
gModel.POST("/onpremmodel", handler.CreateOnPremModel)
gModel.GET("/onpremmodel", handler.GetOnPremModels)
diff --git a/pkg/lkvstore/lkvstore.go b/pkg/lkvstore/lkvstore.go
index c92cbb0..255c037 100644
--- a/pkg/lkvstore/lkvstore.go
+++ b/pkg/lkvstore/lkvstore.go
@@ -7,6 +7,8 @@ import (
"os"
"strings"
"sync"
+ "path/filepath"
+ "github.com/rs/zerolog/log"
)
var (
@@ -32,6 +34,16 @@ func SaveLkvStore() error {
return fmt.Errorf("db file path is not set")
}
+ // Ensure the DB file directory exists before creating the log file
+ dir := filepath.Dir(dbFilePath)
+ if _, err := os.Stat(dir); os.IsNotExist(err) {
+ // Create the directory if it does not exist
+ err = os.MkdirAll(dir, 0755) // Set permissions as needed
+ if err != nil {
+ log.Error().Msgf("Failed to Create the DB Directory: : [%v]", err)
+ }
+ }
+
file, err := os.Create(dbFilePath)
if err != nil {
return fmt.Errorf("failed to create db file: %w", err)
diff --git a/setup.env b/setup.env
deleted file mode 100644
index 160124e..0000000
--- a/setup.env
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-export CBLOG_ROOT=$HOME/go/src/github.com/cloud-barista/cb-log
-export MODEL_ROOT=$HOME/go/src/github.com/cloud-barista/cm-damselfly