From 07662afb30c2e308ecafa24e4418695c03d8bac3 Mon Sep 17 00:00:00 2001 From: Yunkon Kim Date: Mon, 9 Sep 2024 17:59:57 +0900 Subject: [PATCH 1/2] Update README of system-info --- scripts/system-info/README.md | 40 +++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/scripts/system-info/README.md b/scripts/system-info/README.md index a77a2f8..aac2336 100644 --- a/scripts/system-info/README.md +++ b/scripts/system-info/README.md @@ -5,8 +5,17 @@ It can be useful for extracting and referencing the configuration of the source This script helps to quickly understand the current state of the system and diagnose issues. It is useful for checking and referencing the configuration of the source computing environment for the cloud migrator project. +## Prerequisites + +Ensure the apt packages are intstalled. + +```bash +sudo apt-get install python3-dev +``` + ## Tested on -- `Python 3.8.10` + +- `Python 3.10.12` - `pip 20.0.2` ## Dependencies @@ -18,7 +27,22 @@ It is useful for checking and referencing the configuration of the source comput - `GPUtil` - `distro` +### Setup venv (optional) + +```bash +cd [PROJECT_ROOT]/scripts/system-info +python3 -m venv .venv +source .venv/bin/activate +``` + +Note - deactivate venv + +```bash +deactivate +``` + ### Install dependencies + ```bash pip3 install -r requirements.txt ``` @@ -32,6 +56,7 @@ python3 system_info.py ## Features ### 1. OS Information Collection + Collects OS name, version, architecture, platform, boot time, currently logged-in user, kernel version, and distribution information. ```python @@ -45,6 +70,7 @@ def get_os_info(): ``` ### 2. CPU Information Collection + Collects CPU brand, core count, current frequency, context switches, interrupts, architecture, user time, system time, and idle time. ```python @@ -58,6 +84,7 @@ def get_cpu_info(): ``` ### 3. Memory Information Collection + Collects total memory, available memory, used memory, cached memory, and swap memory information. ```python @@ -71,6 +98,7 @@ def get_memory_info(): ``` ### 4. Disk Information Collection + Collects total disk capacity, available capacity, used capacity, read and write count. ```python @@ -84,6 +112,7 @@ def get_disk_info(): ``` ### 5. Network Information Collection + Collects host name, IP address, MAC address, active network interfaces, gateway, and DNS information. ```python @@ -97,6 +126,7 @@ def get_network_info(): ``` ### 6. Advanced Network Information Collection + Collects IP address, netmask, broadcast, and MAC address of each network interface. ```python @@ -107,6 +137,7 @@ def get_advanced_network_info(): ``` ### 7. GPU Information Collection + Collects GPU name and driver version (if GPUtil is installed). ```python @@ -117,6 +148,7 @@ def get_gpu_info(): ``` ### 8. Graphic Card Information Collection + Collects VGA compatible controller information. ```python @@ -126,6 +158,7 @@ def get_graphic_card_info(): ``` ### 9. Process Information Collection + Collects information on all running processes and users on the system. ```python @@ -136,6 +169,7 @@ def get_process_info(): ``` ### 10. Data Saving + Saves all collected system information to a YAML file. ```python @@ -145,9 +179,11 @@ def save_to_yaml(data): ``` ## Output + The collected information is printed to the console in a neat table format, and is also saved to a `system_info.yaml` file. Example + ``` System Information: +-------+--------------+-----------------------+----------------------------------------------------------+ @@ -266,4 +302,4 @@ Process Information: | systemd-resolve | systemd-resolved | | whoopsie | whoopsie | +-----------------+--------------------------------------------------------------------------------+ -``` \ No newline at end of file +``` From 46ccf2ac8735d79bca745ac581a90ac1935836b9 Mon Sep 17 00:00:00 2001 From: Yunkon Kim Date: Mon, 9 Sep 2024 22:43:21 +0900 Subject: [PATCH 2/2] Apply on-premise model and align with Tumblebug v0.9.11 APIs * Apply onprem model (as known as source model) from cm-model repository * Replace `defaultResources` API with `sharedResources` API * Test APIs of recommendation and migration infrastructure * Update `docker-compose.yaml ` * Update API docs --- api/docs.go | 665 ++++-------------- api/swagger.json | 665 ++++-------------- api/swagger.yaml | 476 +++---------- .../docker-compose/docker-compose.yaml | 4 +- go.mod | 9 +- go.sum | 8 +- go.work.sum | 15 + pkg/api/rest/controller/recommendation.go | 8 +- pkg/core/migration/migration.go | 10 +- pkg/core/recommendation/recommendation.go | 33 +- 10 files changed, 427 insertions(+), 1466 deletions(-) diff --git a/api/docs.go b/api/docs.go index 3d13218..06fe610 100644 --- a/api/docs.go +++ b/api/docs.go @@ -723,10 +723,13 @@ const docTemplate = `{ "servers" ], "properties": { + "network": { + "$ref": "#/definitions/onprem.NetworkProperty" + }, "servers": { "type": "array", "items": { - "$ref": "#/definitions/infra.Infra" + "$ref": "#/definitions/onprem.ServerProperty" } } } @@ -773,369 +776,6 @@ const docTemplate = `{ } } }, - "infra.CPU": { - "type": "object", - "required": [ - "cores", - "cpus", - "threads" - ], - "properties": { - "cache": { - "description": "KB", - "type": "integer" - }, - "cores": { - "description": "ea", - "type": "integer" - }, - "cpus": { - "description": "ea", - "type": "integer" - }, - "max_speed": { - "description": "MHz", - "type": "integer" - }, - "model": { - "type": "string" - }, - "threads": { - "description": "ea", - "type": "integer" - }, - "vendor": { - "type": "string" - } - } - }, - "infra.Compute": { - "type": "object", - "required": [ - "compute_resource", - "os" - ], - "properties": { - "compute_resource": { - "$ref": "#/definitions/infra.ComputeResource" - }, - "connection": { - "type": "array", - "items": { - "$ref": "#/definitions/infra.Connection" - } - }, - "os": { - "$ref": "#/definitions/infra.System" - } - } - }, - "infra.ComputeResource": { - "type": "object", - "required": [ - "cpu", - "memory" - ], - "properties": { - "cpu": { - "$ref": "#/definitions/infra.CPU" - }, - "data_disk": { - "type": "array", - "items": { - "$ref": "#/definitions/infra.Disk" - } - }, - "memory": { - "$ref": "#/definitions/infra.Memory" - }, - "root_disk": { - "$ref": "#/definitions/infra.Disk" - } - } - }, - "infra.Connection": { - "type": "object", - "properties": { - "keypair": { - "$ref": "#/definitions/infra.Keypair" - } - } - }, - "infra.DRM": { - "type": "object", - "properties": { - "driver_date": { - "type": "string" - }, - "driver_description": { - "type": "string" - }, - "driver_name": { - "type": "string" - }, - "driver_version": { - "type": "string" - } - } - }, - "infra.Disk": { - "type": "object", - "properties": { - "label": { - "type": "string" - }, - "size": { - "description": "GB", - "type": "integer" - }, - "type": { - "type": "string" - } - } - }, - "infra.GPU": { - "type": "object", - "properties": { - "drm": { - "type": "array", - "items": { - "$ref": "#/definitions/infra.DRM" - } - }, - "nvidia": { - "type": "array", - "items": { - "$ref": "#/definitions/infra.NVIDIA" - } - } - } - }, - "infra.Infra": { - "type": "object", - "properties": { - "compute": { - "$ref": "#/definitions/infra.Compute" - }, - "gpu": { - "$ref": "#/definitions/infra.GPU" - }, - "network": { - "$ref": "#/definitions/network.Network" - }, - "storage": { - "$ref": "#/definitions/infra.Storage" - } - } - }, - "infra.Kernel": { - "type": "object", - "properties": { - "architecture": { - "type": "string" - }, - "release": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "infra.Keypair": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "private_key": { - "type": "string" - }, - "public_key": { - "type": "string" - } - } - }, - "infra.Memory": { - "type": "object", - "required": [ - "size" - ], - "properties": { - "size": { - "description": "MB", - "type": "integer" - }, - "speed": { - "description": "MHz", - "type": "integer" - }, - "type": { - "type": "string" - } - } - }, - "infra.MountPoint": { - "type": "object", - "properties": { - "mounted_information": { - "type": "array", - "items": { - "$ref": "#/definitions/infra.MountedInformation" - } - } - } - }, - "infra.MountedInformation": { - "type": "object", - "properties": { - "destination": { - "type": "string" - }, - "filesystem": { - "type": "string" - }, - "option": { - "type": "string" - }, - "source": { - "type": "string" - } - } - }, - "infra.NVIDIA": { - "type": "object", - "properties": { - "device_attribute": { - "$ref": "#/definitions/infra.NVIDIADeviceAttribute" - }, - "performance": { - "$ref": "#/definitions/infra.NVIDIAPerformance" - } - } - }, - "infra.NVIDIADeviceAttribute": { - "type": "object", - "properties": { - "cuda_version": { - "type": "string" - }, - "driver_version": { - "type": "string" - }, - "gpu_uuid": { - "type": "string" - }, - "product_architecture": { - "type": "string" - }, - "product_brand": { - "type": "string" - }, - "product_name": { - "type": "string" - } - } - }, - "infra.NVIDIAPerformance": { - "type": "object", - "properties": { - "bar1_memory_total": { - "description": "mb", - "type": "integer" - }, - "bar1_memory_usage": { - "description": "percent", - "type": "integer" - }, - "bar1_memory_used": { - "description": "mb", - "type": "integer" - }, - "fb_memory_total": { - "description": "mb", - "type": "integer" - }, - "fb_memory_usage": { - "description": "percent", - "type": "integer" - }, - "fb_memory_used": { - "description": "mb", - "type": "integer" - }, - "gpu_usage": { - "description": "percent", - "type": "integer" - } - } - }, - "infra.Node": { - "type": "object", - "properties": { - "hostname": { - "type": "string" - }, - "hypervisor": { - "type": "string" - }, - "machineid": { - "type": "string" - }, - "timezone": { - "type": "string" - } - } - }, - "infra.OS": { - "type": "object", - "required": [ - "release", - "vendor" - ], - "properties": { - "architecture": { - "type": "string" - }, - "name": { - "type": "string" - }, - "release": { - "type": "string" - }, - "vendor": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "infra.Storage": { - "type": "object", - "properties": { - "mount_point": { - "$ref": "#/definitions/infra.MountPoint" - } - } - }, - "infra.System": { - "type": "object", - "required": [ - "os" - ], - "properties": { - "kernel": { - "$ref": "#/definitions/infra.Kernel" - }, - "node": { - "$ref": "#/definitions/infra.Node" - }, - "os": { - "$ref": "#/definitions/infra.OS" - } - } - }, "model.MyUser": { "type": "object", "properties": { @@ -1275,243 +915,200 @@ const docTemplate = `{ } } }, - "network.CSP": { + "onprem.CpuProperty": { "type": "object", + "required": [ + "cores", + "cpus", + "threads" + ], "properties": { - "name": { - "type": "string" + "architecture": { + "type": "string", + "example": "x86_64" }, - "nlb": { - "type": "array", - "items": { - "$ref": "#/definitions/network.NLB" - } + "cores": { + "description": "Number of physical cores per CPU", + "type": "integer", + "example": 18 }, - "security_group": { - "type": "array", - "items": { - "$ref": "#/definitions/network.SecurityGroup" - } + "cpus": { + "description": "Number of physical CPUs (sockets)", + "type": "integer", + "example": 2 }, - "vpc": { - "type": "array", - "items": { - "$ref": "#/definitions/network.VPC" - } - } - } - }, - "network.DNS": { - "type": "object", - "properties": { - "dns_server": { - "description": "IPv4 or IPv6 DNS Server Addresses", - "type": "array", - "items": { - "type": "string" - } + "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" } } }, - "network.FirewallRule": { + "onprem.DiskProperty": { "type": "object", + "required": [ + "label", + "totalSize", + "type" + ], "properties": { - "action": { - "description": "allow, deny", - "type": "string" + "available": { + "description": "Unit GiB", + "type": "integer" }, - "direction": { - "description": "inbound, outbound", + "label": { "type": "string" }, - "dst": { - "type": "string" + "totalSize": { + "description": "Unit GiB", + "type": "integer", + "example": 1024 }, - "dst_ports": { - "type": "string" + "type": { + "description": "SSD, HDD", + "type": "string", + "example": "SSD" }, - "priority": { - "description": "Lower has higher priority", + "used": { + "description": "Unit GiB", "type": "integer" - }, - "protocol": { - "description": "TCP, UDP, ICMP", - "type": "string" - }, - "src": { - "type": "string" - }, - "src_ports": { - "type": "string" } } }, - "network.Host": { + "onprem.MemoryProperty": { "type": "object", + "required": [ + "totalSize", + "type" + ], "properties": { - "dns": { - "$ref": "#/definitions/network.DNS" + "available": { + "description": "Unit GiB", + "type": "integer" }, - "firewall_rule": { - "type": "array", - "items": { - "$ref": "#/definitions/network.FirewallRule" - } + "totalSize": { + "description": "Unit GiB", + "type": "integer", + "example": 128 }, - "network_interface": { - "type": "array", - "items": { - "$ref": "#/definitions/network.NIC" - } + "type": { + "type": "string", + "example": "DDR4" }, - "route": { - "type": "array", - "items": { - "$ref": "#/definitions/network.Route" - } + "used": { + "description": "Unit GiB", + "type": "integer" } } }, - "network.NIC": { + "onprem.NetworkInterfaceProperty": { "type": "object", + "required": [ + "ipAddress" + ], "properties": { - "address": { - "type": "array", - "items": { - "type": "string" - } - }, - "gateway": { - "type": "array", - "items": { - "type": "string" - } - }, - "interface": { + "ipAddress": { "type": "string" }, - "mac_address": { + "macAddress": { "type": "string" }, "mtu": { + "description": "Maximum Transmission Unit (MTU) in bytes", "type": "integer" } } }, - "network.NLB": { + "onprem.NetworkProperty": { "type": "object", "properties": { - "description": { - "type": "string" - }, - "health_checker": { - "type": "string" - }, - "id": { - "type": "string" - }, - "listener": { - "type": "string" - }, - "name": { - "type": "string" - }, - "target_group": { - "type": "string" - } - } - }, - "network.Network": { - "type": "object", - "properties": { - "csp": { - "$ref": "#/definitions/network.CSP" - }, - "host": { - "$ref": "#/definitions/network.Host" + "gateway": { + "description": "Gateway IP address", + "type": "string", + "example": "172.26.240.0/20" } } }, - "network.Route": { + "onprem.OsProperty": { "type": "object", + "required": [ + "prettyName" + ], "properties": { - "destination": { - "type": "string" + "id": { + "type": "string", + "example": "ubuntu" }, - "netmask": { - "type": "string" + "idLike": { + "type": "string", + "example": "debian" }, - "next_hop": { - "type": "string" - } - } - }, - "network.SecurityGroup": { - "type": "object", - "properties": { - "description": { - "type": "string" + "name": { + "type": "string", + "example": "Ubuntu" }, - "firewall_rule": { - "type": "array", - "items": { - "$ref": "#/definitions/network.FirewallRule" - } + "prettyName": { + "description": "Pretty name", + "type": "string", + "example": "Ubuntu 22.04.3 LTS" }, - "id": { - "type": "string" + "version": { + "description": "Full version string", + "type": "string", + "example": "22.04.3 LTS (Jammy Jellyfish)" }, - "name": { - "type": "string" + "versionCodename": { + "type": "string", + "example": "jammy" }, - "vnet_id": { - "type": "string" + "versionId": { + "type": "string", + "example": "22.04" } } }, - "network.Subnet": { + "onprem.ServerProperty": { "type": "object", "properties": { - "ipv4_cidr": { - "description": "IPv4 Network Address with CIDR Prefix Length", - "type": "string" - }, - "ipv6_cidr": { - "description": "IPv6 Network Address with CIDR Prefix Length", - "type": "string" + "cpu": { + "$ref": "#/definitions/onprem.CpuProperty" }, - "name": { - "type": "string" - } - } - }, - "network.VPC": { - "type": "object", - "properties": { - "address_space": { - "description": "IPv4 CIDR or IPv6 CIDR", + "dataDisks": { "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/onprem.DiskProperty" } }, - "dns_server": { + "hostname": { + "type": "string" + }, + "interfaces": { "type": "array", "items": { - "$ref": "#/definitions/network.DNS" + "$ref": "#/definitions/onprem.NetworkInterfaceProperty" } }, - "id": { - "type": "string" + "memory": { + "$ref": "#/definitions/onprem.MemoryProperty" }, - "region": { - "type": "string" + "os": { + "$ref": "#/definitions/onprem.OsProperty" }, - "subnet": { - "type": "array", - "items": { - "$ref": "#/definitions/network.Subnet" - } + "rootDisk": { + "$ref": "#/definitions/onprem.DiskProperty" } } } diff --git a/api/swagger.json b/api/swagger.json index 08095c8..d513810 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -716,10 +716,13 @@ "servers" ], "properties": { + "network": { + "$ref": "#/definitions/onprem.NetworkProperty" + }, "servers": { "type": "array", "items": { - "$ref": "#/definitions/infra.Infra" + "$ref": "#/definitions/onprem.ServerProperty" } } } @@ -766,369 +769,6 @@ } } }, - "infra.CPU": { - "type": "object", - "required": [ - "cores", - "cpus", - "threads" - ], - "properties": { - "cache": { - "description": "KB", - "type": "integer" - }, - "cores": { - "description": "ea", - "type": "integer" - }, - "cpus": { - "description": "ea", - "type": "integer" - }, - "max_speed": { - "description": "MHz", - "type": "integer" - }, - "model": { - "type": "string" - }, - "threads": { - "description": "ea", - "type": "integer" - }, - "vendor": { - "type": "string" - } - } - }, - "infra.Compute": { - "type": "object", - "required": [ - "compute_resource", - "os" - ], - "properties": { - "compute_resource": { - "$ref": "#/definitions/infra.ComputeResource" - }, - "connection": { - "type": "array", - "items": { - "$ref": "#/definitions/infra.Connection" - } - }, - "os": { - "$ref": "#/definitions/infra.System" - } - } - }, - "infra.ComputeResource": { - "type": "object", - "required": [ - "cpu", - "memory" - ], - "properties": { - "cpu": { - "$ref": "#/definitions/infra.CPU" - }, - "data_disk": { - "type": "array", - "items": { - "$ref": "#/definitions/infra.Disk" - } - }, - "memory": { - "$ref": "#/definitions/infra.Memory" - }, - "root_disk": { - "$ref": "#/definitions/infra.Disk" - } - } - }, - "infra.Connection": { - "type": "object", - "properties": { - "keypair": { - "$ref": "#/definitions/infra.Keypair" - } - } - }, - "infra.DRM": { - "type": "object", - "properties": { - "driver_date": { - "type": "string" - }, - "driver_description": { - "type": "string" - }, - "driver_name": { - "type": "string" - }, - "driver_version": { - "type": "string" - } - } - }, - "infra.Disk": { - "type": "object", - "properties": { - "label": { - "type": "string" - }, - "size": { - "description": "GB", - "type": "integer" - }, - "type": { - "type": "string" - } - } - }, - "infra.GPU": { - "type": "object", - "properties": { - "drm": { - "type": "array", - "items": { - "$ref": "#/definitions/infra.DRM" - } - }, - "nvidia": { - "type": "array", - "items": { - "$ref": "#/definitions/infra.NVIDIA" - } - } - } - }, - "infra.Infra": { - "type": "object", - "properties": { - "compute": { - "$ref": "#/definitions/infra.Compute" - }, - "gpu": { - "$ref": "#/definitions/infra.GPU" - }, - "network": { - "$ref": "#/definitions/network.Network" - }, - "storage": { - "$ref": "#/definitions/infra.Storage" - } - } - }, - "infra.Kernel": { - "type": "object", - "properties": { - "architecture": { - "type": "string" - }, - "release": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "infra.Keypair": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "private_key": { - "type": "string" - }, - "public_key": { - "type": "string" - } - } - }, - "infra.Memory": { - "type": "object", - "required": [ - "size" - ], - "properties": { - "size": { - "description": "MB", - "type": "integer" - }, - "speed": { - "description": "MHz", - "type": "integer" - }, - "type": { - "type": "string" - } - } - }, - "infra.MountPoint": { - "type": "object", - "properties": { - "mounted_information": { - "type": "array", - "items": { - "$ref": "#/definitions/infra.MountedInformation" - } - } - } - }, - "infra.MountedInformation": { - "type": "object", - "properties": { - "destination": { - "type": "string" - }, - "filesystem": { - "type": "string" - }, - "option": { - "type": "string" - }, - "source": { - "type": "string" - } - } - }, - "infra.NVIDIA": { - "type": "object", - "properties": { - "device_attribute": { - "$ref": "#/definitions/infra.NVIDIADeviceAttribute" - }, - "performance": { - "$ref": "#/definitions/infra.NVIDIAPerformance" - } - } - }, - "infra.NVIDIADeviceAttribute": { - "type": "object", - "properties": { - "cuda_version": { - "type": "string" - }, - "driver_version": { - "type": "string" - }, - "gpu_uuid": { - "type": "string" - }, - "product_architecture": { - "type": "string" - }, - "product_brand": { - "type": "string" - }, - "product_name": { - "type": "string" - } - } - }, - "infra.NVIDIAPerformance": { - "type": "object", - "properties": { - "bar1_memory_total": { - "description": "mb", - "type": "integer" - }, - "bar1_memory_usage": { - "description": "percent", - "type": "integer" - }, - "bar1_memory_used": { - "description": "mb", - "type": "integer" - }, - "fb_memory_total": { - "description": "mb", - "type": "integer" - }, - "fb_memory_usage": { - "description": "percent", - "type": "integer" - }, - "fb_memory_used": { - "description": "mb", - "type": "integer" - }, - "gpu_usage": { - "description": "percent", - "type": "integer" - } - } - }, - "infra.Node": { - "type": "object", - "properties": { - "hostname": { - "type": "string" - }, - "hypervisor": { - "type": "string" - }, - "machineid": { - "type": "string" - }, - "timezone": { - "type": "string" - } - } - }, - "infra.OS": { - "type": "object", - "required": [ - "release", - "vendor" - ], - "properties": { - "architecture": { - "type": "string" - }, - "name": { - "type": "string" - }, - "release": { - "type": "string" - }, - "vendor": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "infra.Storage": { - "type": "object", - "properties": { - "mount_point": { - "$ref": "#/definitions/infra.MountPoint" - } - } - }, - "infra.System": { - "type": "object", - "required": [ - "os" - ], - "properties": { - "kernel": { - "$ref": "#/definitions/infra.Kernel" - }, - "node": { - "$ref": "#/definitions/infra.Node" - }, - "os": { - "$ref": "#/definitions/infra.OS" - } - } - }, "model.MyUser": { "type": "object", "properties": { @@ -1268,243 +908,200 @@ } } }, - "network.CSP": { + "onprem.CpuProperty": { "type": "object", + "required": [ + "cores", + "cpus", + "threads" + ], "properties": { - "name": { - "type": "string" + "architecture": { + "type": "string", + "example": "x86_64" }, - "nlb": { - "type": "array", - "items": { - "$ref": "#/definitions/network.NLB" - } + "cores": { + "description": "Number of physical cores per CPU", + "type": "integer", + "example": 18 }, - "security_group": { - "type": "array", - "items": { - "$ref": "#/definitions/network.SecurityGroup" - } + "cpus": { + "description": "Number of physical CPUs (sockets)", + "type": "integer", + "example": 2 }, - "vpc": { - "type": "array", - "items": { - "$ref": "#/definitions/network.VPC" - } - } - } - }, - "network.DNS": { - "type": "object", - "properties": { - "dns_server": { - "description": "IPv4 or IPv6 DNS Server Addresses", - "type": "array", - "items": { - "type": "string" - } + "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" } } }, - "network.FirewallRule": { + "onprem.DiskProperty": { "type": "object", + "required": [ + "label", + "totalSize", + "type" + ], "properties": { - "action": { - "description": "allow, deny", - "type": "string" + "available": { + "description": "Unit GiB", + "type": "integer" }, - "direction": { - "description": "inbound, outbound", + "label": { "type": "string" }, - "dst": { - "type": "string" + "totalSize": { + "description": "Unit GiB", + "type": "integer", + "example": 1024 }, - "dst_ports": { - "type": "string" + "type": { + "description": "SSD, HDD", + "type": "string", + "example": "SSD" }, - "priority": { - "description": "Lower has higher priority", + "used": { + "description": "Unit GiB", "type": "integer" - }, - "protocol": { - "description": "TCP, UDP, ICMP", - "type": "string" - }, - "src": { - "type": "string" - }, - "src_ports": { - "type": "string" } } }, - "network.Host": { + "onprem.MemoryProperty": { "type": "object", + "required": [ + "totalSize", + "type" + ], "properties": { - "dns": { - "$ref": "#/definitions/network.DNS" + "available": { + "description": "Unit GiB", + "type": "integer" }, - "firewall_rule": { - "type": "array", - "items": { - "$ref": "#/definitions/network.FirewallRule" - } + "totalSize": { + "description": "Unit GiB", + "type": "integer", + "example": 128 }, - "network_interface": { - "type": "array", - "items": { - "$ref": "#/definitions/network.NIC" - } + "type": { + "type": "string", + "example": "DDR4" }, - "route": { - "type": "array", - "items": { - "$ref": "#/definitions/network.Route" - } + "used": { + "description": "Unit GiB", + "type": "integer" } } }, - "network.NIC": { + "onprem.NetworkInterfaceProperty": { "type": "object", + "required": [ + "ipAddress" + ], "properties": { - "address": { - "type": "array", - "items": { - "type": "string" - } - }, - "gateway": { - "type": "array", - "items": { - "type": "string" - } - }, - "interface": { + "ipAddress": { "type": "string" }, - "mac_address": { + "macAddress": { "type": "string" }, "mtu": { + "description": "Maximum Transmission Unit (MTU) in bytes", "type": "integer" } } }, - "network.NLB": { + "onprem.NetworkProperty": { "type": "object", "properties": { - "description": { - "type": "string" - }, - "health_checker": { - "type": "string" - }, - "id": { - "type": "string" - }, - "listener": { - "type": "string" - }, - "name": { - "type": "string" - }, - "target_group": { - "type": "string" - } - } - }, - "network.Network": { - "type": "object", - "properties": { - "csp": { - "$ref": "#/definitions/network.CSP" - }, - "host": { - "$ref": "#/definitions/network.Host" + "gateway": { + "description": "Gateway IP address", + "type": "string", + "example": "172.26.240.0/20" } } }, - "network.Route": { + "onprem.OsProperty": { "type": "object", + "required": [ + "prettyName" + ], "properties": { - "destination": { - "type": "string" + "id": { + "type": "string", + "example": "ubuntu" }, - "netmask": { - "type": "string" + "idLike": { + "type": "string", + "example": "debian" }, - "next_hop": { - "type": "string" - } - } - }, - "network.SecurityGroup": { - "type": "object", - "properties": { - "description": { - "type": "string" + "name": { + "type": "string", + "example": "Ubuntu" }, - "firewall_rule": { - "type": "array", - "items": { - "$ref": "#/definitions/network.FirewallRule" - } + "prettyName": { + "description": "Pretty name", + "type": "string", + "example": "Ubuntu 22.04.3 LTS" }, - "id": { - "type": "string" + "version": { + "description": "Full version string", + "type": "string", + "example": "22.04.3 LTS (Jammy Jellyfish)" }, - "name": { - "type": "string" + "versionCodename": { + "type": "string", + "example": "jammy" }, - "vnet_id": { - "type": "string" + "versionId": { + "type": "string", + "example": "22.04" } } }, - "network.Subnet": { + "onprem.ServerProperty": { "type": "object", "properties": { - "ipv4_cidr": { - "description": "IPv4 Network Address with CIDR Prefix Length", - "type": "string" - }, - "ipv6_cidr": { - "description": "IPv6 Network Address with CIDR Prefix Length", - "type": "string" + "cpu": { + "$ref": "#/definitions/onprem.CpuProperty" }, - "name": { - "type": "string" - } - } - }, - "network.VPC": { - "type": "object", - "properties": { - "address_space": { - "description": "IPv4 CIDR or IPv6 CIDR", + "dataDisks": { "type": "array", "items": { - "type": "string" + "$ref": "#/definitions/onprem.DiskProperty" } }, - "dns_server": { + "hostname": { + "type": "string" + }, + "interfaces": { "type": "array", "items": { - "$ref": "#/definitions/network.DNS" + "$ref": "#/definitions/onprem.NetworkInterfaceProperty" } }, - "id": { - "type": "string" + "memory": { + "$ref": "#/definitions/onprem.MemoryProperty" }, - "region": { - "type": "string" + "os": { + "$ref": "#/definitions/onprem.OsProperty" }, - "subnet": { - "type": "array", - "items": { - "$ref": "#/definitions/network.Subnet" - } + "rootDisk": { + "$ref": "#/definitions/onprem.DiskProperty" } } } diff --git a/api/swagger.yaml b/api/swagger.yaml index c9a6fe7..8bb8882 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -127,9 +127,11 @@ definitions: type: object controller.RecommendInfraRequest: properties: + network: + $ref: '#/definitions/onprem.NetworkProperty' servers: items: - $ref: '#/definitions/infra.Infra' + $ref: '#/definitions/onprem.ServerProperty' type: array required: - servers @@ -161,248 +163,6 @@ definitions: name: type: string type: object - infra.CPU: - properties: - cache: - description: KB - type: integer - cores: - description: ea - type: integer - cpus: - description: ea - type: integer - max_speed: - description: MHz - type: integer - model: - type: string - threads: - description: ea - type: integer - vendor: - type: string - required: - - cores - - cpus - - threads - type: object - infra.Compute: - properties: - compute_resource: - $ref: '#/definitions/infra.ComputeResource' - connection: - items: - $ref: '#/definitions/infra.Connection' - type: array - os: - $ref: '#/definitions/infra.System' - required: - - compute_resource - - os - type: object - infra.ComputeResource: - properties: - cpu: - $ref: '#/definitions/infra.CPU' - data_disk: - items: - $ref: '#/definitions/infra.Disk' - type: array - memory: - $ref: '#/definitions/infra.Memory' - root_disk: - $ref: '#/definitions/infra.Disk' - required: - - cpu - - memory - type: object - infra.Connection: - properties: - keypair: - $ref: '#/definitions/infra.Keypair' - type: object - infra.DRM: - properties: - driver_date: - type: string - driver_description: - type: string - driver_name: - type: string - driver_version: - type: string - type: object - infra.Disk: - properties: - label: - type: string - size: - description: GB - type: integer - type: - type: string - type: object - infra.GPU: - properties: - drm: - items: - $ref: '#/definitions/infra.DRM' - type: array - nvidia: - items: - $ref: '#/definitions/infra.NVIDIA' - type: array - type: object - infra.Infra: - properties: - compute: - $ref: '#/definitions/infra.Compute' - gpu: - $ref: '#/definitions/infra.GPU' - network: - $ref: '#/definitions/network.Network' - storage: - $ref: '#/definitions/infra.Storage' - type: object - infra.Kernel: - properties: - architecture: - type: string - release: - type: string - version: - type: string - type: object - infra.Keypair: - properties: - name: - type: string - private_key: - type: string - public_key: - type: string - type: object - infra.Memory: - properties: - size: - description: MB - type: integer - speed: - description: MHz - type: integer - type: - type: string - required: - - size - type: object - infra.MountPoint: - properties: - mounted_information: - items: - $ref: '#/definitions/infra.MountedInformation' - type: array - type: object - infra.MountedInformation: - properties: - destination: - type: string - filesystem: - type: string - option: - type: string - source: - type: string - type: object - infra.NVIDIA: - properties: - device_attribute: - $ref: '#/definitions/infra.NVIDIADeviceAttribute' - performance: - $ref: '#/definitions/infra.NVIDIAPerformance' - type: object - infra.NVIDIADeviceAttribute: - properties: - cuda_version: - type: string - driver_version: - type: string - gpu_uuid: - type: string - product_architecture: - type: string - product_brand: - type: string - product_name: - type: string - type: object - infra.NVIDIAPerformance: - properties: - bar1_memory_total: - description: mb - type: integer - bar1_memory_usage: - description: percent - type: integer - bar1_memory_used: - description: mb - type: integer - fb_memory_total: - description: mb - type: integer - fb_memory_usage: - description: percent - type: integer - fb_memory_used: - description: mb - type: integer - gpu_usage: - description: percent - type: integer - type: object - infra.Node: - properties: - hostname: - type: string - hypervisor: - type: string - machineid: - type: string - timezone: - type: string - type: object - infra.OS: - properties: - architecture: - type: string - name: - type: string - release: - type: string - vendor: - type: string - version: - type: string - required: - - release - - vendor - type: object - infra.Storage: - properties: - mount_point: - $ref: '#/definitions/infra.MountPoint' - type: object - infra.System: - properties: - kernel: - $ref: '#/definitions/infra.Kernel' - node: - $ref: '#/definitions/infra.Node' - os: - $ref: '#/definitions/infra.OS' - required: - - os - type: object model.MyUser: properties: email: @@ -516,164 +276,148 @@ definitions: - commonImage - commonSpec type: object - network.CSP: + onprem.CpuProperty: properties: - name: - type: string - nlb: - items: - $ref: '#/definitions/network.NLB' - type: array - security_group: - items: - $ref: '#/definitions/network.SecurityGroup' - type: array - vpc: - items: - $ref: '#/definitions/network.VPC' - type: array - type: object - network.DNS: - properties: - dns_server: - description: IPv4 or IPv6 DNS Server Addresses - items: - type: string - type: array - type: object - network.FirewallRule: - properties: - action: - description: allow, deny - type: string - direction: - description: inbound, outbound - type: string - dst: - type: string - dst_ports: + architecture: + example: x86_64 type: string - priority: - description: Lower has higher priority + cores: + description: Number of physical cores per CPU + example: 18 type: integer - protocol: - description: TCP, UDP, ICMP - type: string - src: + 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 - src_ports: + 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 - network.Host: - properties: - dns: - $ref: '#/definitions/network.DNS' - firewall_rule: - items: - $ref: '#/definitions/network.FirewallRule' - type: array - network_interface: - items: - $ref: '#/definitions/network.NIC' - type: array - route: - items: - $ref: '#/definitions/network.Route' - type: array - type: object - network.NIC: + onprem.DiskProperty: properties: - address: - items: - type: string - type: array - gateway: - items: - type: string - type: array - interface: + available: + description: Unit GiB + type: integer + label: type: string - mac_address: + totalSize: + description: Unit GiB + example: 1024 + type: integer + type: + description: SSD, HDD + example: SSD type: string - mtu: + used: + description: Unit GiB type: integer + required: + - label + - totalSize + - type type: object - network.NLB: + onprem.MemoryProperty: properties: - description: - type: string - health_checker: - type: string - id: - type: string - listener: - type: string - name: - type: string - target_group: + 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 - network.Network: - properties: - csp: - $ref: '#/definitions/network.CSP' - host: - $ref: '#/definitions/network.Host' - type: object - network.Route: + onprem.NetworkInterfaceProperty: properties: - destination: - type: string - netmask: + ipAddress: type: string - next_hop: + macAddress: type: string + mtu: + description: Maximum Transmission Unit (MTU) in bytes + type: integer + required: + - ipAddress type: object - network.SecurityGroup: + onprem.NetworkProperty: properties: - description: + gateway: + description: Gateway IP address + example: 172.26.240.0/20 type: string - firewall_rule: - items: - $ref: '#/definitions/network.FirewallRule' - type: array + type: object + onprem.OsProperty: + properties: id: + example: ubuntu + type: string + idLike: + example: debian type: string name: + example: Ubuntu type: string - vnet_id: + prettyName: + description: Pretty name + example: Ubuntu 22.04.3 LTS type: string - type: object - network.Subnet: - properties: - ipv4_cidr: - description: IPv4 Network Address with CIDR Prefix Length + version: + description: Full version string + example: 22.04.3 LTS (Jammy Jellyfish) type: string - ipv6_cidr: - description: IPv6 Network Address with CIDR Prefix Length + versionCodename: + example: jammy type: string - name: + versionId: + example: "22.04" type: string + required: + - prettyName type: object - network.VPC: + onprem.ServerProperty: properties: - address_space: - description: IPv4 CIDR or IPv6 CIDR - items: - type: string - type: array - dns_server: + cpu: + $ref: '#/definitions/onprem.CpuProperty' + dataDisks: items: - $ref: '#/definitions/network.DNS' + $ref: '#/definitions/onprem.DiskProperty' type: array - id: - type: string - region: + hostname: type: string - subnet: + interfaces: items: - $ref: '#/definitions/network.Subnet' + $ref: '#/definitions/onprem.NetworkInterfaceProperty' type: array + memory: + $ref: '#/definitions/onprem.MemoryProperty' + os: + $ref: '#/definitions/onprem.OsProperty' + rootDisk: + $ref: '#/definitions/onprem.DiskProperty' type: object externalDocs: description: ▶▶▶ CB-Tumblebug REST API diff --git a/deployments/docker-compose/docker-compose.yaml b/deployments/docker-compose/docker-compose.yaml index 870a4bb..7d58e78 100644 --- a/deployments/docker-compose/docker-compose.yaml +++ b/deployments/docker-compose/docker-compose.yaml @@ -7,7 +7,7 @@ networks: services: # cm-beetle cm-beetle: - image: cloudbaristaorg/cm-beetle:0.2.0 + image: cloudbaristaorg/cm-beetle:0.2.1 container_name: cm-beetle pull_policy: missing build: @@ -55,7 +55,7 @@ services: # CB-Tumblebug cb-tumblebug: - image: cloudbaristaorg/cb-tumblebug:0.9.10 + image: cloudbaristaorg/cb-tumblebug:0.9.11 container_name: cb-tumblebug # build: # context: . diff --git a/go.mod b/go.mod index c59f60c..16fc000 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,12 @@ module github.com/cloud-barista/cm-beetle go 1.23.0 +// Keep this for cm-model contributors +// replace github.com/cloud-barista/cm-model => ../cm-model + require ( - github.com/cloud-barista/cb-tumblebug v0.9.10 - github.com/cloud-barista/cm-honeybee/agent v0.0.0-20240704080504-526db6b80b90 + github.com/cloud-barista/cb-tumblebug v0.9.11 + github.com/cloud-barista/cm-model v0.0.1 github.com/fsnotify/fsnotify v1.7.0 github.com/go-playground/validator/v10 v10.22.0 github.com/go-resty/resty/v2 v2.13.1 @@ -70,5 +73,7 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect + modernc.org/libc v1.50.9 // indirect + modernc.org/sqlite v1.29.10 // indirect xorm.io/builder v0.3.13 // indirect ) diff --git a/go.sum b/go.sum index a5c3c15..4f99c80 100644 --- a/go.sum +++ b/go.sum @@ -4,10 +4,10 @@ gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGq gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/cloud-barista/cb-tumblebug v0.9.10 h1:mnXLczjwi6FMwmrZ0n1LMdvFfDFKbz9MJp3jHDJ78Zk= -github.com/cloud-barista/cb-tumblebug v0.9.10/go.mod h1:uXi+JmmdU+cqcIqpMgfomzZNbNdrLQ+WZgK9ZlOGjY0= -github.com/cloud-barista/cm-honeybee/agent v0.0.0-20240704080504-526db6b80b90 h1:qGFG4sMqwKw06Y0ZzK4L2Bm6M/WHNnLQGZ3r6qUAhR8= -github.com/cloud-barista/cm-honeybee/agent v0.0.0-20240704080504-526db6b80b90/go.mod h1:+h6UB1Z2qrpfizIillcppLuh8zRlmjLSpkl63XGi1Wc= +github.com/cloud-barista/cb-tumblebug v0.9.11 h1:PLqQ+OD4+Nec1xTHJ3Qde7C74t2XiY5D43UemMg838A= +github.com/cloud-barista/cb-tumblebug v0.9.11/go.mod h1:uXi+JmmdU+cqcIqpMgfomzZNbNdrLQ+WZgK9ZlOGjY0= +github.com/cloud-barista/cm-model v0.0.1 h1:tcj5KHacQYuoLgvcuFoA+Cp23pbQg1xoAYNGtVRJXiU= +github.com/cloud-barista/cm-model v0.0.1/go.mod h1:gSuMhQxD813KIdSvkp8uGptYOeyDik749sYcICZjhj8= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/go.work.sum b/go.work.sum index 4048011..c9f5a72 100644 --- a/go.work.sum +++ b/go.work.sum @@ -302,6 +302,8 @@ github.com/cloud-barista/cb-tumblebug v0.0.0-20230724172618-8f225d0127e8/go.mod github.com/cloud-barista/cm-beetle/src v0.0.0-20230724172618-8f225d0127e8/go.mod h1:XQuz7L64MNUu04FmG5gB0z41VcrfaLuQP80EGyQTDgo= github.com/cloud-barista/cm-honeybee v0.1.3 h1:G9Gb2NiiDtw9nRn7v56bpUM5FEfyBYJ8kgIKxZJZSkI= github.com/cloud-barista/cm-honeybee v0.1.3/go.mod h1:A0Qm1CY4O1hAMxDRnEWjXACztP2D2y/U9GNNJvYzyzM= +github.com/cloud-barista/cm-model v0.0.0-20240909022259-4ca4411340d6 h1:lxU1vjbUW3W3be+WTI91WX4KrXD5cDmBMFAvUhqh9cQ= +github.com/cloud-barista/cm-model v0.0.0-20240909022259-4ca4411340d6/go.mod h1:GRtJ+4HdzKwfZySj9/99fnmyfFeaoyA2P+NKvTtFNUY= github.com/cloud-barista/mc-terrarium v0.0.6-0.20240516045927-43023b6a0e18/go.mod h1:qey9GFrJidyJ3tVfeL/gcImgWLqsF64j/fVmBfaddDI= github.com/cloud-barista/mc-terrarium v0.0.7/go.mod h1:qey9GFrJidyJ3tVfeL/gcImgWLqsF64j/fVmBfaddDI= github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= @@ -366,6 +368,7 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= github.com/google/pprof v0.0.0-20230323073829-e72429f035bd/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -408,6 +411,7 @@ github.com/jollaman999/utils v1.0.10/go.mod h1:fb4x+o0k105MFIBBaNRN+tat7F3Rbkoln github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/knqyf263/go-rpmdb v0.0.0-20231206071317-a8af76a6220f/go.mod h1:9LQcoMCMQ9vrF7HcDtXfvqGO4+ddxFQ8+YF/0CVGDww= github.com/knqyf263/go-rpmdb v0.1.0/go.mod h1:9LQcoMCMQ9vrF7HcDtXfvqGO4+ddxFQ8+YF/0CVGDww= github.com/knqyf263/go-rpmdb v0.1.1/go.mod h1:9LQcoMCMQ9vrF7HcDtXfvqGO4+ddxFQ8+YF/0CVGDww= @@ -520,14 +524,18 @@ go.etcd.io/etcd/client/v2 v2.305.12/go.mod h1:aQ/yhsxMu+Oht1FOupSr60oBvcS9cKXHrz 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/contrib/instrumentation/net/http/otelhttp v0.51.0/go.mod h1:vy+2G/6NvVMpwGX/NyLqcC41fxepnuKHk16E6IZUcJc= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0/go.mod h1:XLZfZboOJWHNKUv7eH0inh0E9VV6eWDFB/9yJyTLPp0= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0/go.mod h1:hYwym2nDEeZfG/motx0p7L7J1N1vyzIThemQsb4g2qY= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4= go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -583,8 +591,15 @@ howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= howett.net/plist v1.0.1/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0= +modernc.org/cc/v3 v3.41.0/go.mod h1:Ni4zjJYJ04CDOhG7dn640WGfwBzfE0ecX8TyMB0Fv0Y= +modernc.org/cc/v4 v4.21.2/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY= +modernc.org/ccgo/v3 v3.17.0/go.mod h1:Sg3fwVpmLvCUTaqEUjiBDAvshIaKDB0RXaf+zgqFu8I= +modernc.org/ccgo/v4 v4.17.8/go.mod h1:buJnJ6Fn0tyAdP/dqePbrrvLyr6qslFfTbFrCuaYvtA= +modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= +modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU= modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= +modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss= pault.ag/go/modprobe v0.1.2/go.mod h1:afr2STC/2Maz/qi4+Bma1s0dszZgO/PcM8AKar9DWhM= pault.ag/go/topsort v0.1.1/go.mod h1:r1kc/L0/FZ3HhjezBIPaNVhkqv8L0UJ9bxRuHRVZ0q4= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/pkg/api/rest/controller/recommendation.go b/pkg/api/rest/controller/recommendation.go index 2605b66..e35c939 100644 --- a/pkg/api/rest/controller/recommendation.go +++ b/pkg/api/rest/controller/recommendation.go @@ -20,7 +20,8 @@ import ( // cloudmodel "github.com/cloud-barista/cm-beetle/pkg/api/rest/model/cloud/infra" // "github.com/cloud-barista/cm-beetle/pkg/api/rest/model/onprem/infra" - "github.com/cloud-barista/cm-honeybee/agent/pkg/api/rest/model/onprem/infra" + // "github.com/cloud-barista/cm-honeybee/agent/pkg/api/rest/model/onprem/infra" + onprem "github.com/cloud-barista/cm-model/infra/onprem" "github.com/cloud-barista/cm-beetle/pkg/core/common" "github.com/cloud-barista/cm-beetle/pkg/core/recommendation" @@ -38,7 +39,8 @@ import ( // } type RecommendInfraRequest struct { - Servers []infra.Infra `json:"servers" validate:"required"` + // Servers []infra.Infra `json:"servers" validate:"required"` + onprem.OnPremInfra } type RecommendInfraResponse struct { @@ -70,7 +72,7 @@ func RecommendInfra(c echo.Context) error { log.Trace().Msgf("req: %v\n", req) // Process - recommendedInfraInfo, err := recommendation.Recommend(req.Servers) + recommendedInfraInfo, err := recommendation.Recommend(req.OnPremInfra) recommendedInfraInfo.TargetInfra.Name = "mmci01" // Ouput diff --git a/pkg/core/migration/migration.go b/pkg/core/migration/migration.go index 8f815a1..1ad6621 100644 --- a/pkg/core/migration/migration.go +++ b/pkg/core/migration/migration.go @@ -224,11 +224,11 @@ func DeleteVMInfra(nsId, infraId string) (common.SimpleMsg, error) { // delete the infrastructure with terminate option method = "DELETE" - url = fmt.Sprintf("%s/ns/%s/defaultResources", epTumblebug, nsId) - options = "" - if options != "" { - url += "?" + options - } + url = fmt.Sprintf("%s/ns/%s/sharedResources", epTumblebug, nsId) + // options = "" + // if options != "" { + // url += "?" + options + // } // Set request body requestBody = common.NoBody diff --git a/pkg/core/recommendation/recommendation.go b/pkg/core/recommendation/recommendation.go index 1c01370..9233de0 100644 --- a/pkg/core/recommendation/recommendation.go +++ b/pkg/core/recommendation/recommendation.go @@ -9,9 +9,11 @@ import ( // cloudmodel "github.com/cloud-barista/cm-beetle/pkg/api/rest/model/cloud/infra" - "github.com/cloud-barista/cm-honeybee/agent/pkg/api/rest/model/onprem/infra" + // "github.com/cloud-barista/cm-honeybee/agent/pkg/api/rest/model/onprem/infra" // "github.com/cloud-barista/cm-beetle/pkg/api/rest/model/onprem/infra" + onprem "github.com/cloud-barista/cm-model/infra/onprem" + "github.com/cloud-barista/cm-beetle/pkg/config" "github.com/cloud-barista/cm-beetle/pkg/core/common" "github.com/cloud-barista/cm-beetle/pkg/similarity" @@ -19,7 +21,7 @@ import ( "github.com/rs/zerolog/log" ) -func Recommend(srcInfra []infra.Infra) (RecommendedInfraInfo, error) { +func Recommend(srcInfra onprem.OnPremInfra) (RecommendedInfraInfo, error) { var emptyResp RecommendedInfraInfo var recommendedInfraInfo RecommendedInfraInfo @@ -103,7 +105,7 @@ func Recommend(srcInfra []infra.Infra) (RecommendedInfraInfo, error) { }` // Recommand VMs - for _, server := range srcInfra { + for _, server := range srcInfra.Servers { // Set VM info recommendedVm := tbmodel.TbVmDynamicReq{ @@ -112,7 +114,7 @@ func Recommend(srcInfra []infra.Infra) (RecommendedInfraInfo, error) { CommonSpec: "", // Search and set an appropriate VM spec Description: "a recommended virtual machine", Label: "rehosted-vm", - Name: fmt.Sprintf("rehosted-%s", server.Compute.OS.Node.Hostname), + Name: fmt.Sprintf("rehosted-%s", server.Hostname), RootDiskSize: "", // TBD RootDiskType: "", // TBD SubGroupSize: "", @@ -124,11 +126,11 @@ func Recommend(srcInfra []infra.Infra) (RecommendedInfraInfo, error) { */ // Extract server info from source computing infra info - cores := server.Compute.ComputeResource.CPU.Cores - memory := MBtoGiB(float64(server.Compute.ComputeResource.Memory.Size)) + cores := server.CPU.Cores + memory := MBtoGiB(float64(server.Memory.TotalSize)) coresMax := cores << 1 - var coresMin uint + var coresMin uint32 if cores > 1 { coresMin = cores >> 1 } else { @@ -146,13 +148,12 @@ func Recommend(srcInfra []infra.Infra) (RecommendedInfraInfo, error) { providerName := "aws" regionName := "ap-northeast-2" - osVendor := server.Compute.OS.OS.Vendor - osVersion := server.Compute.OS.OS.Release - osNameWithVersion := strings.ToLower(osVendor + osVersion) + osNameAndVersion := server.OS.Name + " " + server.OS.Version + osNameWithVersion := strings.ToLower(osNameAndVersion) log.Debug(). - Uint("coreLowerLimit", coresMin). - Uint("coreUpperLimit", coresMax). + Uint32("coreLowerLimit", coresMin). + Uint32("coreUpperLimit", coresMax). Uint32("memoryLowerLimit (GiB)", memoryMin). Uint32("memoryUpperLimit (GiB)", memoryMax). Str("providerName", providerName). @@ -265,10 +266,10 @@ func Recommend(srcInfra []infra.Infra) (RecommendedInfraInfo, error) { } keywords := fmt.Sprintf("%s %s %s %s", - server.Compute.OS.OS.Vendor, - server.Compute.OS.OS.Version, - server.Compute.OS.OS.Architecture, - server.Compute.ComputeResource.RootDisk.Type) + server.OS.Name, + server.OS.Version, + server.CPU.Architecture, + server.RootDisk.Type) log.Debug().Msg("keywords for the VM OS image recommendation: " + keywords) // Select VM OS image via LevenshteinDistance-based text similarity