DEV Community

Cover image for I Built a Python CLI to Tackle Oracle Cloud's "Out of Host Capacity" Problem
Mudassir Mazhar
Mudassir Mazhar

Posted on AI-assisted

I Built a Python CLI to Tackle Oracle Cloud's "Out of Host Capacity" Problem

I Built a Python CLI to Tackle Oracle Cloud Ampere A1's "Out of Host Capacity" Problem

Getting an Oracle Cloud Ampere A1 instance can be frustrating.

You may have your OCI account configured, your network ready, your quotas checked, and your VM configuration prepared — but capacity availability can still get in the way.

I wanted a simpler way to handle this workflow.

So I started building a Python automation tool for Oracle Cloud Infrastructure (OCI). What began as a personal automation script gradually evolved into a cross-platform CLI with interactive configuration, installation scripts, monitoring capabilities, safety checks, and support for AI coding agents.

!OCI Always Free A1 VM Automation

Today, I'm sharing it with the developer community.

GitHub: https://github.com/mudassir-93/OCI-Always-Free-VM

The Problem I Wanted to Solve

Working with OCI A1 instances involves more than just clicking the Create Instance button.

Before attempting to launch an instance, there are several things worth checking:

Is A1 capacity currently available in my region and availability domain?
Are my OCPU and memory quotas sufficient?
Is my existing VCN and subnet configuration valid?
Is the selected image appropriate?
Am I staying within my intended compute and storage budget?
How can I monitor capacity without repeatedly doing the same manual checks?

I didn't want to build another cloud dashboard or a complicated infrastructure platform.

I wanted a lightweight tool that could automate repetitive checks and provide a manageable workflow from the terminal.

What I Built
OCI Always Free A1 VM Automation

A Python-based CLI designed to help OCI users inspect their environment, check A1 capacity, validate configuration, and optionally request one VM through an explicitly guarded workflow.

The project supports Windows and Linux.

What It Can Do

  1. A1 Capacity Monitoring

Check OCI A1 availability and monitor capacity using configurable retry and backoff behavior.

  1. Quota and Configuration Checks

Validate important settings such as:

Home region and availability domain.
Existing VCN and public subnet.
Compute and storage limits.
A1 instance configuration.
Image and SSH public-key settings.
Existing instances and resource usage.

  1. Interactive Terminal Interface

Instead of remembering every command, users can open the application and navigate through an interactive terminal menu.

  1. Guided Configuration

The configuration editor allows users to work through settings in organized groups, validate values, review changes, and save safely.

  1. Windows and Linux Installers

The project includes PowerShell and shell installers that create an isolated Python environment and initialize a safe starter configuration.

  1. AI Coding-Agent Support

The repository includes instructions and project memory for tools such as:

Claude Code
OpenAI Codex
Gemini CLI
GitHub Copilot
Other agentic development environments

The idea is to make it easier to understand, maintain, and extend the project with AI assistance.

Some Implementation Decisions I Found Interesting

This project was also a useful exercise in making an existing automation tool more reusable.

A few decisions shaped the architecture.

Keeping the Existing Engine

Rather than rewriting the original automation logic, I introduced a new oci-platform CLI layer around the existing Python engine.

This allowed me to preserve existing functionality while improving how users interact with it.

Handling Windows and Linux Differences

One portability issue came from using the POSIX-only fcntl module for process locking.

That approach wasn't suitable for Windows.

I replaced the unconditional platform-specific import with a cross-platform locking implementation.

It was a good reminder that cross-platform support needs to be considered at the application level, not just in the installer.

Making Configuration Safer

I didn't want setup to accidentally arm VM creation or overwrite an existing installation.

The installers refuse to overwrite an existing target directory, and the configuration workflow keeps VM creation disabled.

These are deliberate design decisions, not just documentation warnings.

Safety Is a Core Part of the Design

Because this application interacts with cloud infrastructure, I wanted the default behavior to be read-only.

VM creation requires three independent safeguards:

mode.creation_enabled=true in the local configuration.
The exact confirmation phrase LAUNCH_ONE_ALWAYS_FREE_INSTANCE.
The CLI flag --enable-create.

An actual launch also requires the operator's explicit authorization.

The application is designed around an existing network rather than automatically creating or modifying networking resources.

It does not upgrade OCI accounts, terminate existing instances, or promise guaranteed capacity or zero billing.

A capacity check is not a reservation, and Always Free eligibility must always be verified against your own OCI account and current Oracle terms.

Development and Testing

I wanted to validate more than just whether the Python code worked on my own machine.

The repository now has GitHub Actions workflows covering:

Python 3.11 and 3.12.
Windows and Ubuntu.
Application compilation and unit tests.
CLI startup and packaging.
Installer safety checks.
A fresh Linux installer integration test.

The Linux integration test checks installation in a clean temporary directory, verifies the installed commit, confirms the starter configuration keeps creation disabled, and checks that existing directories are preserved.

I also encountered an environment-related problem while trying to run a Linux installation test in an isolated Debian container: DNS resolution for raw.githubusercontent.com failed.

Instead of marking that attempt as successful, I added hosted Ubuntu integration coverage to the CI workflow.

The latest main commit passed all six CI jobs.

I also tested a fresh Windows installation and the interactive CLI on a second PC; that result was reported by the operator.

There is still work to do around live OCI validation, so I am not claiming that every real-world tenancy or capacity scenario has been verified.

Getting Started

You need:

Git
Python 3.11 or newer
Windows (PowerShell)

Download the installer:

powershell
Invoke-WebRequest "https://raw.githubusercontent.com/mudassir-93/OCI-Always-Free-VM/main/install.ps1" -OutFile install.ps1

Review the installer:

powershell
Get-Content .\install.ps1

Run the installer:

powershell
.\install.ps1

Linux

Download the installer:

bash
curl -fsSLO https://raw.githubusercontent.com/mudassir-93/OCI-Always-Free-VM/main/install.sh

Review the installer:

bash
less install.sh

Run the installer:

bash
bash install.sh

Launch the Interactive CLI

Windows:

powershell
$cli = "$HOME\oci-automation-platform.venv\Scripts\oci-platform.exe"
& $cli

Linux:

bash
CLI="$HOME/oci-automation-platform/.venv/bin/oci-platform"
"$CLI"

Start with local configuration and diagnostics before connecting to your OCI environment.

The installer creates a starter configuration with VM creation disabled. Follow the detailed instructions in the repository before running live OCI checks.

What's Next?

The initial V1 code-delivery milestone is complete, but I see this as the beginning of community testing rather than the end of development.

Some areas I'd like to improve through feedback:

More real-world OCI A1 edge-case testing.
Better diagnostics and operator feedback.
Additional installation and configuration testing across environments.
Improvements to monitoring and retry behavior.
More useful workflows for AI-assisted maintenance.

I also want to keep the project lightweight rather than turn it into a large platform with unnecessary services.

I'd Love Your Feedback

I'm especially interested in hearing from developers who use Oracle Cloud, Python automation, or cross-platform CLI tools.

A few questions:

Would you find a tool like this useful for managing OCI A1 capacity?
What edge cases should I test before a wider release?
Is the interactive terminal experience a good approach, or would you prefer a different workflow?
What would you improve in the current architecture?

Feedback, bug reports, and contributions are welcome.

Explore the Project

GitHub Repository: https://github.com/mudassir-93/OCI-Always-Free-VM

Thanks for reading!

Top comments (0)