-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Preference Set * YAML lint * YAML lint * YAML lint * YAML lint * Add full test * Full test added * Reordering * PR review
- Loading branch information
Showing
4 changed files
with
342 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
# Copyright 2023 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- !ruby/object:Api::Resource | ||
base_url: projects/{{project}}/locations/{{location}}/preferenceSets | ||
create_url: projects/{{project}}/locations/{{location}}/preferenceSets?preferenceSetId={{preference_set_id}} | ||
self_link: projects/{{project}}/locations/{{location}}/preferenceSets/{{preference_set_id}} | ||
id_format: projects/{{project}}/locations/{{location}}/preferenceSets/{{preference_set_id}} | ||
import_format: | ||
- projects/{{project}}/locations/{{location}}/preferenceSets/{{preference_set_id}} | ||
name: PreferenceSet | ||
description: Manages the PreferenceSet resource. | ||
update_verb: :PATCH | ||
update_mask: true | ||
autogen_async: true | ||
references: !ruby/object:Api::Resource::ReferenceLinks | ||
guides: | ||
'Managing Migration Preferences': 'https://cloud.google.com/migration-center/docs/migration-preferences' | ||
api: 'https://cloud.google.com/migration-center/docs/reference/rest/v1' | ||
examples: | ||
- !ruby/object:Provider::Terraform::Examples | ||
name: 'preference_set_basic' | ||
primary_resource_id: 'default' | ||
vars: | ||
set_name: 'preference-set-test' | ||
- !ruby/object:Provider::Terraform::Examples | ||
name: 'preference_set_full' | ||
primary_resource_id: 'default' | ||
vars: | ||
set_name: 'preference-set-test' | ||
properties: | ||
- !ruby/object:Api::Type::String | ||
name: name | ||
description: 'Output only. Name of the preference set. ' | ||
output: true | ||
- !ruby/object:Api::Type::String | ||
name: createTime | ||
description: 'Output only. The timestamp when the preference set was created. ' | ||
output: true | ||
- !ruby/object:Api::Type::String | ||
name: updateTime | ||
description: 'Output only. The timestamp when the preference set was last updated. ' | ||
output: true | ||
- !ruby/object:Api::Type::String | ||
name: displayName | ||
description: 'User-friendly display name. Maximum length is 63 characters. ' | ||
- !ruby/object:Api::Type::String | ||
name: description | ||
description: 'A description of the preference set. ' | ||
- !ruby/object:Api::Type::NestedObject | ||
name: virtualMachinePreferences | ||
description: 'VirtualMachinePreferences enables you to create sets of assumptions, | ||
for example, a geographical location and pricing track, for your migrated virtual | ||
machines. The set of preferences influence recommendations for migrating virtual | ||
machine assets. ' | ||
properties: | ||
- !ruby/object:Api::Type::String | ||
name: targetProduct | ||
description: "Target product for assets using this preference set. Specify either | ||
target product or business goal, but not both. \n Possible values:\n COMPUTE_MIGRATION_TARGET_PRODUCT_UNSPECIFIED\nCOMPUTE_MIGRATION_TARGET_PRODUCT_COMPUTE_ENGINE\nCOMPUTE_MIGRATION_TARGET_PRODUCT_VMWARE_ENGINE\nCOMPUTE_MIGRATION_TARGET_PRODUCT_SOLE_TENANCY" | ||
- !ruby/object:Api::Type::NestedObject | ||
name: regionPreferences | ||
description: 'The user preferences relating to target regions. ' | ||
properties: | ||
- !ruby/object:Api::Type::Array | ||
name: preferredRegions | ||
item_type: Api::Type::String | ||
description: 'A list of preferred regions, ordered by the most preferred region | ||
first. Set only valid Google Cloud region names. See https://cloud.google.com/compute/docs/regions-zones | ||
for available regions. ' | ||
- !ruby/object:Api::Type::String | ||
name: commitmentPlan | ||
description: "Commitment plan to consider when calculating costs for virtual machine | ||
insights and recommendations. If you are unsure which value to set, a 3 year | ||
commitment plan is often a good value to start with. \n Possible values:\n COMMITMENT_PLAN_UNSPECIFIED\nCOMMITMENT_PLAN_NONE\nCOMMITMENT_PLAN_ONE_YEAR\nCOMMITMENT_PLAN_THREE_YEARS" | ||
- !ruby/object:Api::Type::String | ||
name: sizingOptimizationStrategy | ||
description: "Sizing optimization strategy specifies the preferred strategy used | ||
when extrapolating usage data to calculate insights and recommendations for | ||
a virtual machine. If you are unsure which value to set, a moderate sizing optimization | ||
strategy is often a good value to start with. \n Possible values:\n SIZING_OPTIMIZATION_STRATEGY_UNSPECIFIED\nSIZING_OPTIMIZATION_STRATEGY_SAME_AS_SOURCE\nSIZING_OPTIMIZATION_STRATEGY_MODERATE\nSIZING_OPTIMIZATION_STRATEGY_AGGRESSIVE" | ||
- !ruby/object:Api::Type::NestedObject | ||
name: computeEnginePreferences | ||
description: 'The user preferences relating to Compute Engine target platform. ' | ||
properties: | ||
- !ruby/object:Api::Type::NestedObject | ||
name: machinePreferences | ||
description: 'The type of machines to consider when calculating virtual machine | ||
migration insights and recommendations. Not all machine types are available | ||
in all zones and regions. ' | ||
properties: | ||
- !ruby/object:Api::Type::Array | ||
name: allowedMachineSeries | ||
item_type: !ruby/object:Api::Type::NestedObject | ||
properties: | ||
- !ruby/object:Api::Type::String | ||
name: code | ||
description: 'Code to identify a Compute Engine machine series. Consult | ||
https://cloud.google.com/compute/docs/machine-resource#machine_type_comparison | ||
for more details on the available series. ' | ||
description: 'Compute Engine machine series to consider for insights and recommendations. | ||
If empty, no restriction is applied on the machine series. ' | ||
- !ruby/object:Api::Type::String | ||
name: licenseType | ||
description: "License type to consider when calculating costs for virtual machine | ||
insights and recommendations. If unspecified, costs are calculated based on | ||
the default licensing plan. \n Possible values:\n LICENSE_TYPE_UNSPECIFIED\nLICENSE_TYPE_DEFAULT\nLICENSE_TYPE_BRING_YOUR_OWN_LICENSE" | ||
- !ruby/object:Api::Type::NestedObject | ||
name: vmwareEnginePreferences | ||
description: 'The user preferences relating to Google Cloud VMware Engine target | ||
platform. ' | ||
properties: | ||
- !ruby/object:Api::Type::Double | ||
name: cpuOvercommitRatio | ||
description: 'CPU overcommit ratio. Acceptable values are between 1.0 and 8.0, | ||
with 0.1 increment. ' | ||
- !ruby/object:Api::Type::Double | ||
name: memoryOvercommitRatio | ||
description: 'Memory overcommit ratio. Acceptable values are 1.0, 1.25, 1.5, | ||
1.75 and 2.0. ' | ||
- !ruby/object:Api::Type::Double | ||
name: storageDeduplicationCompressionRatio | ||
description: 'The Deduplication and Compression ratio is based on the logical | ||
(Used Before) space required to store data before applying deduplication and | ||
compression, in relation to the physical (Used After) space required after | ||
applying deduplication and compression. Specifically, the ratio is the Used | ||
Before space divided by the Used After space. For example, if the Used Before | ||
space is 3 GB, but the physical Used After space is 1 GB, the deduplication | ||
and compression ratio is 3x. Acceptable values are between 1.0 and 4.0. ' | ||
- !ruby/object:Api::Type::String | ||
name: commitmentPlan | ||
description: "Commitment plan to consider when calculating costs for virtual | ||
machine insights and recommendations. If you are unsure which value to set, | ||
a 3 year commitment plan is often a good value to start with. \n Possible | ||
values:\n COMMITMENT_PLAN_UNSPECIFIED\nON_DEMAND\nCOMMITMENT_1_YEAR_MONTHLY_PAYMENTS\nCOMMITMENT_3_YEAR_MONTHLY_PAYMENTS\nCOMMITMENT_1_YEAR_UPFRONT_PAYMENT\nCOMMITMENT_3_YEAR_UPFRONT_PAYMENT" | ||
- !ruby/object:Api::Type::NestedObject | ||
name: soleTenancyPreferences | ||
description: 'Preferences concerning Sole Tenancy nodes and VMs. ' | ||
properties: | ||
- !ruby/object:Api::Type::Double | ||
name: cpuOvercommitRatio | ||
description: 'CPU overcommit ratio. Acceptable values are between 1.0 and 2.0 | ||
inclusive. ' | ||
- !ruby/object:Api::Type::String | ||
name: hostMaintenancePolicy | ||
description: "Sole Tenancy nodes maintenance policy. \n Possible values:\n HOST_MAINTENANCE_POLICY_UNSPECIFIED\nHOST_MAINTENANCE_POLICY_DEFAULT\nHOST_MAINTENANCE_POLICY_RESTART_IN_PLACE\nHOST_MAINTENANCE_POLICY_MIGRATE_WITHIN_NODE_GROUP" | ||
- !ruby/object:Api::Type::String | ||
name: commitmentPlan | ||
description: "Commitment plan to consider when calculating costs for virtual | ||
machine insights and recommendations. If you are unsure which value to set, | ||
a 3 year commitment plan is often a good value to start with. \n Possible | ||
values:\n COMMITMENT_PLAN_UNSPECIFIED\nON_DEMAND\nCOMMITMENT_1_YEAR\nCOMMITMENT_3_YEAR" | ||
- !ruby/object:Api::Type::Array | ||
name: nodeTypes | ||
item_type: !ruby/object:Api::Type::NestedObject | ||
properties: | ||
- !ruby/object:Api::Type::String | ||
name: nodeName | ||
description: 'Name of the Sole Tenant node. Consult https://cloud.google.com/compute/docs/nodes/sole-tenant-nodes ' | ||
description: 'A list of sole tenant node types. An empty list means that all | ||
possible node types will be considered. ' | ||
parameters: | ||
- !ruby/object:Api::Type::String | ||
name: location | ||
description: 'Part of `parent`. See documentation of `projectsId`. ' | ||
url_param_only: true | ||
required: true | ||
immutable: true | ||
- !ruby/object:Api::Type::String | ||
name: preferenceSetId | ||
description: 'Required. User specified ID for the preference set. It will become | ||
the last component of the preference set name. The ID must be unique within the | ||
project, must conform with RFC-1034, is restricted to lower-cased letters, and | ||
has a maximum length of 63 characters. The ID must match the regular expression | ||
`[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. ' | ||
url_param_only: true | ||
required: true | ||
immutable: true | ||
async: !ruby/object:Api::OpAsync | ||
operation: !ruby/object:Api::OpAsync::Operation | ||
path: name | ||
base_url: "{{op_id}}" | ||
wait_ms: 1000 | ||
timeouts: | ||
result: !ruby/object:Api::OpAsync::Result | ||
path: response | ||
resource_inside_response: true | ||
status: !ruby/object:Api::OpAsync::Status | ||
path: done | ||
complete: true | ||
allowed: | ||
- true | ||
- false | ||
error: !ruby/object:Api::OpAsync::Error | ||
path: error | ||
message: message |
13 changes: 13 additions & 0 deletions
13
mmv1/templates/terraform/examples/preference_set_basic.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
resource "google_migration_center_preference_set" "<%= ctx[:primary_resource_id] %>" { | ||
location = "us-central1" | ||
preference_set_id = "<%= ctx[:vars]['set_name'] %>" | ||
description = "Terraform integration test description" | ||
display_name = "Terraform integration test display" | ||
virtual_machine_preferences { | ||
vmware_engine_preferences { | ||
cpu_overcommit_ratio = 1.5 | ||
} | ||
sizing_optimization_strategy = "SIZING_OPTIMIZATION_STRATEGY_SAME_AS_SOURCE" | ||
target_product = "COMPUTE_MIGRATION_TARGET_PRODUCT_COMPUTE_ENGINE" | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
mmv1/templates/terraform/examples/preference_set_full.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
resource "google_migration_center_preference_set" "<%= ctx[:primary_resource_id] %>" { | ||
location = "us-central1" | ||
preference_set_id = "<%= ctx[:vars]['set_name'] %>" | ||
description = "Terraform integration test description" | ||
display_name = "Terraform integration test display" | ||
virtual_machine_preferences { | ||
vmware_engine_preferences { | ||
cpu_overcommit_ratio = 1.5 | ||
storage_deduplication_compression_ratio = 1.3 | ||
commitment_plan = "ON_DEMAND" | ||
} | ||
sizing_optimization_strategy = "SIZING_OPTIMIZATION_STRATEGY_SAME_AS_SOURCE" | ||
target_product = "COMPUTE_MIGRATION_TARGET_PRODUCT_COMPUTE_ENGINE" | ||
commitment_plan = "COMMITMENT_PLAN_ONE_YEAR" | ||
region_preferences { | ||
preferred_regions = ["us-central1"] | ||
} | ||
sole_tenancy_preferences { | ||
commitment_plan = "ON_DEMAND" | ||
cpu_overcommit_ratio = 1.2 | ||
host_maintenance_policy = "HOST_MAINTENANCE_POLICY_DEFAULT" | ||
node_types { | ||
node_name = "tf-test" | ||
} | ||
} | ||
compute_engine_preferences { | ||
license_type = "LICENSE_TYPE_BRING_YOUR_OWN_LICENSE" | ||
machine_preferences { | ||
allowed_machine_series { | ||
code = "C3" | ||
} | ||
} | ||
} | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
...party/terraform/services/migrationcenter/resource_migration_center_preference_set_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** Type: MMv1 *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// This file is automatically generated by Magic Modules and manual | ||
// changes will be clobbered when the file is regenerated. | ||
// | ||
// Please read more about how to change this file in | ||
// .github/CONTRIBUTING.md. | ||
// | ||
// ---------------------------------------------------------------------------- | ||
|
||
package migrationcenter_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
) | ||
|
||
func TestAccMigrationCenterPreferenceSet_preferenceSetUpdate(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
CheckDestroy: testAccCheckMigrationCenterPreferenceSetDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccMigrationCenterPreferenceSet_preferenceSetStart(context), | ||
}, | ||
{ | ||
ResourceName: "google_migration_center_preference_set.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"location", "preference_set_id"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccMigrationCenterPreferenceSet_preferenceSetStart(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_migration_center_preference_set" "default" { | ||
location = "us-central1" | ||
preference_set_id = "tf-test-preference-set-test%{random_suffix}" | ||
description = "Terraform integration test description" | ||
display_name = "Terraform integration test display" | ||
virtual_machine_preferences { | ||
vmware_engine_preferences { | ||
cpu_overcommit_ratio = 1.5 | ||
memory_overcommit_ratio = 2.0 | ||
} | ||
sizing_optimization_strategy = "SIZING_OPTIMIZATION_STRATEGY_SAME_AS_SOURCE" | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccMigrationCenterPreferenceSet_preferenceSetUpdate(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_migration_center_preference_set" "default" { | ||
location = "us-central1" | ||
preference_set_id = "tf-test-preference-set-test%{random_suffix}" | ||
description = "Terraform integration test updated description" | ||
display_name = "Terraform integration test updated display" | ||
virtual_machine_preferences { | ||
vmware_engine_preferences { | ||
cpu_overcommit_ratio = 1.4 | ||
} | ||
sizing_optimization_strategy = "SIZING_OPTIMIZATION_STRATEGY_MODERATE" | ||
commitment_plan = "COMMITMENT_PLAN_ONE_YEAR" | ||
preferred_regions = ["us-central1"] | ||
} | ||
} | ||
`, context) | ||
} |