Skip to content

Commit

Permalink
Merge 3738eca into 1c27165
Browse files Browse the repository at this point in the history
  • Loading branch information
danawillow authored Jul 11, 2018
2 parents 1c27165 + 3738eca commit 802b0aa
Show file tree
Hide file tree
Showing 11 changed files with 654 additions and 1 deletion.
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.43
"covered_percent": 80.04
}
}
114 changes: 114 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2565,6 +2565,120 @@ objects:
output: true
description: |
URL to a Network that should handle matching packets.
- !ruby/object:Api::Resource
name: 'Router'
kind: 'compute#router'
base_url: projects/{{project}}/regions/{{region}}/routers
exports:
- !ruby/object:Api::Type::SelfLink
name: 'selfLink'
description: |
Represents a Router resource.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Google Cloud Router': 'https://cloud.google.com/router/docs/'
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/routers'
<%= indent(compile_file({}, 'templates/regional_async.yaml.erb'), 4) %>
parameters:
- !ruby/object:Api::Type::ResourceRef
name: region
resource: Region
imports: name
description: Region where the router resides.
input: true
required: true
properties:
- !ruby/object:Api::Type::Integer
name: 'id'
description: 'The 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
comply with RFC1035. Specifically, 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.
input: true
required: true
- !ruby/object:Api::Type::String
name: description
description: |
An optional description of this resource.
- !ruby/object:Api::Type::ResourceRef
name: network
resource: Network
imports: 'selfLink'
description: |
A reference to the network to which this router belongs.
required: true
input: true
# TODO(danawillow): Figure out the story for interfaces/bgpPeers. Right
# now in Terraform we have three separate resources: router,
# router_interface, and router_peer. Decide whether we want to keep that
# pattern for the other providers, keep it unique for Terraform, or add
# these fields to the Terraform resource (and then within that, decide
# whether to deprecate router_interface and router_peer or leave them
# alone).
- !ruby/object:Api::Type::NestedObject
name: bgp
description: |
BGP information specific to this router.
properties:
- !ruby/object:Api::Type::Integer
name: asn
description: |
Local BGP Autonomous System Number (ASN). Must be an RFC6996
private ASN, either 16-bit or 32-bit. The value will be fixed for
this router resource. All VPN tunnels that link to this router
will have the same local ASN.
required: true
- !ruby/object:Api::Type::Enum
name: advertiseMode
description: |
User-specified flag to indicate which mode to use for advertisement.
Valid values of this enum field are: DEFAULT, CUSTOM
values:
- :DEFAULT
- :CUSTOM
default_value: :DEFAULT
- !ruby/object:Api::Type::Array
name: advertisedGroups
description: |
User-specified list of prefix groups to advertise in custom mode.
This field can only be populated if advertiseMode is CUSTOM and
is advertised to all peers of the router. These groups will be
advertised in addition to any specified prefixes. Leave this field
blank to advertise no custom groups.
This enum field has the one valid value: ALL_SUBNETS
item_type: Api::Type::String # TODO(#324): enum?
- !ruby/object:Api::Type::Array
name: advertisedIpRanges
description: |
User-specified list of individual IP ranges to advertise in
custom mode. This field can only be populated if advertiseMode
is CUSTOM and is advertised to all peers of the router. These IP
ranges will be advertised in addition to any specified groups.
Leave this field blank to advertise no custom IP ranges.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: range
description: |
The IP range to advertise. The value must be a
CIDR-formatted string.
- !ruby/object:Api::Type::String
name: description
description: |
User-specified description for the IP range.
- !ruby/object:Api::Resource
name: 'Snapshot'
kind: 'compute#snapshot'
Expand Down
47 changes: 47 additions & 0 deletions products/compute/examples/ansible/router.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2018 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:Provider::Ansible::Example
dependencies:
- !ruby/object:Provider::Ansible::Task
name: gcp_compute_network
register: network
code: |
name: <%= dependency_name('network', 'router') %>
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>
task: !ruby/object:Provider::Ansible::Task
name: gcp_compute_router
code: |
name: <%= ctx[:name] %>
network: "{{ network }}"
bgp:
asn: 64514
advertise_mode: 'CUSTOM'
advertised_groups:
- 'ALL_SUBNETS'
advertised_ip_ranges:
- range: '1.2.3.4'
- range: '6.7.0.0/16'
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>
verifier: !ruby/object:Provider::Ansible::Verifier
command: |
gcloud compute routers describe
--project="{{ gcp_project}}"
--region=us-west1
"{{ resource_name }}"
failure: !ruby/object:Provider::Ansible::ComputeFailureCondition
region: regions/us-west1
type: routes
39 changes: 39 additions & 0 deletions products/compute/examples/chef/delete_router.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<% if false # the license inside this if block assertains to this file -%>
# Copyright 2018 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.
<% end -%>
<% if name != 'README.md' -%>
<%= compile 'templates/license.erb' -%>
<%= lines(autogen_notice :chef) -%>
<%= compile 'templates/chef/example~auth.rb.erb' -%>
gcompute_region <%= example_resource_name('some-region') -%> do
action :create
r_label 'us-west1'
project ENV['PROJECT'] # ex: 'my-test-project'
credential 'mycred'
end
<% else # name == README.md -%>
# Router requires a network and a region, so define them in your recipe:
# - gcompute_region 'some-region' do ... end
<% end # name == README.md -%>
gcompute_router <%= example_resource_name('my-router') -%> do
action :delete
region <%= example_resource_name('some-region') %>
project ENV['PROJECT'] # ex: 'my-test-project'
credential 'mycred'
end
62 changes: 62 additions & 0 deletions products/compute/examples/chef/router.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<% if false # the license inside this if block assertains to this file -%>
# Copyright 2018 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.
<% end -%>
<% unless name == 'README.md' -%>
<%= compile 'templates/license.erb' -%>
<%= lines(autogen_notice :chef) -%>
<%= compile 'templates/chef/example~auth.rb.erb' -%>
<% end -%>
<% if name == "README.md" -%>
# Router requires a network and a region, so define them in your recipe:
# - gcompute_network 'my-network' do ... end
# - gcompute_region 'some-region' do ... end
<% else # name == README.md -%>
gcompute_network <%= example_resource_name('my-network') -%> do
action :create
project ENV['PROJECT'] # ex: 'my-test-project'
credential 'mycred'
end
gcompute_region <%= example_resource_name('some-region') -%> do
action :create
r_label 'us-west1'
project ENV['PROJECT'] # ex: 'my-test-project'
credential 'mycred'
end
<% end # name == README.md -%>
gcompute_router <%= example_resource_name('my-router') -%> do
action :create
bgp(
asn 64514
advertise_mode 'CUSTOM'
advertised_groups ['ALL_SUBNETS']
advertised_ip_ranges [
{
range '1.2.3.4'
}
{
range '6.7.0.0/16'
}
]
)
network <%= example_resource_name('my-network') %>
region <%= example_resource_name('some-region') %>
project ENV['PROJECT'] # ex: 'my-test-project'
credential 'mycred'
end
37 changes: 37 additions & 0 deletions products/compute/examples/puppet/delete_router.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<% if false # the license inside this if block assertains to this file -%>
# Copyright 2018 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.
<% end -%>
<% if name != "README.md" -%>
<%= compile 'templates/license.erb' -%>

<%= lines(autogen_notice :puppet) -%>

<%= compile 'templates/puppet/examples~credential.pp.erb' -%>

gcompute_region { <%= example_resource_name('some-region') -%>:
name => 'us-west1',
project => $project, # e.g. 'my-test-project'
credential => 'mycred',
}

<% else # name == README.md -%>
# Router requires a network and a region, so define them in your manifest:
# - gcompute_region { 'some-region': ... }
<% end # name == README.md -%>
gcompute_router { <%= example_resource_name('my-router') -%>:
ensure => absent,
region => <%= example_resource_name('some-region') -%>,
project => $project, # e.g. 'my-test-project'
credential => 'mycred',
}
60 changes: 60 additions & 0 deletions products/compute/examples/puppet/router.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<% if false # the license inside this if block assertains to this file -%>
# Copyright 2018 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.
<% end -%>
<% unless name == "README.md" -%>
<%= compile 'templates/license.erb' -%>

<%= lines(autogen_notice :puppet) -%>

<%= compile 'templates/puppet/examples~credential.pp.erb' -%>

<% end # name == README.md -%>
<% if name == "README.md" -%>
# Router requires a network and a region, so define them in your manifest:
# - gcompute_network { 'my-network': ensure => present }
# - gcompute_region { 'some-region': ... }
<% else # name == README.md -%>
gcompute_network { <%= example_resource_name('my-network') -%>:
ensure => present,
project => $project, # e.g. 'my-test-project'
credential => 'mycred',
}

gcompute_region { <%= example_resource_name('some-region') -%>:
name => 'us-west1',
project => $project, # e.g. 'my-test-project'
credential => 'mycred',
}

<% end # name == README.md -%>
gcompute_router { <%= example_resource_name('my-router') -%>:
ensure => present,
network => <%= example_resource_name('my-network') -%>,
bgp => {
asn => 64514,
advertise_mode => 'CUSTOM',
advertised_groups => ['ALL_SUBNETS'],
advertised_ip_ranges => [
{
range => '1.2.3.4',
},
{
range => '6.7.0.0/16',
}
]
},
region => <%= example_resource_name('some-region') -%>,
project => $project, # e.g. 'my-test-project'
credential => 'mycred',
}
Loading

0 comments on commit 802b0aa

Please sign in to comment.