Skip to content

Commit 720cc05

Browse files
authored
Merge pull request #33 from platform9/feat/blueprint-resource
feat(resmgr): pcd_cluster_blueprint resource (write path) — validated live
2 parents 9b4588d + fffa1d5 commit 720cc05

7 files changed

Lines changed: 462 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ All notable changes to this project are documented here. The format is based on
9595
from the Keystone catalog, token via the shared ProviderClient) plus `pcd_host_config` (interface
9696
↔ traffic-type mapping and physical-network labels), `pcd_host_role` (assign a role such as
9797
`pf9-ostackhost-neutron` to a host), `pcd_host_config_assignment` (attach a host config to a host),
98-
and a `pcd_cluster_blueprint` data source (read a blueprint by name). The `pcd_cluster_blueprint`
99-
resource (write path) is tracked separately — see DECISIONS.md.
98+
and a `pcd_cluster_blueprint` data source (read a blueprint by name).
99+
- `pcd_cluster_blueprint` resource — manage a cluster blueprint (networking, image library, VM
100+
storage, HA/rebalancing, and Cinder backends). PCD supports one blueprint per region, so the
101+
usual workflow is to `terraform import` the existing blueprint and manage it in place (in-place
102+
update verified live). The write API requires the whole object, so all attributes are
103+
`Optional+Computed` and round-tripped; `storage_backends_json` is sensitive (driver credentials)
104+
and is read back so writes preserve the current backends unless you change it.
100105
- Registry documentation generation wired via `tfplugindocs` (`make generate`) — renders
101106
`docs/` for every resource and data source plus the provider index from schema
102107
descriptions. Generated docs are produced on demand / at release and are not committed.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import pcd_cluster_blueprint.example <blueprint_name>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# PCD supports a single blueprint per region. The usual workflow is to import
2+
# the existing blueprint (see import.sh) and then manage it here.
3+
resource "pcd_cluster_blueprint" "example" {
4+
name = "cluster-1"
5+
networking_type = "ovn"
6+
dns_domain_name = "example.local."
7+
8+
virtual_networking = {
9+
enabled = true
10+
underlay_type = "vlan"
11+
vnid_range = "1000:2000"
12+
}
13+
14+
# storage_backends_json is omitted here so the imported Cinder backends are
15+
# preserved. It is required only when creating a brand-new blueprint, and it
16+
# carries driver credentials (sensitive).
17+
}

internal/provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func (p *pcdProvider) Resources(_ context.Context) []func() resource.Resource {
9191
dns.NewRecordSetResource,
9292
keymanager.NewSecretResource,
9393
keymanager.NewContainerResource,
94+
resmgr.NewBlueprintResource,
9495
resmgr.NewHostConfigResource,
9596
resmgr.NewHostRoleResource,
9697
resmgr.NewHostConfigAssignmentResource,

internal/services/resmgr/blueprint_data_source.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,21 @@ type blueprintAPI struct {
5353
ImageLibrarySharedStorage bool `json:"imageLibrarySharedStorage"`
5454
InstanceSharedStorage bool `json:"instanceSharedStorage"`
5555
VMStorage string `json:"vmStorage"`
56+
VMHighAvailability *haAPI `json:"vmHighAvailability"`
57+
AutoResourceRebalancing *rebalanceAPI `json:"autoResourceRebalancing"`
5658
StorageBackends json.RawMessage `json:"storageBackends"`
5759
}
5860

61+
type haAPI struct {
62+
Enabled bool `json:"enabled"`
63+
}
64+
65+
type rebalanceAPI struct {
66+
Enabled bool `json:"enabled"`
67+
RebalancingStrategy string `json:"rebalancingStrategy"`
68+
RebalancingFrequencyMins int64 `json:"rebalancingFrequencyMins"`
69+
}
70+
5971
type virtualNetworkingAPI struct {
6072
Enabled bool `json:"enabled"`
6173
UnderlayType string `json:"underlayType"`

0 commit comments

Comments
 (0)