Skip to content

Commit

Permalink
Generate task componets dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Oct 31, 2024
1 parent 0a2522b commit 6985a03
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 979 deletions.
8 changes: 0 additions & 8 deletions conf/cm-cicada.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ cm-cicada:
schema: http
login: default
password: default
- id: tumblebug_api
type: http
description: TumbleBug API
host: 192.168.110.14
port: 1323
schema: http
login: default
password: default
dag_directory_host: "./_airflow/airflow-home/dags"
dag_directory_container: "/usr/local/airflow/dags" # Use dag_directory_host for dag_directory_container, if this value is empty
listen:
Expand Down
10 changes: 7 additions & 3 deletions dao/taskComponent.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ func TaskComponentGetList(page int, row int) (*[]model.TaskComponent, error) {
}

func TaskComponentCreate(taskComponent *model.TaskComponent) (*model.TaskComponent, error) {
taskComponent.CreatedAt = time.Now()
taskComponent.UpdatedAt = time.Now()
now := time.Now()

taskComponent.CreatedAt = now
taskComponent.UpdatedAt = now

result := db.DB.Create(taskComponent)
result := db.DB.Session(&gorm.Session{SkipHooks: true}).Create(taskComponent)
err := result.Error
if err != nil {
return nil, err
Expand All @@ -74,6 +76,8 @@ func TaskComponentCreate(taskComponent *model.TaskComponent) (*model.TaskCompone
}

func TaskComponentUpdate(taskComponent *model.TaskComponent) error {
taskComponent.UpdatedAt = time.Now()

result := db.DB.Model(&model.TaskComponent{}).Where("id = ?", taskComponent.ID).Updates(taskComponent)
err := result.Error
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions dao/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
)

func WorkflowCreate(workflow *model.Workflow) (*model.Workflow, error) {
workflow.CreatedAt = time.Now()
workflow.UpdatedAt = time.Now()
now := time.Now()

workflow.CreatedAt = now
workflow.UpdatedAt = now

result := db.DB.Create(workflow)
result := db.DB.Session(&gorm.Session{SkipHooks: true}).Create(workflow)
err := result.Error
if err != nil {
return nil, err
Expand Down
100 changes: 5 additions & 95 deletions lib/airflow/example/task_component/beetle_task_infra_migration.json
Original file line number Diff line number Diff line change
@@ -1,97 +1,7 @@
{
"name": "beetle_task_infra_migration",
"description": "Do infra migration with beetle.",
"data": {
"options": {
"api_connection_id": "beetle_api",
"endpoint": "/beetle/migration/ns/mig01/mci",
"method": "POST",
"request_body": "{\n \"name\": \"recommended-infra01\",\n \"installMonAgent\": \"no\",\n \"label\": \"DynamicVM\",\n \"systemLabel\": \"\",\n \"description\": \"Made in CB-TB\",\n \"vm\": [\n {\n \"name\": \"recommended-vm01\",\n \"subGroupSize\": \"3\",\n \"label\": \"DynamicVM\",\n \"description\": \"Description\",\n \"commonSpec\": \"azure+koreacentral+standard_b4ls_v2\",\n \"commonImage\": \"azure+koreacentral+ubuntu22.04\",\n \"rootDiskType\": \"default\",\n \"rootDiskSize\": \"default\",\n \"vmUserPassword\": \"test\",\n \"connectionName\": \"azure-koreacentral\"\n }\n ]\n}"
},
"param_option": {
"params": {
"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": "yes",
"enum": ["yes", "no"],
"example": "no"
},
"label": {
"description": "Label is for describing the mcis in a keyword (any string can be used)",
"type": "string",
"example": "DynamicVM"
},
"name": {
"type": "string",
"example": "mcis01"
},
"systemLabel": {
"description": "SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose",
"type": "string",
"example": ""
},
"vm": {
"type": "array",
"items": {
"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. if not, it will use predefined ConnectionName in Spec objects",
"type": "string"
},
"description": {
"type": "string",
"example": "Description"
},
"label": {
"type": "string",
"example": "DynamicVM"
},
"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.",
"type": "string",
"example": "g1-1"
},
"rootDiskSize": {
"description": "\"default\", Integer (GB): [\"50\", ..., \"1000\"]",
"type": "string",
"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",
"example": "default, TYPE1, ..."
},
"subGroupSize": {
"description": "if subGroupSize is (not empty) && (> 0), subGroup will be gernetad. VMs will be created accordingly.",
"type": "string",
"example": "3"
},
"vmUserPassword": {
"type": "string"
}
}
}
}
}
}
}
}
"name": "beetle_task_recommend_infra",
"description": "Do infra recommendation with beetle.",
"api_connection_id": "beetle_api",
"swagger_yaml_endpoint": "/beetle/api/doc.yaml",
"endpoint": "/migration/ns/{nsId}/mci"
}
Loading

0 comments on commit 6985a03

Please sign in to comment.