Initial commit: VMware vSphere API simulator scaffold.
Add the FastAPI app, PostgreSQL migrations, Docker/Helm packaging, API contracts, docs, client examples, and the unit/integration/compatibility test suite for local client and tooling labs without a real vCenter.
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/hashicorp/vsphere" {
|
||||
version = "2.12.0"
|
||||
constraints = "~> 2.8"
|
||||
hashes = [
|
||||
"h1:WqZLjrDFhrpS0Y0IdSrKGNE/iuJf3l38K8Wz+ZRlJLE=",
|
||||
"zh:02eee1071636834570106f70df904807e4d5cff2cf378c9e1dcfbebbeef4411b",
|
||||
"zh:0ea4ed072d6b9bd8517a1b5c1b06ec05fac6293376c94a9b4625a41ca0626117",
|
||||
"zh:0fa82a384b25a58b65523e0ea4768fa1212b1f5cfc0c9379d31162454fedcc9d",
|
||||
"zh:23cede3a4cb8080662dc0416f2ea6b43e6ca0907c3af0ddae544df923b878080",
|
||||
"zh:2fd2e293115fe4a3ca5f3df051ef852315d5eada304ffa8caaa11d95d15f2ab0",
|
||||
"zh:532577c8897109a23eb768d23479870ccc353987b9bf28fd6532c1adc2878743",
|
||||
"zh:a575a9d5e0b08866fe78da9bf50afee29a3278a0f7e0c269f0626e4a4d25bba1",
|
||||
"zh:c7461658ae2d81881e84a37b6e1c69b05fcee1110fac0b57ebf7ea1a0f5406f2",
|
||||
"zh:d9af3f73391a02d8c1d0e7a0f7da72afff8d49445da8c98bf6e63ad799c5dbc9",
|
||||
"zh:deeed7463f1f532bb3edf70c786c8e3eca0b255cb1c74bcf69a5978d4757ed2c",
|
||||
"zh:ed21ac2b742326098818876125c3a8177b76ae01ce82a88238b786c8020ef151",
|
||||
"zh:f4ff28277d68956d1adc94c5d6fbc109f4a389e8ebb707d24b99ab3113235428",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
vsphere = {
|
||||
source = "hashicorp/vsphere"
|
||||
version = "~> 2.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "vsphere" {
|
||||
user = var.vsphere_user
|
||||
password = var.vsphere_password
|
||||
vsphere_server = var.vsphere_server
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "vsphere_datacenter" "dc" {
|
||||
name = var.datacenter
|
||||
}
|
||||
|
||||
data "vsphere_datastore" "ds" {
|
||||
name = var.datastore
|
||||
datacenter_id = data.vsphere_datacenter.dc.id
|
||||
}
|
||||
|
||||
data "vsphere_compute_cluster" "cluster" {
|
||||
name = var.cluster
|
||||
datacenter_id = data.vsphere_datacenter.dc.id
|
||||
}
|
||||
|
||||
data "vsphere_network" "network" {
|
||||
name = var.network
|
||||
datacenter_id = data.vsphere_datacenter.dc.id
|
||||
}
|
||||
|
||||
data "vsphere_virtual_machine" "web" {
|
||||
name = var.vm_name
|
||||
datacenter_id = data.vsphere_datacenter.dc.id
|
||||
}
|
||||
|
||||
# Lab VM create (SOAP CreateVM_Task). Use a unique name per apply.
|
||||
resource "vsphere_virtual_machine" "lab" {
|
||||
count = var.create_lab_vm ? 1 : 0
|
||||
name = var.lab_vm_name
|
||||
resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
|
||||
datastore_id = data.vsphere_datastore.ds.id
|
||||
num_cpus = 1
|
||||
memory = 1024
|
||||
guest_id = "otherGuest64"
|
||||
wait_for_guest_net_timeout = 0
|
||||
wait_for_guest_ip_timeout = 0
|
||||
|
||||
network_interface {
|
||||
network_id = data.vsphere_network.network.id
|
||||
}
|
||||
|
||||
disk {
|
||||
label = "disk0"
|
||||
size = 16
|
||||
}
|
||||
}
|
||||
|
||||
output "vm_id" {
|
||||
value = data.vsphere_virtual_machine.web.id
|
||||
}
|
||||
|
||||
output "lab_vm_id" {
|
||||
value = try(vsphere_virtual_machine.lab[0].id, null)
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
variable "vsphere_server" {
|
||||
type = string
|
||||
default = "localhost"
|
||||
}
|
||||
|
||||
variable "vsphere_user" {
|
||||
type = string
|
||||
default = "administrator@vsphere.local"
|
||||
}
|
||||
|
||||
variable "vsphere_password" {
|
||||
type = string
|
||||
default = "VMware1!"
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "datacenter" {
|
||||
type = string
|
||||
default = "Datacenter"
|
||||
}
|
||||
|
||||
variable "vm_name" {
|
||||
type = string
|
||||
default = "web-01"
|
||||
}
|
||||
|
||||
variable "datastore" {
|
||||
type = string
|
||||
default = "datastore1"
|
||||
}
|
||||
|
||||
variable "cluster" {
|
||||
type = string
|
||||
default = "Cluster"
|
||||
}
|
||||
|
||||
variable "network" {
|
||||
type = string
|
||||
default = "VM Network"
|
||||
}
|
||||
|
||||
variable "create_lab_vm" {
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "lab_vm_name" {
|
||||
type = string
|
||||
default = "tf-lab-01"
|
||||
}
|
||||
Reference in New Issue
Block a user