Skip to content

Commit

Permalink
Merge branch 'master' into sql-settings-version
Browse files Browse the repository at this point in the history
  • Loading branch information
slevenick authored Aug 31, 2018
2 parents e7fb3d2 + e903fc6 commit 61843f4
Show file tree
Hide file tree
Showing 39 changed files with 1,042 additions and 200 deletions.
2 changes: 1 addition & 1 deletion build/ansible
Submodule ansible updated 39 files
+2 −2 lib/ansible/module_utils/gcp_utils.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_address.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py
+100 −2 lib/ansible/modules/cloud/google/gcp_compute_backend_service.py
+33 −0 lib/ansible/modules/cloud/google/gcp_compute_backend_service_facts.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_disk.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_firewall.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_global_address.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py
+31 −16 lib/ansible/modules/cloud/google/gcp_compute_health_check.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_http_health_check.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_https_health_check.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_image.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_instance.py
+86 −4 lib/ansible/modules/cloud/google/gcp_compute_instance_group.py
+9 −0 lib/ansible/modules/cloud/google/gcp_compute_instance_group_facts.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_instance_template.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_network.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_route.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_router.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_target_pool.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_url_map.py
+0 −2 lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py
+0 −2 lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py
+13 −2 lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py
+2 −2 lib/ansible/modules/cloud/google/gcp_spanner_database.py
+0 −2 lib/ansible/modules/cloud/google/gcp_storage_bucket.py
+0 −2 lib/ansible/modules/cloud/google/gcp_storage_bucket_access_control.py
+65 −0 test/integration/targets/gcp_dns_resource_record_set/tasks/main.yml
2 changes: 1 addition & 1 deletion build/chef/_bundle
Submodule _bundle updated 1 files
+10 −2 README.md
2 changes: 1 addition & 1 deletion build/chef/compute
Submodule compute updated 57 files
+2 −0 CONTRIBUTING.md
+54 −5 README.md
+144 −0 libraries/google/compute/property/backendservice_iap.rb
+51 −0 libraries/google/compute/property/health_check_proxy_header.rb
+3 −2 libraries/google/compute/property/healthcheck_http_health_check.rb
+3 −2 libraries/google/compute/property/healthcheck_https_health_check.rb
+3 −2 libraries/google/compute/property/healthcheck_ssl_health_check.rb
+3 −2 libraries/google/compute/property/healthcheck_tcp_health_check.rb
+2 −6 resources/address.rb
+2 −6 resources/backend_bucket.rb
+17 −6 resources/backend_service.rb
+2 −6 resources/disk.rb
+2 −6 resources/disk_type.rb
+2 −6 resources/firewall.rb
+2 −6 resources/forwarding_rule.rb
+2 −6 resources/global_address.rb
+2 −6 resources/global_forwarding_rule.rb
+19 −11 resources/health_check.rb
+2 −6 resources/http_health_check.rb
+2 −6 resources/https_health_check.rb
+2 −6 resources/image.rb
+2 −6 resources/instance.rb
+2 −6 resources/instance_group.rb
+4 −4 resources/instance_group_manager.rb
+2 −6 resources/instance_template.rb
+2 −6 resources/license.rb
+2 −6 resources/machine_type.rb
+2 −6 resources/network.rb
+2 −6 resources/region.rb
+2 −6 resources/route.rb
+2 −6 resources/router.rb
+2 −6 resources/snapshot.rb
+2 −6 resources/ssl_certificate.rb
+2 −6 resources/subnetwork.rb
+2 −6 resources/target_http_proxy.rb
+2 −6 resources/target_https_proxy.rb
+2 −6 resources/target_pool.rb
+2 −6 resources/target_ssl_proxy.rb
+2 −6 resources/target_tcp_proxy.rb
+2 −6 resources/target_vpn_gateway.rb
+2 −6 resources/url_map.rb
+2 −6 resources/vpn_tunnel.rb
+2 −6 resources/zone.rb
+126 −0 spec/backend_service_spec.rb
+6 −0 spec/data/network/gcompute_backend_service/success1~name.yaml
+6 −0 spec/data/network/gcompute_backend_service/success1~title.yaml
+6 −0 spec/data/network/gcompute_backend_service/success2~name.yaml
+6 −0 spec/data/network/gcompute_backend_service/success2~title.yaml
+6 −0 spec/data/network/gcompute_backend_service/success3~name.yaml
+6 −0 spec/data/network/gcompute_backend_service/success3~title.yaml
+3 −3 spec/data/network/gcompute_health_check/success1~name.yaml
+3 −3 spec/data/network/gcompute_health_check/success1~title.yaml
+7 −7 spec/data/network/gcompute_health_check/success2~name.yaml
+7 −7 spec/data/network/gcompute_health_check/success2~title.yaml
+3 −3 spec/data/network/gcompute_health_check/success3~name.yaml
+3 −3 spec/data/network/gcompute_health_check/success3~title.yaml
+46 −46 spec/health_check_spec.rb
2 changes: 1 addition & 1 deletion build/chef/dns
2 changes: 1 addition & 1 deletion build/chef/spanner
Submodule spanner updated 1 files
+1 −1 README.md
2 changes: 1 addition & 1 deletion build/chef/sql
2 changes: 1 addition & 1 deletion build/puppet/_bundle
Submodule _bundle updated 1 files
+10 −2 README.md
2 changes: 1 addition & 1 deletion build/puppet/bigquery
2 changes: 1 addition & 1 deletion build/puppet/compute
Submodule compute updated 59 files
+2 −0 CONTRIBUTING.md
+56 −5 README.md
+141 −0 lib/google/compute/property/backendservice_iap.rb
+50 −0 lib/google/compute/property/health_check_proxy_header.rb
+3 −2 lib/google/compute/property/healthcheck_http_health_check.rb
+3 −2 lib/google/compute/property/healthcheck_https_health_check.rb
+3 −2 lib/google/compute/property/healthcheck_ssl_health_check.rb
+3 −2 lib/google/compute/property/healthcheck_tcp_health_check.rb
+0 −2 lib/puppet/provider/gcompute_address/google.rb
+0 −2 lib/puppet/provider/gcompute_backend_bucket/google.rb
+8 −2 lib/puppet/provider/gcompute_backend_service/google.rb
+0 −2 lib/puppet/provider/gcompute_disk/google.rb
+0 −2 lib/puppet/provider/gcompute_disk_type/google.rb
+0 −2 lib/puppet/provider/gcompute_firewall/google.rb
+0 −2 lib/puppet/provider/gcompute_forwarding_rule/google.rb
+0 −2 lib/puppet/provider/gcompute_global_address/google.rb
+0 −2 lib/puppet/provider/gcompute_global_forwarding_rule/google.rb
+21 −10 lib/puppet/provider/gcompute_health_check/google.rb
+0 −2 lib/puppet/provider/gcompute_http_health_check/google.rb
+0 −2 lib/puppet/provider/gcompute_https_health_check/google.rb
+0 −2 lib/puppet/provider/gcompute_image/google.rb
+0 −2 lib/puppet/provider/gcompute_instance/google.rb
+0 −2 lib/puppet/provider/gcompute_instance_group/google.rb
+0 −2 lib/puppet/provider/gcompute_instance_group_manager/google.rb
+0 −2 lib/puppet/provider/gcompute_instance_template/google.rb
+0 −2 lib/puppet/provider/gcompute_license/google.rb
+0 −2 lib/puppet/provider/gcompute_machine_type/google.rb
+0 −2 lib/puppet/provider/gcompute_network/google.rb
+0 −2 lib/puppet/provider/gcompute_region/google.rb
+0 −2 lib/puppet/provider/gcompute_route/google.rb
+0 −2 lib/puppet/provider/gcompute_router/google.rb
+0 −2 lib/puppet/provider/gcompute_snapshot/google.rb
+0 −2 lib/puppet/provider/gcompute_ssl_certificate/google.rb
+0 −2 lib/puppet/provider/gcompute_subnetwork/google.rb
+0 −2 lib/puppet/provider/gcompute_target_http_proxy/google.rb
+0 −2 lib/puppet/provider/gcompute_target_https_proxy/google.rb
+0 −2 lib/puppet/provider/gcompute_target_pool/google.rb
+0 −2 lib/puppet/provider/gcompute_target_ssl_proxy/google.rb
+0 −2 lib/puppet/provider/gcompute_target_tcp_proxy/google.rb
+0 −2 lib/puppet/provider/gcompute_target_vpn_gateway/google.rb
+0 −2 lib/puppet/provider/gcompute_url_map/google.rb
+0 −2 lib/puppet/provider/gcompute_vpn_tunnel/google.rb
+0 −2 lib/puppet/provider/gcompute_zone/google.rb
+14 −0 lib/puppet/type/gcompute_backend_service.rb
+17 −2 lib/puppet/type/gcompute_health_check.rb
+6 −0 spec/data/network/gcompute_backend_service/success1~name.yaml
+6 −0 spec/data/network/gcompute_backend_service/success1~title.yaml
+6 −0 spec/data/network/gcompute_backend_service/success2~name.yaml
+6 −0 spec/data/network/gcompute_backend_service/success2~title.yaml
+6 −0 spec/data/network/gcompute_backend_service/success3~name.yaml
+6 −0 spec/data/network/gcompute_backend_service/success3~title.yaml
+3 −3 spec/data/network/gcompute_health_check/success1~name.yaml
+3 −3 spec/data/network/gcompute_health_check/success1~title.yaml
+7 −7 spec/data/network/gcompute_health_check/success2~name.yaml
+7 −7 spec/data/network/gcompute_health_check/success2~title.yaml
+3 −3 spec/data/network/gcompute_health_check/success3~name.yaml
+3 −3 spec/data/network/gcompute_health_check/success3~title.yaml
+100 −0 spec/gcompute_backend_service_provider_spec.rb
+44 −44 spec/gcompute_health_check_provider_spec.rb
2 changes: 1 addition & 1 deletion build/puppet/spanner
2 changes: 1 addition & 1 deletion build/terraform
12 changes: 12 additions & 0 deletions google/python_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,17 @@ def python_literal(value)
raise "Unsupported Python literal #{value}"
end
end

# Generates a method declaration with function name `name` and args `args`
# Arguments may have nils and will be ignored.
def method_decl(name, args)
"def #{name}(#{args.compact.join(', ')}):"
end

# Generates a method call to function name `name` and args `args`
# Arguments may have nils and will be ignored.
def method_call(name, args)
"#{name}(#{args.compact.join(', ')})"
end
end
end
27 changes: 27 additions & 0 deletions google/ruby_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,32 @@ def ruby_literal(value)
raise "Unsupported Ruby literal #{value}"
end
end

def method_decl(name, args)
["def #{name}", ("(#{args.compact.join(', ')})" unless args.empty?)].compact.join
end

# rubocop:disable Metrics/AbcSize
def method_call(name, args, indent = 0)
args = args.compact
format([
# All on one line.
[
[name.to_s, ("(#{args.join(', ')})" unless args.empty?)].compact.join
],
# All but first on one line.
[
[name.to_s, ("(#{args[0..-1].join(', ')}" unless args.empty?)].compact.join,
"#{indent(args.last, indent + name.length + 2)})"
],
# All on separate lines.
[
"#{name}(#{args.first},",
indent_list(args.slice(1..-2), indent + name.length + 1, true),
indent("#{args.last})", indent + name.length + 1)
]
], 0, indent)
end
# rubocop:enable Metrics/AbcSize
end
end
19 changes: 19 additions & 0 deletions products/compute/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ overrides: !ruby/object:Provider::ResourceOverrides
version_added: '2.7'
BackendService: !ruby/object:Provider::Ansible::ResourceOverride
properties:
loadBalancingScheme: !ruby/object:Provider::Ansible::PropertyOverride
version_added: '2.7'
iap: !ruby/object:Provider::Ansible::PropertyOverride
version_added: '2.7'
timeoutSec: !ruby/object:Provider::Ansible::PropertyOverride
aliases:
- timeout_seconds
Expand Down Expand Up @@ -226,6 +230,21 @@ overrides: !ruby/object:Provider::ResourceOverrides
timeoutSec: !ruby/object:Provider::Ansible::PropertyOverride
aliases:
- timeout_seconds
InstanceGroup: !ruby/object:Provider::Ansible::ResourceOverride
properties:
instances: !ruby/object:Provider::Ansible::PropertyOverride
version_added: '2.7'
exclude: false
update: |
instance = InstanceLogic(module)
instance.run()
post_action: |
if fetch:
instance = InstanceLogic(module)
instance.run()
fetch.update({'instances': instance.list_instances()})
provider_helpers:
- 'products/compute/helpers/python/instancegroup_instances.py'
Instance: !ruby/object:Provider::Ansible::ResourceOverride
provider_helpers:
- 'products/compute/helpers/python/provider_instance.py'
Expand Down
78 changes: 71 additions & 7 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,32 @@ objects:
name: 'id'
description: 'The unique identifier for the resource.'
output: true
# 'loadBalancingScheme' is undefined: string? enum? ref? http://b/63215956
# | - !ruby/object:Api::Type::???
# | name: 'loadBalancingScheme'
- !ruby/object:Api::Type::NestedObject
name: 'iap'
description: Settings for enabling Cloud Identity Aware Proxy
properties:
- !ruby/object:Api::Type::Boolean
name: 'enabled'
description: Enables IAP.
- !ruby/object:Api::Type::String
name: 'oauth2ClientId'
description: OAuth2 Client ID for IAP
- !ruby/object:Api::Type::String
name: 'oauth2ClientSecret'
description: OAuth2 Client Secret for IAP
- !ruby/object:Api::Type::String
name: 'oauth2ClientSecretSha256'
description: OAuth2 Client Secret SHA-256 for IAP
output: true
- !ruby/object:Api::Type::Enum
name: 'loadBalancingScheme'
description: |
Indicates whether the backend service will be used with internal or
external load balancing. A backend service created for one type of
load balancing cannot be used with the other.
values:
- :INTERNAL
- :EXTERNAL
- !ruby/object:Api::Type::String
name: 'name'
description: |
Expand Down Expand Up @@ -780,6 +803,14 @@ objects:
is unspecified, the firewall rule will be enabled.
min_version: beta
send_empty_value: true
- !ruby/object:Api::Type::Boolean
name: 'enableLogging'
description: |
This field denotes whether to enable logging for a particular
firewall rule. If logging is enabled, logs will be exported to
Stackdriver.
min_version: beta
send_empty_value: true
- !ruby/object:Api::Type::Integer
name: 'id'
description: 'The unique identifier for the resource.'
Expand Down Expand Up @@ -1258,10 +1289,25 @@ objects:
name: 'HealthCheck'
kind: 'compute#healthCheck'
base_url: projects/{{project}}/global/healthChecks
description:
An HealthCheck resource. This resource defines a template for how
individual virtual machines should be checked for health, via one of the
supported protocols.
exports:
- !ruby/object:Api::Type::SelfLink
name: 'selfLink'
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation': 'https://cloud.google.com/load-balancing/docs/health-checks'
api: 'https://cloud.google.com/compute/docs/reference/rest/latest/healthChecks'
description: |
Health Checks determine whether instances are responsive and able to do work.
They are an important part of a comprehensive load balancing configuration,
as they enable monitoring instances behind load balancers.
Health Checks poll instances at a specified interval. Instances that
do not respond successfully to some number of probes in a row are marked
as unhealthy. No new connections are sent to unhealthy instances,
though existing connections will continue. The health check will
continue to poll unhealthy instances. If an instance later responds
successfully to some number of consecutive probes, it is marked
healthy again and can receive new connections.
<%= indent(compile_file({}, 'templates/global_async.yaml.erb'), 4) %>
properties:
- !ruby/object:Api::Type::Integer
Expand All @@ -1284,6 +1330,7 @@ objects:
description: |
A so-far unhealthy instance will be marked healthy after this many
consecutive successes. The default value is 2.
default_value: 2
- !ruby/object:Api::Type::Integer
name: 'id'
description: |
Expand All @@ -1292,6 +1339,8 @@ objects:
output: true
- !ruby/object:Api::Type::String
name: 'name'
required: true
input: true
description: |
Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
Expand Down Expand Up @@ -1324,6 +1373,7 @@ objects:
- :TCP
- :SSL
- :HTTP
- :HTTPS
- !ruby/object:Api::Type::NestedObject
name: 'httpHealthCheck'
properties:
Expand Down Expand Up @@ -1816,6 +1866,20 @@ objects:
imports: 'name'
description: 'A reference to the zone where the instance group resides.'
required: true
- !ruby/object:Api::Type::Array
name: 'instances'
description: |
The list of instances associated with this InstanceGroup.
All instances must be created before being added to an InstanceGroup.
All instances not in this list will be removed from the InstanceGroup
and will not be deleted.
Only the full identifier of the instance will be returned.
exclude: true
item_type: !ruby/object:Api::Type::ResourceRef
name: 'instance'
description: 'An instance being added to the InstanceGroup'
resource: 'Instance'
imports: 'selfLink'
properties:
- !ruby/object:Api::Type::Time
name: 'creationTimestamp'
Expand Down
2 changes: 2 additions & 0 deletions products/compute/healthcheck_protocol_props.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
description: |
The request path of the <%= protocol -%> health check request.
The default value is /.
default_value: "/"
<% elsif ['SSL', 'TCP'].include?(protocol) -%>
- !ruby/object:Api::Type::String
name: 'request'
Expand Down Expand Up @@ -47,3 +48,4 @@
values:
- :NONE
- :PROXY_V1
default_value: :NONE
64 changes: 64 additions & 0 deletions products/compute/helpers/python/instancegroup_instances.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<%
# Instance Logic handling for Instance Groups
# This code handles the adding + removing of instances from an instance group.
# It should be run after all normal create/update/delete logic.

-%>
class InstanceLogic(object):
def __init__(self, module):
self.module = module
self.current_instances = self.list_instances()
self.module_instances = []

# Transform module list of instances (dicts of instance responses) into a list of selfLinks.
instances = self.module.params.get('instances')
if instances:
for instance in instances:
self.module_instances.append(replace_resource_dict(instance, 'selfLink'))

def run(self):
# Find all instances to add and add them
instances_to_add = list(set(self.module_instances) - set(self.current_instances))
if instances_to_add:
self.add_instances(instances_to_add)

# Find all instances to remove and remove them
instances_to_remove = list(set(self.current_instances) - set(self.module_instances))
if instances_to_remove:
self.remove_instances(instances_to_remove)

def list_instances(self):
auth = GcpSession(self.module, 'compute')
response = return_if_object(self.module, auth.post(self._list_instances_url(), {'instanceState': 'ALL'}),
'compute#instanceGroupsListInstances')

# Transform instance list into a list of selfLinks for diffing with module parameters
instances = []
for instance in response.get('items', []):
instances.append(instance['instance'])
return instances

def add_instances(self, instances):
auth = GcpSession(self.module, 'compute')
wait_for_operation(self.module, auth.post(self._add_instances_url(), self._build_request(instances)))

def remove_instances(self, instances):
auth = GcpSession(self.module, 'compute')
wait_for_operation(self.module, auth.post(self._remove_instances_url(), self._build_request(instances)))

def _list_instances_url(self):
return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{name}/listInstances".format(**self.module.params)

def _remove_instances_url(self):
return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{name}/removeInstances".format(**self.module.params)

def _add_instances_url(self):
return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{name}/addInstances".format(**self.module.params)

def _build_request(self, instances):
request = {
'instances': []
}
for instance in instances:
request['instances'].append({'instance': instance})
return request
Loading

0 comments on commit 61843f4

Please sign in to comment.