Skip to content

Commit

Permalink
Merge 010dacc into d2a8485
Browse files Browse the repository at this point in the history
  • Loading branch information
danawillow committed Jun 26, 2018
2 parents d2a8485 + 010dacc commit 1d88ab9
Show file tree
Hide file tree
Showing 15 changed files with 1,054 additions and 5 deletions.
2 changes: 2 additions & 0 deletions api/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module Properties
attr_reader :description
attr_reader :kind
attr_reader :base_url
attr_reader :update_url
attr_reader :self_link
# This is useful in case you need to change the query made for
# GET/DELETE requests only. In particular, this is often used
Expand Down Expand Up @@ -223,6 +224,7 @@ def validate
super
check_optional_property :async, Api::Async
check_optional_property :base_url, String
check_optional_property :update_url, String
check_property :description, String
check_optional_property :exclude, :boolean
check_optional_property :kind, String
Expand Down
2 changes: 1 addition & 1 deletion coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"result": {
"covered_percent": 80.37
"covered_percent": 80.43
}
}
4 changes: 4 additions & 0 deletions products/compute/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ overrides: !ruby/object:Provider::ResourceOverrides
TargetVpnGateway: !ruby/object:Provider::Ansible::ResourceOverride
exclude: false
# Not yet implemented.
Autoscaler: !ruby/object:Provider::Ansible::ResourceOverride
exclude: true
RegionAutoscaler: !ruby/object:Provider::Ansible::ResourceOverride
exclude: true
Snapshot: !ruby/object:Provider::Ansible::ResourceOverride
exclude: true
# Ansible tasks must alter infrastructure.
Expand Down
78 changes: 78 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,43 @@ objects:
description: 'The URLs of the resources that are using this address.'
item_type: Api::Type::String
output: true
- !ruby/object:Api::Resource
name: 'Autoscaler'
kind: 'compute#autoscaler'
base_url: projects/{{project}}/zones/{{zone}}/autoscalers
update_url: projects/{{project}}/zones/{{zone}}/autoscalers?autoscaler={{name}}
exports:
- !ruby/object:Api::Type::SelfLink
name: selfLink
description: |
Represents an Autoscaler resource.
Autoscalers allow you to automatically scale virtual machine instances in
managed instance groups according to an autoscaling policy that you
define.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Autoscaling Groups of Instances': 'https://cloud.google.com/compute/docs/autoscaler/'
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/autoscalers'
<%= indent(compile_file({}, 'templates/zonal_async.yaml.erb'), 4) %>
parameters:
- !ruby/object:Api::Type::ResourceRef
name: 'zone'
resource: 'Zone'
imports: 'name'
description: |
URL of the zone where the instance group resides.
required: true
input: true
properties:
<%= indent(compile('products/compute/autoscaler_properties.yaml'), 6) %>
- !ruby/object:Api::Type::ResourceRef
name: 'target'
resource: 'InstanceGroupManager'
imports: 'selfLink'
description: |
URL of the managed instance group that this autoscaler will scale.
required: true
- !ruby/object:Api::Resource
name: 'BackendBucket'
kind: 'compute#backendBucket'
Expand Down Expand Up @@ -1919,6 +1956,9 @@ objects:
name: 'InstanceGroupManager'
kind: 'compute#instanceGroupManager'
base_url: projects/{{project}}/zones/{{zone}}/instanceGroupManagers
exports:
- !ruby/object:Api::Type::SelfLink
name: 'selfLink'
description: |
Creates a managed instance group using the information that you specify in
the request. After the group is created, it schedules an action to create
Expand Down Expand Up @@ -2361,6 +2401,44 @@ objects:
description: 'List of zones within the region'
item_type: Api::Type::String
output: true
- !ruby/object:Api::Resource
name: 'RegionAutoscaler'
kind: 'compute#autoscaler'
base_url: projects/{{project}}/regions/{{region}}/autoscalers
update_url: projects/{{project}}/regions/{{region}}/autoscalers?autoscaler={{name}}
exports:
- !ruby/object:Api::Type::SelfLink
name: selfLink
description: |
Represents an Autoscaler resource.
Autoscalers allow you to automatically scale virtual machine instances in
managed instance groups according to an autoscaling policy that you
define.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Autoscaling Groups of Instances': 'https://cloud.google.com/compute/docs/autoscaler/'
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/regionAutoscalers'
<%= indent(compile_file({}, 'templates/regional_async.yaml.erb'), 4) %>
parameters:
- !ruby/object:Api::Type::ResourceRef
name: 'region'
resource: 'Region'
imports: 'name'
description: |
URL of the region where the instance group resides.
required: true
input: true
properties:
<%= indent(compile('products/compute/autoscaler_properties.yaml'), 6) %>
- !ruby/object:Api::Type::String
name: 'target'
# TODO(#303): resourceref once RegionIGM exists
# resource: 'RegionInstanceGroupManager'
# imports: 'selfLink'
description: |
URL of the managed instance group that this autoscaler will scale.
required: true
- !ruby/object:Api::Resource
name: 'Route'
kind: 'compute#route'
Expand Down
149 changes: 149 additions & 0 deletions products/compute/autoscaler_properties.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Copyright 2017 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::Type::Integer
name: 'id'
description: 'Unique identifier for the resource.'
output: true
- !ruby/object:Api::Type::Time
name: 'creationTimestamp'
description: 'Creation timestamp in RFC3339 text format.'
output: true
- !ruby/object:Api::Type::String
name: 'name'
description: |
Name of the resource. The name must be 1-63 characters long and match
the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the
first character must be a lowercase letter, and all following
characters must be a dash, lowercase letter, or digit, except the last
character, which cannot be a dash.
required: true
input: true
- !ruby/object:Api::Type::String
name: 'description'
description: |
An optional description of this resource.
- !ruby/object:Api::Type::NestedObject
name: 'autoscalingPolicy'
description: |
The configuration parameters for the autoscaling algorithm. You can
define one or more of the policies for an autoscaler: cpuUtilization,
customMetricUtilizations, and loadBalancingUtilization.
If none of these are specified, the default will be to autoscale based
on cpuUtilization to 0.6 or 60%.
required: true
properties:
- !ruby/object:Api::Type::Integer
name: 'minNumReplicas'
description: |
The minimum number of replicas that the autoscaler can scale down
to. This cannot be less than 0. If not provided, autoscaler will
choose a default value depending on maximum number of instances
allowed.
- !ruby/object:Api::Type::Integer
name: 'maxNumReplicas'
description: |
The maximum number of instances that the autoscaler can scale up
to. This is required when creating or updating an autoscaler. The
maximum number of replicas should not be lower than minimal number
of replicas.
required: true
- !ruby/object:Api::Type::Integer
name: 'coolDownPeriodSec'
description: |
The number of seconds that the autoscaler should wait before it
starts collecting information from a new instance. This prevents
the autoscaler from collecting information when the instance is
initializing, during which the collected usage would not be
reliable. The default time autoscaler waits is 60 seconds.
Virtual machine initialization times might vary because of
numerous factors. We recommend that you test how long an
instance may take to initialize. To do this, create an instance
and time the startup process.
default_value: 60
- !ruby/object:Api::Type::NestedObject
name: 'cpuUtilization'
description: |
Defines the CPU utilization policy that allows the autoscaler to
scale based on the average CPU utilization of a managed instance
group.
properties:
- !ruby/object:Api::Type::Double
name: 'utilizationTarget'
description: |
The target CPU utilization that the autoscaler should maintain.
Must be a float value in the range (0, 1]. If not specified, the
default is 0.6.
If the CPU level is below the target utilization, the autoscaler
scales down the number of instances until it reaches the minimum
number of instances you specified or until the average CPU of
your instances reaches the target utilization.
If the average CPU is above the target utilization, the autoscaler
scales up until it reaches the maximum number of instances you
specified or until the average utilization reaches the target
utilization.
- !ruby/object:Api::Type::Array
name: 'customMetricUtilizations'
description: |
Defines the CPU utilization policy that allows the autoscaler to
scale based on the average CPU utilization of a managed instance
group.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: 'metric'
description: |
The identifier (type) of the Stackdriver Monitoring metric.
The metric cannot have negative values.
The metric must have a value type of INT64 or DOUBLE.
required: true
- !ruby/object:Api::Type::Double
name: 'utilizationTarget'
description: |
The target value of the metric that autoscaler should
maintain. This must be a positive value. A utilization
metric scales number of virtual machines handling requests
to increase or decrease proportionally to the metric.
For example, a good metric to use as a utilizationTarget is
www.googleapis.com/compute/instance/network/received_bytes_count.
The autoscaler will work to keep this value constant for each
of the instances.
required: true
- !ruby/object:Api::Type::Enum
name: 'utilizationTargetType'
description: |
Defines how target utilization value is expressed for a
Stackdriver Monitoring metric. Either GAUGE, DELTA_PER_SECOND,
or DELTA_PER_MINUTE.
values:
- :GAUGE
- :DELTA_PER_SECOND
- :DELTA_PER_MINUTE
required: true
- !ruby/object:Api::Type::NestedObject
name: 'loadBalancingUtilization'
description: |
Configuration parameters of autoscaling based on a load balancer.
properties:
- !ruby/object:Api::Type::Double
name: 'utilizationTarget'
description: |
Fraction of backend capacity utilization (set in HTTP(s) load
balancing configuration) that autoscaler should maintain. Must
be a positive float value. If not defined, the default is 0.8.
4 changes: 4 additions & 0 deletions products/compute/chef.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ overrides: !ruby/object:Provider::ResourceOverrides
provider_helpers:
- 'products/compute/helpers/ruby/provider_target_pool.rb'
# Not yet implemented.
Autoscaler: !ruby/object:Provider::Chef::ResourceOverride
exclude: true
RegionAutoscaler: !ruby/object:Provider::Chef::ResourceOverride
exclude: true
SslPolicy: !ruby/object:Provider::Chef::ResourceOverride
exclude: true
TargetVpnGateway: !ruby/object:Provider::Chef::ResourceOverride
Expand Down
48 changes: 48 additions & 0 deletions products/compute/helpers/terraform/autoscaler_overrides.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2017 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.

id: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
name: !ruby/object:Provider::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validateGCPName'
autoscalingPolicy.minNumReplicas: !ruby/object:Provider::Terraform::PropertyOverride
name: minReplicas
# Even though this field isn't actually required by the API, it makes our
# lives easier if we treat it as a required field. It has a default that is
# set by the API based on the value of maxNumReplicas. Normally in this case
# we would just set it to Optional+Computed. However, this currently doesn't
# work with nested fields. Make it required so we don't set the field to zero
# when our users aren't expecting us to. For more info, see
# https://github.com/GoogleCloudPlatform/magic-modules/issues/305.
required: true
autoscalingPolicy.maxNumReplicas: !ruby/object:Provider::Terraform::PropertyOverride
name: maxReplicas
autoscalingPolicy.coolDownPeriodSec: !ruby/object:Provider::Terraform::PropertyOverride
name: cooldownPeriod
autoscalingPolicy.cpuUtilization: !ruby/object:Provider::Terraform::PropertyOverride
default_from_api: true
autoscalingPolicy.cpuUtilization.utilizationTarget: !ruby/object:Provider::Terraform::PropertyOverride
name: target
required: true # See comment for minReplicas
autoscalingPolicy.customMetricUtilizations: !ruby/object:Provider::Terraform::PropertyOverride
name: metric
autoscalingPolicy.customMetricUtilizations.metric: !ruby/object:Provider::Terraform::PropertyOverride
name: name
autoscalingPolicy.customMetricUtilizations.utilizationTarget: !ruby/object:Provider::Terraform::PropertyOverride
name: target
autoscalingPolicy.customMetricUtilizations.utilizationTargetType: !ruby/object:Provider::Terraform::PropertyOverride
name: type
autoscalingPolicy.loadBalancingUtilization.utilizationTarget: !ruby/object:Provider::Terraform::PropertyOverride
name: target
required: true # See comment for minReplicas
4 changes: 4 additions & 0 deletions products/compute/puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ overrides: !ruby/object:Provider::ResourceOverrides
handlers: !ruby/object:Provider::Puppet::Handlers
flush: raise 'Region cannot be edited' if @dirty
# Not yet implemented.
Autoscaler: !ruby/object:Provider::Puppet::ResourceOverride
exclude: true
RegionAutoscaler: !ruby/object:Provider::Puppet::ResourceOverride
exclude: true
TargetVpnGateway: !ruby/object:Provider::Puppet::ResourceOverride
exclude: true
SslPolicy: !ruby/object:Provider::Puppet::ResourceOverride
Expand Down
Loading

0 comments on commit 1d88ab9

Please sign in to comment.