From c970f53fd8c73ea264ec7b64c21796e601ae857a Mon Sep 17 00:00:00 2001 From: Rifa Achrinza <25147899+achrinza@users.noreply.github.com> Date: Mon, 12 May 2025 23:04:05 +0800 Subject: [PATCH] feat: add `bosh-cpi-config.yaml` Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com> --- src/api/json/catalog.json | 5 +++ src/schemas/json/bosh-cpi-config.json | 58 +++++++++++++++++++++++++++ src/test/bosh-cpi-config/complex.yaml | 40 ++++++++++++++++++ src/test/bosh-cpi-config/minimal.yaml | 3 ++ 4 files changed, 106 insertions(+) create mode 100644 src/schemas/json/bosh-cpi-config.json create mode 100644 src/test/bosh-cpi-config/complex.yaml create mode 100644 src/test/bosh-cpi-config/minimal.yaml diff --git a/src/api/json/catalog.json b/src/api/json/catalog.json index 25c11f6a749..d1e67698d93 100644 --- a/src/api/json/catalog.json +++ b/src/api/json/catalog.json @@ -832,6 +832,11 @@ "fileMatch": [".bowerrc"], "url": "https://json.schemastore.org/bowerrc.json" }, + { + "name": "BOSH CPI Config", + "description": "CPI-specific config for BOSH Director", + "url": "https://json.schemastore.org/bosh-cpi-config.json" + }, { "name": "BOSH Deploy Config", "description": "Deploy config for BOSH CLI", diff --git a/src/schemas/json/bosh-cpi-config.json b/src/schemas/json/bosh-cpi-config.json new file mode 100644 index 00000000000..a5f74ebe090 --- /dev/null +++ b/src/schemas/json/bosh-cpi-config.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://json.schemastore.org/bosh-cpi-config.json", + "$comment": "This schema was built from information on https://bosh.io/docs/cpi-config/ and https://github.com/cloudfoundry/bosh/blob/0bb56927d04d3ce2b7f9d4283a9acd5ee2d6aaf3/src/bosh-director/lib/bosh/director/cpi_config/cpi.rb.", + "$ref": "#/definitions/CPIConfig", + "definitions": { + "CPIConfig": { + "type": "object", + "title": "BOSH Director CPI Config", + "description": "To define CPIs and CPI-specific properties for a BOSH Director.\n\nIntroduced in: v261", + "properties": { + "cpis": { + "type": "array", + "items": { + "$ref": "#/definitions/CPIs" + } + } + } + }, + "CPIs": { + "type": "object", + "required": [ + "name", + "type" + ], + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "exec_path": { + "type": "string" + }, + "migrated_from": { + "$ref": "#/definitions/MigratedFrom" + }, + "properties": { + "type": "object" + } + } + }, + "MigratedFrom":{ + "type": "array", + "description": "Allows for reusing IaaS resources from existing CPI configurations (such as pre-CPI config by using the special \"\" CPI name) without needing to re-upload stemcells or recreate all resources immediately.\n\nIntroduced in: v262.8.0 (https://github.com/cloudfoundry/bosh/commit/1a98a964f9c0238ba6a9b330e20a266cde9370c0)", + "items": { + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string" + } + } + } + } + } +} diff --git a/src/test/bosh-cpi-config/complex.yaml b/src/test/bosh-cpi-config/complex.yaml new file mode 100644 index 00000000000..5c656c26b46 --- /dev/null +++ b/src/test/bosh-cpi-config/complex.yaml @@ -0,0 +1,40 @@ +cpis: +- name: openstack-a1 + type: openstack + exec_path: /var/vcap/jobs/openstack_cpi/bin/cpi + migrated_from: + - name: '' + - name: oldenstack + # Taken from: https://github.com/cloudfoundry/bosh-openstack-cpi-release/blob/222b7c0db9341b561ebfcbc817f1fc5b4e314e0d/src/openstack_cpi_golang/cpi/config/config_test.go#L21C1-L28C44 + properties: + auth_url: the_auth_url + username: the_username + api_key: the_api_key + domain: the_domain + tenant: the_tenant + region: the_region + default_key_name: the_default_key_name + stemcell_public_visibility": true + +- name: vsphere-a1 + type: vsphere + # Taken from: https://github.com/cloudfoundry/bosh-vsphere-cpi-release/blob/3a59941b634503c9720c00878105cd74965daac4/src/vsphere_cpi/spec/unit/bosh_release/jobs/cpi/templates/cpi.json.erb_spec.rb#L26-L50 + properties: + host: vcenter-address + user: vcenter-user + password: vcenter-password + enable_auto_anti_affinity_drs_rules: true + enable_human_readable_name: true + upgrade_hw_version: true + vm_storage_policy_name: VM Storage Policy + http_logging: true + datacenters: + - name: datacenter-1 + vm_folder: vm-folder + template_folder: template-folder + datastore_pattern: datastore-pattern + datastore_cluster_pattern: datastore-cluster-pattern + persistent_datastore_pattern: persistent-datastoreppattern + persistent_datastore_cluster_pattern: persistent-datastore-cluster-pattern + disk_path: disk-path + clusters: [cluster-1] diff --git a/src/test/bosh-cpi-config/minimal.yaml b/src/test/bosh-cpi-config/minimal.yaml new file mode 100644 index 00000000000..55291e47442 --- /dev/null +++ b/src/test/bosh-cpi-config/minimal.yaml @@ -0,0 +1,3 @@ +cpis: +- name: openstack-a1 + type: openstack