-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d46ad15
commit 1a99bb2
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM ubuntu:latest | ||
|
||
RUN apt -y update && apt -y install curl iproute2 | ||
|
||
ENV COLONY_API_URL=https://colony-api-development.mgmt-20.kubefirst.com | ||
ENV COLONY_HARDWARE_ID=2de76518-16e2-45ec-b3ae-ee8db5f4de6f | ||
|
||
COPY . . | ||
|
||
CMD [ "./entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Function to get architecture info | ||
get_architecture_info() { | ||
architecture_info=$(lscpu | grep Architecture: | awk '{print $2}') | ||
echo "$architecture_info" | ||
} | ||
|
||
# Function to get number of cpu | ||
get_cpu_info() { | ||
cpu_info=$(nproc) | ||
echo "$cpu_info" | ||
} | ||
|
||
# Function to get memory info | ||
get_mem_info() { | ||
mem_info=$(free -m | grep Mem | awk '{print $2}') | ||
echo "$mem_info" | ||
} | ||
|
||
# Function to get physical disk info | ||
get_disk_info() { | ||
disk_info=$(lsblk -o NAME,TYPE,SIZE | grep disk | awk 'NR>1{if (NR!=1) printf ","; printf "\"%s\"", $1}') | ||
echo "["${disk_info#,}"]" | ||
} | ||
|
||
|
||
# Function to get physical interface info | ||
get_interface_info() { | ||
interface_info=$(ip -o link show | awk -F': ' 'NR>1{print ",\""$2"\""}') | ||
echo "["${interface_info:1}"]" | ||
} | ||
|
||
|
||
# Main function to generate JSON output | ||
generate_json() { | ||
architecture_info=$(get_architecture_info) | ||
cpu_info=$(get_cpu_info) | ||
mem_info=$(get_mem_info) | ||
disk_info=$(get_disk_info) | ||
interface_info=$(get_interface_info) | ||
|
||
json_output=$(cat <<EOF | ||
{ | ||
"cpuArchitecture": "$architecture_info", | ||
"cpuCores": "$cpu_info", | ||
"memory": "$mem_info", | ||
"blockDevices": $disk_info, | ||
"interfaceInfo": $interface_info | ||
} | ||
EOF | ||
) | ||
|
||
echo "$json_output" | ||
|
||
# curl --request PUT \ | ||
# --url "${COLONY_API_URL}/api/v1/mock/hardwares/${COLONY_HARDWARE_ID}" \ | ||
# --header 'Accept: application/json' \ | ||
# --header 'Content-Type: application/json' \ | ||
# --data "$json_output" | ||
|
||
} | ||
|
||
# Call the main function to generate JSON output | ||
generate_json |