How to use Python Script to Provision 1000 VMs on Huawei Fusion Cloud 6.3 to call the API

i am learning to use Python / pycharm / PIP to provision 1000 VM through a script to call the  API but i don't know how to start doing it.
 
What is the proper way to install python with IDE, Pycharm and PIP for Windows 10?
Where to obtain the python template code to provision 1000 VMs for example for me to modify the flavours, image, types, servers, network?
How to put the digital token on the script and where & how to execute the script if is connected thr VPN client from my PC?
How to generate a private key from the python script as well?


I managed to use web POSTMAN from google chrome to test calling the API to provision some VM as stated in below.

1. Connected to Private Cloud Fusion Cloud 6.3 from Web POSTMAN

2. Obtained a digital token
POST => https://iam-apigateway-proxy.domain.com/v3/auth/tokens

{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"domain": {
"name": "XXX"
},
"name": "XXX",
"password": "XXX"
}
}
},
"scope": {
"project": {
"id": "XXX",
"domain": {
"name": "XXX"

3. Provisioned System Volume
POST => https://evs.domain.com/v2/cd088007d3b84e7fa894478e6fe667c4/volumes

{ "volume":
{
"size": 60,
"availability_zone": "az0.dc0",
"volume_type": "ssd",
"name":"volume1",
"multiattach": false,
"imageRef":"ca9384bd-5d78-49ce-a4c3-6d90d77c623c"
}
}

4. Provisioned VM  
POST => https://ecs.domain.com/v2/cd088007d3b84e7fa894478e6fe667c4/servers
{
"server": {
"flavorRef": "a80cfe5c-60c5-4d16-989a-56f47af273f2",
"name": "IVH-VM1",
"networks": [
{
"uuid": "2f963ced-11a4-4008-82c6-8cb1a230a785"
}
],
"metadata": {
"region_ID": "az0.dc0"
},
"adminPass": "Huawei@123",
"block_device_mapping_v2": [
{
"uuid": "7d8e8bd1-f550-4cfc-8355-52646f111285",
"source_type": "volume",
"destination_type": "volume",
"delete_on_termination": "False",
"boot_index": 0
}
],
"availability_zone": "az0.dc0"
}
}

Tks.
Lucky ThamFreelancerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Break your 4x questions above into 4x separate postings, as they're all fairly unrelated + the overlapping answers will make tracking questions + answers complex.

I'll answer each briefly...

1) i am learning to use Python / pycharm / PIP to provision 1000 VM through a script to call the  API but i don't know how to start doing it.

Keep in mind, best to just dive in + get started. Then when you hit a problem post your progress + what you expected to happened + what happened differently.

So fixing answering specific problem questions, rather than writing an entire code base.

2) What is the proper way to install python with IDE, Pycharm and PIP for Windows 10?

There is no proper way to do anything. Pick an approach which matches your preferences + get started.

Refer to docs of each set of software you'll be using + dive in.

3) Where to obtain the python template code to provision 1000 VMs for example for me to modify the flavours, image, types, servers, network?

Just pick any version which seems to meet your preferences + test till you find an approach which works.

Likely you'll have to design + write this code yourself. Check GitHub for possible projects similar to what you're after to save some dev time.

Keep in mind, trying to do this on Windows will greatly increase your time to do pretty much anything, because you'll always be fighting the battle of trying to get simple software to work on Windows.

For example, is you run Ubuntu Bionic, you just install a simply Python package + installing upgrades occurs the same simple way.

Likely far better to generate containers by the 1000s, than VMs... unless you have a lot of money to burn.

Also keep in mind, with 1000s of VMs or LXD containers or Docker containers, you'll have to come up with some way to NAT all your IPs from one or a few IP addresses through a proxy like HAProxy to allow the outside world to connect with all your VMs/Containers.

How you handle your networking will shape how your answer all your other questions.

The way I handle this is to run with OVH hardware (254 IPs/machine), then associate an IP per LXD container with one or many sites running inside each container... because...

Each proxy you go through, like HAProxy will reduce your throughput by roughly 50%.

If your running actual sites with actual traffic or APIs with actual call volume, you simply can't use tech that reduces performance.

4) How to put the digital token on the script and where & how to execute the script if is connected thr VPN client from my PC?

Don't even know where to start on this, as I'm unsure why your asking the question.

Maybe you're concerned about security. If this is the case don't use a VPN, use ssh... as VPN speed depends on your IP drop... outgoing VPN company's IP, rather than your net connection.

5) How to generate a private key from the python script as well?

Keys are generated in pairs (public/private) by various technologies, like openssl or an SSL Certificate Authority or ssh-keygen.

So you generate keys via python by calling the appropriate command line utility.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Virtualization

From novice to tech pro — start learning today.