This is a small python flask program used to gather property data from multiple cloud sources and present them on web pages. The following sources have been inregrated: Aliyun, Azure, Oracle Cloud, DnsPod
- Build Dockerfile
- sudo docker build -t icicle/cmp:v1 . --no-cache
- Put oracle cloud pem key file into $(pwd)/.oci folder
- Put .env file into $(pwd)/cmp/env folder and set up environment variables in it
- Run Docker container
- sudo docker network create cmp-network
- sudo docker run --name cmp-redis --network cmp-network -d redis:alpine
- sudo docker run --name cmp-mysql -e MYSQL_ROOT_PASSWORD="" -e MYSQL_DATABASE=sysop_cmp --network cmp-network -d mysql:8.0
- sudo docker run -d -p 8848:8000 -v
$(pwd)/.oci:/root/.oci -v $ (pwd)/cmp/env:/cmp/env --network cmp-network --name cmp-app icicle/cmp:v1
- Open browser
For aliyun, we use accesskey & secret to authenticate.
#user1
user1_AccessKeyId="<access-key-id>"
user1_AccessKeySecret="<access-key-secret>"
user1_RegionId="<region-id>"
user1_AccountName="<account-name>"
user1_RegionId2="<second-region-id-if-you-have>"
#user2
user2_AccessKeyId="<access-key-id>"
user2_AccessKeySecret="<access-key-secret>"
user2_RegionId="<region-id>"
user2_AccountName="<second-account-name-if-you-have>"
user2_RegionId2="<second-region-id-if-you-have>"
For oracle cloud, we use API keys, you can create them under user settings.
OC_USER_OCID="<user-ocid>"
OC_FINGERPRINT="<key-file-fingerprint>"
OC_TENANCY="<tenancy-id>"
OC_KEY_FILE="~/.oci/oci_api_key.pem"
OC_REGION_1="<region-id>"
OC_REGION_2="<second-region-id-if-you-have>"
OC_REGION_3="third-region-id-if-you-have"
For azure, we use service principal to authenticate. So if you don't have it, go create one.
APP_ID="<service-principal-app-id>"
PASSWORD="<service-principal-password>"
TENANT_ID="<tenant-id>"
APP_URL="<service-principal-app-url>"
RESOURCE_GROUP="<resource-group-name>"
SQL_SERVER_NAME="<sql-server-name-if-you-have>"
For dnspod, please refer to https://www.dnspod.cn/
LOGIN_TOKEN="<dnspod-token>"
- Python setup Under project root folder, do the following:
- python3 -m venv env
- source env/bin/activate
- pip install -r requirements.txt
- Edit .env file to set up environment variables and put it under ~/cmp/cmp/env/
- Put pem key file under ~/.oci/ folder for the use of accessing oracle cloud api
- Azure setup Before start, you need to make sure that you have created a service principal for your azure account first. If you haven't done it, please refer to the following documentation to create one.
- Import repo key
- sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
- Create repo file echo -e "[azure-cli] name=Azure CLI baseurl=https://packages.microsoft.com/yumrepos/azure-cli enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/azure-cli.repo
- Install azure cli
- sudo yum -y install azure-cli
- Set region to China
- az cloud set -n AzureChinaCloud
- Sign in(Replace the variables to your own ones)
- az login --service-principal -u APP_URL --username APP_ID --password PASSWORD --tenant TENANT_ID
- change the following path:
- cmp/icicleazure.py: change load_dotenv('/cmp/env/.env') to load_dotenv('/your-home-directory/cmp/cmp/env/.env')
- cmp/commands.py: change load_dotenv('/cmp/env/.env') to load_dotenv('/your-home-directory/cmp/cmp/env/.env')
- Under project root folder, run this command to generate cloud property data
- flask generate
- Start web server
- flask run --host=0.0.0.0
cmp_package
├── cmp // package folder
│ ├── commands.py // commands to generate data
│ ├── env // used to store .env file
│ ├── errors.py // customized error pages
│ ├── iciclealiyun.py // fetch data from aliyun python api
│ ├── icicleazure.py // fetch data from azure-cli
│ ├── iciclednspod.py // fetch data from dnspod api
│ ├── icicleoracle.py // fetch data from oracle cloud python api
│ ├── __init__.py // This is the starting point.
│ ├── models.py // Define sql schemas
│ ├── settings.py // used to store db settings
│ ├── static // used to store js, css and images
│ ├── templates // html files
│ └── views.py // view functions to control data interactions
├── Dockerfile // used to make this whole app into a docker image
├── README.md // descriptions
├── requirements.txt // python libraries
└── wsgi.py // used by gunicorn, in order to find where flask app is located at.