feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# 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.
"""The command group for the VMware Engine VPC peering CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class NetworkPeering(base.Group):
"""Manage VMware Engine VPC peering using Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,189 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# 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.
"""VMware Engine VPC network peering create command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import networkpeering
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_peerings import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Create a VMware Engine VPC network peering. VPC network peering creation is considered finished when the network peering is in ACTIVE state. Check the progress of a VPC network peering using `{parent_command} list`.
""",
'EXAMPLES':
"""
To create a VPC network peering called `new-peering` that connects the VMware Engine network `my-vmware-engine-network` with another VMware Engine network `another-vmware-engine-network` from project `another-project`, run:
$ {command} new-peering --vmware-engine-network=my-vmware-engine-network --peer-network=another-vmware-engine-network --peer-network-type=VMWARE_ENGINE_NETWORK --peer-project=another-project
In this example, the project is taken from gcloud properties core/project and location is taken as `global`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Create(base.CreateCommand):
"""Create a VMware Engine VPC network peering."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
peer_network_choices = [
'PEER_NETWORK_TYPE_UNSPECIFIED',
'STANDARD',
'VMWARE_ENGINE_NETWORK',
'PRIVATE_SERVICES_ACCESS',
'NETAPP_CLOUD_VOLUMES',
'THIRD_PARTY_SERVICE',
'DELL_POWERSCALE',
'GOOGLE_CLOUD_NETAPP_VOLUMES',
]
flags.AddNetworkPeeringToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--vmware-engine-network',
required=True,
help="""\
ID of the VMware Engine network to attach the new peering to.
""")
parser.add_argument(
'--peer-network',
required=True,
help="""\
ID of the network to peer with the VMware Engine network. The peer network can be a consumer VPC network or another VMware Engine network.
""")
parser.add_argument(
'--peer-network-type',
required=True,
choices=peer_network_choices,
help="""\
Type of the VPC network to peer with the VMware Engine network. PEER_NETWORK_TYPE must be one of the following:
* STANDARD: Peering connection used for connecting to another VPC network established by the same user.
For example, a peering connection to another VPC network in the same project or to an on-premises network.
* VMWARE_ENGINE_NETWORK: Peering connection used for connecting to another VMware Engine network.
* PRIVATE_SERVICES_ACCESS: Peering connection used for establishing private services access.
* NETAPP_CLOUD_VOLUMES: Peering connection used for connecting to NetApp Cloud Volumes.
* THIRD_PARTY_SERVICE: Peering connection used for connecting to third-party services. Most third-party services require manual setup of reverse peering on the VPC network associated with the third-party service.
* DELL_POWERSCALE: Peering connection used for connecting to Dell PowerScale Filers.
* GOOGLE_CLOUD_NETAPP_VOLUMES: Peering connection used for connecting to Google Cloud NetApp Volumes.
""",
)
parser.add_argument(
'--vmware-engine-network-project',
help="""\
Project of the VMware Engine network to attach the new peering to. Use this flag when the VMware Engine network is in another project.
""")
parser.add_argument(
'--peer-project',
help="""\
Project ID or project number of the peer network. Use this flag when the peer network is in another project.
""")
parser.add_argument(
'--description',
help="""\
User-provided description of the VPC network peering.
""")
parser.add_argument(
'--peer-mtu',
required=False,
type=arg_parsers.BinarySize(lower_bound='1GB'),
help="""\
Maximum transmission unit (MTU) in bytes.
""")
parser.add_argument(
'--export-custom-routes',
required=False,
action='store_true',
default=True,
help="""\
True if custom routes are exported to the peered VPC network; false otherwise. The default value is true.
""")
parser.add_argument(
'--import-custom-routes',
required=False,
action='store_true',
default=True,
help="""\
True if custom routes are imported to the peered VPC network; false otherwise. The default value is true.
""")
parser.add_argument(
'--import-custom-routes-with-public-ip',
required=False,
action='store_true',
default=True,
help="""\
True if all subnet routes with public IP address range are imported; false otherwise. The default value is true.
""")
parser.add_argument(
'--export-custom-routes-with-public-ip',
required=False,
action='store_true',
default=True,
help="""\
True if all subnet routes with public IP address range are exported; false otherwise. The default value is true.
""")
parser.add_argument(
'--exchange-subnet-routes',
required=False,
action='store_true',
default=True,
help="""\
True if full-mesh connectivity is created and managed automatically between peered VPC networks; false otherwise. This field is always true because Google Compute Engine automatically creates and manages subnetwork routes between two VPC networks when the peering state is ACTIVE.
""")
def Run(self, args):
peering = args.CONCEPTS.network_peering.Parse()
client = networkpeering.NetworkPeeringClient()
is_async = args.async_
operation = client.Create(
peering,
vmware_engine_network_id=args.vmware_engine_network,
peer_network_id=args.peer_network,
peer_network_type=args.peer_network_type,
description=args.description,
vmware_engine_network_project=args.vmware_engine_network_project,
peer_project=args.peer_project,
peer_mtu=args.peer_mtu,
export_custom_routes=args.export_custom_routes,
import_custom_routes=args.import_custom_routes,
export_custom_routes_with_public_ip=args.export_custom_routes_with_public_ip,
import_custom_routes_with_public_ip=args.import_custom_routes_with_public_ip,
exchange_subnet_routes=args.exchange_subnet_routes
)
if is_async:
log.CreatedResource(
operation.name, kind='VPC network peering', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for vpc peering [{}] to be created'.format(
peering.RelativeName()))
log.CreatedResource(peering.RelativeName(), kind='VPC network peering')
return resource

View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# 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.
"""VMware Engine VPC network peering delete command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import networkpeering
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_peerings import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Delete a VPC network peering. After you delete a VPC network peering, you won't be able to access the corresponding VMware Engine network through the peer network.
""",
'EXAMPLES':
"""
To delete a VPC network peering with name `my-peering`, run:
$ {command} my-peering
In this example, the project is taken from gcloud properties core/project and location is taken as `global`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DescribeCommand):
"""Delete a Google Cloud VMware Engine VPC network peering."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkPeeringToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
def Run(self, args):
peering = args.CONCEPTS.network_peering.Parse()
client = networkpeering.NetworkPeeringClient()
is_async = args.async_
operation = client.Delete(peering)
if is_async:
log.DeletedResource(
operation.name, kind='VPC network peering', is_async=True)
return operation
return client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for vpc peering [{}] to be deleted'.format(
peering.RelativeName()),
has_result=False)

View File

@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# 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.
"""'VMware engine VPC network peering describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import networkpeering
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_peerings import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Get information about a VPC network peering.
""",
'EXAMPLES':
"""
To get information about a VPC network peering called `new-peering`, run:
$ {command} new-peering
In this example, the project is taken from gcloud properties core/project and location is taken as `global`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Google Cloud VMware Engine VPC network peering."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkPeeringToParser(parser, positional=True)
def Run(self, args):
peering = args.CONCEPTS.network_peering.Parse()
client = networkpeering.NetworkPeeringClient()
return client.Get(peering)

View File

@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# 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.
"""VMware engine vpc network list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import networkpeering
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_peerings import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List VPC network peerings across all locations in your project.
""",
'EXAMPLES':
"""
To list all the VPC network peerings created on or after April 12, 2021, sorted from oldest to newest, run:
$ {command} --filter="createTime > 2021-04-12T00:00:00.00Z" --sort-by=createTime
In this example, the location is taken as `global`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Google Cloud VMware Engine VPC network peerings."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLocationArgToParser(parser)
parser.display_info.AddFormat('table(name.segment(-1):label=NAME,'
'name.segment(-5):label=PROJECT,'
'name.segment(-3):label=LOCATION,'
'createTime,state)')
def Run(self, args):
location = args.CONCEPTS.location.Parse()
client = networkpeering.NetworkPeeringClient()
return client.List(location)

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# 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.
"""The command group for the VMware Engine VPC peering routes CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class NetworkPeeringRoutes(base.Group):
"""Manage VMware Engine VPC peering routes using Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,87 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# 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.
"""VMware Engine VPC network peering routes list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import networkpeeringroutes
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_peerings import flags
from googlecloudsdk.core.resource import resource_projector
DETAILED_HELP = {
'DESCRIPTION':
"""
List VPC network peering routes across all locations in your project.
""",
'EXAMPLES':
"""
To list peering routes imported from peer network via my-peering:
$ {command} --network-peering=my-peering --filter="direction=INCOMING"
To list peering routes exported to peer network via my-peering:
$ {command} --network-peering=my-peering --filter="direction=OUTGOING"
In above examples, the location is taken as `global`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Google Cloud VMware Engine VPC network peering routes."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkPeeringToParser(parser)
parser.display_info.AddFormat("""\
table(
dest_range,
type,
next_hop_region,
status,
direction)
""")
def Run(self, args):
networkpeering = args.CONCEPTS.network_peering.Parse()
client = networkpeeringroutes.NetworkPeeringRoutesClient()
items = client.List(networkpeering)
def _TransformStatus(direction, imported):
"""Create customized status field based on direction and imported."""
if imported:
if direction == 'INCOMING':
return 'accepted'
return 'accepted by peer'
if direction == 'INCOMING':
return 'rejected by config'
return 'rejected by peer config'
for item in items:
route = resource_projector.MakeSerializable(item)
# Set "status" to "Imported" or "Imported by peer" based on direction.
route['status'] = _TransformStatus(
route['direction'], route.get('imported', False)
)
yield route

View File

@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# 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.
"""VMware Engine VPC network peering update command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import networkpeering
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_peerings import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Update a VMware Engine VPC network peering description.
""",
'EXAMPLES':
"""
To update only the description of a VPC network peering named `my-peering` to `Example description`, run:
$ {command} my-peering --description="Example description"
In this example, the project is taken from gcloud properties core/project and location is taken as `global`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Google Cloud VMware Engine VPC network peering."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkPeeringToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--description',
required=False,
help="""\
Updated description for this VPC network peering.
""")
def Run(self, args):
peering = args.CONCEPTS.network_peering.Parse()
client = networkpeering.NetworkPeeringClient()
is_async = args.async_
operation = client.Update(peering, description=args.description)
if is_async:
log.UpdatedResource(
operation.name, kind='VPC network peering', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for vpc peering [{}] to be updated'.format(
peering.RelativeName()))
log.UpdatedResource(peering.RelativeName(), kind='VPC network peering')
return resource