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,30 @@
# -*- 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 edge-cloud CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class EdgeCloud(base.Group):
"""Manage edge-cloud resources."""
category = base.COMPUTE_CATEGORY
def Filter(self, context, args):
del context, args

View File

@@ -0,0 +1,30 @@
# -*- 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 Edge Container (Kubernetes Edge) CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class EdgeContainer(base.Group):
"""Manage Edge Container resources."""
category = base.COMPUTE_CATEGORY
def Filter(self, context, args):
del context, args

View File

@@ -0,0 +1,26 @@
# -*- 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 clusters resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Clusters(base.Group):
"""Manage Kubernetes Edge clusters."""

View File

@@ -0,0 +1,159 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Command to create a GDCE cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.container import cluster
from googlecloudsdk.api_lib.edge_cloud.container import util
from googlecloudsdk.api_lib.util import waiter
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.container import flags as container_flags
from googlecloudsdk.command_lib.edge_cloud.container import print_warning
from googlecloudsdk.command_lib.edge_cloud.container import resource_args
from googlecloudsdk.command_lib.run import flags
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
_EXAMPLES = """
To create a cluster called `my-cluster` in region us-central1,
run:
$ {command} my-cluster --location=us-central1
"""
_API_REFERENCE_ = """
This command uses the edgecontainer/{API} API. The full documentation for this
API can be found at: https://cloud.google.com/edge-cloud
"""
_RCP_LRO_MAXIMUM_TIMEOUT_ = 1800000 # 30 min
_LCP_LRO_MAXIMUM_TIMEOUT_ = 36000000 # 10 hours
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create an Edge Container cluster."""
detailed_help = {
'EXAMPLES': _EXAMPLES,
'API REFERENCE': _API_REFERENCE_.format(
API=util.VERSION_MAP.get(base.ReleaseTrack.GA)
),
}
@staticmethod
def Args(parser):
resource_args.AddClusterResourceArg(parser, 'to create')
container_flags.AddAdminUsers(parser)
container_flags.AddClusterIPV4CIDR(parser)
container_flags.AddServicesIPV4CIDR(parser)
container_flags.AddDefaultMaxPodsPerNode(parser)
container_flags.AddFleetProject(parser)
container_flags.AddLabels(parser)
container_flags.AddMaintenanceWindowRecurrence(parser)
container_flags.AddMaintenanceWindowEnd(parser)
container_flags.AddMaintenanceWindowStart(parser)
container_flags.AddControlPlaneKMSKey(parser)
container_flags.AddLROMaximumTimeout(parser)
container_flags.AddSystemAddonsConfig(parser)
container_flags.AddExternalLbIpv4AddressPools(parser)
container_flags.AddControlPlaneNodeLocation(parser)
container_flags.AddControlPlaneNodeCount(parser)
container_flags.AddControlPlaneNodeStorageSchema(parser)
container_flags.AddControlPlaneMachineFilter(parser)
container_flags.AddControlPlaneSharedDeploymentPolicy(parser)
container_flags.AddOfflineRebootTtL(parser)
container_flags.AddReleaseChannel(parser)
container_flags.AddVersion(parser)
container_flags.AddZoneStorageKMSKey(parser)
container_flags.AddContainerDefaultRuntimeClass(parser)
container_flags.AddEnableGoogleGroupAuthentication(parser)
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
cluster_ref = cluster.GetClusterReference(args)
req = cluster.GetClusterCreateRequest(args, self.ReleaseTrack())
error = cluster.ValidateClusterCreateRequest(req, self.ReleaseTrack())
if error is not None:
log.error(error)
return None
cluster_client = util.GetClientInstance(self.ReleaseTrack())
op = cluster_client.projects_locations_clusters.Create(req)
op_ref = resources.REGISTRY.ParseRelativeName(
op.name, collection='edgecontainer.projects.locations.operations'
)
log.status.Print(
'Create request issued for: [{cluster}]'.format(
cluster=cluster_ref.clustersId
)
)
if not flags.FlagIsExplicitlySet(args, 'async_'):
progress_string = (
'Waiting for operation [{operation}] to complete'.format(
operation=op_ref.RelativeName()
)
)
operation_poller = util.OperationPoller(
cluster_client.projects_locations_clusters,
cluster_client.projects_locations_operations,
)
lro_maximum_timeout = _RCP_LRO_MAXIMUM_TIMEOUT_
if cluster.IsLCPCluster(args):
lro_maximum_timeout = _LCP_LRO_MAXIMUM_TIMEOUT_
if flags.FlagIsExplicitlySet(args, 'lro_timeout'):
lro_maximum_timeout = int(args.lro_timeout)
response = waiter.WaitFor(
operation_poller,
op_ref,
progress_string,
max_wait_ms=lro_maximum_timeout,
)
log.status.Print(
'Created cluster [{cluster}].'.format(cluster=cluster_ref.clustersId)
)
return print_warning.PrintWarning(response, None)
log.status.Print(
'Check operation [{operation}] for status.'.format(
operation=op_ref.RelativeName()
)
)
return print_warning.PrintWarning(op, None)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(Create):
"""Create an Edge Container cluster."""
@staticmethod
def Args(parser, track=base.ReleaseTrack.ALPHA):
"""Registers alpha track flags for this command."""
Create.detailed_help['API REFERENCE'] = _API_REFERENCE_.format(
API=util.VERSION_MAP.get(track)
)
Create.Args(parser)
container_flags.AddClusterIPV6CIDR(parser)
container_flags.AddServicesIPV6CIDR(parser)
container_flags.AddExternalLbIpv6AddressPools(parser)
container_flags.AddExternalLoadBalancerAddressPools(parser)
container_flags.AddEnableClusterIsolation(parser)
container_flags.AddEnableRemoteBackup(parser)
container_flags.AddEnableRobinCNS(parser)
container_flags.AddControlPlaneNodeSystemPartitionSize(parser)

View File

@@ -0,0 +1,25 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Delete an Edge Container cluster.
description: |
Delete an Edge Container cluster.
examples: |
To delete a cluster called 'my-cluster' in region us-central1, run:
$ {command} my-cluster --location=us-central1
request:
collection: edgecontainer.projects.locations.clusters
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
resource:
help_text: Edge Container cluster to delete.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:cluster
async:
collection: edgecontainer.projects.locations.operations

View File

@@ -0,0 +1,21 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Show details about the cluster.
description: Show details about the cluster.
examples: |
To show details about a cluster called 'my-cluster' in region us-central1, run:
$ {command} my-cluster --location=us-central1
request:
collection: edgecontainer.projects.locations.clusters
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
resource:
help_text: The cluster you want to describe.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:cluster

View File

@@ -0,0 +1,107 @@
# -*- 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.
"""Command to get credentials of a GEC cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container import util as container_util
from googlecloudsdk.api_lib.edge_cloud.container import cluster
from googlecloudsdk.api_lib.edge_cloud.container import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.container import flags
from googlecloudsdk.command_lib.edge_cloud.container import kubeconfig
from googlecloudsdk.command_lib.edge_cloud.container import resource_args
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class GetCredentials(base.Command):
"""Get credentials of an edge-container cluster."""
detailed_help = {
'EXAMPLES': kubeconfig.COMMAND_EXAMPLE,
'DESCRIPTION': kubeconfig.COMMAND_DESCRIPTION.format(
kind='Edge Container'
),
}
@classmethod
def Args(cls, parser):
resource_args.AddClusterResourceArg(parser, 'to get credentials')
flags.AddAuthProviderCmdPath(parser)
flags.AddOfflineCredential(parser)
def Run(self, args):
"""Runs the get-credentials command."""
container_util.CheckKubectlInstalled()
cluster_ref = resources.REGISTRY.ParseRelativeName(
args.CONCEPTS.cluster.Parse().RelativeName(),
collection='edgecontainer.projects.locations.clusters',
)
messages = util.GetMessagesModule(self.ReleaseTrack())
cluster_client = util.GetClientInstance(self.ReleaseTrack())
req = messages.EdgecontainerProjectsLocationsClustersGetRequest(
name=cluster_ref.RelativeName()
)
resp = cluster_client.projects_locations_clusters.Get(req)
context = kubeconfig.GenerateContext(
cluster_ref.projectsId, cluster_ref.locationsId, cluster_ref.clustersId
)
if cluster.IsOfflineCredential(args):
if resp.controlPlane is None or resp.controlPlane.local is None:
log.error(
'Offline credential is currently supported only in local '
'control plane cluster'
)
return None
offline_credential_req = (
messages.EdgecontainerProjectsLocationsClustersGenerateOfflineCredentialRequest()
)
offline_credential_req.cluster = cluster_ref.RelativeName()
offline_credential_resp = (
cluster_client.projects_locations_clusters.GenerateOfflineCredential(
offline_credential_req
)
)
context += '_' + offline_credential_resp.userId + '_offline'
kubeconfig.GenerateKubeconfigForOfflineCredential(
resp, context, offline_credential_resp
)
log.warning(
'This offline credential will expire at '
+ offline_credential_resp.expireTime
)
else:
cmd_args = kubeconfig.GenerateAuthProviderCmdArgs(
self.ReleaseTrack(),
cluster_ref.clustersId,
cluster_ref.projectsId,
cluster_ref.locationsId,
)
exec_auth_args = kubeconfig.GenerateExecAuthCmdArgs(
cluster_ref.clustersId,
cluster_ref.projectsId,
cluster_ref.locationsId,
)
kubeconfig.GenerateKubeconfig(
resp, context, args.auth_provider_cmd_path, cmd_args, exec_auth_args
)

View File

@@ -0,0 +1,138 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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.
"""Command to list GDCE clusters."""
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.edge_cloud.container import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.container import resource_args
from googlecloudsdk.core import log
from googlecloudsdk.core import properties
from googlecloudsdk.core import resources
DETAILED_HELP = {
'DESCRIPTION':
"""\
List Edge Container clusters.
""",
'EXAMPLES':
"""\
To list the clusters in region us-central1, run:
$ {command} --location=us-central1
""",
'API REFERENCE':
"""\
This command uses the edgecontainer/v1alpha API. The full documentation for\
this API can be found at: https://cloud.google.com/edge-cloud
""",
}
DISPLAY_TABLE = '''
table(
name.basename():label=NAME,
endpoint:label=ENDPOINT,
labels:label=LABELS,
controlPlaneVersion:label=CONTROL_PLANE_VERSION,
nodeVersion:label=NODE_VERSION,
createTime.date():label=CREATED
)
'''
CLUSTERS_COLLECTION_NAME = 'edgecontainer.projects.locations.clusters'
V1_API_VERSION = 'v1'
V1_ALPHA_API_VERSION = 'v1alpha'
LOC_FLAG = '--location'
LOC_FLAG_HELP = ('Parent Edge Container location to list all contained Edge'
' Container clusters.')
RCP_DEPRECATION_RELEASE_NOTES_LINK = (
'https://cloud.google.com/distributed-cloud/edge/latest/docs/'
'release-notes#March_14_2024')
DEPRECATION_WARNING_TEMPLATE = (
'DEPRECATION: Cluster {} is hosting a control plane in the cloud, which is '
'now deprecated. Please migrate all clusters to host the control plane '
'locally on edge-cloud machines: ' + RCP_DEPRECATION_RELEASE_NOTES_LINK
)
def GetUriFromResourceFunc(api_version):
def UriFunc(cluster, **kwargs):
kwargs['api_version'] = api_version
kwargs['collection'] = 'edgecontainer.projects.locations.clusters'
return resources.REGISTRY.Parse(cluster.name, **kwargs).SelfLink()
return UriFunc
def IsRCPCluster(cluster):
return cluster.controlPlane is None or cluster.controlPlane.local is None
def PrintWarningsAndReturnTrue(cluster):
if IsRCPCluster(cluster) and cluster.status != 'PROVISIONING':
log.warning(DEPRECATION_WARNING_TEMPLATE.format(cluster.name))
return True
# TODO(b/331978625): Unify GA in python after validating Alpha.
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(base.ListCommand):
"""List Edge Container clusters."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: An argparse.ArgumentParser-like object. It is mocked out in order
to capture some information, but behaves like an ArgumentParser.
"""
resource_args.AddLocationOptionalResourceArgForListing(parser)
parser.display_info.AddFormat(DISPLAY_TABLE)
parser.display_info.AddUriFunc(GetUriFromResourceFunc(V1_ALPHA_API_VERSION))
def Run(self, args):
"""This is what gets called when the user runs this command.
Args:
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
Some value that we want to have printed later.
"""
cluster_client = util.GetClientInstance(self.ReleaseTrack())
messages = util.GetMessagesModule(self.ReleaseTrack())
vals = properties.VALUES
project_id = args.project or vals.core.project.Get(required=True)
location = args.location or vals.edge_container.location.Get(required=True)
return list_pager.YieldFromList(
cluster_client.projects_locations_clusters,
messages.EdgecontainerProjectsLocationsClustersListRequest(
parent=f'projects/{project_id}/locations/{location}',
pageSize=args.page_size,
filter=args.filter
),
batch_size=args.page_size,
field='clusters',
limit=args.limit,
batch_size_attribute='pageSize',
predicate=PrintWarningsAndReturnTrue)

View File

@@ -0,0 +1,35 @@
# TODO(b/331978625): Unify GA in python after validating Alpha.
- release_tracks: [GA]
help_text:
brief: List Edge Container clusters.
description: |
List Edge Container clusters.
examples: |
To list the clusters in region us-central1, run:
$ {command} --location=us-central1
request:
collection: edgecontainer.projects.locations.clusters
GA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Parent Edge Container location to list all contained Edge Container clusters.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:location
output:
format: |
table(
name.basename():label=NAME,
endpoint:label=ENDPOINT,
labels:label=LABELS,
controlPlaneVersion:label=CONTROL_PLANE_VERSION,
nodeVersion:label=NODE_VERSION,
createTime.date():label=CREATED
)

View File

@@ -0,0 +1,26 @@
# -*- 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 node pools resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class NodePools(base.Group):
"""Manage Kubernetes Edge node pools."""

View File

@@ -0,0 +1,138 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Command to create an Edge Container node pool."""
from googlecloudsdk.api_lib.edge_cloud.container import nodepool
from googlecloudsdk.api_lib.edge_cloud.container import util
from googlecloudsdk.api_lib.util import waiter
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.container import flags as container_flags
from googlecloudsdk.command_lib.edge_cloud.container import print_warning
from googlecloudsdk.command_lib.edge_cloud.container import resource_args
from googlecloudsdk.command_lib.run import flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
_EXAMPLES = """
To create a node pool called `my-nodePool`, containing 3 nodes in region `us-central1`, run:
$ {command} my-nodePool --cluster=<my-cluster> --location=us-central1 --node-location=<my-node-location> --node-count=3
To create a node pool called `my-nodePool`, containing 3 nodes in region `us-central1`,
using only machine names matching a specific pattern, run:
$ {command} my-nodePool --cluster=<my-cluster> --location=us-central1 --node-location=<my-node-location> --node-count=3 --machine-filter="name:<name>"
To create a node pool called `my-nodePool`, containing 3 nodes in region `us-central1`,
using only machine names NOT matching a specific pattern, run:
$ {command} my-nodePool --cluster=<my-cluster> --location=us-central1 --node-location=<my-node-location> --node-count=3 --machine-filter="NOT name:<name>"
"""
_API_REFERENCE_ = """
This command uses the edgecontainer/{API} API. The full documentation for this
API can be found at: https://cloud.google.com/edge-cloud
"""
_LRO_MAXIMUM_TIMEOUT_ = 68400000 # 19 hours
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create an Edge Container node pool."""
detailed_help = {
'EXAMPLES': _EXAMPLES,
'API REFERENCE': _API_REFERENCE_.format(
API=util.VERSION_MAP.get(base.ReleaseTrack.GA)
),
}
@staticmethod
def Args(parser):
# TODO(b/176452774) Generate an argument for the `labels` param.
resource_args.AddNodePoolResourceArg(parser, 'to create')
container_flags.AddNodeCount(parser)
container_flags.AddNodeLocation(parser)
container_flags.AddNodeStorageSchema(parser)
container_flags.AddMachineFilter(parser)
container_flags.AddLocalDiskKMSKey(parser)
container_flags.AddLROMaximumTimeout(parser)
container_flags.AddNodeLabelsForCreateNodePool(parser)
labels_util.AddCreateLabelsFlags(parser)
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
node_pool_ref = nodepool.GetNodePoolReference(args)
req = nodepool.GetNodePoolCreateRequest(args, self.ReleaseTrack())
client = util.GetClientInstance(self.ReleaseTrack())
op = client.projects_locations_clusters_nodePools.Create(req)
op_ref = resources.REGISTRY.ParseRelativeName(
op.name, collection='edgecontainer.projects.locations.operations'
)
log.status.Print(
'Create request issued for: [{nodePool}]'.format(
nodePool=node_pool_ref.nodePoolsId
)
)
if not flags.FlagIsExplicitlySet(args, 'async_'):
progress_string = (
'Waiting for operation [{operation}] to complete'.format(
operation=op_ref.RelativeName()
)
)
operation_poller = util.OperationPoller(
client.projects_locations_clusters_nodePools,
client.projects_locations_operations,
)
lro_maximum_timeout = _LRO_MAXIMUM_TIMEOUT_
if flags.FlagIsExplicitlySet(args, 'lro_timeout'):
lro_maximum_timeout = int(args.lro_timeout)
response = waiter.WaitFor(
operation_poller,
op_ref,
progress_string,
max_wait_ms=lro_maximum_timeout,
)
log.status.Print(
'Created node pool [{nodePool}].'.format(
nodePool=node_pool_ref.nodePoolsId
)
)
return print_warning.PrintWarning(response, None)
log.status.Print(
'Check operation [{operation}] for status.'.format(
operation=op_ref.RelativeName()
)
)
return print_warning.PrintWarning(op, None)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(Create):
"""Create an Edge Container node pool."""
@staticmethod
def Args(parser, track=base.ReleaseTrack.ALPHA):
"""Registers alpha track flags for this command."""
Create.detailed_help['API REFERENCE'] = _API_REFERENCE_.format(
API=util.VERSION_MAP.get(track)
)
Create.Args(parser)
container_flags.AddNodeSystemPartitionSize(parser)

View File

@@ -0,0 +1,25 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Delete an Edge Container nodePool.
description: |
Delete an Edge Container nodePool.
examples: |
To delete a nodePool called 'my-nodePool' in region us-central1, run:
$ {command} my-nodePool --cluster=<my-cluster> --location=us-central1
request:
collection: edgecontainer.projects.locations.clusters.nodePools
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
resource:
help_text: Edge Container nodePool to delete.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:nodePool
async:
collection: edgecontainer.projects.locations.operations

View File

@@ -0,0 +1,21 @@
release_tracks: [ALPHA, GA]
help_text:
brief: Show details about the nodePool.
description: Show details about the nodePool.
examples: |
To show details about a node pool called 'my-nodePool' in region us-central1, run:
$ {command} my-nodePool --location=us-central1 --cluster=<my-cluster>
request:
collection: edgecontainer.projects.locations.clusters.nodePools
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
resource:
help_text: The nodePool you want to describe.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:nodePool

View File

@@ -0,0 +1,37 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: List Edge Container nodePools.
description: |
List Edge Container nodePools.
examples: |
To list the nodePools in region us-central1, run:
$ {command} --location=us-central1 --cluster=<my-cluster>
request:
collection: edgecontainer.projects.locations.clusters.nodePools
ALPHA:
api_version: v1alpha
GA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Parent Edge Container location to list all contained Edge Container nodePools.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:cluster_with_default
output:
format: |
table(
name.basename():label=NAME,
name.scope(clusters).segment(0):label=CLUSTER,
nodeCount:label=NODE_COUNT,
nodeLocation:label=NODE_LOCATION,
nodeVersion:label=NODE_VERSION,
labels:label=LABELS,
createTime.date():label=CREATED
)

View File

@@ -0,0 +1,139 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Command to update an Edge Container node pool."""
from googlecloudsdk.api_lib.edge_cloud.container import nodepool
from googlecloudsdk.api_lib.edge_cloud.container import util
from googlecloudsdk.api_lib.util import waiter
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.container import flags as container_flags
from googlecloudsdk.command_lib.edge_cloud.container import print_warning
from googlecloudsdk.command_lib.edge_cloud.container import resource_args
from googlecloudsdk.command_lib.run import flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
from googlecloudsdk.core.resource import resource_printer
_EXAMPLES = """
To update the number of nodes in a node pool called `my-node-pool` in region `us-central1`,
run:
$ {command} my-node-pool --location=us-central1 --cluster=<my-cluster> \
--node-count=<new-count>
"""
_API_REFERENCE_ = """
This command uses the edgecontainer/{API} API. The full documentation for this
API can be found at: https://cloud.google.com/edge-cloud
"""
_LRO_MAXIMUM_TIMEOUT_ = 68400000 # 19 hours
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Updates an Edge Container node pool."""
detailed_help = {
'EXAMPLES': _EXAMPLES,
'API REFERENCE': _API_REFERENCE_.format(
API=util.VERSION_MAP.get(base.ReleaseTrack.GA)
),
}
@staticmethod
def Args(parser):
resource_args.AddNodePoolResourceArg(parser, 'to update')
container_flags.AddNodeCount(parser, required=False)
container_flags.AddMachineFilter(parser)
container_flags.AddLROMaximumTimeout(parser)
container_flags.AddNodeLabelsForUpdateNodePool(parser)
labels_util.AddUpdateLabelsFlags(parser)
container_flags.AddLocalDiskKMSKey(parser)
container_flags.AddUseGoogleManagedKey(parser)
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
node_pool_ref = nodepool.GetNodePoolReference(args)
client = util.GetClientInstance(self.ReleaseTrack())
get_req = nodepool.GetNodePoolGetRequest(args, self.ReleaseTrack())
existing_node_pool = client.projects_locations_clusters_nodePools.Get(
get_req
)
update_req = nodepool.GetNodePoolUpdateRequest(
args, self.ReleaseTrack(), existing_node_pool
)
op = client.projects_locations_clusters_nodePools.Patch(update_req)
op_ref = resources.REGISTRY.ParseRelativeName(
op.name, collection='edgecontainer.projects.locations.operations'
)
log.status.Print(
'Update request issued for: [{nodePool}]'.format(
nodePool=node_pool_ref.nodePoolsId
)
)
if not flags.FlagIsExplicitlySet(args, 'async_'):
progress_string = (
'Waiting for operation [{operation}] to complete'.format(
operation=op_ref.RelativeName()
)
)
operation_poller = util.OperationPoller(
client.projects_locations_clusters_nodePools,
client.projects_locations_operations,
)
lro_maximum_timeout = _LRO_MAXIMUM_TIMEOUT_
if flags.FlagIsExplicitlySet(args, 'lro_timeout'):
lro_maximum_timeout = int(args.lro_timeout)
response = waiter.WaitFor(
operation_poller,
op_ref,
progress_string,
max_wait_ms=lro_maximum_timeout,
)
updated_node_pool = client.projects_locations_clusters_nodePools.Get(
get_req
)
log.status.Print(
'Updated node pool [{nodePool}].'.format(
nodePool=node_pool_ref.nodePoolsId
)
)
resource_printer.Print(updated_node_pool, 'json', out=log.status)
return print_warning.PrintWarning(response, None)
log.status.Print(
'Check operation [{operation}] for status.'.format(
operation=op_ref.RelativeName()
)
)
return print_warning.PrintWarning(op, None)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(Update):
"""Updates an Edge Container node pool."""
@staticmethod
def Args(parser, track=base.ReleaseTrack.ALPHA):
"""Registers alpha track flags for this command."""
Update.detailed_help['API REFERENCE'] = _API_REFERENCE_.format(
API=util.VERSION_MAP.get(track)
)
Update.Args(parser)

View File

@@ -0,0 +1,45 @@
# -*- 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.
"""Command to print access tokens for a GKE cluster on GEC."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.container import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.container import resource_args
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
@base.Hidden
class PrintAccessToken(base.Command):
"""Generate an access token for an Edge Container cluster."""
@staticmethod
def Args(parser):
"""Register flags for this command."""
resource_args.AddClusterResourceArg(parser, "to access")
def Run(self, args):
"""Run the command."""
cluster_ref = args.CONCEPTS.cluster.Parse()
messages = util.GetMessagesModule(self.ReleaseTrack())
cluster_client = util.GetClientInstance(self.ReleaseTrack())
req = messages.EdgecontainerProjectsLocationsClustersGenerateAccessTokenRequest(
cluster=cluster_ref.RelativeName())
resp = cluster_client.projects_locations_clusters.GenerateAccessToken(req)
return resp

View File

@@ -0,0 +1,177 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Update an Edge Container cluster.
description: |
Update an Edge Container cluster.
examples: |
To update the maintenance window recurrence rule of a cluster called
'my-cluster' in region us-central1, run:
$ {command} my-cluster --location=us-central1 --maintenance-window-recurrence="FREQ=WEEKLY"
request:
collection: edgecontainer.projects.locations.clusters
ALPHA:
api_version: v1alpha
GA:
api_version: v1
modify_request_hooks:
- googlecloudsdk.command_lib.edge_cloud.container.container_runtime:UpdateContainerRuntimeclass
- googlecloudsdk.command_lib.edge_cloud.container.cluster_isolation:UpdateClusterIsolation
- googlecloudsdk.command_lib.edge_cloud.container.maintenance_policy:AddMaintenanceExclusionWindow
- googlecloudsdk.command_lib.edge_cloud.container.maintenance_policy:RemoveMaintenanceExclusionWindow
- googlecloudsdk.command_lib.edge_cloud.container.maintenance_policy:ClearMaintenanceWindow
- googlecloudsdk.command_lib.edge_cloud.container.max_unavailable:ClearMaxUnavailable
- googlecloudsdk.command_lib.edge_cloud.container.kms:UseGoogleManagedKey
- googlecloudsdk.command_lib.edge_cloud.container.kms:UpdateKmsKey
- googlecloudsdk.command_lib.edge_cloud.container.kms:UseGoogleManagedZoneKey
- googlecloudsdk.command_lib.edge_cloud.container.kms:UpdateZoneKmsKey
- googlecloudsdk.command_lib.edge_cloud.container.robin:HandleEnableRobinCNSUpdate
arguments:
resource:
help_text: Edge Container cluster to update.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:cluster
params:
- group:
mutex: true
params:
- arg_name: clear-maintenance-window
action: store_true
help_text: |
If set, removes the maintenance window setting from the cluster. If any exclusion windows exist, they must be removed beforehand as a maintenance policy cannot exist without a maintenance window.
- group:
help_text: Updates cluster maintenance window setting (more than one flags can be specified from this group)
mutex: false
params:
- arg_name: maintenance-window-start
api_field: cluster.maintenancePolicy.window.recurringWindow.window.startTime
repeated: false
help_text: |
Start time of the recurring cluster maintenance window in the [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339.txt)
format. E.g. "2021-01-01T00:00:00Z" or "2021-01-01T00:00:00-05:00"
- arg_name: maintenance-window-end
api_field: cluster.maintenancePolicy.window.recurringWindow.window.endTime
repeated: false
help_text: |
End time of the recurring cluster maintenance window in the [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339.txt)
format. E.g. "2021-01-01T00:00:00Z" or "2021-01-01T00:00:00-05:00"
- arg_name: maintenance-window-recurrence
api_field: cluster.maintenancePolicy.window.recurringWindow.recurrence
repeated: false
help_text: |
An [RFC 5545](https://tools.ietf.org/html/rfc5545#section-3.8.5.3)
recurrence rule for how the cluster maintenance window recurs. They go
on for the span of time between the start and the end time. E.g. FREQ=WEEKLY;BYDAY=SU.
- arg_name: remove-maintenance-exclusion-window
help_text: |
Name of the maintenance exclusion to remove.
- group:
help_text: Add a maintenance exclusion window (all flags must be specified to add a valid maintenance exclusion window). There can be a maximum of 3 exclusion windows set at a given time. A maintenance exclusion window cannot be added in the absence of a maintenance window.
mutex: false
params:
- arg_name: add-maintenance-exclusion-name
repeated: false
help_text: |
Unique name (per cluster) of the maintenance exclusion window that can be used to remove it.
- arg_name: add-maintenance-exclusion-start
repeated: false
help_text: |
Start time of the maintenance exclusion window (can occur in the past) in the RFC 3339
(https://www.rfc-editor.org/rfc/rfc3339.txt) format. E.g.
"2021-01-01T00:00:00Z" or "2021-01-01T00:00:00-05:00".
- arg_name: add-maintenance-exclusion-end
repeated: false
help_text: |
End time of the maintenance exclusion window in the RFC 3339
(https://www.rfc-editor.org/rfc/rfc3339.txt) format. E.g.
"2021-01-01T00:00:00Z" or "2021-01-01T00:00:00-05:00".
- arg_name: release-channel
api_field: cluster.releaseChannel
repeated: false
help_text: |
Release channel a cluster is subscribed to. It supports two values, NONE and REGULAR. NONE
is used to opt out of any release channel. Clusters subscribed to the REGULAR channel will
be automatically upgraded to versions that are considered GA quality, and cannot be manually
upgraded.
- arg_name: offline-reboot-ttl
type: googlecloudsdk.core.util.times:ParseDuration
processor: googlecloudsdk.core.util.times:FormatDurationForJson
api_field: cluster.survivabilityConfig.offlineRebootTtl
required: false
help_text: |
Specifies the maximum duration a node can reboot offline (without connection to Google) and
then rejoin its cluster to resume its designated workloads. This duration is relative to the
machine's most recent connection to Google. The maximum allowed duration is 7 days. If left
unspecified, the default 0 means not allowed. The parameter should be an ISO 8601 duration
string, for example, "P1DT1H2M3S".
- group:
release_tracks: [ALPHA]
mutex: true
params:
- arg_name: clear-max-unavailable-worker-nodes
action: store_true
help_text: |
Clear the worker node upgrade parallelism, which will default to the upgrade stage size.
- arg_name: max-unavailable-worker-nodes
api_field: cluster.upgradeSettings.maxUnavailableWorkerNodes
help_text: |
Set the worker node upgrade parallelism. The value must be between 1 and the worker node
upgrade stage size, inclusively. If unset, the worker node upgrade parallelism defaults
to the upgrade stage size. This value does not affect the control plane node upgrade
parallelism.
- group:
mutex: true
params:
- arg_name: use-google-managed-key
action: store_true
help_text: |
If set, use Google managed key for the cluster control plane nodes encryption.
- arg_name: control-plane-kms-key
repeated: false
help_text: |
If set, use the specified KMS key for the cluster control plane nodes encryption.
- group:
mutex: true
params:
- arg_name: use-google-managed-zone-key
action: store_true
help_text: |
If set, use Google managed key for zone storage encryption.
- arg_name: zone-storage-kms-key
repeated: false
help_text: |
If set, use the specified KMS key for zone storage encryption.
- arg_name: container-default-runtime-class
repeated: false
help_text: |
If set, use the specified default container runtime class for the cluster.
- arg_name: enable-robin-cns
release_tracks: [ALPHA]
hidden: true
action: store_true
help_text: |
If set, Robin CNS will be enabled on the cluster.
WARNING:
Enabling Robin CNS is irreversible. Once enabled, it cannot be disabled.
Enabling Robin CNS will take over all unused local Persistent Volumes (PVs)
in the cluster. Any data on these PVs will be permanently lost.
- arg_name: enable-cluster-isolation
release_tracks: [ALPHA]
repeated: false
help_text: |
If set to true, the cluster will be created in a secure cluster isolation mode.
response:
modify_response_hooks:
- googlecloudsdk.command_lib.edge_cloud.container.print_warning:PrintWarning
async:
collection: edgecontainer.projects.locations.operations
extract_resource_result: false
update:
read_modify_update: true

View File

@@ -0,0 +1,87 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Command to upgrade an Edge Container cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.container import cluster
from googlecloudsdk.api_lib.edge_cloud.container import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.container import flags as container_flags
from googlecloudsdk.command_lib.edge_cloud.container import print_warning
from googlecloudsdk.command_lib.edge_cloud.container import resource_args
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
_EXAMPLES = """
To upgrade an Edge Container cluster to 1.5.1 immediately, run:
$ {command} my-cluster --version=1.5.1 --schedule=IMMEDIATELY
"""
_API_REFERENCE_ = """
This command uses the edgecontainer/{API} API. The full documentation for this
API can be found at: https://cloud.google.com/edge-cloud
"""
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Upgrade(base.Command):
"""Upgrade an Edge Container cluster."""
detailed_help = {
'EXAMPLES': _EXAMPLES,
'API REFERENCE': _API_REFERENCE_.format(
API=util.VERSION_MAP.get(base.ReleaseTrack.GA)
),
}
@staticmethod
def Args(parser):
resource_args.AddClusterResourceArg(parser, 'to upgrade')
container_flags.AddUpgradeVersion(parser)
container_flags.AddUpgradeSchedule(parser)
def Run(self, args):
cluster_ref = cluster.GetClusterReference(args)
req = cluster.GetClusterUpgradeRequest(args, self.ReleaseTrack())
cluster_client = util.GetClientInstance(self.ReleaseTrack())
op = cluster_client.projects_locations_clusters.Upgrade(req)
op_ref = resources.REGISTRY.ParseRelativeName(
op.name, collection='edgecontainer.projects.locations.operations'
)
log.status.Print(
'Upgrade request issued for: [{cluster}]\nCheck operation [{operation}]'
' for status.'.format(
cluster=cluster_ref.clustersId, operation=op_ref.RelativeName()
)
)
return print_warning.PrintWarning(op, None)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpgradeAlpha(Upgrade):
"""Upgrade an Edge Container cluster."""
@staticmethod
def Args(parser, track=base.ReleaseTrack.ALPHA):
Upgrade.detailed_help['API REFERENCE'] = _API_REFERENCE_.format(
API=util.VERSION_MAP.get(track)
)
Upgrade.Args(parser)

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Get server config.
description: |
*{command}* gets the server configuration for an Edge Container location. This configuration
includes the default cluster version, the supported cluster versions and version configuration
for each release channel.
examples: |
To get server config in region us-central1, run:
$ {command} --location=us-central1
request:
collection: edgecontainer.projects.locations
method: getServerConfig
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
resource:
help_text: The location of the server configuration.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:location
is_positional: false

View File

@@ -0,0 +1,26 @@
# -*- 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 machines resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Clusters(base.Group):
"""Manage Kubernetes Edge machines."""

View File

@@ -0,0 +1,21 @@
release_tracks: [ALPHA, GA]
help_text:
brief: Show details about the machine.
description: Show details about the machine.
examples: |
To show details about a machine called 'my-machine' in region us-central1, run:
$ {command} my-machine --location=us-central1
request:
collection: edgecontainer.projects.locations.machines
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
resource:
help_text: The machine you want to describe.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:machine

View File

@@ -0,0 +1,38 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: List Edge Container machines.
description: |
List Edge Container machines.
examples: |
To list the machines in region us-central1, run:
$ {command} --location=us-central1
request:
collection: edgecontainer.projects.locations.machines
ALPHA:
api_version: v1alpha
GA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Parent Edge Container location to list all contained Edge Container machines.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:location
output:
format: |
table(
name.basename():label=NAME,
status:label=STATUS,
zone:label=ZONE,
labels['/cpu']:label=CPU,
labels['/ram_mb']:label=RAM_MB,
version:label=VERSION,
hostedNode.split('/').join('/').sub('controlPlaneNodes','controlPlane/nodes').split('/').slice(:-2).join('/'):label=HOSTED_NODE_POOL,
purpose:label=PURPOSE
)

View File

@@ -0,0 +1,26 @@
# -*- 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 edge-containers operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Operations(base.Group):
"""Command group for working with Kubernetes Edge operations."""

View File

@@ -0,0 +1,25 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Get description of a long-running edge container operation.
description: |
Get information about a long-running edge container operation.
examples: |-
To get information about a long-running operation with name 'projects/my-project/locations/us-east1/operations/123', run the following command:
$ {command} projects/my-project/locations/us-east1/operations/123
request:
collection: edgecontainer.projects.locations.operations
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
resource:
help_text: The ID of the operation to describe.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:operation
output:
format: json

View File

@@ -0,0 +1,31 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Poll long-running edge container operation until it completes.
description: |
Poll a long-running edge container operation until it completes. When
the operation is complete, this command will display the results of the
analysis.
examples: |
To poll a long-running edge container operation named 'projects/my-project/locations/us-east1/operations/123' until it completes, run the following:
$ {command} projects/my-project/locations/us-east1/operations/123
request:
collection: edgecontainer.projects.locations.operations
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
resource:
help_text: ID for the operation to poll until complete.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:operation
async:
collection: edgecontainer.projects.locations.operations
result_attribute: response
output:
format: json

View File

@@ -0,0 +1,26 @@
# -*- 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 Edge Container regions."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Clusters(base.Group):
"""Manages Edge Container regions."""

View File

@@ -0,0 +1,23 @@
release_tracks: [ALPHA, GA]
help_text:
brief: |
Describe an Edge Container region (location).
description: |
Describe an Edge Container region (location).
examples: |
To display the metadata for the region `us-central1`, run:
$ {command} us-central1
arguments:
resource:
help_text: The region to describe.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:location
request:
collection: edgecontainer.projects.locations
ALPHA:
api_version: v1alpha
GA:
api_version: v1

View File

@@ -0,0 +1,32 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: List Edge Container regions.
description: |
List all regions (locations) where Edge Container clusters can be created.
examples: |
To list all the regions (locations) where Edge Container clusters can be created, run:
$ {command}
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:project
help_text: |
The project name.
request:
collection: edgecontainer.projects.locations
ALPHA:
api_version: v1alpha
GA:
api_version: v1
response:
id_field: name
output:
format: |
table(
locationId:label=NAME:sort=1
)

View File

@@ -0,0 +1,26 @@
# -*- 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 VpnConnections resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class VpnConnections(base.Group):
"""Manage Edge VPN connections between an Edge Container cluster and a VPC network."""

View File

@@ -0,0 +1,69 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Create a VPN connection between an Edge Container cluster and a VPC network.
description: |
Creates a new VPN connection.
examples: |
To create a connection called 'my-vpn-connection' between the VPC network 'my-vpc' and
the Edge Container cluster 'my-cluster' which is at region us-central1, run:
$ {command} my-vpn-connection --location=us-central1 --vpc-network='my-vpc' --cluster='my-cluster'
Here VPC network and cluster should be under the same project.
request:
collection: edgecontainer.projects.locations.vpnConnections
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
params:
- arg_name: vpn_connection
help_text: VPN connection to create.
required: true
is_primary_resource: true
resource_spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:vpnConnection
- arg_name: cluster
help_text: |
The name of the cluster to be connected under current project.
resource_spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:cluster
required: true
resource_method_params:
vpnConnection.cluster: "{__relative_name__}"
- arg_name: vpc-network
api_field: vpnConnection.vpc
help_text: |
The name of the VPC network to be connected. By default it is assumed to be under the same
project as cluster. If this VPC network is under a different project, `vpc-project` is
required.
required: true
- arg_name: nat-gateway-ip
api_field: vpnConnection.natGatewayIp
help_text: |
The NAT gateway IP for the gateway floating IPs. Required if cluster sits behind NAT.
- arg_name: high-availability
api_field: vpnConnection.enableHighAvailability
type: bool
help_text: |
Enables high availability on cluster side. This creates an additional VPN endpoint in
cluster. Multiple Nodes/NodePools are required to enable this feature.
- arg_name: vpc-project
api_field: vpnConnection.vpcProject.projectId
help_text: |
The project of the VPC network. Required if the project of VPC network differs from the
project of the cluster.
- arg_name: router
api_field: vpnConnection.router
help_text: |
Name of the Cloud Router to use when creating the VPN connection. This Cloud Router must be
in the same region as the cluster and connected to the provided VPC network. If not
provided, a service-managed Cloud Router will either be created or reused to create the VPN
connection.
labels:
api_field: vpnConnection.labels
async:
collection: edgecontainer.projects.locations.operations

View File

@@ -0,0 +1,25 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Delete a VPN connection between an Edge Container cluster and a VPC network.
description: |
Delete a VPN connection.
examples: |
To delete a VPN connection called 'test-vpn-connection' at region 'us-central1', run:
$ {command} test-vpn-connection --location=us-central1
request:
collection: edgecontainer.projects.locations.vpnConnections
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
resource:
help_text: VPN connection to delete.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:vpnConnection
async:
collection: edgecontainer.projects.locations.operations

View File

@@ -0,0 +1,25 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Show details about a VPN connection.
description: Show details about a VPN connection.
examples: |
To show details about the VPN connection 'test-vpn-connection' at region us-central1, run:
$ {command} test-vpn-connection --location=us-central1
request:
collection: edgecontainer.projects.locations.vpnConnections
ALPHA:
api_version: v1alpha
GA:
api_version: v1
arguments:
resource:
help_text: VPN connection you want to describe.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:vpnConnection
response:
modify_response_hooks:
- googlecloudsdk.command_lib.edge_cloud.container.vpn:CreateDescribeVPNTableViewResponseHook

View File

@@ -0,0 +1,35 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: List VPN connections.
description: |
List VPN connections.
examples: |
To list the VPN connections at region us-central1, run:
$ {command} --location=us-central
request:
collection: edgecontainer.projects.locations.vpnConnections
ALPHA:
api_version: v1alpha
GA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Parent location to list all contained VPN connections.
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:location
output:
format: |
table(
name.basename():label=NAME,
cluster.basename():label=CLUSTER,
vpc.basename():label=VPC,
labels:label=LABELS,
createTime.date():label=CREATED
)

View File

@@ -0,0 +1,26 @@
# -*- 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 Edge Container regions."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Clusters(base.Group):
"""Inspect Edge Container zones."""

View File

@@ -0,0 +1,36 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: |
Describe an Edge Container zone.
description: |
Describe an Edge Container zone.
examples: |
To display the metadata for the zone `us-central1-edge-operator-a`, run:
$ {command} us-central1-edge-operator-a
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:zone
is_positional: true
help_text: |
The zone name.
request:
collection: edgecontainer.projects.locations
ALPHA:
api_version: v1alpha
GA:
api_version: v1
# Because the resource argument is a zone, the default list method will
# attempt to list '/projects/{project}/locations/{zone}/locations', whereas
# the GetLocation API should be called with a region (and then the zone
# extracted from the response). This hook replaces 'locations/{zone}' with
# 'locations/{region}'.
modify_request_hooks:
- googlecloudsdk.command_lib.edge_cloud.container.locations:ReplaceResourceZoneWithRegion
response:
modify_response_hooks:
- googlecloudsdk.command_lib.edge_cloud.container.locations:ExtractZoneFromLocation

View File

@@ -0,0 +1,34 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: List Edge Container zones.
description: |
List all zones where Edge Container node pools can be created.
examples: |
To list all the zones where Edge Container node pools can be created, run:
$ {command}
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.edge_cloud.container.resources:project
help_text: |
The project name.
request:
collection: edgecontainer.projects.locations
ALPHA:
api_version: v1alpha
GA:
api_version: v1
response:
modify_response_hooks:
- googlecloudsdk.command_lib.edge_cloud.container.locations:ExtractZonesFromLocations
output:
format: |
table(
name:label=ZONE:sort=1,
region
)

View File

@@ -0,0 +1,39 @@
# -*- 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 Distributed Cloud Edge Network CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class EdgeNetworkAlpha(base.Group):
"""Manage Distributed Cloud Edge Network resources."""
category = base.COMPUTE_CATEGORY
def Filter(self, context, args):
del context, args
@base.ReleaseTracks(base.ReleaseTrack.GA)
class EdgeNetwork(base.Group):
"""Manage Distributed Cloud Edge Network resources."""
category = base.COMPUTE_CATEGORY
def Filter(self, context, args):
del context, args

View File

@@ -0,0 +1,26 @@
# -*- 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 interconnect resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Interconnects(base.Group):
"""Manage Distributed Cloud Edge Network interconnects."""

View File

@@ -0,0 +1,26 @@
# -*- 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 attachment resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Attachments(base.Group):
"""Manage Distributed Cloud Edge Network interconnect attachments."""

View File

@@ -0,0 +1,26 @@
# -*- 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 attachment resource(dedicated)."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Attachments(base.Group):
"""Manage Distributed Cloud Edge Network dedicated interconnect attachments."""

View File

@@ -0,0 +1,60 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Create a Distributed Cloud Edge Network interconnect attachment.
description: |
Create a new dedicated Distributed Cloud Edge Network interconnect attachment.
examples: |
To create a dedicated interconnect attachment called 'my-attachment' in edge zone 'us-central1-edge-den1', run:
$ {command} my-attachment --location=us-central1 --zone=us-central1-edge-den1 --interconnect=INTERCONNECT-LINK1 --network=my-edge-network --vlan-id=200 --mtu=1500
request:
collection: edgenetwork.projects.locations.zones.interconnectAttachments
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
modify_request_hooks:
- googlecloudsdk.command_lib.edge_cloud.networking.resources:SetResourcesPathForAttachment
arguments:
resource:
help_text: Distributed Cloud Edge Network interconnectAttachment to create.
# The following should point to the resource argument definition under
# your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:attachment
params:
- arg_name: interconnect
api_field: interconnectAttachment.interconnect
required: true
help_text: |
The underlying interconnect object that this attachment's traffic will traverse through.
- arg_name: network
api_field: interconnectAttachment.network
help_text: |
The network to use for dynamic routing.
- arg_name: mtu
api_field: interconnectAttachment.mtu
type: int
default: 1500
help_text: |
Maximum transmission unit (MTU) is the size of the largest
IP packet that can be transmitted on this attachment. Default
value is 1500 bytes, and the valid values are 1500 and 9000.
- arg_name: vlan-id
api_field: interconnectAttachment.vlanId
default: 0
type: int
help_text: |
The ID of the vlan to tag the subnetwork. Default value is 0.
- arg_name: description
api_field: interconnectAttachment.description
help_text: |
An optional, textual description for the interconnect attachment.
labels:
api_field: interconnectAttachment.labels
async:
collection: edgenetwork.projects.locations.operations

View File

@@ -0,0 +1,27 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Delete a Distributed Cloud Edge Network interconnect attachment.
description: |
Delete a Distributed Cloud Edge Network interconnect attachment.
examples: |
To delete an interconnect attachment called 'my-attachment' in edge zone 'us-central1-edge-den1', run:
$ {command} my-attachment --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.interconnectAttachments
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: Distributed Cloud Edge Network interconnectAttachment to delete.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:attachment
async:
collection: edgenetwork.projects.locations.operations

View File

@@ -0,0 +1,41 @@
release_tracks: [ALPHA, GA]
help_text:
brief: Show details about a Distributed Cloud Edge Network interconnect attachment.
description: |
Show details about a Distributed Cloud Edge Network interconnect attachment.
examples: |
To show details about an interconnect attachment called 'my-attachment' in edge zone 'us-central1-edge-den1', run:
$ {command} my-attachment --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.interconnectAttachments
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: The interconnect attachment you want to describe.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:attachment
output:
GA:
format: |
yaml(
createTime,
description,
interconnect,
labels,
mtu,
name,
network,
router,
state,
updateTime,
vlanId
)

View File

@@ -0,0 +1,50 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: List Distributed Cloud Edge Network interconnect attachments.
description: |
List Distributed Cloud Edge Network interconnect attachments.
examples: |
To list the interconnect attachments in edge zone 'us-central1-edge-den1', run:
$ {command} --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.interconnectAttachments
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Parent Distributed Cloud Edge Network zone to list all contained Distributed Cloud Edge Network interconnect attachments.
# The following should point to the parent resource argument definition
# under your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:zone
output:
GA:
format: |
table(
name.basename():label=NAME,
mtu:label=MTU,
vlanId:label=VLANID,
interconnect.basename():label=INTERCONNECT,
network.basename():label=NETWORK,
state.sub("STATE_", ""):label=STATE
)
ALPHA:
format: |
table(
name.basename():label=NAME,
mtu:label=MTU,
vlanId:label=VLANID,
interconnect.basename():label=INTERCONNECT,
peeringType.sub("REMOTE_PEERING_NETWORK_TYPE_", ""):label=REMOTEPEERINGTYPE,
network.basename():label=NETWORK,
state.sub("STATE_", ""):label=STATE
)

View File

@@ -0,0 +1,37 @@
release_tracks: [ALPHA, GA]
help_text:
brief: Show details about the Distributed Cloud Edge Network interconnect.
description: Show details about the Distributed Cloud Edge Network interconnect.
examples: |
To show details about an interconnect called 'my-interconnect1' in edge zone 'us-central1-edge-den1', run:
$ {command} my-interconnect1 --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.interconnects
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: The interconnect you want to describe.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:interconnect
output:
GA:
format: |
yaml(
createTime,
description,
deviceCloudResourceName,
interconnectType,
labels,
name,
physicalPorts,
updateTime
)

View File

@@ -0,0 +1,56 @@
# -*- 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.
"""Command to get the diagnostics of a Distributed Cloud Edge Network interconnect.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.networking.interconnects import interconnects
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.networking import resource_args
DESCRIPTION = (
'Get the diagnostics of a specified Distributed Cloud Edge Network '
'interconnect.')
EXAMPLES = """\
To get the diagnostics of the Distributed Cloud Edge Network interconnect
'my-interconnect' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-interconnect --location=us-central1 --zone=us-central1-edge-den1
"""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class GetStatus(base.Command):
"""Get the diagnostics of a specified Distributed Cloud Edge Network interconnect.
*{command}* is used to get the diagnostics of a Distributed Cloud Edge Network
interconnect.
"""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES}
@staticmethod
def Args(parser):
resource_args.AddInterconnectResourceArg(parser, 'to get diagnostics', True)
def Run(self, args):
interconnects_client = interconnects.InterconnectsClient(
self.ReleaseTrack())
interconnect_ref = args.CONCEPTS.interconnect.Parse()
return interconnects_client.GetStatus(interconnect_ref)

View File

@@ -0,0 +1,46 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: List Distributed Cloud Edge Network interconnects.
description: |
List Distributed Cloud Edge Network interconnects.
examples: |
To list the Distributed Cloud Edge Network interconnects in edge zone 'us-central1-edge-den1', run:
$ {command} --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.interconnects
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Parent Distributed Cloud Edge Network zone to list all contained Distributed Cloud Edge Network interconnects.
# The following should point to the parent resource argument definition
# under your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:zone
output:
GA:
format: |
table(
name.basename():label=NAME,
uuid:label=UUID,
deviceCloudResourceName:label=DEVICECLOUDRESOURCENAME,
physicalPorts.list():label=PHYSICALPORTS
)
ALPHA:
format: |
table(
name.basename():label=NAME,
uuid:label=UUID,
deviceCloudResourceName:label=DEVICECLOUDRESOURCENAME,
physicalPorts.list():label=PHYSICALPORTS,
remotePeeringNetworkType.sub("REMOTE_PEERING_NETWORK_TYPE_", ""):label=REMOTEPEERINGTYPE
)

View File

@@ -0,0 +1,26 @@
# -*- 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 Distributed Cloud Edge Network network resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Networks(base.Group):
"""Manage Distributed Cloud Edge Network networks."""

View File

@@ -0,0 +1,42 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Create a Distributed Cloud Edge Network network.
description: |
Create a new Distributed Cloud Edge Network network resource.
examples: |
To create a network called 'my-network' with MTU value of 9000 bytes in edge zone 'us-central1-edge-den1',
run:
$ {command} my-network --location=us-central1 --zone=us-central1-edge-den1 --mtu=9000
request:
collection: edgenetwork.projects.locations.zones.networks
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: Distributed Cloud Edge Network network to create.
# The following should point to the resource argument definition under
# your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:network
params:
- arg_name: description
api_field: network.description
help_text: |
An optional, textual description for the network.
- arg_name: mtu
api_field: network.mtu
help_text: |
Maximum transmission unit (MTU) is the size of the largest
IP packet that can be transmitted on this network. Default value
is 1500 bytes, and the valid values are 1500 and 9000.
labels:
api_field: network.labels
async:
collection: edgenetwork.projects.locations.operations

View File

@@ -0,0 +1,27 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Delete a Distributed Cloud Edge Network network.
description: |
Delete a Distributed Cloud Edge Network network.
examples: |
To delete a Distributed Cloud Edge Network network called 'my-network' in edge zone 'us-central1-edge-den1', run:
$ {command} my-network --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.networks
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: Distributed Cloud Edge Network network to delete.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:network
async:
collection: edgenetwork.projects.locations.operations

View File

@@ -0,0 +1,23 @@
release_tracks: [ALPHA, GA]
help_text:
brief: Show details about the Distributed Cloud Edge Network network.
description: Show details about the Distributed Cloud Edge Network network.
examples: |
To show details about a network called 'my-network' in edge zone 'us-central1-edge-den1', run:
$ {command} my-network --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.networks
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: The Distributed Cloud Edge Network network you want to describe.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:network

View File

@@ -0,0 +1,53 @@
# -*- 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.
"""Command to get the status of a Distributed Cloud Edge Network network."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.networking.networks import networks
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.networking import resource_args
DESCRIPTION = (
'Get the status of a specified Distributed Cloud Edge Network network.')
EXAMPLES = """\
To get the status of the Distributed Cloud Edge Network network
'my-network' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-network --location=us-central1 --zone=us-central1-edge-den1
"""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class GetStatus(base.Command):
"""Get the status of a specified Distributed Cloud Edge Network network.
*{command}* is used to get the status of a Distributed Cloud Edge Network
network.
"""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES}
@staticmethod
def Args(parser):
resource_args.AddNetworkResourceArg(parser, 'to get status', True)
def Run(self, args):
networks_client = networks.NetworksClient(self.ReleaseTrack())
network_ref = args.CONCEPTS.network.Parse()
return networks_client.GetStatus(network_ref)

View File

@@ -0,0 +1,37 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: List Distributed Cloud Edge Network networks.
description: |
List Distributed Cloud Edge Network networks.
examples: |
To list the Distributed Cloud Edge Network networks in edge zone 'us-central1-edge-den1', run:
$ {command} --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.networks
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Parent Distributed Cloud Edge Network zone to list all contained Distributed Cloud Edge Network networks.
# The following should point to the parent resource argument definition
# under your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:zone
output:
format: |
table(
name.basename():label=NAME,
mtu:label=MTU,
description:label=DESCRIPTION,
createTime:label=CREATETIME,
updateTime:label=UPDATETIME
)

View File

@@ -0,0 +1,26 @@
# -*- 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 Distributed Cloud Edge Network operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Operations(base.Group):
"""Command group for working with Distributed Cloud Edge Network operations."""

View File

@@ -0,0 +1,25 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Get description of a long-running edge network operation.
description: |
Get information about a long-running edge network operation.
examples: |-
To get information about a long-running operation with name 'projects/my-project/locations/us-east1/operations/123', run the following command:
$ {command} projects/my-project/locations/us-east1/operations/123
request:
collection: edgenetwork.projects.locations.operations
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: The ID of the operation to describe.
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:operation
output:
format: json

View File

@@ -0,0 +1,31 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Poll long-running edge network operation until it completes.
description: |
Poll a long-running edge network operation until it completes. When
the operation is complete, this command will display the results of the
analysis.
examples: |
To poll a long-running edge network operation named 'projects/my-project/locations/us-east1/operations/123' until it completes, run the following:
$ {command} projects/my-project/locations/us-east1/operations/123
request:
collection: edgenetwork.projects.locations.operations
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: ID for the operation to poll until complete.
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:operation
async:
collection: edgenetwork.projects.locations.operations
result_attribute: response
output:
format: json

View File

@@ -0,0 +1,26 @@
# -*- 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 Distributed Cloud Edge Network routers resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Routers(base.Group):
"""Manage Distributed Cloud Edge Network routers."""

View File

@@ -0,0 +1,121 @@
# -*- 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.
"""Command to add a BGP peer to a Distributed Cloud Edge Network router."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.networking.routers import routers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.networking import resource_args
from googlecloudsdk.command_lib.edge_cloud.networking.routers import flags as routers_flags
from googlecloudsdk.core import log
DESCRIPTION = ('Create a BGP peer to a Distributed Cloud Edge Network router')
EXAMPLES_GA = """\
To create and add a BGP peer for the Distributed Cloud Edge Network router
'my-router' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-router --interface=my-int-r1 --peer-asn=33333 --peer-name=peer1 --peer-ipv4-range=208.117.254.232/31 --location=us-central1 --zone=us-central1-edge-den1
"""
EXAMPLES_ALPHA = """\
To create and add a BGP peer for the Distributed Cloud Edge Network router
'my-router' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-router --interface=my-int-r1 --peer-asn=33333 --peer-name=peer1 --peer-ipv4-range=208.117.254.232/31 --location=us-central1 --zone=us-central1-edge-den1
$ {command} my-router --interface=my-int-r1 --peer-asn=33333 --peer-name=peer1 --peer-ipv6-range=2001:0db8:85a3:0000:0000:8a2e:0370:7334/126 --location=us-central1 --zone=us-central1-edge-den1
"""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class AddBgpPeerAlpha(base.UpdateCommand):
"""Add a BGP peer to a Distributed Cloud Edge Network router.
*{command}* is used to add a BGP peer to a Distributed Cloud Edge Network
router.
"""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES_ALPHA}
@classmethod
def Args(cls, parser):
resource_args.AddRouterResourceArg(
parser, 'to which we add a bgp peer', True
)
routers_flags.AddBgpPeerArgs(
parser,
for_update=False,
enable_peer_ipv6_range=True,
)
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
routers_client = routers.RoutersClient(self.ReleaseTrack())
router_ref = args.CONCEPTS.router.Parse()
update_req_op = routers_client.AddBgpPeer(router_ref, args)
async_ = args.async_
if not async_:
response = routers_client.WaitForOperation(update_req_op)
log.UpdatedResource(
router_ref.RelativeName(), details='Operation was successful.'
)
return response
log.status.Print(
'Updating [{0}] with operation [{1}].'.format(
router_ref.RelativeName(), update_req_op.name
)
)
@base.ReleaseTracks(base.ReleaseTrack.GA)
class AddBgpPeer(base.UpdateCommand):
"""Add a BGP peer to a Distributed Cloud Edge Network router.
*{command}* is used to add a BGP peer to a Distributed Cloud Edge Network
router.
"""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES_GA}
@classmethod
def Args(cls, parser):
resource_args.AddRouterResourceArg(
parser, 'to which we add a bgp peer', True
)
routers_flags.AddBgpPeerArgs(parser)
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
routers_client = routers.RoutersClient(self.ReleaseTrack())
router_ref = args.CONCEPTS.router.Parse()
update_req_op = routers_client.AddBgpPeer(router_ref, args)
async_ = args.async_
if not async_:
response = routers_client.WaitForOperation(update_req_op)
log.UpdatedResource(
router_ref.RelativeName(), details='Operation was successful.')
return response
log.status.Print('Updating [{0}] with operation [{1}].'.format(
router_ref.RelativeName(), update_req_op.name))

View File

@@ -0,0 +1,75 @@
# -*- 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.
"""Command to add an interface to a Distributed Cloud Edge Network router."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.networking.routers import routers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.networking import resource_args
from googlecloudsdk.command_lib.edge_cloud.networking.routers import flags as routers_flags
from googlecloudsdk.core import log
DESCRIPTION = 'Create an interface to a Distributed Cloud Edge Network router.'
EXAMPLES = """\
To create and add a northbound interface for Distributed Cloud Edge Network router 'my-router' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-router --interface-name=my-int-r1 --interconnect-attachment=my-link-attachment --ip-address=208.117.254.233 --ip-mask-length=31 --location=us-central1 --zone=us-central1-edge-den1
To create and add a southbound interface for Distributed Cloud Edge Network router 'my-router' in edge zone 'us-central1-edge-den1', run:
$ {command} my-router --interface-name=my-int-r2 --subnetwork=my-subnet --location=us-central1 --zone=us-central1-edge-den1
"""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class AddInterface(base.UpdateCommand):
"""Add an interface to a Distributed Cloud Edge Network router.
*{command}* is used to add an interface to a Distributed Cloud Edge Network
router.
"""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES}
@classmethod
def Args(cls, parser):
resource_args.AddRouterResourceArg(
parser, 'to which we add an interface', True
)
routers_flags.AddInterfaceArgs(parser)
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
routers_client = routers.RoutersClient(self.ReleaseTrack())
router_ref = args.CONCEPTS.router.Parse()
update_req_op = routers_client.AddInterface(router_ref, args)
async_ = getattr(args, 'async_', False)
if not async_:
response = routers_client.WaitForOperation(update_req_op)
log.UpdatedResource(
router_ref.RelativeName(), details='Operation was successful.'
)
return response
log.status.Print(
'Updating [{0}] with operation [{1}].'.format(
router_ref.RelativeName(), update_req_op.name
)
)

View File

@@ -0,0 +1,55 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Create a Distributed Cloud Edge Network router.
description: |
Create a new Distributed Cloud Edge Network router.
examples: |
To create a router called 'my-router' with asn 65555 in edge zone 'us-central1-edge-den1', run:
$ {command} my-router --network=my-network --location=us-central1 --zone=us-central1-edge-den1
--asn=65555
request:
collection: edgenetwork.projects.locations.zones.routers
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
modify_request_hooks:
- googlecloudsdk.command_lib.edge_cloud.networking.resources:SetResourcesPathForRouter
arguments:
resource:
help_text: Distributed Cloud Edge Network router to create.
# The following should point to the resource argument definition under
# your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:router
params:
- arg_name: network
api_field: router.network
required: true
help_text: |
The network that this subnetwork belongs to.
- arg_name: asn
api_field: router.bgp.asn
required: true
help_text: |
The locally assigned BGP ASN.
- arg_name: keepalive-interval-in-seconds
api_field: router.bgp.keepaliveIntervalInSeconds
type: int
default: 20
hidden: true
help_text: |
The interval in seconds between BGP keepalive messages that are sent to the peer.
- arg_name: description
api_field: router.description
help_text: |
An optional, textual description for the router.
labels:
api_field: router.labels
async:
collection: edgenetwork.projects.locations.operations

View File

@@ -0,0 +1,27 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Delete a Distributed Cloud Edge Network router.
description: |
Delete a Distributed Cloud Edge Network router.
examples: |
To delete a router called 'my-router' in edge zone 'us-central1-edge-den1', run:
$ {command} my-router --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.routers
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: Distributed Cloud Edge Network router to delete.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:router
async:
collection: edgenetwork.projects.locations.operations

View File

@@ -0,0 +1,24 @@
release_tracks: [ALPHA, GA]
help_text:
brief: Show details about the Distributed Cloud Edge Network router.
description: |
Show details about the Distributed Cloud Edge Network router.
examples: |
To show details about a router named 'my-router' in edge zone 'us-central1-edge-den1', run:
$ {command} my-router --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.routers
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: The router you want to describe.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:router

View File

@@ -0,0 +1,64 @@
# -*- 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.
"""Command to get the status of a Distributed Cloud Edge Network router."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.networking.routers import routers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.networking import resource_args
DESCRIPTION = (
'Get the status of a specified Distributed Cloud Edge Network router.')
EXAMPLES = """\
To get the status of the Distributed Cloud Edge Network router
'my-router' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-router --location=us-central1 --zone=us-central1-edge-den1
"""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class GetStatus(base.Command):
"""Get the status of a specified Distributed Cloud Edge Network router.
*{command}* is used to get the status of a Distributed Cloud Edge Network
router.
"""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES}
@staticmethod
def Args(parser):
resource_args.AddRouterResourceArg(parser, 'to get status', True)
def _PreprocessResult(self, router_status):
"""Make the nextHopReachable value explicit for each route status."""
# This is necessary because if nextHopReachable == false, then when it's
# serialized by the server it will not be included, but we want to print it
# out explicitly, whether it's true or false.
for route_status in router_status.result.staticRouteStatus:
route_status.nextHopReachable = bool(route_status.nextHopReachable)
return router_status
def Run(self, args):
routers_client = routers.RoutersClient(self.ReleaseTrack())
router_ref = args.CONCEPTS.router.Parse()
if self.ReleaseTrack() == base.ReleaseTrack.GA:
return routers_client.GetStatus(router_ref)
return self._PreprocessResult(routers_client.GetStatus(router_ref))

View File

@@ -0,0 +1,36 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: List Distributed Cloud Edge Network routers.
description: |
List Distributed Cloud Edge Network routers.
examples: |
To list the routers in edge zone 'us-central1-edge-den1', run:
$ {command} --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.routers
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Parent Distributed Cloud Edge Network zone to list all contained Distributed Cloud Edge Network routers.
# The following should point to the parent resource argument definition
# under your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:zone
output:
format: |
table(
name.basename():label=NAME,
network.basename():label=NETWORK,
bgp.asn:label=ASN,
state.sub("STATE_", ""):label=STATE
)

View File

@@ -0,0 +1,85 @@
# -*- 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.
"""Command to remove a BGP peer from a Distributed Cloud Edge Network router."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.networking.routers import routers
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.networking import resource_args
from googlecloudsdk.core import log
DESCRIPTION = (
'Delete a list of BGP peer from a Distributed Cloud Edge Network router'
)
EXAMPLES = """\
To delete a BGP peer 'peer1' from the Distributed Cloud Edge Network router 'my-router' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-router --peer-name=peer1 --location=us-central1 --zone=us-central1-edge-den1
"""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class RemoveBgpPeer(base.UpdateCommand):
"""Remove a BGP peer from a Distributed Cloud Edge Network router.
*{command}* is used to delete a BGP peer from a Distributed Cloud
Edge
Network router.
"""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES}
@staticmethod
def Args(parser):
resource_args.AddRouterResourceArg(
parser, 'from which we delete a BGP peer', True
)
bgp_peer_parser = parser.add_mutually_exclusive_group(required=True)
bgp_peer_parser.add_argument(
'--peer-names',
type=arg_parsers.ArgList(),
metavar='PEER_NAME',
help="""The list of names for peers being removed.
Only single value allowed currently.
""",
)
bgp_peer_parser.add_argument(
'--peer-name', help='The name of the BGP peer being removed.'
)
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
routers_client = routers.RoutersClient(self.ReleaseTrack())
router_ref = args.CONCEPTS.router.Parse()
update_req_op = routers_client.RemoveBgpPeer(router_ref, args)
async_ = args.async_
if not async_:
response = routers_client.WaitForOperation(update_req_op)
log.UpdatedResource(
router_ref.RelativeName(), details='Operation was successful.'
)
return response
log.status.Print(
'Updating [{0}] with operation [{1}].'.format(
router_ref.RelativeName(), update_req_op.name
)
)

View File

@@ -0,0 +1,74 @@
# -*- 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.
"""Command to an interface on a Distributed Cloud Edge Network router."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.networking.routers import routers
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.networking import resource_args
from googlecloudsdk.core import log
DESCRIPTION = ('Remove an interface on a Distributed Cloud Edge '
'Network router.')
EXAMPLES = """\
To remove the interface 'my-int-r1' on Distributed Cloud Edge Network router 'my-router' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-router --interface-name=my-int-r1 --location=us-central1 --zone=us-central1-edge-den1
"""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class RemoveInterface(base.UpdateCommand):
"""remove an interface on a Distributed Cloud Edge Network router.
*{command}* is used to remove an interface to a Distributed Cloud Edge
Network router.
"""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES}
@staticmethod
def Args(parser):
resource_args.AddRouterResourceArg(parser,
'from which we remove an interface',
True)
interface_parser = parser.add_mutually_exclusive_group(required=True)
interface_parser.add_argument(
'--interface-names',
type=arg_parsers.ArgList(),
metavar='INTERFACE_NAME',
help='The list of names for interfaces being removed.')
interface_parser.add_argument(
'--interface-name', help='The name of the interface being removed.')
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
routers_client = routers.RoutersClient(self.ReleaseTrack())
router_ref = args.CONCEPTS.router.Parse()
update_req_op = routers_client.RemoveInterface(router_ref, args)
async_ = getattr(args, 'async_', False)
if not async_:
response = routers_client.WaitForOperation(update_req_op)
log.UpdatedResource(
router_ref.RelativeName(), details='Operation was successful.')
return response
log.status.Print('Updating [{0}] with operation [{1}].'.format(
router_ref.RelativeName(), update_req_op.name))

View File

@@ -0,0 +1,99 @@
# -*- 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.
"""Command to update a Distributed Cloud Edge Network router."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.networking.routers import routers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.networking import resource_args
from googlecloudsdk.command_lib.edge_cloud.networking.routers import flags as routers_flags
from googlecloudsdk.core import log
DESCRIPTION = """Update a Distributed Cloud Edge Network router.
Note that `update` operations are not thread-safe, meaning that if more than one
user is updating a router at a time, there can be race conditions. Please ensure
that at most one `update` operation is being applied to a given router at a
time.
"""
EXAMPLES = """\
To add a northbound route advertisement for destination range 8.8.0.0/16 for Distributed Cloud Edge Network router 'my-router' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-router --add-advertisement-ranges=8.8.0.0/16 --location=us-central1 --zone=us-central1-edge-den1
To remove a northbound route advertisement for destination range 8.8.0.0/16 for Distributed Cloud Edge Network router 'my-router' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-router --remove-advertisement-ranges=8.8.0.0/16 --location=us-central1 --zone=us-central1-edge-den1
To replace the set of route advertisements with just 8.8.0.0/16 and 1.1.0.0/16, in Distributed Cloud Edge Network router 'my-router' in edge zone 'us-central1-edge-den1' , run:
$ {command} my-router --set-advertisement-ranges=8.8.0.0/16,1.1.0.0/16 --location=us-central1 --zone=us-central1-edge-den1
"""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Update(base.UpdateCommand):
"""Update a Distributed Cloud Edge Network router.
*{command}* is used update a Distributed Cloud Edge Network router.
"""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES}
@staticmethod
def Args(parser):
resource_args.AddRouterResourceArg(parser, 'to be updated', True)
routers_flags.AddUpdateArgs(parser)
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
routers_client = routers.RoutersClient(self.ReleaseTrack())
router_ref = args.CONCEPTS.router.Parse()
if not self.has_routes_arg(args):
return
update_req_op = routers_client.ChangeAdvertisements(router_ref, args)
async_ = getattr(args, 'async_', False)
if not async_:
response = routers_client.WaitForOperation(update_req_op)
log.UpdatedResource(
router_ref.RelativeName(), details='Operation was successful.')
return response
log.status.Print('Updating [{0}] with operation [{1}].'.format(
router_ref.RelativeName(), update_req_op.name))
def has_routes_arg(self, args):
relevant_args = [
args.add_advertisement_ranges,
args.remove_advertisement_ranges,
args.set_advertisement_ranges,
]
filtered = filter(None, relevant_args)
number_found = sum(1 for _ in filtered)
if number_found == 0:
return False
if number_found == 1:
return True
raise ValueError(
'Invalid argument: Expected at most one of add_advertisement_ranges '
'remove_advertisement_ranges set_advertisement_ranges')

View File

@@ -0,0 +1,27 @@
# -*- 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 Distributed Cloud Edge Network routes resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Routes(base.Group):
"""Manage Distributed Cloud Edge Network routes."""

View File

@@ -0,0 +1,55 @@
- release_tracks: [ALPHA]
help_text:
brief: Create a Distributed Cloud Edge Network route.
description: |
Create a new Distributed Cloud Edge Network route.
examples: |
To create a route called `AMF_OAM_VRF_1_macVlan` in zone `us-east1-den3`,
with destination range `10.145.201.1/32`, and next hop of `10.140.65.2`,
use the command
$ {command} AMF_OAM_VRF_1_macVlan \
--network=AMF_OAM \
--destination-range=10.145.201.1/32 \
--zone=us-east1-den3 \
--next-hop-address=10.140.64.2
request:
collection: edgenetwork.projects.locations.zones.routes
api_version: v1alpha1
modify_request_hooks:
- googlecloudsdk.command_lib.edge_cloud.networking.resources:SetResourcesPathForRoute
arguments:
resource:
help_text: Distributed Cloud Edge Network route to create.
# The following should point to the resource argument definition under
# your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:route
params:
- arg_name: network
api_field: route.network
required: true
help_text: |
Network that this route belongs to.
- arg_name: destination-range
api_field: route.destinationCidr
required: true
help_text: |
Destination subnet of this route (in CIDR format).
- arg_name: next-hop-address
api_field: route.nextHopAddress
required: true
help_text: |
IP address of the next hop along this route.
- arg_name: description
api_field: route.description
help_text: |
An optional, textual description for the route.
labels:
api_field: route.labels
async:
collection: edgenetwork.projects.locations.operations

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA]
help_text:
brief: Delete a Distributed Cloud Edge Network route.
description: |
Delete a Distributed Cloud Edge Network route.
examples: |
To delete a route called `AMF_OAM_VRF_1_macVlan` in edge zone `us-central1-edge-den1`, run:
$ {command} 'AMF_OAM_VRF_1_macVlan' \
--location=us-central1 \
--zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.routes
api_version: v1alpha1
arguments:
resource:
help_text: Distributed Cloud Edge Network route to delete.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:route
async:
collection: edgenetwork.projects.locations.operations

View File

@@ -0,0 +1,21 @@
release_tracks: [ALPHA]
help_text:
brief: Show details about the Distributed Cloud Edge Network route.
description: |
Show details about the Distributed Cloud Edge Network route.
examples: |
To show details about a route named `my-route` in edge zone `us-central1-edge-den1`, run:
$ {command} my-route --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.routes
api_version: v1alpha1
arguments:
resource:
help_text: The route you want to describe.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:route

View File

@@ -0,0 +1,34 @@
- release_tracks: [ALPHA]
help_text:
brief: List Distributed Cloud Edge Network routes.
description: |
List Distributed Cloud Edge Network routes.
examples: |
To list the routes in edge zone `us-central1-edge-den1`, run:
$ {command} --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.routes
api_version: v1alpha1
response:
id_field: name
arguments:
resource:
help_text: Parent Distributed Cloud Edge Network zone to list all contained Distributed Cloud Edge Network routes.
# The following should point to the parent resource argument definition
# under your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:zone
output:
format: |
table(
name.basename():label=NAME,
network.basename():label=NETWORK,
nextHopAddress:label=NEXT_HOP,
destinationCidr:label=DESTINATION_CIDR,
state:label=STATE
)

View File

@@ -0,0 +1,26 @@
# -*- 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 subnet resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Subnets(base.Group):
"""Manage Distributed Cloud Edge Network subnets."""

View File

@@ -0,0 +1,62 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Create a Distributed Cloud Edge Network subnet.
description: |
Create a new Distributed Cloud Edge Network subnet.
examples: |
To create a Distributed Cloud Edge Network subnet called `my-subnet` with VLAN ID and owned ip ranges specified in the edge zone 'us-central1-edge-den1', run:
$ {command} my-subnet --network=my-network --location=us-central1 --zone=us-central1-edge-den1 --ipv4-range=192.168.1.1/24,172.10.10.1/24 --ipv6-range=2001:db8::1/64,4001:230::1/64 --vlan-id=100 --bonding-type=bonded
request:
collection: edgenetwork.projects.locations.zones.subnets
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
modify_request_hooks:
- googlecloudsdk.command_lib.edge_cloud.networking.resources:SetResourcesPathForSubnet
arguments:
resource:
help_text: Distributed Cloud Edge Network subnet to create.
# The following should point to the resource argument definition under
# your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:subnet
params:
- arg_name: description
api_field: subnet.description
help_text: |
An optional, textual description for the subnet.
- arg_name: ipv4-range
api_field: subnet.ipv4Cidr
type: "googlecloudsdk.calliope.arg_parsers:ArgList:"
help_text: |
The ranges of ipv4 addresses that are owned by this subnetwork in CIDR format.
- arg_name: ipv6-range
api_field: subnet.ipv6Cidr
type: "googlecloudsdk.calliope.arg_parsers:ArgList:"
help_text: |
The ranges of ipv6 addresses that are owned by this subnetwork in CIDR format.
- arg_name: network
api_field: subnet.network
required: true
help_text: |
The network that this subnetwork belongs to.
- arg_name: vlan-id
api_field: subnet.vlanId
type: int
help_text: |
The ID of the VLAN to tag the subnetwork. If not specified we assign one automatically.
- arg_name: bonding-type
api_field: subnet.bondingType
help_text: |
Whether or not the VLAN being created will be present on bonded or non-bonded port types. If not specified, the VLAN will be created on both port types by default.
release_tracks: [ALPHA]
labels:
api_field: subnet.labels
async:
collection: edgenetwork.projects.locations.operations

View File

@@ -0,0 +1,27 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Delete a Distributed Cloud Edge Network subnet.
description: |
Delete a Distributed Cloud Edge Network subnet.
examples: |
To delete a subnet called 'my-subnet' in the edge zone 'us-central1-edge-den1', run:
$ {command} my-subnet --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.subnets
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: Distributed Cloud Edge Network subnet to delete.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:subnet
async:
collection: edgenetwork.projects.locations.operations

View File

@@ -0,0 +1,24 @@
release_tracks: [ALPHA, GA]
help_text:
brief: Show details about the Distributed Cloud Edge Network subnet.
description: |
Show details about the Distributed Cloud Edge Network subnet.
examples: |
To show details about a subnet named 'my-subnet' in the edge zone 'us-central1-edge-den1', run:
$ {command} my-subnet --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.subnets
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
arguments:
resource:
help_text: The subnet you want to describe.
# The following should point to the resource argument definition under your
# surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:subnet

View File

@@ -0,0 +1,38 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: List Distributed Cloud Edge Network subnets.
description: |
List Distributed Cloud Edge Network subnets.
examples: |
To list the subnets in the edge zone 'us-central1-edge-den1', run:
$ {command} --location=us-central1 --zone=us-central1-edge-den1
request:
collection: edgenetwork.projects.locations.zones.subnets
ALPHA:
api_version: v1alpha1
GA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Parent Distributed Cloud Edge Network zone to list all contained Distributed Cloud Edge Network subnets.
# The following should point to the parent resource argument definition
# under your surface's command_lib directory.:
spec: !REF googlecloudsdk.command_lib.edge_cloud.networking.resources:zone
output:
format: |
table(
name.basename():label=NAME,
network.basename():label=NETWORK,
vlanId:label=VLANID,
ipv4Cidr.list():label=IPV4CIDR,
ipv6Cidr.list():label=IPV6CIDR,
state.sub("STATE_", ""):label=STATE
)

View File

@@ -0,0 +1,26 @@
# -*- 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 zone resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Zones(base.Group):
"""Manage Distributed Cloud Edge Network zones."""

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.
"""Command to initialize a Distributed Cloud Edge Network zone."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.edge_cloud.networking.zones import zones
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.edge_cloud.networking import resource_args
from googlecloudsdk.core import log
DESCRIPTION = ('Initialize a specified Distributed Cloud Edge Network zone.')
EXAMPLES = """\
To initialize a Distributed Cloud Edge Network zone called
'us-central1-edge-den1', run:
$ {command} us-central1-edge-den1 --location=us-central1
"""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class InitialzeZone(base.Command):
"""Initialize a specified Distributed Cloud Edge Network zone.
*{command}* is used to initialize a Distributed Cloud Edge Network
zone.
"""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES}
@staticmethod
def Args(parser):
resource_args.AddZoneResourceArg(parser, 'to initialize', True)
def Run(self, args):
zones_client = zones.ZonesClient(self.ReleaseTrack())
zone_ref = args.CONCEPTS.zone.Parse()
log.status.Print('Starting to initialize the zone...')
zones_client.InitializeZone(zone_ref)
log.status.Print('Initialized zone [{0}].'.format(zone_ref.RelativeName()))