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,35 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 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)
@base.DefaultUniverseOnly
class Vmware(base.Group):
"""Manage Google Cloud VMware Engine resources."""
category = base.COMPUTE_CATEGORY
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class VmwareAlpha(Vmware):
"""Manage Google Cloud VMware Engine resources."""

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 announcements 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 Announcements(base.Group):
"""Manage announcements in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,105 @@
# -*- 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 announcements list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import announcements
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION': """
List announcements in a VMware Engine.
""",
'EXAMPLES': """
To list maintanance announcements run:
$ {command} --type=maintenance --location=us-west2-a --project=my-project
Or:
$ {command} --type=maintenance
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
class _MissingKeyHandler(dict):
def __missing__(self, key):
return f'{{{{{key}}}}}'
def _value_or_default(metadata, key, default='N/A'):
"""Returns the value of the key in the metadata or the default value."""
if metadata and key in metadata:
return metadata[key]
return default
def _format_description(resource):
"""Formats the description of the announcement."""
description_template = (
resource['description'].replace('{{', '{').replace('}}', '}')
)
description_args = _MissingKeyHandler(resource['metadata'])
return description_template.format_map(description_args)
def _add_type_argument(parser):
"""Adds a type argument to filter the announcements list."""
parser.add_argument(
'--type',
required=True,
choices=['maintenance'],
help='The type of announcement to list.',
)
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List announcements in a Google Cloud VMware Engine."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLocationArgToParser(parser)
_add_type_argument(parser)
parser.display_info.AddTransforms({
'value_or_default': _value_or_default,
'format_description': _format_description,
})
parser.display_info.AddFormat(
'table(name.segment(-1):label=NAME,'
'name.segment(-3):label=LOCATION,'
'metadata.value_or_default(target):label=TARGET,'
'format_description():label=DESCRIPTION,'
'code:label=CODE,'
'metadata.value_or_default(upgrade_start_date):label=UPGRADE_START_DATE,'
'metadata.value_or_default(upgrade_type):label=UPGRADE_TYPE,'
'createTime)'
)
def Run(self, args):
location = args.CONCEPTS.location.Parse()
return announcements.AnnouncementsClient().List(location, args.type.upper())

View File

@@ -0,0 +1,30 @@
# -*- 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 Engine datastore CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.Hidden
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Datastores(base.Group):
"""Manage VMware Engine datastores in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,140 @@
# -*- 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 datastores create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import datastores
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DatastoresClient = datastores.DatastoresClient
DETAILED_HELP = {
'DESCRIPTION': """
Create a datastore. Datastore creation is considered finished when the datastore is in ACTIVE state. Check the progress of a datastore using `{parent_command} list`.
""",
'EXAMPLES': """
To create a datastore named `my-datastore` in `us-west2-a` connected to filestore instance `projects/my-project/locations/us-west2-a/instances/my-filestore-instance`, run:
$ {command} my-datastore --location=us-west2-a --project=my-project --filestore=projects/my-project/locations/us-west2-a/instances/my-filestore-instance
Or:
$ {command} my-datastore --filestore=projects/my-project/locations/us-west2-a/instances/my-filestore-instance
Or:
$ {command} my-datastore --netapp=projects/my-project/locations/us-west2-a/volumes/my-netapp-volume
Or:
$ {command} my-datastore --third-party-nfs-network=my-network --third-party-nfs-file-share=my-fileshare --third-party-nfs-servers=10.0.0.1,10.0.0.2 --location=us-west2-a --project=my-project
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Create(base.CreateCommand):
"""Create a datastore."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDatastoreArgToParser(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 datastore.
""",
)
datastore_type_group = parser.add_group(
mutex=True,
required=True,
)
datastore_type_group.add_argument(
'--netapp',
help="""\
Google NetApp volume to be used as datastore.
""",
)
datastore_type_group.add_argument(
'--filestore',
help="""\
Google Filestore instance to be used as datastore.
""",
)
third_party_nfs_group = datastore_type_group.add_group()
third_party_nfs_group.add_argument(
'--third-party-nfs-network',
required=True,
help="""\
Network name of NFS's VPC.
""",
)
third_party_nfs_group.add_argument(
'--third-party-nfs-file-share',
required=True,
help="""\
Mount folder name of NFS.
""",
)
third_party_nfs_group.add_argument(
'--third-party-nfs-servers',
required=True,
help="""\
Comma-separated list of server IP addresses of the NFS file service.
""",
type=arg_parsers.ArgList(min_length=1),
metavar='SERVER',
)
def Run(self, args):
datastore = args.CONCEPTS.datastore.Parse()
client = DatastoresClient()
is_async = args.async_
operation = client.Create(
datastore,
description=args.description,
netapp_volume=args.netapp,
filestore_instance=args.filestore,
third_party_nfs_network=args.third_party_nfs_network,
third_party_nfs_file_share=args.third_party_nfs_file_share,
third_party_nfs_servers=args.third_party_nfs_servers,
)
if is_async:
log.CreatedResource(operation.name, kind='datastore', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for datastore [{}] to be created'.format(
datastore.RelativeName()
),
)
log.CreatedResource(datastore.RelativeName(), kind='datastore')
return resource

View File

@@ -0,0 +1,80 @@
# -*- 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 datastores delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.datastores import DatastoresClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION': """
Delete a datastore.
""",
'EXAMPLES': """
To delete a datastore named `my-datastore` in location `us-west2-a`, run:
$ {command} my-datastore --location=us-west2-a --project=my-project
Or:
$ {command} 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 Delete(base.DeleteCommand):
"""Delete a datastore."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDatastoreArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.add_argument(
'--etag',
help="""\
Etag of the datastore.
""",
)
def Run(self, args):
datastore = args.CONCEPTS.datastore.Parse()
client = DatastoresClient()
is_async = args.async_
operation = client.Delete(datastore, etag=args.etag)
if is_async:
log.DeletedResource(operation.name, kind='datastore', is_async=True)
return operation
return client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for datastore [{}] to be deleted'.format(
datastore.RelativeName()
),
has_result=False,
)

View File

@@ -0,0 +1,60 @@
# -*- 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 datastores describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import datastores
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DatastoresClient = datastores.DatastoresClient
DETAILED_HELP = {
'DESCRIPTION': """
Describe a datastore.
""",
'EXAMPLES': """
To describe a datastore named `my-datastore` in location `us-west2-a`, run:
$ {command} my-datastore --location=us-west2-a --project=my-project
Or:
$ {command} 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 Describe(base.DescribeCommand):
"""Describe a datastore."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDatastoreArgToParser(parser, positional=True)
def Run(self, args):
datastore = args.CONCEPTS.datastore.Parse()
client = DatastoresClient()
return client.Get(datastore)

View File

@@ -0,0 +1,119 @@
# -*- 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 datastores list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from typing import Any, Dict
from googlecloudsdk.api_lib.vmware import datastores
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DatastoresClient = datastores.DatastoresClient
def _GetServiceType(r: Dict[str, Any]) -> str:
"""Gets the service type from a datastore resource.
Args:
r: The datastore resource.
Returns:
A string representing the service type, or an empty string if not found.
"""
if r.get('nfsDatastore'):
if r['nfsDatastore'].get('googleFileService'):
if r['nfsDatastore']['googleFileService'].get('netappVolume'):
return 'NETAPP'
if r['nfsDatastore']['googleFileService'].get('filestoreInstance'):
return 'FILESTORE'
if r['nfsDatastore'].get('thirdPartyFileService'):
return 'THIRD_PARTY'
return ''
def _GetVolume(r: Dict[str, Any]) -> str:
"""Gets the volume information from a datastore resource.
Args:
r: The datastore resource.
Returns:
A string representing the volume, or an empty string if not found.
"""
if r.get('nfsDatastore'):
nfs = r['nfsDatastore']
if nfs.get('googleFileService'):
gfs = nfs['googleFileService']
if gfs.get('netappVolume'):
return gfs['netappVolume'].split('/')[-1]
if gfs.get('filestoreInstance'):
return gfs['filestoreInstance'].split('/')[-1]
if nfs.get('thirdPartyFileService'):
tfs = nfs['thirdPartyFileService']
file_share = tfs.get('fileShare', '')
servers = tfs.get('servers', [])
if servers:
return ','.join(servers) + ':' + file_share
return file_share
return ''
TRANSFORMS = {'service_type': _GetServiceType, 'volume': _GetVolume}
DETAILED_HELP = {
'DESCRIPTION': """
List datastores.
""",
'EXAMPLES': """
To list datastores in location `us-west2-a`, run:
$ {command} --location=us-west2-a --project=my-project
Or:
$ {command}
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 List(base.ListCommand):
"""List datastores."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLocationArgToParser(parser)
parser.display_info.AddTransforms(TRANSFORMS)
parser.display_info.AddFormat('table(name.segment(-1):label=NAME,'
'name.segment(-5):label=PROJECT,'
'name.segment(-3):label=LOCATION,'
'createTime,state,'
'service_type():label=SERVICE_TYPE,'
'volume():label=VOLUME)')
def Run(self, args):
location = args.CONCEPTS.location.Parse()
client = DatastoresClient()
return client.List(location)

View File

@@ -0,0 +1,83 @@
# -*- 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 datastores update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import datastores
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DatastoresClient = datastores.DatastoresClient
DETAILED_HELP = {
'DESCRIPTION': """
Update a datastore.
""",
'EXAMPLES': """
To update a datastore named `my-datastore` in location `us-west2-a` with a new description, run:
$ {command} my-datastore --location=us-west2-a --project=my-project --description="new description"
Or:
$ {command} my-datastore --description="new description"
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 Update(base.UpdateCommand):
"""Update a datastore."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDatastoreArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--description',
help="""\
New description for the datastore.
""",
)
def Run(self, args):
datastore = args.CONCEPTS.datastore.Parse()
client = DatastoresClient()
is_async = args.async_
operation = client.Update(datastore, description=args.description)
if is_async:
log.UpdatedResource(operation.name, kind='datastore', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for datastore [{}] to be updated'.format(
datastore.RelativeName()
),
)
log.UpdatedResource(datastore.RelativeName(), kind='datastore')
return resource

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 DNS binding permission 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 DnsBindPermission(base.Group):
"""Manage DNS binding permission 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-bind-permission describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import dnsbindpermission
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION': """
Gets all the users and service accounts having bind permission on the intranet VPC associated with the consumer project granted by the Grant API.
""",
'EXAMPLES': """
To get all the users and service accounts having bind permission on the intranet VPC associated with the consumer project `my-project`, run:
$ {command} --project=my-project
Or:
$ {command}
In the second example, the project is taken from gcloud properties core/project.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Get all users and service accounts having bind permission."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddProjectArgToParser(parser)
def Run(self, args):
return dnsbindpermission.DNSBindPermissionClient().Get(
args.CONCEPTS.project.Parse()
)

View File

@@ -0,0 +1,109 @@
# -*- 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-bind-permission grant' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import dnsbindpermission
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION': """
Grants the bind permission to the customer provided user/service account to bind their DNS zone with the intranet VPC associated with the project.
""",
'EXAMPLES': """
To grant the bind permission to the customer provided user `user@abc.com` to bind their DNS zone with the intranet VPC associated with project `my-project`, run:
$ {command} --user=user@abc.com --project=my-project
Or:
$ {command} --user=user@abc.com
In the second example, the project is taken from gcloud properties core/project.
To grant the bind permission to the customer provided service account `service-account@gserviceaccount.com` to bind their DNS zone with the intranet VPC associated with project `my-project`, run:
$ {command} --service-account=service-account@gserviceaccount.com --project=my-project
Or:
$ {command} --service-account=service-account@gserviceaccount.com
In the second example, the project is taken from gcloud properties core/project.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Grant(base.Command):
"""Grants a DNS Bind Permission."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddProjectArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'--user',
required=False,
help="""\
The consumer provided user which needs to be granted permission to bind with the intranet VPC corresponding to the consumer project. If this field is not provided then the service-account should be provided.
""",
)
group.add_argument(
'--service-account',
required=False,
help="""\
The consumer provided service account which needs to be granted permission to bind with the intranet VPC corresponding to the consumer project. If this field is not provided then the user should be provided.
""",
)
def Run(self, args):
project = args.CONCEPTS.project.Parse()
client = dnsbindpermission.DNSBindPermissionClient()
is_async = args.async_
operation = client.Grant(
project, user=args.user, service_account=args.service_account
)
if is_async:
log.UpdatedResource(
operation.name, kind='DNS Bind Permission', is_async=True
)
return
dns_bind_permission = '{project}/locations/global/dnsBindPermission'.format(
project=project.RelativeName()
)
client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message=('waiting for DNS Bind Permission [{}] to be granted').format(
dns_bind_permission
),
has_result=False,
)
resource = client.Get(project)
log.UpdatedResource(
dns_bind_permission, kind='DNS Bind Permission'
)
return resource

View File

@@ -0,0 +1,109 @@
# -*- 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-bind-permission revoke' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import dnsbindpermission
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION': """
Revokes the bind permission from the customer provided user/service account on the intranet VPC associated with the consumer project.
""",
'EXAMPLES': """
To revoke the bind permission to the customer provided user `user@abc.com` on the intranet VPC associated with the consumer project `my-project`, run:
$ {command} --user=user@abc.com --project=my-project
Or:
$ {command} --user=user@abc.com
In the second example, the project is taken from gcloud properties core/project.
To revoke the bind permission to the customer provided service account `service-account@gserviceaccount.com` on the intranet VPC associated with the consumer project `my-project`, run:
$ {command} --service-account=service-account@gserviceaccount.com --project=my-project
Or:
$ {command} --service-account=service-account@gserviceaccount.com
In the second example, the project is taken from gcloud properties core/project.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Grant(base.Command):
"""Revokes a DNS Bind Permission."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddProjectArgToParser(parser)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'--user',
required=False,
help="""\
The consumer provided user whose permission needs to be revoked on the intranet VPC corresponding to the consumer project. If this field is not provided then the service-account should be provided.
""",
)
group.add_argument(
'--service-account',
required=False,
help="""\
The consumer provided service account whose permission needs to be revoked on the intranet VPC corresponding to the consumer project. If this field is not provided then the user should be provided.
""",
)
def Run(self, args):
project = args.CONCEPTS.project.Parse()
client = dnsbindpermission.DNSBindPermissionClient()
is_async = args.async_
operation = client.Revoke(
project, user=args.user, service_account=args.service_account
)
if is_async:
log.UpdatedResource(
operation.name, kind='DNS Bind Permission', is_async=True
)
return
dns_bind_permission = '{project}/locations/global/dnsBindPermission'.format(
project=project.RelativeName()
)
client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message=('waiting for DNS Bind Permission [{}] to be revoked').format(
dns_bind_permission
),
has_result=False,
)
resource = client.Get(project)
log.UpdatedResource(
dns_bind_permission, kind='DNS Bind Permission'
)
return resource

View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 locations 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 Locations(base.Group):
"""List locations in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 locations list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.locations import LocationsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List supported VMware Engine locations.
""",
'EXAMPLES':
"""
To list VMware Engine locations, run:
$ {command}
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Google Cloud VMware Engine locations."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddProjectArgToParser(parser, positional=False)
parser.display_info.AddFormat("""\
table(
locationId:label=ID,
name
)""")
def Run(self, args):
project = args.CONCEPTS.project.Parse()
client = LocationsClient()
return client.List(project)

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""VMware engine vpc network list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import networkpeering
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_peerings import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List VPC network peerings across all locations in your project.
""",
'EXAMPLES':
"""
To list all the VPC network peerings created on or after April 12, 2021, sorted from oldest to newest, run:
$ {command} --filter="createTime > 2021-04-12T00:00:00.00Z" --sort-by=createTime
In this example, the location is taken as `global`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Google Cloud VMware Engine VPC network peerings."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLocationArgToParser(parser)
parser.display_info.AddFormat('table(name.segment(-1):label=NAME,'
'name.segment(-5):label=PROJECT,'
'name.segment(-3):label=LOCATION,'
'createTime,state)')
def Run(self, args):
location = args.CONCEPTS.location.Parse()
client = networkpeering.NetworkPeeringClient()
return client.List(location)

View File

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

View File

@@ -0,0 +1,87 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""VMware Engine VPC network peering routes list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import networkpeeringroutes
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_peerings import flags
from googlecloudsdk.core.resource import resource_projector
DETAILED_HELP = {
'DESCRIPTION':
"""
List VPC network peering routes across all locations in your project.
""",
'EXAMPLES':
"""
To list peering routes imported from peer network via my-peering:
$ {command} --network-peering=my-peering --filter="direction=INCOMING"
To list peering routes exported to peer network via my-peering:
$ {command} --network-peering=my-peering --filter="direction=OUTGOING"
In above examples, the location is taken as `global`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Google Cloud VMware Engine VPC network peering routes."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkPeeringToParser(parser)
parser.display_info.AddFormat("""\
table(
dest_range,
type,
next_hop_region,
status,
direction)
""")
def Run(self, args):
networkpeering = args.CONCEPTS.network_peering.Parse()
client = networkpeeringroutes.NetworkPeeringRoutesClient()
items = client.List(networkpeering)
def _TransformStatus(direction, imported):
"""Create customized status field based on direction and imported."""
if imported:
if direction == 'INCOMING':
return 'accepted'
return 'accepted by peer'
if direction == 'INCOMING':
return 'rejected by config'
return 'rejected by peer config'
for item in items:
route = resource_projector.MakeSerializable(item)
# Set "status" to "Imported" or "Imported by peer" based on direction.
route['status'] = _TransformStatus(
route['direction'], route.get('imported', False)
)
yield route

View File

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

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 network policy 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 NetworkPolicies(base.Group):
"""Manage VMware Engine network policies in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,115 @@
# -*- 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 network-policies create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.networkpolicies import NetworkPoliciesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_policies import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Create a VMware Engine network policy. Only one network policy applies to a VMware Engine network per region. Check the progress of a network policy creation using `{parent_command} list`.
""",
'EXAMPLES':
"""
To create a network policy called `my-network-policy` which connects to the VMware Engine network `my-vmware-engine-network` using the edge services address range `192.168.0.0/26` with the internet access service enabled and the external IP access service disabled, run:
$ {command} my-network-policy --location=us-west2 --project=my-project --vmware-engine-network=my-vmware-engine-network --edge-services-cidr=192.168.0.0/26 --internet-access --no-external-ip-access
Or:
$ {command} my-network-policy --vmware-engine-network=my-vmware-engine-network --edge-services-cidr=192.168.0.0/26 --internet-access
In the second example, the project and the location are taken from gcloud properties core/project and compute/region respectively. If the `--external-ip-access` flag is not specified, it is taken as `False`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a VMware Engine network policy."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkPolicyToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--vmware-engine-network',
required=True,
help="""\
Resource ID of the VMware Engine network to attach the new policy to.
""")
parser.add_argument(
'--description',
help="""\
User-provided description of the network policy.
""")
parser.add_argument(
'--edge-services-cidr',
required=True,
help="""\
IP address range to use for internet access and external IP access gateways, in CIDR notation. An RFC 1918 CIDR block with a "/26" prefix is required.
""")
parser.add_argument(
'--internet-access',
action='store_true',
default=False,
help="""\
Enable or disable network service that allows VMware workloads to access the internet. Use `--no-internet-access` to disable. If the flag is not provided, internet access is disabled.
""")
parser.add_argument(
'--external-ip-access',
action='store_true',
default=False,
help="""\
Enable or disable network service that allows external IP addresses to be assigned to VMware workloads. To enable this service, `internet-access` must also be enabled. Use `--no-external-ip-access` to disable. If the flag is not provided, access to VMware workloads through external IP addresses is disabled.
""")
def Run(self, args):
network_policy = args.CONCEPTS.network_policy.Parse()
client = NetworkPoliciesClient()
is_async = args.async_
operation = client.Create(
network_policy,
vmware_engine_network_id=args.vmware_engine_network,
edge_services_cidr=args.edge_services_cidr,
description=args.description,
internet_access=args.internet_access,
external_ip_access=args.external_ip_access,
)
if is_async:
log.CreatedResource(
operation.name, kind='VMware Engine network policy', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for network policy [{}] to be created'.format(
network_policy.RelativeName()
),
)
log.CreatedResource(
network_policy.RelativeName(), kind='VMware Engine network policy'
)
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 network-policies delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.networkpolicies import NetworkPoliciesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_policies import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Delete a VMware Engine network policy.
""",
'EXAMPLES':
"""
To delete a network policy called `my-network-policy` in project `my-project` and region `us-west2`, run:
$ {command} my-network-policy --location=us-west2 --project=my-project
Or:
$ {command} my-network-policy
In the second example, the project and the location are taken from gcloud properties core/project and compute/region respectively.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a VMware Engine network policy."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkPolicyToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
def Run(self, args):
network_policy = args.CONCEPTS.network_policy.Parse()
client = NetworkPoliciesClient()
is_async = args.async_
operation = client.Delete(network_policy)
if is_async:
log.DeletedResource(
operation.name, kind='VMware Engine network policy', is_async=True)
return operation
return client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for network policy [{}] to be deleted'.format(
network_policy.RelativeName()),
has_result=False)

View File

@@ -0,0 +1,58 @@
# -*- 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 network-policies describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.networkpolicies import NetworkPoliciesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_policies import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Describe a VMware Engine network policy.
""",
'EXAMPLES':
"""
To get a description of a network policy called `my-network-policy` in project `my-project` and region `us-west2`, run:
$ {command} my-network-policy --location=us-west2 --project=my-project
Or:
$ {command} my-network-policy
In the second example, the project and the location are taken from gcloud properties core/project and compute/region respectively.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a VMware Engine network policy."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkPolicyToParser(parser, positional=True)
def Run(self, args):
network_policy = args.CONCEPTS.network_policy.Parse()
client = NetworkPoliciesClient()
return client.Get(network_policy)

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 external access firewall rules 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 ExternalAccessRules(base.Group):
"""Manage VMware Engine external access firewall rules in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,148 @@
# -*- 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-access-rules create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.externalaccessrules import ExternalAccessRulesClient
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_policies import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Create a VMware Engine external access firewall rule. Check the progress of a VMware Engine external access firewall rule creation using `{parent_command} list`.
""",
'EXAMPLES':
"""
To create an external access firewall rule called `my-external-access-rule` associated with the network policy `my-network-policy` in the `us-west2` region, run:
$ {command} my-external-access-rule --network-policy=my-network-policy --priority=1000 --ip-protocol=TCP --source-ranges=34.148.30.114/32 --destination-ranges=projects/sample-project/locations/us-west2-a/privateClouds/my-private-cloud/externalAddresses/my-external-address --source-ports=22,10000-11000 --destination-ports=22 --action=ALLOW --location=us-west2 --project=sample-project
Or:
$ {command} my-external-access-rule --network-policy=my-network-policy --priority=1000 --ip-protocol=TCP --source-ranges=34.148.30.114/32 --destination-ranges=projects/sample-project/locations/us-west2-a/privateClouds/my-private-cloud/externalAddresses/my-external-address --source-ports=22,10000-11000 --destination-ports=22
In the second example, the project and the location are taken from gcloud properties core/project and compute/region respectively. The `--action` field also isn't specified, so its value defaults to `ALLOW`.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a VMware Engine external access firewall rule."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddExternalAccessRuleToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--description',
help="""\
User-provided description of the external access rule.
""")
parser.add_argument(
'--priority',
required=True,
type=arg_parsers.BoundedInt(100, 4096),
help="""\
Priority of this external access rule. Valid values are numbers between 100 and 4096, with 100 being the highest priority. Firewall rules are processed from highest to lowest priority.
""")
parser.add_argument(
'--ip-protocol',
required=True,
choices=['TCP', 'UDP', 'ICMP'],
help="""\
Internet protocol covered by the rule. Valid values are TCP, UDP, and ICMP.
""")
parser.add_argument(
'--source-ranges',
required=True,
type=arg_parsers.ArgList(min_length=1),
metavar='SOURCE_IP_RANGES',
help="""\
A list of source IP addresses that the rule applies to. Each entry in the list can be a CIDR notation or a single IP address. When the value is set to `0.0.0.0/0`, all IP addresses are allowed.
""")
parser.add_argument(
'--destination-ranges',
required=True,
type=arg_parsers.ArgList(min_length=1),
metavar='DESTINATION_IP_RANGES',
help="""\
A list of destination IP addresses that the rule applies to. Each entry in the list can be an ExternalAddress resource name or `0.0.0.0/0`. When the value is set to `0.0.0.0/0`, all IP addresses are allowed.
""")
parser.add_argument(
'--source-ports',
type=arg_parsers.ArgList(min_length=1),
metavar='SOURCE_PORTS',
help="""\
List of allowed source ports. Each entry must be either an integer or a range.
""")
parser.add_argument(
'--destination-ports',
type=arg_parsers.ArgList(min_length=1),
metavar='DESTINATION_PORTS',
help="""\
List of allowed destination ports. Each entry must be either an integer or a range.
""")
parser.add_argument(
'--action',
choices=['ALLOW', 'DENY'],
default='ALLOW',
help="""\
Whether the firewall rule allows or denies traffic based on a successful rule match. By default, the action is ALLOW.
""")
def Run(self, args):
external_access_rule = args.CONCEPTS.external_access_rule.Parse()
client = ExternalAccessRulesClient()
is_async = args.async_
operation = client.Create(
external_access_rule,
priority=args.priority,
ip_protocol=args.ip_protocol,
source_ranges=args.source_ranges,
destination_ranges=args.destination_ranges,
source_ports=args.source_ports,
destination_ports=args.destination_ports,
description=args.description,
action=args.action,
)
if is_async:
log.CreatedResource(
operation.name,
kind='VMware Engine external access rule',
is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for external access rule [{}] to be created'.format(
external_access_rule.RelativeName()
),
)
log.CreatedResource(
external_access_rule.RelativeName(),
kind='VMware Engine external access rule',
)
return resource

View File

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

View File

@@ -0,0 +1,58 @@
# -*- 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-access-rules describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.externalaccessrules import ExternalAccessRulesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_policies import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Describe a VMware Engine external access firewall rule.
""",
'EXAMPLES':
"""
To get a description of an external access firewall rule called `my-external-access-rule` in project `my-project` and region `us-west2` associated with network policy `my-network-policy`, run:
$ {command} my-external-access-rule --network-policy=my-network-policy --location=us-west2 --project=my-project
Or:
$ {command} my-external-access-rule --network-policy=my-network-policy
In the second example, the project and the location are taken from gcloud properties core/project and compute/region respectively.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a VMware Engine external access rule."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddExternalAccessRuleToParser(parser, positional=True)
def Run(self, args):
external_access_rule = args.CONCEPTS.external_access_rule.Parse()
client = ExternalAccessRulesClient()
return client.Get(external_access_rule)

View File

@@ -0,0 +1,73 @@
# -*- 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-access-rules list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.externalaccessrules import ExternalAccessRulesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_policies import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
List VMware Engine external access firewall rules.
"""
}
EXAMPLE_FORMAT = """\
To list external access firewall rules in your project in the region `us-west2` associated with network policy `my-network-policy`, sorted from oldest to newest, run:
$ {{command}} --location=us-west2 --project=my-project --network-policy=my-network-policy --sort-by=~create_time
Or:
$ {{command}} --sort-by=~create_time --network-policy=my-network-policy
In the second example, the project and the location are taken from gcloud properties `core/project` and `compute/region` respectively.
To list custom set of fields of external access firewall rules in a project, run:
$ {{command}} --format="{0}"
"""
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List VMware Engine external access rules."""
detailed_help = DETAILED_HELP.copy()
detailed_help['EXAMPLES'] = EXAMPLE_FORMAT.format(
flags.LIST_WITH_CUSTOM_FIELDS_FORMAT)
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkPolicyToParser(parser)
parser.display_info.AddFormat(
'table(name.segment(-1):label=NAME,'
'priority,ipProtocol,sourcePorts.list(),'
'destinationPorts.list(),action)')
def Run(self, args):
network_policy = args.CONCEPTS.network_policy.Parse()
client = ExternalAccessRulesClient()
return client.List(network_policy)
def Epilog(self, resources_were_displayed):
del resources_were_displayed
log.status.Print('\n' + flags.LIST_NOTICE)

View File

@@ -0,0 +1,136 @@
# -*- 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-access-rules update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.externalaccessrules import ExternalAccessRulesClient
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_policies import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Update a VMware Engine external access firewall rule.
""",
'EXAMPLES':
"""
To update an external access firewall rule named `my-external-access-rule` so that it denies the traffic for that rule, run:
$ {command} my-external-access-rule --network-policy=my-network-policy --action=DENY --location=us-west2 --project=my-project
Or:
$ {command} my-external-access-rule --network-policy=my-network-policy --action=DENY
In the second example, the project and the location are taken from gcloud properties core/project and compute/regions respectively.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a VMware Engine network policy."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddExternalAccessRuleToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--description',
help="""\
User-provided description of the external access rule.
""")
parser.add_argument(
'--priority',
type=arg_parsers.BoundedInt(100, 4096),
help="""\
Priority of this external access rule. Valid values are numbers between 100 and 4096, with 100 being the highest priority. Firewall rules are processed from highest to lowest priority.
""")
parser.add_argument(
'--ip-protocol',
choices=['TCP', 'UDP', 'ICMP'],
help="""\
Internet protocol covered by the rule. Valid values are TCP, UDP, and ICMP.
""")
parser.add_argument(
'--source-ranges',
type=arg_parsers.ArgList(min_length=1),
metavar='SOURCE_IP_RANGES',
help="""\
A list of source IP addresses that the rule applies to. Each entry in the list can be a CIDR notation or a single IP address. When the value is set to `0.0.0.0/0`, all IP addresses are allowed.
""")
parser.add_argument(
'--destination-ranges',
type=arg_parsers.ArgList(min_length=1),
metavar='DESTINATION_IP_RANGES',
help="""\
A list of destination IP addresses that the rule applies to. Each entry in the list be an ExternalAddress resource name or `0.0.0.0/0`. When the value is set to `0.0.0.0/0`, all IP addresses are allowed.
""")
parser.add_argument(
'--source-ports',
type=arg_parsers.ArgList(min_length=1),
metavar='SOURCE_PORTS',
help="""\
List of allowed source ports. Each entry must be either an integer or a range.
""")
parser.add_argument(
'--destination-ports',
type=arg_parsers.ArgList(min_length=1),
metavar='DESTINATION_PORTS',
help="""\
List of allowed destination ports. Each entry must be either an integer or a range.
""")
parser.add_argument(
'--action',
choices=['ALLOW', 'DENY'],
help="""\
Whether the firewall rule allows or denies traffic based on a successful rule match.
""")
def Run(self, args):
external_access_rule = args.CONCEPTS.external_access_rule.Parse()
client = ExternalAccessRulesClient()
is_async = args.async_
operation = client.Update(external_access_rule, args.priority,
args.ip_protocol, args.source_ranges,
args.destination_ranges, args.source_ports,
args.destination_ports, args.description,
args.action)
if is_async:
log.UpdatedResource(
operation.name,
kind='VMware Engine external access rule',
is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for external access rule [{}] to be updated'.format(
external_access_rule.RelativeName()),
has_result=True)
log.UpdatedResource(
external_access_rule.RelativeName(),
kind='VMware Engine external access rule',
)
return resource

View File

@@ -0,0 +1,73 @@
# -*- 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 network-policies list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.networkpolicies import NetworkPoliciesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_policies import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List VMware Engine network policies.
""",
'EXAMPLES':
"""
To list network policies in your project in the region `us-west2` sorted from oldest to newest, run:
$ {command} --location=us-west2 --project=my-project --sort-by=~create_time
Or:
$ {command} --sort-by=~create_time
In the second example, the project and the location are taken from gcloud properties core/project and compute/region respectively.
To list network policies in your project from all regions, run:
$ {command} --location=- --project=my-project
Or:
$ {command} --location=-
In the last example, the project is taken from gcloud properties core/project.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List VMware Engine network policies."""
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,internetAccess,externalIp,'
'edgeServicesCidr,vmwareEngineNetwork)')
def Run(self, args):
location = args.CONCEPTS.location.Parse()
client = NetworkPoliciesClient()
return client.List(location)

View File

@@ -0,0 +1,104 @@
# -*- 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 network-policies update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.networkpolicies import NetworkPoliciesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.network_policies import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Update a VMware Engine network policy.
""",
'EXAMPLES':
"""
To update a network policy named `my-network-policy` so that it disables the external IP access service, run:
$ {command} my-network-policy --location=us-west2 --project=my-project --no-external-ip-access
Or:
$ {command} my-network-policy --no-external-ip-access
In the second example, the project and the location are taken from gcloud properties core/project and compute/regions respectively.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a VMware Engine network policy."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkPolicyToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--description',
help="""\
Updated description for the network policy.
""")
parser.add_argument(
'--edge-services-cidr',
help="""\
Updated IP address range to use for internet access and external IP access gateways, in CIDR notation.
""")
parser.add_argument(
'--internet-access',
action='store_true',
default=None,
help="""\
Enable or disable network service that allows VMware workloads to access the internet. Use `--no-internet-access` to disable.
""")
parser.add_argument(
'--external-ip-access',
action='store_true',
default=None,
help="""\
Enable or disable network service that allows external IP addresses to be assigned to VMware workloads. To enable this service, `internet-access` must also be enabled. Use `--no-external-ip-access` to disable.
""")
def Run(self, args):
network_policy = args.CONCEPTS.network_policy.Parse()
client = NetworkPoliciesClient()
is_async = args.async_
operation = client.Update(network_policy, args.description,
args.edge_services_cidr, args.internet_access,
args.external_ip_access)
if is_async:
log.UpdatedResource(
operation.name, kind='VMware Engine network policy', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for network policy [{}] to be updated'.format(
network_policy.RelativeName()
),
)
log.UpdatedResource(
network_policy.RelativeName(), kind='VMware Engine network policy'
)
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 Engine network CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Networks(base.Group):
"""Manage VMware Engine networks in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,107 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware networks create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.networks import NetworksClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.networks import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Create a VMware Engine network. VMware Engine network creation is considered finished when the VMware Engine network is in ACTIVE state. Check the progress of a VMware Engine network creation using `{parent_command} list`.
""",
'EXAMPLES':
"""
To create a VMware Engine network of type `STANDARD`, run:
$ {command} my-network --type=STANDARD --location=global --project=my-project
Or:
$ {command} my-network --type=STANDARD
In the second example, the project is taken from gcloud properties core/project and the location is taken as `global`.
To create a VMware Engine network of type `LEGACY` in the `us-west2` region, run:
$ {command} my-network --type=LEGACY --location=us-west2 --project=my-project
Or:
$ {command} my-network --type=LEGACY --location=us-west2
In the last example, the project is taken from gcloud properties core/project. For VMware Engine networks of type `LEGACY`, you must always specify a region as the location.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Google Cloud VMware Engine network."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
type_choices = {
'STANDARD':
'Standard network type used for private cloud connectivity. A '
'VMware Engine network of type STANDARD is a global resource.',
'LEGACY':
'Network type used by private clouds created in projects without a'
' network of type STANDARD. This network type is only used for new'
' PCs in existing projects that continue to use LEGACY network. A '
'VMware Engine network of type LEGACY is a regional resource.'
}
flags.AddNetworkToParser(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 VMware Engine network.
""")
parser.add_argument(
'--type',
required=True,
choices=type_choices,
help="""Type of the VMware Engine network.""")
def Run(self, args):
network = args.CONCEPTS.vmware_engine_network.Parse()
client = NetworksClient()
is_async = args.async_
operation = client.Create(network, args.type, args.description)
if is_async:
log.CreatedResource(
operation.name, kind='VMware Engine network', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for VMware Engine network [{}] to be created'.format(
network.RelativeName()
),
)
log.CreatedResource(network.RelativeName(), kind='VMware Engine network')
return resource

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 networks delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.networks import NetworksClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.networks import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Delete a VMware Engine network.
""",
'EXAMPLES':
"""
To delete a network called `my-network` of type `STANDARD` in project `my-project` and region `global`, run:
$ {command} my-network --location=global --project=my-project
Or:
$ {command} my-network
In the second example, the project is taken from gcloud properties core/project and the location is taken as `global`.
To delete a network called `my-network` of type `LEAGACY` in project `my-project` and region `us-west2`, run:
$ {command} my-network --location=us-west2 --project=my-project
Or:
$ {command} my-network --location=us-west2
In the last example, the project is taken from gcloud properties core/project. For VMware Engine networks of type `LEGACY`, you must always specify a region as the location.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Google Cloud VMware Engine network."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
def Run(self, args):
network = args.CONCEPTS.vmware_engine_network.Parse()
client = NetworksClient()
is_async = args.async_
operation = client.Delete(network)
if is_async:
log.DeletedResource(
operation.name, kind='VMware Engine network', is_async=True)
return operation
return client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for VMware Engine network [{}] to be deleted'.format(
network.RelativeName()),
has_result=False)

View File

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

View File

@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware networks list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.networks import NetworksClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.networks import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List VMware Engine networks.
""",
'EXAMPLES':
"""
To list VMware Engine networks of type `STANDARD` in your project, run:
$ {command} --location=global --project=my-project
Or:
$ {command}
In the second example, the project is taken from gcloud properties core/project and the location is taken as `global`.
To list VMware Engine networks of type `LEGACY` in the location `us-west2` in your project, run:
$ {command} --location=us-west2 --project=my-project
Or:
$ {command} --location=us-west2
In the last example, the project is taken from gcloud properties core/project. For VMware Engine networks of type `LEGACY`, you must always specify a region as the location.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Google Cloud VMware Engine networks."""
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,type)')
def Run(self, args):
location = args.CONCEPTS.location.Parse()
client = NetworksClient()
return client.List(location)

View File

@@ -0,0 +1,92 @@
# -*- 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 networks update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.networks import NetworksClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware.networks import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION':
"""
Update a VMware Engine network.
""",
'EXAMPLES':
"""
To update a network named `my-network` of type `STANDARD` by changing its description to `Example description`, run:
$ {command} my-network --location=global --project=my-project --description='Example description'
Or:
$ {command} my-network --description='Example description'
In the second example, the project is taken from gcloud properties core/project and the location is taken as `global`.
To update a network named `my-network` of type `LEGACY` by changing its description to `Example description`, run:
$ {command} my-network --location=us-west2 --project=my-project --description='Example description'
Or:
$ {command} my-network --location=us-west2 --description='Example description'
In the last example, the project is taken from gcloud properties core/project. For VMware Engine networks of type `LEGACY`, you must always specify a region as the location.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Google Cloud VMware Engine network."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNetworkToParser(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 VMware Engine network
""")
def Run(self, args):
network = args.CONCEPTS.vmware_engine_network.Parse()
client = NetworksClient()
is_async = args.async_
operation = client.Update(network, description=args.description)
if is_async:
log.UpdatedResource(
operation.name, kind='VMware Engine network', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for VMware Engine network [{}] to be updated'.format(
network.RelativeName()
),
)
log.UpdatedResource(network.RelativeName(), kind='VMware Engine network')
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 node-types 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 NodeTypes(base.Group):
"""Show node types in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

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 node-types describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.nodetypes import NodeTypesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Display data associated with a VMware Engine node type, such as its compute, storage, and memory.
""",
'EXAMPLES':
"""
To describe node type `standard-72` in location `us-west1-a`, run:
$ {command} standard-72 --location=us-central1 --project=my-project
Or:
$ {command} standard-72
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):
"""Display data associated with a Google Cloud VMware Engine node type."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddNodeTypeArgToParser(parser, positional=True)
def Run(self, args):
resource = args.CONCEPTS.node_type.Parse()
client = NodeTypesClient()
return client.Get(resource)

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 node-types list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.nodetypes import NodeTypesClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List VMware Engine node types.
""",
'EXAMPLES':
"""
To list VMware Engine node types, run:
$ {command} --location=us-central1 --project=my-project
Or:
$ {command}
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 supported Google Cloud VMware Engine node types."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLocationArgToParser(parser)
parser.display_info.AddFormat("""\
table(
nodeTypeId:label=ID,
displayName:label=NAME,
virtualCpuCount,
memoryGb,diskSizeGb
)""")
def Run(self, args):
location = args.CONCEPTS.location.Parse()
client = NodeTypesClient()
return client.List(location)

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 operations 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 Operations(base.Group):
"""List and describe operations in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 operations describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.operations import OperationsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Describe a VMware Engine operation. An operation contains information about the status of a previous request.
""",
'EXAMPLES':
"""
To get details about an operation on a private cloud with the operation ID `operation-111-222-333-444`, run:
$ {command} operation-111-222-333-444 --location=us-central1 --project=my-project
Or:
$ {command} operation-111-222-333-444 --location=us-central1
In the second example, the location is taken from gcloud property compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Google Cloud VMware Engine operation."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddOperationArgToParser(parser)
def Run(self, args):
resource = args.CONCEPTS.operation.Parse()
client = OperationsClient()
return client.Get(resource)

View File

@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 operations list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.operations import OperationsClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
List VMware Engine operations in a location.
""",
'EXAMPLES':
"""
To list VMware Engine operations in a location `us-west2-a`, run:
$ {command} --location=us-west2-a
Or:
$ {command}
In the second example, the location is taken from gcloud property compute/zone.
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Google Cloud VMware Engine operations."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLocationArgToParser(parser)
parser.display_info.AddFormat("""\
table(
name.scope("operations"):label=ID,
name.scope("locations").segment(0):label=LOCATION,
metadata.target:label=TARGET,
metadata.verb:label=NAME,
done:label=DONE
)""")
def Run(self, args):
location = args.CONCEPTS.location.Parse()
client = OperationsClient()
return client.List(location)

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the vmware 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)

Some files were not shown because too many files have changed in this diff Show More