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

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

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the vmware private-clouds CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class PrivateClouds(base.Group):
"""Manage private clouds in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the vmware clusters CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Clusters(base.Group):
"""Manage clusters in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,120 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware clusters create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.clusters import ClustersClient
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.command_lib.vmware.clusters import util
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Create a cluster in a VMware Engine private cloud. Successful creation of a cluster results in a cluster in READY state. Check the progress of a cluster using `{parent_command} list`.
""",
'EXAMPLES':
"""
To create a cluster called `my-cluster` in private cloud `my-private-cloud`, with 3 initial `standard-72` nodes in zone `us-west2-a`, run:
$ {command} my-cluster --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --node-type-config=type=standard-72,count=3
Or:
$ {command} my-cluster --private-cloud=my-private-cloud --node-type-config=type=standard-72,count=3
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Google Cloud VMware Engine cluster."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddClusterArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--node-type-config',
required=True,
type=arg_parsers.ArgDict(
spec={
'type': str,
'count': int,
'custom-core-count': int
},
required_keys=('type', 'count')),
action='append',
help="""\
Information about the type and number of nodes associated with the cluster.
type (required): canonical identifier of the node type.
count (required): number of nodes of this type in the cluster.
custom-core-count (optional): customized number of cores available to each node of the type.
To get a list of valid values for your node type,
run the gcloud vmware node-types describe command and reference the
availableCustomCoreCounts field in the output.
""")
flags.AddAutoscalingSettingsFlagsToParser(parser)
def Run(self, args):
cluster = args.CONCEPTS.cluster.Parse()
client = ClustersClient()
is_async = args.async_
nodes_configs = util.ParseNodesConfigsParameters(args.node_type_config)
autoscaling_settings = None
if args.autoscaling_settings_from_file:
autoscaling_settings = util.ParseAutoscalingSettingsFromFileFormat(
args.autoscaling_settings_from_file
)
if (
args.autoscaling_min_cluster_node_count
or args.autoscaling_max_cluster_node_count
or args.autoscaling_cool_down_period
or args.autoscaling_policy
):
autoscaling_settings = util.ParseAutoscalingSettingsFromInlinedFormat(
args.autoscaling_min_cluster_node_count,
args.autoscaling_max_cluster_node_count,
args.autoscaling_cool_down_period,
args.autoscaling_policy,
)
operation = client.Create(cluster, nodes_configs, autoscaling_settings)
if is_async:
log.CreatedResource(operation.name, kind='cluster', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for cluster [{}] to be created'.format(
cluster.RelativeName()))
log.CreatedResource(cluster.RelativeName(), kind='cluster')
return resource

View File

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware clusters delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.clusters import ClustersClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Delete a cluster in a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To delete a cluster called `my-cluster` in private cloud `my-private-cloud` and zone `us-west2-a`, run:
$ {command} my-cluster --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} my-cluster --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Google Cloud VMware Engine cluster."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddClusterArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
def Run(self, args):
cluster = args.CONCEPTS.cluster.Parse()
client = ClustersClient()
is_async = args.async_
operation = client.Delete(cluster)
if is_async:
log.DeletedResource(operation.name, kind='cluster', is_async=True)
return operation
return client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for cluster [{}] to be deleted'.format(
cluster.RelativeName()),
has_result=False)

View File

@@ -0,0 +1,96 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware clusters describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.clusters import ClustersClient
from googlecloudsdk.api_lib.vmware.nodetypes import NodeTypesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core.resource import resource_projector
DETAILED_HELP = {
'DESCRIPTION':
"""
Display data associated with a VMware Engine cluster, such as its node count, node type, and status.
""",
'EXAMPLES':
"""
To describe a cluster called `my-cluster` in private cloud `my-private-cloud` and zone `us-west2-a`, run:
$ {command} my-cluster --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} my-cluster --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Google Cloud VMware Engine cluster."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddClusterArgToParser(parser, positional=True)
def Run(self, args):
cluster = args.CONCEPTS.cluster.Parse()
location = cluster.Parent().Parent()
clusters_client = ClustersClient()
node_types_client = NodeTypesClient()
existing_cluster = resource_projector.MakeSerializable(
clusters_client.Get(cluster)
)
node_types = node_types_client.List(location)
id_to_node_type = {
node_type.nodeTypeId: node_type for node_type in node_types
}
cluster_memory, cluster_storage, cluster_vcpu, cluster_cores = 0, 0, 0, 0
for node_type_id, node_type_config in existing_cluster[
'nodeTypeConfigs'
].items():
if node_type_id not in id_to_node_type:
continue
node_type = id_to_node_type[node_type_id]
node_count = node_type_config['nodeCount']
custom_core_count = node_type_config.get('customCoreCount') or 0
cores_count = custom_core_count or node_type.totalCoreCount or 0
vcpu_ratio = (
node_type.virtualCpuCount // node_type.totalCoreCount
if node_type.totalCoreCount
else 0
)
cluster_memory += (node_type.memoryGb or 0) * node_count
cluster_storage += (node_type.diskSizeGb or 0) * node_count
cluster_vcpu += cores_count * vcpu_ratio * node_count
cluster_cores += cores_count * node_count
existing_cluster['clusterMemoryGb'] = cluster_memory
existing_cluster['clusterStorageGb'] = cluster_storage
existing_cluster['clusterVirtualCpuCount'] = cluster_vcpu
existing_cluster['clusterCoreCount'] = cluster_cores
return existing_cluster

View File

@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware clusters list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.clusters import ClustersClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List clusters in a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To list clusters in the `my-private-cloud` private cloud run:
$ {command} --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List clusters in a Google Cloud VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
parser.display_info.AddFormat('table(name.segment(-1):label=NAME,'
'name.segment(-5):label=LOCATION,'
'name.segment(-3):label=PRIVATE_CLOUD,'
'createTime,state)')
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = ClustersClient()
return client.List(privatecloud)

View File

@@ -0,0 +1,164 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware clusters mount-datastore' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import json
from googlecloudsdk.api_lib.vmware import clusters
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
ClustersClient = clusters.ClustersClient
DETAILED_HELP = {
'DESCRIPTION': """
Mount a datastore to a cluster in a VMware Engine private cloud.
""",
'EXAMPLES': """
To mount a datastore `my-datastore` to cluster `my-cluster` in private cloud `my-private-cloud` in zone `us-west2-a`, providing subnet, run:
$ {command} my-cluster --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --datastore=projects/my-project/locations/us-west2-a/datastores/my-datastore --subnet=my-subnet
Or:
$ {command} my-cluster --private-cloud=my-private-cloud --datastore=projects/my-project/locations/us-west2-a/datastores/my-datastore --subnet=my-subnet
To mount a datastore `my-datastore` to cluster `my-cluster` in private cloud `my-private-cloud` in zone `us-west2-a`, providing a json file for datastore network, run:
$ {command} my-cluster --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --datastore=projects/my-project/locations/us-west2-a/datastores/my-datastore --datastore-network=network-config.json
Where `network-config.json` contains:
{
"subnet": "my-subnet",
"mtu": 1500,
"connection-count": 4
}
In the examples without location and project, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.Hidden
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class MountDatastore(base.UpdateCommand):
"""Mount a datastore to a Google Cloud VMware Engine cluster."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddClusterArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--datastore',
required=True,
help='The datastore resource name to mount.',
)
network_group = parser.add_mutually_exclusive_group(required=True)
inlined_network_group = network_group.add_argument_group(
help='Datastore network configuration if not providing via file.'
)
inlined_network_group.add_argument(
'--subnet',
required=True,
help="""Subnet to use for inlined datastore network configuration.""",
)
inlined_network_group.add_argument(
'--mtu',
type=int,
help="""MTU for inlined datastore network configuration.""",
)
inlined_network_group.add_argument(
'--connection-count',
type=int,
help="""Connection count for inlined datastore network configuration.""",
)
network_group.add_argument(
'--datastore-network',
type=arg_parsers.FileContents(),
help="""Path to a JSON file containing the datastore network configuration.""",
)
parser.add_argument(
'--access-mode',
choices=['READ_WRITE', 'READ_ONLY'],
help="""Access mode for the datastore.""",
)
parser.add_argument(
'--nfs-version',
choices=['NFS_V3', 'NFS_V4'],
help="""NFS version for the datastore.""",
)
parser.add_argument(
'--ignore-colocation',
action='store_true',
help="""If set, ignore colocation checks.""",
)
def Run(self, args):
cluster = args.CONCEPTS.cluster.Parse()
client = ClustersClient()
is_async = args.async_
subnet = args.subnet
mtu = args.mtu
connection_count = args.connection_count
if args.datastore_network:
try:
datastore_network_config = json.loads(args.datastore_network)
subnet = datastore_network_config.get('subnet')
mtu = datastore_network_config.get('mtu')
connection_count = datastore_network_config.get('connection-count')
except ValueError as e:
raise ValueError(
'Invalid JSON format for datastore-network file: ' + str(e)
)
operation = client.MountDatastore(
cluster_ref=cluster,
datastore=args.datastore,
subnet=subnet,
mtu=mtu,
connection_count=connection_count,
access_mode=args.access_mode,
nfs_version=args.nfs_version,
ignore_colocation=args.ignore_colocation,
)
if is_async:
log.UpdatedResource(
operation.name,
kind=f'cluster {cluster.RelativeName()}',
is_async=True,
)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message=f'waiting for cluster [{cluster.RelativeName()}] to be updated',
)
log.UpdatedResource(
cluster.RelativeName(),
kind='cluster',
details=f'datastore [{args.datastore}] mounted',
)
return resource

View File

@@ -0,0 +1,28 @@
# -*- 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.
"""The command group for the VMware Engine nodes CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Nodes(base.Group):
"""Manage nodes in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,57 @@
# -*- 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.
"""'vmware nodes describe command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.nodes import NodesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION': """
Display data associated with a VMware Engine node, such as its name, state, node type, ip, fqdn.
""",
'EXAMPLES': """
To describe a node called `my-node` in private cloud `my-private-cloud` cluster `my-cluster` and zone `us-west2-a`, run:
$ {command} my-node --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --cluster=my-cluster
Or:
$ {command} my-node --private-cloud=my-private-cloud --cluster=my-cluster
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Google Cloud VMware Engine node."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNodeArgToParser(parser)
def Run(self, args):
node = args.CONCEPTS.node.Parse()
client = NodesClient()
return client.Get(node)

View File

@@ -0,0 +1,65 @@
# -*- 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.
"""'vmware nodes list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.nodes import NodesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION': """
List nodes in a VMware Engine private cloud's cluster.
""",
'EXAMPLES': """
To list nodes in the `my-private-cloud` private cloud and `my-cluster` cluster:
$ {command} --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --cluster=my-cluster
Or:
$ {command} --private-cloud=my-private-cloud --cluster=my-cluster
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List nodes in a Google Cloud VMware Engine private cloud's cluster."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddClusterArgToParser(parser)
parser.display_info.AddFormat(
'table(name.segment(-1):label=NAME,'
'name.segment(-7):label=LOCATION,'
'name.segment(-5):label=PRIVATE_CLOUD,'
'name.segment(-3):label=CLUSTER,'
'state,nodeTypeId,fqdn,'
'internalIp)'
)
def Run(self, args):
cluster = args.CONCEPTS.cluster.Parse()
client = NodesClient()
return client.List(cluster)

View File

@@ -0,0 +1,92 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware clusters unmount-datastore' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import clusters
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
ClustersClient = clusters.ClustersClient
DETAILED_HELP = {
'DESCRIPTION': """
Unmount a datastore from a cluster in a VMware Engine private cloud.
""",
'EXAMPLES': """
To unmount a datastore `my-datastore` from cluster `my-cluster` in private cloud `my-private-cloud` in zone `us-west2-a`, run:
$ {command} my-cluster --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --datastore=projects/my-project/locations/us-west2-a/datastores/my-datastore
Or:
$ {command} my-cluster --private-cloud=my-private-cloud --datastore=projects/my-project/locations/us-west2-a/datastores/my-datastore
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.Hidden
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class UnmountDatastore(base.UpdateCommand):
"""Unmount a datastore from a Google Cloud VMware Engine cluster."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddClusterArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--datastore',
required=True,
help='The datastore resource name to unmount.',
)
def Run(self, args):
cluster = args.CONCEPTS.cluster.Parse()
client = ClustersClient()
is_async = args.async_
operation = client.UnmountDatastore(
cluster_ref=cluster,
datastore=args.datastore,
)
if is_async:
log.UpdatedResource(
operation.name,
kind=f'cluster {cluster.RelativeName()}',
is_async=True,
)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message=f'waiting for cluster [{cluster.RelativeName()}] to be updated',
)
log.UpdatedResource(
cluster.RelativeName(),
kind='cluster',
details=f'datastore [{args.datastore}] unmounted',
)
return resource

View File

@@ -0,0 +1,408 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware clusters update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from typing import List
from googlecloudsdk.api_lib.vmware import clusters
from googlecloudsdk.calliope import actions
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.command_lib.vmware.clusters import util
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION': """
Adjust the number of nodes in the VMware Engine cluster. Successful addition or removal of a node results in a cluster in READY state. Check the progress of a cluster using `{parent_command} list`.
""",
'EXAMPLES': """
To resize a cluster called `my-cluster` in private cloud `my-private-cloud` and zone `us-west2-a` to have `3` nodes of type `standard-72`, run:
$ {command} my-cluster --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --update-nodes-config=type=standard-72,count=3
Or:
$ {command} my-cluster --private-cloud=my-private-cloud --update-nodes-config=type=standard-72,count=3
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
To enable autoscale in a cluster called `my-cluster` in private cloud `my-private-cloud` and zone `us-west2-a`, run:
$ {command} my-cluster --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --autoscaling-min-cluster-node-count=3 --autoscaling-max-cluster-node-count=5 --update-autoscaling-policy=name=custom-policy,node-type-id=standard-72,scale-out-size=1,storage-thresholds-scale-in=10,storage-thresholds-scale-out=80
""",
}
_NODE_TYPE_CONFIG_HELP = """
Information about the type and number of nodes associated with the cluster.
type (required): canonical identifier of the node type.
count (required): number of nodes of this type in the cluster.
"""
_OLD_NODE_TYPE_CONFIG_HELP = _NODE_TYPE_CONFIG_HELP + """
custom_core_count: can be passed, but the value will be ignored. Updating custom core count is not supported.
"""
def _ParseOldNodesConfigsParameters(existing_cluster, nodes_configs):
"""Parses the node configs parameters passed in the old format.
In the old format, the nodes configs are passed in a way that specifies what
exact node configs should be attached to the cluster after the operation. It's
not possible to remove existing node types. Even unchanged nodes configs have
to be specified in the parameters.
Args:
existing_cluster: cluster whose nodes configs should be updated
nodes_configs: nodes configs to be attached to the cluster
Returns:
list of NodeTypeConfig objects prepared for further processing
Raises:
InvalidNodeConfigsProvidedError:
if duplicate node types were specified or if a config for an existing node
type is not specified
"""
current_node_types = [
prop.key for prop in existing_cluster.nodeTypeConfigs.additionalProperties
]
requested_node_types = [config['type'] for config in nodes_configs]
duplicated_types = util.FindDuplicatedTypes(requested_node_types)
if duplicated_types:
raise util.InvalidNodeConfigsProvidedError(
f'types: {duplicated_types} provided more than once.'
)
unspecified_types = set(current_node_types) - set(requested_node_types)
if unspecified_types:
raise util.InvalidNodeConfigsProvidedError(
'when using `--node-type-config` parameters you need to specify node'
' counts for all node types present in the cluster. Missing node'
f' types: {list(unspecified_types)}.'
)
return [
util.NodeTypeConfig(
type=config['type'], count=config['count'], custom_core_count=0
)
for config in nodes_configs
]
def _ParseNewNodesConfigsParameters(
existing_cluster, updated_nodes_configs, removed_types
):
"""Parses the node configs parameters passed in the new format.
In the new format, the nodes configs are passed using two parameters. One of
them specifies which configs should be updated or created (unchanged configs
don't have to be specified at all). The other lists the configs to be removed.
This format is more flexible than the old one because it allows for config
removal and doesn't require re-specifying unchanged configs.
Args:
existing_cluster: cluster whose nodes configs should be updated
updated_nodes_configs: list of nodes configs to update or create
removed_types: list of node types for which nodes configs should be removed
Returns:
list of NodeTypeConfig objects prepared for further processing
Raises:
InvalidNodeConfigsProvidedError:
if duplicate node types were specified
"""
requested_node_types = [
config['type'] for config in updated_nodes_configs
] + removed_types
duplicated_types = util.FindDuplicatedTypes(requested_node_types)
if duplicated_types:
raise util.InvalidNodeConfigsProvidedError(
f'types: {duplicated_types} provided more than once.'
)
node_count = {}
for prop in existing_cluster.nodeTypeConfigs.additionalProperties:
node_count[prop.key] = prop.value.nodeCount
for config in updated_nodes_configs:
node_count[config['type']] = config['count']
for node_type in removed_types:
node_count[node_type] = 0
return [
util.NodeTypeConfig(type=node_type, count=count, custom_core_count=0)
for node_type, count in node_count.items()
]
def _ValidatePoliciesToRemove(
existing_cluster, updated_settings, policies_to_remove
):
"""Checks if the policies specified for removal actually exist and that they are not updated in the same call.
Args:
existing_cluster: cluster before the update
updated_settings: updated autoscale settings
policies_to_remove: list of policy names to remove
Raises:
InvalidAutoscalingSettingsProvidedError: if the validation fails.
"""
if not policies_to_remove:
return
if updated_settings and updated_settings.autoscaling_policies:
for name in updated_settings.autoscaling_policies:
if name in policies_to_remove:
raise util.InvalidAutoscalingSettingsProvidedError(
f"policy '{name}' specified both for update and removal"
)
if not existing_cluster.autoscalingSettings:
raise util.InvalidAutoscalingSettingsProvidedError(
f"nonexistent policies '{policies_to_remove}' specified for removal"
)
existing_policies = {
p.key
for p in existing_cluster.autoscalingSettings.autoscalingPolicies.additionalProperties
}
for name in policies_to_remove:
if name not in existing_policies:
raise util.InvalidAutoscalingSettingsProvidedError(
f"nonexistent policies '{policies_to_remove}' specified for removal"
)
def _RemoveAutoscalingPolicies(
autoscaling_settings: util.AutoscalingSettings,
policies_to_remove: List[str],
) -> util.AutoscalingSettings:
if not policies_to_remove:
return autoscaling_settings
for policy in policies_to_remove:
del autoscaling_settings.autoscaling_policies[policy]
return autoscaling_settings
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Update(base.UpdateCommand):
"""Update a Google Cloud VMware Engine cluster."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddClusterArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--node-type-config',
required=False,
type=arg_parsers.ArgDict(
spec={'type': str, 'count': int, 'custom-core-count': int},
required_keys=('type', 'count'),
),
action=actions.DeprecationAction(
'--node-type-config',
warn=(
'The {flag_name} option is deprecated; please use'
' --update-nodes-config and --remove-nodes-config instead.'
),
removed=False,
action='append',
),
metavar='[count=COUNT],[type=TYPE]',
help=_OLD_NODE_TYPE_CONFIG_HELP,
)
parser.add_argument(
'--update-nodes-config',
required=False,
default=list(),
type=arg_parsers.ArgDict(
spec={'type': str, 'count': int},
required_keys=('type', 'count'),
),
action='append',
help=_NODE_TYPE_CONFIG_HELP,
)
parser.add_argument(
'--remove-nodes-config',
required=False,
metavar='TYPE',
default=list(),
type=str,
action='append',
help='Type of node that should be removed from the cluster',
)
autoscaling_settings_group = parser.add_mutually_exclusive_group(
required=False
)
inlined_autoscaling_settings_group = autoscaling_settings_group.add_group()
inlined_autoscaling_settings_group.add_argument(
'--autoscaling-min-cluster-node-count',
type=int,
help='Minimum number of nodes in the cluster',
)
inlined_autoscaling_settings_group.add_argument(
'--autoscaling-max-cluster-node-count',
type=int,
help='Maximum number of nodes in the cluster',
)
inlined_autoscaling_settings_group.add_argument(
'--autoscaling-cool-down-period',
type=str,
help=(
'Cool down period (in minutes) between consecutive cluster'
' expansions/contractions'
),
)
inlined_autoscaling_settings_group.add_argument(
'--update-autoscaling-policy',
type=arg_parsers.ArgDict(
spec={
'name': str,
'node-type-id': str,
'scale-out-size': int,
'min-node-count': int,
'max-node-count': int,
'cpu-thresholds-scale-in': int,
'cpu-thresholds-scale-out': int,
'granted-memory-thresholds-scale-in': int,
'granted-memory-thresholds-scale-out': int,
'consumed-memory-thresholds-scale-in': int,
'consumed-memory-thresholds-scale-out': int,
'storage-thresholds-scale-in': int,
'storage-thresholds-scale-out': int,
},
required_keys=['name'],
),
action='append',
default=list(),
help='Autoscaling policy to be applied to the cluster',
)
autoscaling_settings_group.add_argument(
'--autoscaling-settings-from-file',
type=arg_parsers.YAMLFileContents(),
help=(
'A YAML file containing the autoscaling settings to be applied to'
' the cluster'
),
)
parser.add_argument(
'--remove-autoscaling-policy',
required=False,
metavar='NAME',
default=list(),
type=str,
action='append',
help=(
'Names of autoscaling policies that should be removed from the'
' cluster'
),
)
def Run(self, args):
cluster = args.CONCEPTS.cluster.Parse()
client = clusters.ClustersClient()
if args.node_type_config and (
args.update_nodes_config or args.remove_nodes_config
):
raise util.InvalidNodeConfigsProvidedError(
'flag `--node-type-config` is mutually exclusive with'
' `--update-nodes-config` and `--remove-nodes-config` flags.'
)
existing_cluster = client.Get(cluster)
if args.node_type_config:
configs = _ParseOldNodesConfigsParameters(
existing_cluster, args.node_type_config
)
elif args.update_nodes_config or args.remove_nodes_config:
configs = _ParseNewNodesConfigsParameters(
existing_cluster, args.update_nodes_config, args.remove_nodes_config
)
else:
configs = None
if args.autoscaling_settings_from_file:
updated_settings = util.ParseAutoscalingSettingsFromFileFormat(
args.autoscaling_settings_from_file
)
elif (
args.autoscaling_min_cluster_node_count
or args.autoscaling_max_cluster_node_count
or args.autoscaling_cool_down_period
or args.update_autoscaling_policy
):
updated_settings = util.ParseAutoscalingSettingsFromInlinedFormat(
args.autoscaling_min_cluster_node_count,
args.autoscaling_max_cluster_node_count,
args.autoscaling_cool_down_period,
args.update_autoscaling_policy,
)
else:
updated_settings = None
_ValidatePoliciesToRemove(
existing_cluster, updated_settings, args.remove_autoscaling_policy
)
autoscaling_settings = None
if updated_settings is not None or args.remove_autoscaling_policy:
old_settings = util.ParseAutoscalingSettingsFromApiFormat(
existing_cluster
)
autoscaling_settings = util.MergeAutoscalingSettings(
old_settings, updated_settings
)
autoscaling_settings = _RemoveAutoscalingPolicies(
autoscaling_settings, args.remove_autoscaling_policy
)
operation = client.Update(cluster, configs, autoscaling_settings)
is_async = args.async_
if is_async:
log.UpdatedResource(operation.name, kind='cluster', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for cluster [{}] to be updated'.format(
cluster.RelativeName()
),
)
log.UpdatedResource(cluster.RelativeName(), kind='cluster')
return resource

View File

@@ -0,0 +1,206 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.command_lib.vmware.clusters import util
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION': """
Create a VMware Engine private cloud. Private cloud creation is considered finished when the private cloud is in READY state. Check the progress of a private cloud using `{parent_command} list`.
""",
'EXAMPLES': """
To create a private cloud in the `us-west2-a` zone using `standard-72` nodes that connects to the `my-network` VMware Engine network, run:
$ {command} my-private-cloud --location=us-west2-a --project=my-project --cluster=my-management-cluster --node-type-config=type=standard-72,count=3 --management-range=192.168.0.0/24 --vmware-engine-network=my-network
Or:
$ {command} my-private-cloud --cluster=my-management-cluster --node-type-config=type=standard-72,count=3 --management-range=192.168.0.0/24 --vmware-engine-network=my-network
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
To create a stretched private cloud in the `us-west2` region using `us-west2-a` zone as preferred and `us-west2-b` zone as secondary
$ {command} my-private-cloud --project=sample-project --location=us-west2 --cluster=my-management-cluster --node-type-config=type=standard-72,count=6 --management-range=192.168.0.0/24 --vmware-engine-network=my-network --type=STRETCHED --preferred-zone=us-west2-a --secondary-zone=us-west2-b
The project is taken from gcloud properties core/project.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.UniverseCompatible
class Create(base.CreateCommand):
"""Create a VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser, positional=True)
flags.AddClusterArgToParser(
parser, positional=False, hide_resource_argument_flags=True
)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--description',
help="""\
Text describing the private cloud.
""",
)
parser.add_argument(
'--management-range',
required=True,
help="""\
IP address range in the private cloud to use for management appliances, in CIDR format. Use an IP address range that meets the [VMware Engine networking requirements](https://cloud.google.com/vmware-engine/docs/quickstart-networking-requirements).
""",
)
parser.add_argument(
'--vmware-engine-network',
required=True,
help="""\
Resource ID of the VMware Engine network attached to the private cloud.
""",
)
parser.add_argument(
'--node-type-config',
required=True,
type=arg_parsers.ArgDict(
spec={'type': str, 'count': int, 'custom-core-count': int},
required_keys=('type', 'count'),
),
action='append',
help="""\
Information about the type and number of nodes associated with the cluster.
type (required): canonical identifier of the node type.
count (required): number of nodes of this type in the cluster.
custom-core-count (optional): customized number of cores available to each node of the type.
To get a list of valid values for your node type,
run the gcloud vmware node-types describe command and reference the
availableCustomCoreCounts field in the output.
""",
)
parser.add_argument(
'--type',
required=False,
default='STANDARD',
choices={
'STANDARD': """Standard private is a zonal resource, with 3 or more nodes nodes. Default type.""",
'TIME_LIMITED': """Time limited private cloud is a zonal resource, can have only 1 node and
has limited life span. Will be deleted after defined period of time,
can be converted into standard private cloud by expanding it up to 3
or more nodes.""",
'STRETCHED': """Stretched private cloud is a regional resource with redundancy,
with a minimum of 6 nodes, nodes count has to be even.""",
},
help='Type of the private cloud',
)
parser.add_argument(
'--preferred-zone',
required=False,
help="""\
Zone that will remain operational when connection between the two zones is
lost. Specify the resource name of a zone that belongs to the region of the
private cloud.
""",
)
parser.add_argument(
'--secondary-zone',
required=False,
help="""\
Additional zone for a higher level of availability and load balancing.
Specify the resource name of a zone that belongs to the region of the
private cloud.
""",
)
parser.add_argument(
'--service-subnet',
required=False,
hidden=True,
action='append',
help="""\
A non-overlapping CIDR range and prefix length for the service subnets.
The service subnets are used for appliance or service deployment, such as storage,
backup, disaster recovery, and media streaming.
""",
)
flags.AddAutoscalingSettingsFlagsToParser(parser)
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
is_async = args.async_
nodes_configs = util.ParseNodesConfigsParameters(args.node_type_config)
autoscaling_settings = None
if args.autoscaling_settings_from_file:
autoscaling_settings = util.ParseAutoscalingSettingsFromFileFormat(
args.autoscaling_settings_from_file
)
if (
args.autoscaling_min_cluster_node_count
or args.autoscaling_max_cluster_node_count
or args.autoscaling_cool_down_period
or args.autoscaling_policy
):
autoscaling_settings = util.ParseAutoscalingSettingsFromInlinedFormat(
args.autoscaling_min_cluster_node_count,
args.autoscaling_max_cluster_node_count,
args.autoscaling_cool_down_period,
args.autoscaling_policy,
)
operation = client.Create(
privatecloud,
cluster_id=args.cluster,
nodes_configs=nodes_configs,
network_cidr=args.management_range,
vmware_engine_network_id=args.vmware_engine_network,
description=args.description,
private_cloud_type=args.type,
preferred_zone=args.preferred_zone,
secondary_zone=args.secondary_zone,
autoscaling_settings=autoscaling_settings,
service_subnet=args.service_subnet,
)
if is_async:
log.CreatedResource(operation.name, kind='private cloud', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for private cloud [{}] to be created'.format(
privatecloud.RelativeName()
),
)
log.CreatedResource(privatecloud.RelativeName(), kind='private cloud')
return resource

View File

@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Marks a VMware Engine private cloud for deletion. The resource is deleted 3 hours after being marked for deletion. This process can be reversed by using `{parent_command} undelete`.
""",
'EXAMPLES':
"""
To mark a private cloud called `my-private-cloud` for deletion, run:
$ {command} my-private-cloud --location=us-west2-a --project=my-project
Or:
$ {command} my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Google Cloud VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.add_argument(
'--delay-hours',
required=False,
default=3,
choices=[0, 1, 2, 3, 4, 5, 6, 7, 8],
type=int,
help="""
Number of hours to wait before deleting the private cloud. Specifying a value of `0` for this field begins the deletion process immediately.
""")
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
is_async = args.async_
operation = client.Delete(privatecloud, args.delay_hours)
if is_async:
log.DeletedResource(operation.name, kind='private cloud', is_async=True)
return operation
return client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for private cloud [{}] to be deleted'.format(
privatecloud.RelativeName()),
has_result=False)

View File

@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds delete-now' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION': """
Permanently delete a private cloud that is currently in soft deletion.
""",
'EXAMPLES': """
To permanently delete a private cloud called `my-private-cloud` currently in soft-deleted state, run:
$ {command} my-private-cloud --location=us-west2-a --project=my-project
Or:
$ {command} my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class DeleteNow(base.DeleteCommand):
"""Permanent deletion of a Google Cloud VMware Engine private cloud currently in soft-deleted state."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
is_async = args.async_
operation = client.DeleteNow(privatecloud)
if is_async:
log.DeletedResource(operation.name, kind='private cloud', is_async=True)
return
message_string = 'waiting for private cloud [{}] to be permanently deleted'
return client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message=message_string.format(privatecloud.RelativeName()),
has_result=False,
)

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Describe a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To get a description of a private cloud called `my-private-cloud` in project `my-project` and zone `us-west2-a`, run:
$ {command} my-private-cloud --location=us-west2-a --project=my-project
Or:
$ {command} my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Google Cloud VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser, positional=True)
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
return client.Get(privatecloud)

View File

@@ -0,0 +1,28 @@
# -*- 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.
"""The command group for the vmware dns-forwarding CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class DnsForwarding(base.Group):
"""Manage dns-forwarding in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,57 @@
# -*- 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.
"""'vmware dns-forwarding describe command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import privateclouds
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
_DETAILED_HELP = {
'DESCRIPTION': """
Display data associated with a VMware Engine DNS forwarding, such as the domains and their respective name servers.
""",
'EXAMPLES': """
To describe a DNS forwarding config in private cloud `my-private-cloud` and zone `us-west2-a`, run:
$ {command} --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Google Cloud VMware Engine dns-forwarding."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser, positional=False)
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = privateclouds.PrivateCloudsClient()
return client.GetDnsForwarding(privatecloud)

View File

@@ -0,0 +1,96 @@
# -*- 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.
"""'vmware dns-forwarding update command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
_DETAILED_HELP = {
'DESCRIPTION': """
Update DNS forwarding.
""",
'EXAMPLES': """
To update a DNS forwarding config in private cloud `my-private-cloud` and zone `us-west2-a` to forward DNS requests
for domain `activedirectory.my.corp` to name servers `192.168.20.15` and `192.168.20.16`
and for domain `proxy.my.corp` to nameservers `192.168.30.15` and `192.168.30.16`, run:
$ {command} --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --rule=domain=activedirectory.my.corp,name-servers=192.168.20.15;192.168.20.16 --rule=domain=proxy.my.corp,name-servers=192.168.30.15;192.168.30.16
Or:
$ {command} --private-cloud=my-private-cloud --rule=domain=activedirectory.my.corp,name-servers=192.168.20.15;192.168.20.16 --rule=domain=proxy.my.corp,name-servers=192.168.30.15;192.168.30.16
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Google Cloud VMware Engine dns-forwarding."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser, positional=False)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.add_argument(
'--rule',
type=arg_parsers.ArgDict(
required_keys=['domain', 'name-servers'],
spec={
'domain': str,
'name-servers': arg_parsers.ArgList(custom_delim_char=';')
}
),
action='append',
required=False,
default=[],
metavar='domain=DOMAIN,name-servers="NAME_SERVER1;NAME_SERVER2[;NAME_SERVER3]"',
help="""\
Domain name and the name servers used to resolve DNS requests for this domain.
""",
)
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
is_async = args.async_
operation = client.UpdateDnsForwarding(privatecloud, args.rule)
if is_async:
log.UpdatedResource(operation.name, kind='dns forwarding', is_async=True)
return operation
_ = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message=(
'waiting for DNS forwarding of private cloud [{}] to be updated'
.format(privatecloud.RelativeName())
),
)
resource = client.GetDnsForwarding(privatecloud)
log.UpdatedResource(resource, kind='dns forwarding')
return resource

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the vmware external-addresses CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ExternalAddresses(base.Group):
"""Manage external IP addresses in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware external-addresses create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.externaladdresses import ExternalAddressesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION': """
Create an external IP address that represents an allocated external IP address and its corresponding internal IP address in the private cloud.
""",
'EXAMPLES': """
To create an external IP address called `myip` that corresponds to the internal IP address `165.87.54.14` that belongs to the private cloud `my-private-cloud` in project `my-project` and location `us-east2-b`, run:
$ {command} myip --project=my-project --private-cloud=my-private-cloud --location=us-east2-b --internal-ip=165.87.54.14 --description="A short description for the new external address"
Or:
$ {command} myip --private-cloud=my-private-cloud --internal-ip=165.87.54.14 --description="A short description for the new external address"
In the second example, the project and region are taken from gcloud properties core/project and vmware/region.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create an external IP address."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddExternalAddressArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--internal-ip',
required=True,
help="""\
internal ip address to which external address will be linked
""")
parser.add_argument(
'--description',
help="""\
Text describing the external address
""",
)
def Run(self, args):
external_address = args.CONCEPTS.external_address.Parse()
client = ExternalAddressesClient()
is_async = args.async_
operation = client.Create(
external_address, args.internal_ip, args.description
)
if is_async:
log.CreatedResource(
operation.name, kind='external address', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for external address [{}] to be created'.format(
external_address.RelativeName()))
log.CreatedResource(
external_address.RelativeName(), kind='external address'
)
return resource

View File

@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware external-addresses delete command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.externaladdresses import ExternalAddressesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Delete external IP address from a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To delete an external IP address called `first-ip` in private cloud
`my-privatecloud` and location `us-east2-b`, run:
$ {command} first-ip --private-cloud=my-privatecloud --location=us-east2-b --project=my-project
Or:
$ {command} first-ip --private-cloud=my-privatecloud
In the second example, the project and region are taken from gcloud properties core/project and vmware/region.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete external IP address from a VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddExternalAddressArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
def Run(self, args):
external_address = args.CONCEPTS.external_address.Parse()
client = ExternalAddressesClient()
is_async = args.async_
operation = client.Delete(external_address)
if is_async:
log.DeletedResource(
operation.name, kind='external address', is_async=True)
return operation
client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for external address [{}] to be deleted'.format(
external_address.RelativeName()),
has_result=False)
log.DeletedResource(
external_address.RelativeName(),
kind='external address',
is_async=False)
return

View File

@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware external-addresses describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.externaladdresses import ExternalAddressesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Describe an external IP address in a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To get a description of an address called `first-ip` in the
`my-privatecloud` private cloud in the `us-east2-b`
location, run:
$ {command} first-ip --private-cloud=my-privatecloud --location=us-east2-b --project=my-project
Or:
$ {command} first-ip --private-cloud=my-privatecloud
In the second example, the project and region are taken from gcloud properties core/project and vmware/region.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe an external IP address in a VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddExternalAddressArgToParser(parser)
def Run(self, args):
resource = args.CONCEPTS.external_address.Parse()
client = ExternalAddressesClient()
return client.Get(resource)

View File

@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware external-addresses list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.externaladdresses import ExternalAddressesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List external IP addresses in a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To list external IP addresses in the `my-privatecloud` private cloud, run:
$ {command} --private-cloud=my-privatecloud --project=my-project --location=us-east2-b
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List external IP addresses in a VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
parser.display_info.AddFormat('table(name.segment(-1):label=NAME,'
'name.segment(-5):label=PROJECT,'
'name.segment(-3):label=PRIVATE_CLOUD,'
'internalIp,externalIp,createTime,state)')
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = ExternalAddressesClient()
return client.List(privatecloud)

View File

@@ -0,0 +1,92 @@
# -*- 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.
"""'vmware external-addresses update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import externaladdresses
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION': """
Updates an external IP address in a VMware Engine private cloud. Only description and internal-ip can be updated.
""",
'EXAMPLES': """
To update an external IP address called `myip` that belongs to the private cloud `my-private-cloud` in project `my-project` and location `us-west1-a` by changing its description to `"Updated description for the external IP address"` and internal-ip to `165.87.54.14`, run:
$ {command} myip --project=my-project --private-cloud=my-private-cloud --location=us-west1-a --internal-ip=165.87.54.14 --description="Updated description for the external IP address"
Or:
$ {command} myip --private-cloud=my-private-cloud --internal-ip=165.87.54.14 --description="Updated description for the external IP address"
In the second example, the project and region are taken from gcloud properties core/project and vmware/region.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update an external IP address in a VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddExternalAddressArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--internal-ip',
help="""\
Updated internal ip address for this external address
""",
)
parser.add_argument(
'--description',
help="""\
Updated description for this external address
""",
)
def Run(self, args):
external_address = args.CONCEPTS.external_address.Parse()
client = externaladdresses.ExternalAddressesClient()
is_async = args.async_
operation = client.Update(
external_address, args.internal_ip, args.description
)
if is_async:
log.UpdatedResource(
operation.name, kind='external address', is_async=True
)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for external address [{}] to be updated'.format(
external_address.RelativeName()
),
)
log.UpdatedResource(
external_address.RelativeName(), kind='external address'
)
return resource

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the VMware HCX CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Hcx(base.Group):
"""Manage HCX using Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

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 the VMware HCX activation keys CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class HcxActivationKeys(base.Group):
"""Manage VMware HCX activation keys using Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,77 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware hcx activationkeys create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.hcxactivationkeys import HcxActivationKeysClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Create a HCX activation key in a VMware Engine private cloud. Successful creation of a HCX activation key results in a HCX activation key in AVAILABLE state. Check the progress of a HCX activation key using `{parent_command} list`.
""",
'EXAMPLES':
"""
To create a HCX activation key called `key1` in private cloud `my-private-cloud` in zone `us-west2-a`, run:
$ {command} key1 --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} my-cluster --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Google Cloud VMware HCX activation key."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddHcxActivationKeyArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
def Run(self, args):
hcx_activation_key = args.CONCEPTS.hcx_activation_key.Parse()
client = HcxActivationKeysClient()
is_async = args.async_
operation = client.Create(hcx_activation_key)
if is_async:
log.CreatedResource(
operation.name, kind='hcx activation key', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for hcx activation key [{}] to be created'.format(
hcx_activation_key.RelativeName()))
log.CreatedResource(
hcx_activation_key.RelativeName(), kind='hcx activation key'
)
return resource

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware hcx activationkeys describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.hcxactivationkeys import HcxActivationKeysClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Display data associated with an HCX activation key, such as the key itself, its resource name, and when it was created.
""",
'EXAMPLES':
"""
To describe a HCX activation key called `key1` in private cloud `my-private-cloud` in zone `us-west2-a`, run:
$ {command} key1 --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} key1 --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Google Cloud VMware HCX activation key."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddHcxActivationKeyArgToParser(parser)
def Run(self, args):
key = args.CONCEPTS.hcx_activation_key.Parse()
client = HcxActivationKeysClient()
return client.Get(key)

View File

@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware hcx activationkeys list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.hcxactivationkeys import HcxActivationKeysClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List HCX activation keys in a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To list HCX activation keys in the `my-private-cloud` private cloud run:
$ {command} --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List HCX activation keys in a Google Cloud VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
parser.display_info.AddFormat('table(name.segment(-1):label=NAME,'
'name.segment(-5):label=LOCATION,'
'name.segment(-3):label=PRIVATE_CLOUD,'
'createTime,state,activationKey)')
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = HcxActivationKeysClient()
return client.List(privatecloud)

View File

@@ -0,0 +1,29 @@
# -*- 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.
"""The command group for the vmware identity-sources CLI."""
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.GA)
class IdentitySources(base.Group):
"""Manage identity sources in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,163 @@
# -*- 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.
"""'vmware private-clouds identity-sources create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.identitysources import IdentitySourcesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
from googlecloudsdk.core.util import files
_DETAILED_HELP = {
'DESCRIPTION': """
Create a new identity source resource in a given private cloud.
""",
'EXAMPLES': """
To create an identity source called `my-is` in a private cloud `my-pc` located in project `my-project` and zone `us-west1-a`:
$ {command} my-is --private-cloud my-pc --project my-project --location us-west1-a --domain example.com
--base-users-dn dc=example,dc=com --base-groups-dn dc=example,dc=com --domain-user user@example.com
--domain-password secretPassword123 --protocol LDAP --primary-server ldap://example.com
Or:
$ {command} my-is --private-cloud my-pc --domain example.com --base-users-dn dc=example,dc=com
--base-groups-dn dc=example,dc=com --domain-user user@example.com --domain-password secretPassword123
--protocol LDAP --primary-server ldap://example.com
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone` respectively.
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Google Cloud VMware Engine identity source."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddIdentitySourceArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--domain',
required=True,
help='The domain name of the identity source.',
)
parser.add_argument(
'--domain-alias',
required=False,
help='The domain alias of the identity source.',
)
parser.add_argument(
'--base-users-dn',
required=True,
help='The base distinguished name for users.',
)
parser.add_argument(
'--base-groups-dn',
required=True,
help='The base distinguished name for groups.',
)
parser.add_argument(
'--domain-user',
required=True,
help=(
'ID of a user in the domain who has a minimum of read-only access'
' to the base distinguished names of users and groups.'
),
)
parser.add_argument(
'--domain-password',
required=True,
help=(
'Password of the user in the domain who has a minimum of read-only'
' access to the base distinguished names of users and groups.'
),
)
parser.add_argument(
'--protocol',
required=True,
choices=['LDAP', 'LDAPS'],
help='The LDAP server connection protocol.',
)
parser.add_argument(
'--primary-server',
required=True,
help="""
Primary domain controller LDAP server for the domain.
Format `ldap://hostname:port` or `ldaps://hostname:port`
""",
)
parser.add_argument(
'--secondary-server',
help="""
Secondary domain controller LDAP server for the domain.
Format `ldap://hostname:port` or `ldaps://hostname:port`
""",
)
parser.add_argument(
'--ssl-certificate-from-file',
action='append',
default=[],
help=(
'Path to the root CA certificate files in CER format for the LDAPS'
' server. Can be passed multiple times.'
),
)
def Run(self, args):
source = args.CONCEPTS.identity_source.Parse()
client = IdentitySourcesClient()
is_async = args.async_
certificates = [
files.ReadFileContents(path) for path in args.ssl_certificate_from_file
]
operation = client.Create(
source,
domain=args.domain,
domain_alias=args.domain_alias,
base_users_dn=args.base_users_dn,
base_groups_dn=args.base_groups_dn,
domain_user=args.domain_user,
domain_password=args.domain_password,
protocol=args.protocol,
primary_server=args.primary_server,
secondary_server=args.secondary_server,
ssl_certificates=certificates,
)
if is_async:
log.CreatedResource(operation.name, kind='identity source', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for identity source [{}] to be created'.format(
source.RelativeName()
),
)
log.CreatedResource(source.RelativeName(), kind='identity source')
return resource

View File

@@ -0,0 +1,78 @@
# -*- 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.
"""'vmware logging-server delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.identitysources import IdentitySourcesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
_DETAILED_HELP = {
'DESCRIPTION': """
Delete an identity source resource.
""",
'EXAMPLES': """
To delete an identity source called `my-is` from a private cloud `my-pc` located in
a project `my-project` and zone `us-west1-a`, run:
$ {command} my-is --private-cloud=my-pc --project=my-project --location=us-west1-a
Or:
$ {command} my-is --private-cloud=my-pc
In the second example, the project and location are taken from gcloud properties `core/project` and
`compute/zone` respectively.
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Google Cloud VMware Engine identity source."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddIdentitySourceArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
def Run(self, args):
identity_source = args.CONCEPTS.identity_source.Parse()
client = IdentitySourcesClient()
operation = client.Delete(identity_source)
if args.async_:
log.DeletedResource(operation.name, kind='identity source', is_async=True)
return operation
client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for identity source [{}] to be deleted'.format(
identity_source.RelativeName()
),
has_result=False,
)
log.DeletedResource(identity_source.RelativeName(), kind='identity source')

View File

@@ -0,0 +1,58 @@
# -*- 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.
"""'vmware private-clouds identity-sources describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.identitysources import IdentitySourcesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
_DETAILED_HELP = {
'DESCRIPTION': """
Describe a Google Cloud VMware Engine identity source.
""",
'EXAMPLES': """
To retrieve an identity source called `my-is` from a Private Cloud `my-pc`located in project `my-project` and zone `us-west1-a`:
$ {command} my-identity-source --project=my-project --location=us-west1-a --private-cloud=my-pc
Or:
$ {command} my-identity-source --private-cloud=my-pc
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone` respectively.
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Google Cloud VMware Engine identity source."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddIdentitySourceArgToParser(parser)
def Run(self, args):
source = args.CONCEPTS.identity_source.Parse()
client = IdentitySourcesClient()
return client.Get(source)

View File

@@ -0,0 +1,64 @@
# -*- 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.
"""'vmware private-clouds identity-sources list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.identitysources import IdentitySourcesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
_DETAILED_HELP = {
'DESCRIPTION': """
List identity source resources in a given private cloud.
""",
'EXAMPLES': """
To retrieve all identity sources from a private cloud `my-pc` located in project `my-project` and zone `us-west1-a`:
$ {command} --project=my-project --location=us-west1-a --private-cloud=my-pc
Or:
$ {command} --private-cloud=my-pc
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone` respectively.
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Google Cloud VMware Engine identity sources in a given private cloud."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
parser.display_info.AddFormat(
'table(name.segment(-1):label=NAME,'
'name.segment(-5):label=LOCATION,'
'name.segment(-3):label=PRIVATE_CLOUD,'
'vmware_identity_source,appliance_type,domain,domain_user)'
)
def Run(self, args):
pc = args.CONCEPTS.private_cloud.Parse()
client = IdentitySourcesClient()
return client.List(pc)

View File

@@ -0,0 +1,123 @@
# -*- 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.
"""'vmware private-clouds identity-sources update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.identitysources import IdentitySourcesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
from googlecloudsdk.core.util import files
_DETAILED_HELP = {
'DESCRIPTION': """
Update an identity source. Only base-users-dn, base-groups-dn, domain-user, domain-password and ssl-certificates can be updated.
""",
'EXAMPLES': """
To update an identity source called `my-identity-source` in private cloud `my-private-cloud` and zone `us-west2-a`
by changing base-users-dn to `dc=example,dc=com`, domain-user to `user@example.com`, and domain-password to `secretPassword123` run:
$ {command} my-identity-source --project=my-project --location=us-west2-a --private-cloud=my-private-cloud
--base-users-dn dc=example,dc=com --domain-user user@example.com --domain-password secretPassword123
Or:
$ {command} my-identity-source --private-cloud=my-private-cloud --base-users-dn dc=example,dc=com
--domain-user user@example.com --domain-password secretPassword123
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone` respectively.
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Google Cloud VMware Engine identity source."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddIdentitySourceArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--base-users-dn',
help='The base distinguished name for users.',
)
parser.add_argument(
'--base-groups-dn',
help='The base distinguished name for groups.',
)
parser.add_argument(
'--domain-user',
help=(
'ID of a user in the domain who has a minimum of read-only access'
' to the base distinguished names of users and groups.'
),
)
parser.add_argument(
'--domain-password',
help=(
'Password of the user in the domain who has a minimum of read-only'
' access to the base distinguished names of users and groups.'
),
)
parser.add_argument(
'--ssl-certificate-from-file',
action='append',
default=[],
help=(
'Path to the root CA certificate files in CER format for the LDAPS'
' server. Can be passed multiple times.'
),
)
def Run(self, args):
source = args.CONCEPTS.identity_source.Parse()
client = IdentitySourcesClient()
certificates = [
files.ReadFileContents(path) for path in args.ssl_certificate_from_file
]
operation = client.Update(
source,
base_users_dn=args.base_users_dn,
base_groups_dn=args.base_groups_dn,
domain_user=args.domain_user,
domain_password=args.domain_password,
ssl_certificates=certificates,
)
is_async = args.async_
if is_async:
log.UpdatedResource(operation.name, kind='identity source', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for identity source [{}] to be updated'.format(
source.RelativeName()
),
)
log.UpdatedResource(source.RelativeName(), kind='identity source')
return resource

View File

@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import resources
from googlecloudsdk.core.resource import resource_projector
DETAILED_HELP = {
'DESCRIPTION': """
List VMware Engine private clouds.
""",
'EXAMPLES': """
To list VMware Engine operations in the location `us-west2-a`, run:
$ {command} --location=us-west2-a
Or:
$ {command}
In the second example, the location is taken from gcloud properties compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Google Cloud VMware Engine private clouds."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLocationArgToParser(parser)
parser.display_info.AddFormat(
'table(name.segment(-1):label=NAME,'
'name.segment(-5):label=PROJECT,'
'name.segment(-3):label=LOCATION,'
'createTime,state,vcenter.fqdn:label=VCENTER_FQDN,type,'
'managementCluster.stretchedClusterConfig.preferredLocation.segment(-1):'
'label=PREFERRED_ZONE,'
'managementCluster.stretchedClusterConfig.secondaryLocation.segment(-1):'
'label=SECONDARY_ZONE)'
)
def Run(self, args):
location = args.CONCEPTS.location.Parse()
client = PrivateCloudsClient()
items = client.List(location)
for item in items:
private_cloud = resource_projector.MakeSerializable(item)
if not private_cloud.get('type'):
private_cloud['type'] = (
client.messages.PrivateCloud.TypeValueValuesEnum.STANDARD
)
if private_cloud.get('type') == 'STRETCHED':
# private cloud name example:
# projects/sample-project/locations/us-west1-a/privateClouds/pc-name
private_cloud_name = private_cloud.get('name').split('/')
private_cloud_resource = resources.REGISTRY.Create(
'vmwareengine.projects.locations.privateClouds',
projectsId=private_cloud_name[-5],
locationsId=private_cloud_name[-3],
privateCloudsId=private_cloud_name[-1],
)
private_cloud['managementCluster'] = client.GetManagementCluster(
private_cloud_resource
)
yield private_cloud

View File

@@ -0,0 +1,28 @@
# -*- 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.
"""The command group for the vmware logging-servers CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class LoggingServers(base.Group):
"""Manage logging-server in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,114 @@
# -*- 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.
"""'vmware logging-server create command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.loggingservers import LoggingServersClient
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
_DETAILED_HELP = {
'DESCRIPTION': """
Create a logging-server in a VMware Engine private cloud to forward VCSA or ESXI logs to it.
""",
'EXAMPLES': """
To create a logging-server called `my-logging-server` in private cloud `my-private-cloud`, with source type `ESXI`, host name `192.168.0.30`, protocol `UDP` and port `514`, run:
$ {command} my-logging-server --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --source-type=ESXI --hostname=192.168.0.30 --protocol=UDP --port=514
Or:
$ {command} my-logging-server --private-cloud=my-private-cloud --source-type=ESXI --hostname=192.168.0.30 --protocol=UDP --port=514
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Google Cloud VMware Engine logging-server."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLoggingServerArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--hostname',
required=True,
help="""\
Fully-qualified domain name (FQDN) or IP Address of the logging server.
""",
)
parser.add_argument(
'--source-type',
required=True,
choices=['VCSA', 'ESXI'],
help="""\
The type of component that produces logs that will be forwarded
to this logging server.
""",
)
parser.add_argument(
'--protocol',
choices=['UDP', 'TCP', 'TLS', 'SSL', 'RELP'],
required=True,
help="""\
Defines possible protocols used to send logs to
a logging server.
""",
)
parser.add_argument(
'--port',
required=True,
type=arg_parsers.BoundedInt(0, 65535),
help="""\
Port number at which the logging server receives logs.
""",
)
def Run(self, args):
logging_server = args.CONCEPTS.logging_server.Parse()
client = LoggingServersClient()
is_async = args.async_
operation = client.Create(
logging_server,
args.hostname,
args.source_type,
args.protocol,
args.port,
)
if is_async:
log.CreatedResource(operation.name, kind='logging-server', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for logging-server [{}] to be created'.format(
logging_server.RelativeName()
),
)
log.CreatedResource(logging_server.RelativeName(), kind='logging-server')
return resource

View File

@@ -0,0 +1,77 @@
# -*- 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.
"""'vmware logging-server delete command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.loggingservers import LoggingServersClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
_DETAILED_HELP = {
'DESCRIPTION': """
Delete logging-server from a VMware Engine private cloud.
""",
'EXAMPLES': """
To delete an logging-server called `my-logging-server` in private cloud
`my-private-cloud` and location `us-east2-b`, run:
$ {command} my-logging-server --private-cloud=my-private-cloud --location=us-east2-b --project=my-project
Or:
$ {command} my-logging-server --private-cloud=my-private-cloud
In the second example, the project and region are taken from gcloud properties core/project and vmware/region.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete logging-server from a VMware Engine private cloud."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLoggingServerArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
def Run(self, args):
logging_server = args.CONCEPTS.logging_server.Parse()
client = LoggingServersClient()
is_async = args.async_
operation = client.Delete(logging_server)
if is_async:
log.DeletedResource(operation.name, kind='logging-server', is_async=True)
return operation
client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for logging-server [{}] to be deleted'.format(
logging_server.RelativeName()
),
has_result=False,
)
log.DeletedResource(
logging_server.RelativeName(), kind='logging-server', is_async=False
)

View File

@@ -0,0 +1,57 @@
# -*- 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.
"""'vmware logging-servers describe command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.loggingservers import LoggingServersClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
_DETAILED_HELP = {
'DESCRIPTION': """
Display data associated with a VMware Engine logging-server, such as its host name, port, protocol, and source type.
""",
'EXAMPLES': """
To describe a logging-server called `my-logging-server` in private cloud `my-private-cloud` and zone `us-west2-a`, run:
$ {command} my-logging-server --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} my-logging-server --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Google Cloud VMware Engine logging-server."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLoggingServerArgToParser(parser)
def Run(self, args):
logging_server = args.CONCEPTS.logging_server.Parse()
client = LoggingServersClient()
return client.Get(logging_server)

View File

@@ -0,0 +1,64 @@
# -*- 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.
"""'vmware logging-server list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.loggingservers import LoggingServersClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
_DETAILED_HELP = {
'DESCRIPTION': """
List logging-server in a VMware Engine private cloud.
""",
'EXAMPLES': """
To list logger-server in the `my-private-cloud` private cloud run:
$ {command} --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List logging-server in a Google Cloud VMware Engine private cloud."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
parser.display_info.AddFormat(
'table(name.segment(-1):label=NAME,'
'name.segment(-5):label=LOCATION,'
'name.segment(-3):label=PRIVATE_CLOUD,'
'sourceType,hostname,port,protocol,'
'createTime)'
)
def Run(self, args):
private_cloud = args.CONCEPTS.private_cloud.Parse()
client = LoggingServersClient()
return client.List(private_cloud)

View File

@@ -0,0 +1,112 @@
# -*- 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.
"""'vmware logging-server update command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.loggingservers import LoggingServersClient
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
_DETAILED_HELP = {
'DESCRIPTION': """
Update a Logging Server. Only source_type, hostname, protocol, port can be updated.
""",
'EXAMPLES': """
To update a logging-server called `my-logging-server` in private cloud `my-private-cloud` and zone `us-west2-a` to change `ESXI` source_type, `192.168.20.15` hostname
`UDP` protocol and `514` port, run:
$ {command} my-logging-server --location=us-west2-a --project=my-project --private-cloud=my-private-cloud --source-type=ESXI --hostname=192.168.20.15 --protocol=UDP --port=514
Or:
$ {command} my-logging-server --private-cloud=my-private-cloud --source-type=ESXI --hostname=192.168.20.15 --protocol=UDP --port=514
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Google Cloud VMware Engine logging-server."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLoggingServerArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--hostname',
help="""\
Fully-qualified domain name (FQDN) or IP Address of the logging server.
""",
)
parser.add_argument(
'--source-type',
choices=['VCSA', 'ESXI'],
help="""\
The type of component that produces logs that will be forwarded
to this logging server.
""",
)
parser.add_argument(
'--protocol',
choices=['UDP', 'TCP', 'TLS', 'RELP', 'SSL'],
help="""\
Defines possible protocols used to send logs to
a logging server.
""",
)
parser.add_argument(
'--port',
type=arg_parsers.BoundedInt(0, 65535),
help="""\
Port number at which the logging server receives logs.
""",
)
def Run(self, args):
logging_server = args.CONCEPTS.logging_server.Parse()
client = LoggingServersClient()
operation = client.Update(
logging_server,
args.hostname,
args.source_type,
args.protocol,
args.port,
)
is_async = args.async_
if is_async:
log.UpdatedResource(operation.name, kind='logging-server', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for logging-server [{}] to be updated'.format(
logging_server.RelativeName()
),
)
log.UpdatedResource(logging_server.RelativeName(), kind='logging-server')
return resource

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the vmware Management DNS zone bindings CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ManagementDnsZoneBindings(base.Group):
"""Manage Management DNS zone bindings in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

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.
"""'vmware private-clouds management-dns-zone-bindings create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.managementdnszonebinding import ManagementDNSZoneBindingClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Create a management DNS zone binding.
""",
'EXAMPLES':
"""
To create a management DNS zone binding called `my-mgmt-dns-zone-binding` that corresponds to the vmware engine network `sample-vmware-engine-network` in private cloud
`my-private-cloud`, in location `us-east2-b`, run:
$ {command} my-mgmt-dns-zone-binding --project=my-project --private-cloud=my-private-cloud --location=us-east2-b --vmware-engine-network=sample-vmware-engine-network
Or:
$ {command} my-mgmt-dns-zone-binding --private-cloud=my-private-cloud --vmware-engine-network=sample-vmware-engine-network
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone` respectively.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a management DNS zone binding."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddManagementDnsZoneBindingArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'--vpc-network',
required=False,
help="""\
Resource name of the Google Cloud VPC network to bind to the management DNS zone of the private cloud.
""")
group.add_argument(
'--vmware-engine-network',
required=False,
help="""\
Resource name of VMware Engine network to bind to the management DNS zone of the private cloud.
""")
parser.add_argument(
'--description',
help="""\
Text describing the binding resource that represents the network getting bound to the management DNS zone.
""")
def Run(self, args):
mdzb = args.CONCEPTS.management_dns_zone_binding.Parse()
client = ManagementDNSZoneBindingClient()
is_async = args.async_
operation = client.Create(
mdzb,
vpc_network=args.vpc_network,
vmware_engine_network=args.vmware_engine_network,
description=args.description,
)
if is_async:
log.CreatedResource(
operation.name, kind='management DNS zone binding', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message=('waiting for management DNS zone binding [{}] ' +
'to be created').format(mdzb.RelativeName()))
log.CreatedResource(mdzb.RelativeName(), kind='management DNS zone binding')
return resource

View File

@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds management-dns-zone-bindings delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.managementdnszonebinding import ManagementDNSZoneBindingClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Delete a management DNS zone binding.
""",
'EXAMPLES':
"""
To delete a management DNS zone binding called `my-mgmt-dns-zone-binding` in private cloud
`my-private-cloud`, in location `us-east2-b`, run:
$ {command} my-mgmt-dns-zone-binding --project=my-project --private-cloud=my-private-cloud --location=us-east2-b
Or:
$ {command} my-mgmt-dns-zone-binding --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone` respectively.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a management DNS zone binding."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddManagementDnsZoneBindingArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
def Run(self, args):
mdzb = args.CONCEPTS.management_dns_zone_binding.Parse()
client = ManagementDNSZoneBindingClient()
is_async = args.async_
operation = client.Delete(mdzb)
if is_async:
log.DeletedResource(
operation.name, kind='management DNS zone binding', is_async=True)
return operation
client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message=('waiting for management DNS zone binding [{}] ' +
'to be deleted').format(mdzb.RelativeName()), has_result=False)
log.DeletedResource(
mdzb.RelativeName(),
kind='management DNS zone binding',
is_async=False)
return operation

View File

@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds management-dns-zone-bindings describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.managementdnszonebinding import ManagementDNSZoneBindingClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Describe a management DNS zone binding.
""",
'EXAMPLES':
"""
To get a description of a management DNS zone binding called `my-mgmt-dns-zone-binding` that corresponds to the vmware engine network `sample-vmware-engine-network` in private cloud
`my-private-cloud`, in location `us-east2-b`, run:
$ {command} my-mgmt-dns-zone-binding --project=my-project --private-cloud=my-private-cloud --location=us-east2-b
Or:
$ {command} my-mgmt-dns-zone-binding --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone respectively.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a management DNS zone binding."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddManagementDnsZoneBindingArgToParser(parser)
def Run(self, args):
mdzb = args.CONCEPTS.management_dns_zone_binding.Parse()
client = ManagementDNSZoneBindingClient()
return client.Get(mdzb)

View File

@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds management-dns-zone-bindings list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.managementdnszonebinding import ManagementDNSZoneBindingClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION': """
List management DNS zone bindings in a VMware Engine private cloud.
""",
'EXAMPLES': """
To list management DNS zone bindings in the `my-private-cloud` private cloud, run:
$ {command} --private-cloud=my-private-cloud --project=my-project --location=us-east2-b
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List management DNS zone bindings in a VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
parser.display_info.AddFormat('table(name.segment(-1):label=NAME,'
'name.segment(-5):label=PROJECT,'
'name.segment(-3):label=PRIVATE_CLOUD,'
'firstof(vmwareEngineNetwork,vpcNetwork):'
'label=BIND_NETWORK,'
'createTime,state)')
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = ManagementDNSZoneBindingClient()
return client.List(privatecloud, limit=args.limit)

View File

@@ -0,0 +1,80 @@
# -*- 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.
"""'vmware private-clouds management-dns-zone-bindings repair' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.managementdnszonebinding import ManagementDNSZoneBindingClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION': """
Repair a management DNS zone binding.
""",
'EXAMPLES': """
To repair a management DNS zone binding called `my-mgmt-dns-zone-binding` in private cloud
`my-private-cloud`, in project `my-project`, in location `us-east2-b`, run:
$ {command} my-mgmt-dns-zone-binding --project=my-project --private-cloud=my-private-cloud --location=us-east2-b
Or:
$ {command} my-mgmt-dns-zone-binding --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone` respectively.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Repair(base.UpdateCommand):
"""Repair a management DNS zone binding."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddManagementDnsZoneBindingArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
def Run(self, args):
mdzb = args.CONCEPTS.management_dns_zone_binding.Parse()
client = ManagementDNSZoneBindingClient()
is_async = args.async_
operation = client.Repair(mdzb)
if is_async:
log.UpdatedResource(
operation.name, kind='management DNS zone binding', is_async=True
)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message=(
'waiting for management DNS zone binding [{}] ' + 'to be repaired'
).format(mdzb.RelativeName()),
)
log.UpdatedResource(
mdzb.RelativeName(), kind='management DNS zone binding', is_async=False
)
return resource

View File

@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds management-dns-zone-bindings update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.managementdnszonebinding import ManagementDNSZoneBindingClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Update a management DNS zone binding.
""",
'EXAMPLES':
"""
To update a management DNS zone binding called `my-mgmt-dns-zone-binding` in private cloud `my-private-cloud` and zone `us-west2-a` with description `New Description`, run:
$ {command} my-mgmt-dns-zone-binding --project=my-project --private-cloud=my-private-cloud --location=us-east2-b --description="New Description"
Or:
$ {command} my-mgmt-dns-zone-binding --private-cloud=my-private-cloud --description="New Description"
In the second example, the project and location are taken from gcloud properties `core/project` and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a management DNS zone binding."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddManagementDnsZoneBindingArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--description',
required=True,
help="""\
Text describing the binding resource that represents the network getting bound to the management DNS zone.
""")
def Run(self, args):
mdzb = args.CONCEPTS.management_dns_zone_binding.Parse()
client = ManagementDNSZoneBindingClient()
operation = client.Update(mdzb, args.description)
is_async = args.async_
if is_async:
log.UpdatedResource(operation.name
, kind='management DNS zone binding', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message=('waiting for management DNS zone binding [{}] ' +
'to be updated').format(mdzb.RelativeName()))
log.UpdatedResource(mdzb.RelativeName(), kind='management DNS zone binding')
return resource

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the vmware nsx CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Nsx(base.Group):
"""Manage NSX using Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the vmware nsx credentials CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class NsxCredentials(base.Group):
"""Manage VMware NSX credentials using Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware nsx credentials describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Retrieve VMware NSX sign-in credentials associated with a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To get sign-in credentials for NSX in private cloud `my-private-cloud`, run:
$ {command} --private-cloud=my-private-cloud --location=us-west2-a --project=my-project
Or:
$ {command} --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Retrieve VMware NSX sign-in credentials associated with a Google Cloud VMware Engine private cloud.
"""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
def Run(self, args):
resource = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
return client.GetNsxCredentials(resource)

View File

@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware nsx credentials reset' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Reset VMware NSX sign-in credentials associated with a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To reset sign-in credentials for NSX in private cloud `my-private-cloud`, run:
$ {command} --private-cloud=my-private-cloud --location=us-west2-a --project=my-project
Or:
$ {command} --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Reset(base.UpdateCommand):
"""Reset VMware NSX sign-in credentials associated with a Google Cloud VMware Engine private cloud.
"""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
def Run(self, args):
private_cloud = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
is_async = args.async_
operation = client.ResetNsxCredentials(private_cloud)
if is_async:
log.UpdatedResource(operation.name, kind='nsx credentials', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for nsx credentials [{}] to be reset'.format(
private_cloud.RelativeName()
),
)
log.UpdatedResource(private_cloud.RelativeName(), kind='nsx credentials')
return resource

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 the VMware Engine subnets CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Subnets(base.Group):
"""Manage vmware subnets in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds subnets describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.private_clouds.subnets import SubnetsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Describe a Subnet by its resource name. It contains details of the subnet, such as ip_cidr_range, gateway_ip, state, and type.
""",
'EXAMPLES':
"""
To get the information about a subnet resource called `my-subnet`, that belongs to the private cloud `my-private-cloud` in project `my-project` and zone `us-west1-a`, run:
$ {command} my-subnet --private-cloud=my-private-cloud --location=us-west1-a --project=my-project
Or:
$ {command} my-subnet --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone`, respectively.
"""
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a subnet in a VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddSubnetArgToParser(parser)
def Run(self, args):
subnet = args.CONCEPTS.subnet.Parse()
client = SubnetsClient()
return client.Get(subnet)

View File

@@ -0,0 +1,83 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds subnets list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.private_clouds.subnets import SubnetsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List subnets in a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To list subnets that belong to the private cloud `my-privatecloud` in project `my-project` and zone `us-east2-b`, run:
$ {command} --private-cloud=my-privatecloud --location=us-east2-b --project=my-project
Or:
$ {command} --private-cloud=my-privatecloud
In the above example, the project and the location are taken from gcloud properties `core/project` and `compute/zone`, respectively.
To list subnets that belong to all the private clouds in project `my-project` and zone `us-east2-b`, run:
$ {command} --private-cloud=- --location=us-east2-b --project=my-project
Or:
$ {command} --private-cloud=-
In the above example, the project and the location are taken from gcloud properties `core/project` and `compute/zone`, respectively.
To list subnets for all private clouds in all locations in project `my-project`, run:
$ {command} --private-cloud=- --location=- --project=my-project
Or:
$ {command} --private-cloud=- --location=-
In the last example, the project is taken from gcloud properties `core/project`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List subnets in a VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
parser.display_info.AddFormat('table(name.segment(-1):label=NAME,'
'name.segment(-5):label=LOCATION,'
'name.segment(-3):label=PRIVATE_CLOUD,'
'type,gatewayIp,ipCidrRange,state,vlanId)')
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = SubnetsClient()
return client.List(privatecloud)

View File

@@ -0,0 +1,82 @@
# -*- 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.
"""'vmware private-clouds subnets update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.private_clouds.subnets import SubnetsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Update a Subnet. Only ip-cidr-range can be updated. This is a synchronous command and doesn't support `--async` and `--no-async` flags.
""",
'EXAMPLES':
"""
To update a subnet named `my-subnet`, that belongs to the private cloud `my-private-cloud` in project `my-project` and zone `us-west1-a` by changing its ip-cidr-range to `10.0.0.0/24`, run:
$ {command} my-subnet --private-cloud=my-private-cloud --location=us-west1 --project=my-project --ip-cidr-range=10.0.0.0/24
Or:
$ {command} my-subnet --private-cloud=my-private-cloud --ip-cidr-range=10.0.0.0/24
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone`, respectively.
"""
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a subnet."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddSubnetArgToParser(parser)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--ip-cidr-range',
required=True,
help="""\
Updated IP CIDR range for this subnet.
""")
def Run(self, args):
subnet = args.CONCEPTS.subnet.Parse()
client = SubnetsClient()
operation = client.Update(subnet, args.ip_cidr_range)
# Since this is a passthrough API, it doesn't return a standard operation.
# It returns an operation with only two fields: `done` and `response`. If
# `operation.done == true` we extract the resource from `operation.response`
# field otherwise we wait for the operation to be completed.
if operation.done:
resource = client.GetResponse(operation)
else:
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for subnet [{}] to be updated'.format(
subnet.RelativeName()
),
)
log.UpdatedResource(subnet.RelativeName(), kind='subnet')
return resource

View File

@@ -0,0 +1,77 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds undelete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Unmark a VMware Engine private cloud that was previously marked for deletion by `{parent_command} delete`.
""",
'EXAMPLES':
"""
To unmark a private cloud called `my-private-cloud` for deletion, run:
$ {command} my-private-cloud --location=us-west2-a --project=my-project
Or:
$ {command} my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class UnDelete(base.RestoreCommand):
"""Cancel deletion of a Google Cloud VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
is_async = args.async_
operation = client.UnDelete(privatecloud)
if is_async:
log.RestoredResource(operation.name, kind='private cloud', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for private cloud deletion [{}] to be canceled'.format(
privatecloud.RelativeName()))
log.RestoredResource(privatecloud.RelativeName(), kind='private cloud')
return resource

View File

@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware private-clouds update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Update a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To update a private cloud named `my-private-cloud` by changing its description to `Example description` run:
$ {command} my-private-cloud --location=us-west2-a --project=my-project --description='Example description'
Or:
$ {command} my-private-cloud --description='Example description'
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Google Cloud VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--description',
help="""\
Text describing the private cloud
""")
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
is_async = args.async_
operation = client.Update(privatecloud, description=args.description)
if is_async:
log.UpdatedResource(operation.name, kind='private cloud', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for private cloud [{}] to be updated'.format(
privatecloud.RelativeName()))
log.UpdatedResource(privatecloud.RelativeName(), kind='private cloud')
return resource

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the vmware upgrades CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Upgrades(base.Group):
"""Manage upgrades in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware upgrades describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import upgrades
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION': """
Display data associated with a VMware Engine upgrade, such as its schdule, and status.
""",
'EXAMPLES': """
To describe a upgrade called `my-upgrade` for a private cloud `my-private-cloud` and zone `us-west2-a`, run:
$ {command} my-upgrade --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} my-upgrade --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Google Cloud VMware Engine upgrades."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddUpgradeArgToParser(parser)
def Run(self, args):
upgrade = args.CONCEPTS.upgrade.Parse()
return upgrades.UpgradesClient().Get(upgrade)

View File

@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware upgredes list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import upgrades
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION': """
List upgrades for a VMware Engine private cloud.
""",
'EXAMPLES': """
To list upgrades for the `my-private-cloud` private cloud run:
$ {command} --location=us-west2-a --project=my-project --private-cloud=my-private-cloud
Or:
$ {command} --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List upgrades for a Google Cloud VMware Engine private cloud."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
parser.display_info.AddFormat(
'table(name.segment(-1):label=NAME,'
'name.segment(-5):label=LOCATION,'
'name.segment(-3):label=PRIVATE_CLOUD,'
'state,type,description,schedule.start_time,create_time)'
)
def Run(self, args):
privatecloud = args.CONCEPTS.private_cloud.Parse()
return upgrades.UpgradesClient().List(privatecloud)

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the vmware vCenter CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Vcenter(base.Group):
"""Manage vCenter resources in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the vmware vcenter credentials CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class VcenterCredentials(base.Group):
"""Manage VMware vCenter credentials using Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware vcenter credentials describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Retrieve VMware vCenter sign-in credentials associated with a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To get sign-in credentials for vCenter in private cloud `my-private-cloud`, run:
$ {command} --private-cloud=my-private-cloud --location=us-west2-a --project=my-project
Or:
$ {command} --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe Google Cloud VMware Engine vCenter credentials."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
parser.add_argument(
'--username',
hidden=True,
help="""\
The username of the user to be queried for credentials.
""",
)
def Run(self, args):
resource = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
return client.GetVcenterCredentials(resource, args.username)

View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware vcenter credentials reset' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.privateclouds import PrivateCloudsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Reset VMware vCenter sign-in credentials associated with a VMware Engine private cloud.
""",
'EXAMPLES':
"""
To reset sign-in credentials for vCenter in private cloud `my-private-cloud`, run:
$ {command} --private-cloud=my-private-cloud --location=us-west2-a --project=my-project
Or:
$ {command} --private-cloud=my-private-cloud
In the second example, the project and location are taken from gcloud properties `core/project` and `compute/zone`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Reset(base.UpdateCommand):
"""Reset VMware vCenter sign-in credentials associated with a Google Cloud VMware Engine private cloud.
"""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddPrivatecloudArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--username',
hidden=True,
help="""\
The username of the user to reset the credentials.
""",
)
def Run(self, args):
private_cloud = args.CONCEPTS.private_cloud.Parse()
client = PrivateCloudsClient()
is_async = args.async_
operation = client.ResetVcenterCredentials(private_cloud, args.username)
if is_async:
log.UpdatedResource(
operation.name, kind='vcenter credentials', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for vcenter credentials [{}] to be reset'.format(
private_cloud.RelativeName()
),
)
log.UpdatedResource(
private_cloud.RelativeName(), kind='vcenter credentials'
)
return resource